Compare commits

...

187 commits

Author SHA1 Message Date
0673cf370a Merge remote-tracking branch 'openeuicc/master' into jmp
All checks were successful
/ build-debug (push) Successful in 4m30s
Conflicts:
	.forgejo/workflows/build-debug.yml
	app-unpriv/src/main/java/im/angry/openeuicc/di/UnprivilegedUiComponentFactory.kt
2024-12-22 08:56:31 -05:00
bcd1295a18 ui: Disable language picker for privileged OpenEUICC (for now)
...because AOSP is stupid and doesn't allow apps signed with the
platform key to use language settings.
2024-12-21 15:01:07 -05:00
50ba81f131 i18n: Update translations of all new strings 2024-12-21 14:31:14 -05:00
d0b3d54c66 ui: Allow multi-line strings in EuiccInfoActivity 2024-12-20 19:33:43 -05:00
3a860601a3 ui: Optimize ATR strings 2024-12-20 19:32:58 -05:00
6b4723daee refactor: ATR should not be the concern of lpac-jni
...instead, use a separate interface to represent channel types that do
support reading ATR.
2024-12-20 19:30:33 -05:00
3ef78a23db feat: atr in euiccinfo activity
commit 0fbec512ab7dd8be207bb771129a29eb5f9434a8
Author: septs <github@septs.pw>
Date:   Wed Dec 18 21:27:53 2024 +0800

    feat: atr in euiccinfo activity
2024-12-20 19:06:23 -05:00
31d595a6b1 ui: Don't reset profile name while resuming the rename fragment 2024-12-20 19:04:31 -05:00
e7ef370e46 feat: sgp.22 version in euicc info activity (#130)
Co-authored-by: Peter Cai <peter@typeblog.net>
Reviewed-on: PeterCxy/OpenEUICC#130
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-20 22:56:31 +01:00
653a7b32ee ui: wizard: Prevent clicking next multiple times 2024-12-18 21:13:08 -05:00
0f8749ee04 ui: wizard: Verify the EuiccChannel is still valid every time next is pressed 2024-12-18 21:11:15 -05:00
c0a6917645 Remove unused isForegroundTaskRunning
idk what this was used for
2024-12-18 20:57:37 -05:00
6e3176668a core: Reconnect to USB readers after switching profiles as well
Apparently some reader + card combination results in the need to
re-establish the ISD-R even though this is not a modem.

It doesn't hurt to run waitForReconnect() anyway :)
2024-12-18 20:44:08 -05:00
66bee041a0 ui: wizard: IMEI input type should be numberPassword 2024-12-18 20:05:27 -05:00
43f247a71b fix: share file name display (#122)
Co-authored-by: Peter Cai <peter@typeblog.net>
Reviewed-on: PeterCxy/OpenEUICC#122
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-19 00:19:34 +01:00
960f8855ad refactor: simplify profile operation (#129)
Co-authored-by: Peter Cai <peter@typeblog.net>
Reviewed-on: PeterCxy/OpenEUICC#129
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-19 00:18:59 +01:00
de3ae19a10 ui: wizard: Resize activity root view with IME
...and hide the IME whenever we switch between the fragments.
2024-12-18 18:16:33 -05:00
75d3894462 ui: wizard: Save input state on pause
Fixes #131 and supersedes #132.
2024-12-18 18:02:24 -05:00
895899d03a i18n: Optimize strings and update translations 2024-12-17 22:34:06 -05:00
a87f154653 EuiccChannelManagerService: Stop throwing exceptions for USB channels when switching 2024-12-17 22:02:37 -05:00
b88345057c feat: add header to saved log file (#123)
Co-authored-by: Peter Cai <peter@typeblog.net>
Reviewed-on: PeterCxy/OpenEUICC#123
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-18 01:28:24 +01:00
9596b8632c refactor: strong preference key constraint (#128)
Reviewed-on: PeterCxy/OpenEUICC#128
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-18 01:26:06 +01:00
087c760010 fix: password mask toggle in profile download wizard (#125)
![image](/attachments/540449a1-7f12-4194-881f-21d0787101b8)

Reviewed-on: PeterCxy/OpenEUICC#125
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-17 04:17:47 +01:00
24076e8fb4 ui: Remove old toast for profile name length
We'll add back i18n later.
2024-12-15 22:51:36 -05:00
f135a0da60 ui: Fixup rename error toasts 2024-12-15 22:49:02 -05:00
3b7bd8b31e fix: Validate nickname and convert to proper UTF-8 before passing to JNI
The JNI "modified" UTF-8 isn't what SGP.22 mandates. Let's encode
properly, validate the length, and pass the string as a C
null-terminated string directly over JNI.

This also introduces new exceptions that are exposed via UI as Toasts.
2024-12-15 16:02:27 -05:00
74e946cc8f i18n: Update message for LPA string parsing failure 2024-12-15 14:42:12 -05:00
3430406603 ui: wizard: Add toast for when clipboard is empty 2024-12-15 14:40:59 -05:00
24f04f54e4 Add icon for loading from clipboard 2024-12-15 14:37:30 -05:00
0fbda7dd78 feat: load lpa string from clipboard 2024-12-15 14:34:00 -05:00
905d0c897e ui: wizard: Save activity before showing nvram warning dialog 2024-12-15 13:19:23 -05:00
f395cee2e0 chore: cleanup unused resource from 343dfb43f8 (#119)
Reviewed-on: PeterCxy/OpenEUICC#119
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-15 18:47:57 +01:00
456754db5d fix: move language switcher component name in advanced category (#118)
Co-authored-by: Peter Cai <peter@typeblog.net>
Reviewed-on: PeterCxy/OpenEUICC#118
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-15 16:46:06 +01:00
7d1c7663bc fix: format channel name (#117)
Reviewed-on: PeterCxy/OpenEUICC#117
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-15 16:42:59 +01:00
9d18253e44 ui: Cancel download from the low nvram warning dialog 2024-12-14 22:47:00 -05:00
6039679693 refactor: Remove the need for specifying preference keys when binding
Co-authored-by: septs <github@septs.pw>
2024-12-14 20:59:15 -05:00
5a8d92c3df feat: hide copied toast in android 13 or higher (#114)
see https://developer.android.com/develop/ui/views/touch-and-input/copy-paste#duplicate-notifications

Co-authored-by: Peter Cai <peter@typeblog.net>
Reviewed-on: PeterCxy/OpenEUICC#114
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-15 02:44:44 +01:00
55c99831f3 ui: Copyable eid string
peter: redid parts of EuiccInfoViewHolder to remove the need for root
context (we can get it from activity directly).

Co-Authored-By: septs <github@septs.pw>

commit 2a6eb746bff034ed6032b8eac7462963bb39bcf1
Author: septs <github@septs.pw>
Date:   Sat Dec 14 11:26:42 2024 +0800

    feat: hide copied toast in android 13 or higher

commit d5bfd090b7b2e2c74c2cef698a43fc3607db260c
Merge: 0b2a498 aed2479
Author: septs <github@septs.pw>
Date:   Sat Dec 14 03:58:59 2024 +0800

    Merge branch 'master' into copyable-eid-string

commit 0b2a4988f2a2c2c7131a06867fc6bf622b281828
Author: septs <github@septs.pw>
Date:   Fri Dec 13 12:35:27 2024 +0800

    refactor: eid copied toast

commit ce854575aae304de68bddc0490998af5729632ab
Author: septs <github@septs.pw>
Date:   Fri Dec 13 12:27:18 2024 +0800

    revert: EuiccManagementFragment

commit 41229cac5727001ecb21992f5005b5b96b1d9557
Author: septs <github@septs.pw>
Date:   Fri Dec 13 12:27:10 2024 +0800

    revert: EuiccManagementFragment

commit 1f2b2d73ddfdc690442c0167e7f2f1748a78c921
Author: septs <github@septs.pw>
Date:   Fri Dec 13 12:25:01 2024 +0800

    feat: add euiccinfo activity specific strings

commit ca76ac841eab489ff1f825fef2f2aecd1ae88bb1
Merge: 110d490 55d96c6
Author: septs <github@septs.pw>
Date:   Fri Dec 13 12:23:34 2024 +0800

    Merge branch 'master' into copyable-eid-string

commit 110d49005a0cba26ee72eedfda0fc9e38a501d2a
Author: septs <github@septs.pw>
Date:   Fri Dec 13 12:23:21 2024 +0800

    revert: common strings

commit dc12e8d4107b9c80a1ca2bee0c5897f3e7d8dfa4
Author: septs <github@septs.pw>
Date:   Fri Dec 13 12:22:47 2024 +0800

    revert: unpriv strings

commit ccba9be141c533145464da3dbbc88afa16fac1fd
Merge: 34c5e41 0687354
Author: septs <github@septs.pw>
Date:   Fri Dec 13 12:15:42 2024 +0800

    Merge branch 'master' of ssh://gitea-ssh.angry.im:2222/PeterCxy/OpenEUICC into copyable-eid-string

commit 34c5e41dde663026b72b2c80301bfde2d14c0964
Author: septs <github@septs.pw>
Date:   Thu Dec 12 11:45:59 2024 +0800

    chore: simplify clickable

commit 4f1ed329f12b590691d273ac2150cb81ded11521
Author: septs <github@septs.pw>
Date:   Thu Dec 12 11:37:15 2024 +0800

    feat: copyable eid string
2024-12-14 20:38:24 -05:00
343dfb43f8 Remove unused SlotSelectFragment 2024-12-14 16:13:47 -05:00
815d4d4324 Expose USB device name as intrinsic name for use with download wizard 2024-12-14 16:11:49 -05:00
ec334d104a ui: Implement log content sharing 2024-12-14 15:18:47 -05:00
70f1e00eb4 refactor: Extract shared log-saving behavior
...so that we implement log-sharing once and apply it to both spots.
2024-12-14 14:55:27 -05:00
bc238c45cd ui: Add switching timeout message to the new DI text provider 2024-12-14 14:38:09 -05:00
14ea84c36e ui: Add placeholder text for when no eUICC is found to TextProvider 2024-12-14 14:21:05 -05:00
aefa79b18b refactor: Channel format should use DI instead of resource overriding
i18n makes resource overriding unreliable.
2024-12-14 13:47:23 -05:00
aed2479044 ui: wizard: Prevent de-selecting checkboxes 2024-12-13 08:34:21 -05:00
f294fb5e17 ui: wizard: Reintroduce support for downloading to USB readers
...and fixup our API which caused this problem in the first place.
2024-12-13 08:33:02 -05:00
55d96c6732 feat: if profile delete confirm text is mismatched then show toast (#110)
Reviewed-on: PeterCxy/OpenEUICC#110
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-13 05:15:08 +01:00
06873545e2 refactor: certificate issuer detecting (#108)
Reviewed-on: PeterCxy/OpenEUICC#108
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-13 04:41:03 +01:00
6d962a12b5 fix: euiccinfo activity channel title (#103)
Co-authored-by: Peter Cai <peter@typeblog.net>
Reviewed-on: PeterCxy/OpenEUICC#103
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-12 02:09:01 +01:00
8f9c7137f6 feat: show incorrect lpa string alert dialog (#101)
Reviewed-on: PeterCxy/OpenEUICC#101
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-12 01:59:06 +01:00
125f1da6af i18n: Add Simplified Chinese (zh-CN) translation
Also fix up some untranslatable strings and translation mistakes in
ja while we are at it.

Co-authored-by: sekaiacg <sekaiacg@gmail.com>
2024-12-08 19:57:16 -05:00
4a482b9c73 Implement a generic preference overlay mechanism
We'll need this as we'll probably soon have more priv/unpriv-specific
preferences. For example, exposing removable eSIMs to the system.
2024-12-08 17:22:46 -05:00
ca46b578f7 ui: Display ARA-M SHA-1 under info 2024-12-08 17:15:36 -05:00
23022b14be feat: copy ara-m sha-1 in settings 2024-12-08 17:12:51 -05:00
2d66c1f334 ui: Switch completely to the new download flow
...and delete the old ProfileDownloadFragment
2024-12-08 16:26:36 -05:00
09b98b37ab Export DownloadWizardActivity 2024-12-08 16:19:14 -05:00
fdbf9b3252 ui: wizard: Reimplement low nvram warning 2024-12-08 16:17:50 -05:00
84f47cb0f0 ui: wizard: Use dp instead of sp in margins 2024-12-08 16:09:39 -05:00
0229ef41df ui: wizard: Allow saving diagnostics text 2024-12-08 16:07:23 -05:00
15d3b701a5 Switch LuiActivity to the new wizard
...and rename / alias the old DirectProfileDownloadActivity to the new
DownloadWizardActivity
2024-12-08 15:42:24 -05:00
700578a369 ui: wizard: Handle download success
Turns out when you test only errors you forget things can actually
succeed...
2024-12-08 15:34:38 -05:00
eab60bf3d3 ui: priv: Set isMEP and isRemovable when creating footer views
Else, footer views may be created before we actually intialize that
info.
2024-12-08 13:44:02 -05:00
5b80afd5fe ui: Expose download error reason in diagnostics 2024-12-08 13:39:15 -05:00
400c2ff9f9 ProfileDeleteFragment: Stop using non-local returns for no reason 2024-12-08 12:59:27 -05:00
b4f562f90b Make MainActivity permission checks clearer 2024-12-08 12:58:24 -05:00
5a000278d3 Revert meaningless PermissionUtils 2024-12-08 12:55:42 -05:00
38d38523f9 Revert MainActivity changes 2024-12-08 12:54:33 -05:00
022ca1da9d chore: improve readability (#95)
Reviewed-on: PeterCxy/OpenEUICC#95
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-08 18:51:48 +01:00
1140ddb249 lpac-jni: IgnoreTLSCertificate -> AllowAllTrustManager 2024-12-08 11:15:11 -05:00
9be1ae7cd1 lpac-jni: Expose error reason enum as string 2024-12-08 11:14:10 -05:00
a7e97378fc Rework EuiccInfoActivity formatting 2024-12-08 10:51:14 -05:00
790cbb5a58 i18n: Update ja translations 2024-12-08 10:42:32 -05:00
2247749b37 ui: Set layout_constrainedWidth for profile title 2024-12-08 10:35:03 -05:00
249aea482b refactor: euicc info activity (#98)
improve maintainability

Co-authored-by: Peter Cai <peter@typeblog.net>
Reviewed-on: PeterCxy/OpenEUICC#98
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-08 16:31:39 +01:00
dc0489a693 chore: simplify source code intent (#97)
Co-authored-by: Peter Cai <peter@typeblog.net>
Reviewed-on: PeterCxy/OpenEUICC#97
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-08 16:30:00 +01:00
d3e54ece58 chore: improve compatibility check (#96)
Reviewed-on: PeterCxy/OpenEUICC#96
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-08 16:29:05 +01:00
4e5bb5b11e retire Android.mk to prevent AOSP from complaining
we don't use Android.mk for AOSP, but we do for the NDK JNI build. Let's
rename it so that the latest AOSP 15 QPR 1 stops complaining.
2024-12-07 21:25:10 -05:00
68cc6adc9b chore: reduce translatable strings (#93)
Co-authored-by: Peter Cai <peter@typeblog.net>
Reviewed-on: PeterCxy/OpenEUICC#93
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-08 03:11:44 +01:00
9e637f766d fix: profile class always display (#92)
Reviewed-on: PeterCxy/OpenEUICC#92
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-08 03:10:53 +01:00
acce39fd3b chore: flatten install packages (#85)
Co-authored-by: Peter Cai <peter@typeblog.net>
Reviewed-on: PeterCxy/OpenEUICC#85
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-07 15:58:56 +01:00
fb8b6de350 chore: cleanup (#81)
Co-authored-by: Peter Cai <peter@typeblog.net>
Reviewed-on: PeterCxy/OpenEUICC#81
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-07 15:57:14 +01:00
75221fcf79 fix: build failed (ES10c.EuiccMemoryReset) (#90)
Reviewed-on: PeterCxy/OpenEUICC#90
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-07 15:56:24 +01:00
4ae19aea3b feat: expose ES10c.EuiccMemoryReset (#88)
Co-authored-by: Peter Cai <peter@typeblog.net>
Reviewed-on: PeterCxy/OpenEUICC#88
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-07 04:43:31 +01:00
ff6bd45ac6 feat: show profile class with unfiltered profile list (#86)
Co-authored-by: Peter Cai <peter@typeblog.net>
Reviewed-on: PeterCxy/OpenEUICC#86
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-07 04:41:49 +01:00
858b6d55d6 feat: show notification sequence number in upper right (#84)
![](https://gitea.angry.im/attachments/049f819a-b647-4db6-ae3d-6519cf8ff2e9)

Reviewed-on: PeterCxy/OpenEUICC#84
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-07 04:39:44 +01:00
78bf3612ee lpac-jni: Expose error reason as return value 2024-12-01 18:47:58 -05:00
afeb5c5282 i18n: Fixup Japanese translation for notification types
~ing in the en text means the action itself, not the process.
2024-12-01 17:22:58 -05:00
f74145d0b7 i18n: Update new strings 2024-12-01 17:15:51 -05:00
c6de599db0 lpac-jni: Cancel es9p/10b sessions on download failure 2024-12-01 17:08:09 -05:00
0a78daee8b feat: language preferences (#76)
see https://developer.android.com/guide/topics/resources/app-languages

Reviewed-on: PeterCxy/OpenEUICC#76
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-01 20:26:14 +01:00
e7f58bbaaf chore: simplify settings intent (#77)
Reviewed-on: PeterCxy/OpenEUICC#77
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-01 14:57:30 +01:00
562e5922be chore: suppress gradle warning (#75)
We recommend using a newer Android Gradle plugin to use `compileSdk = 35`

This Android Gradle plugin (8.1.2) was tested up to `compileSdk = 34`.

You are strongly encouraged to update your project to use a newer
Android Gradle plugin that has been tested with `compileSdk = 35`.

If you are already using the latest version of the Android Gradle plugin,
you may need to wait until a newer version with support for `compileSdk = 35` is available.

To suppress this warning, add/update

```
android.suppressUnsupportedCompileSdk=35
```

to this project's gradle.properties.

Reviewed-on: PeterCxy/OpenEUICC#75
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-12-01 14:46:42 +01:00
50c77ea467 refactor: preference repository (#74)
reduce template code

Reviewed-on: PeterCxy/OpenEUICC#74
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-11-30 16:05:44 +01:00
6bb1a16aee feat: show unfiltered profile list in developer options (#73)
resolves #40 #30

Reviewed-on: PeterCxy/OpenEUICC#73
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-11-30 15:47:54 +01:00
92daa56f1a Add Japanese translate (#71)
Reviewed-on: PeterCxy/OpenEUICC#71
Co-authored-by: reindex <reindex@noreply.gitea.angry.im>
Co-committed-by: reindex <reindex@noreply.gitea.angry.im>
2024-11-30 15:29:09 +01:00
90878438f9 refactor: gitignore (#69)
Rebuild root dot-gitignore file

Update subdirectory dot-gitignore file

Reviewed-on: PeterCxy/OpenEUICC#69
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-11-27 15:06:32 +01:00
96bc9865ff lpac_jni: Clear exceptions before setting response 2024-11-24 19:50:27 -05:00
dcae65011e lpac_jni: Move HTTP diagnostics to LPA 2024-11-24 19:49:47 -05:00
1c4263a47a ui: wizard: Make clear what HTTP and APDU mean 2024-11-24 19:45:45 -05:00
d7214141e6 ui: wizard: Only show full APDU response when it is a failure 2024-11-24 19:45:05 -05:00
326b39ed05 ui: wizard: Add APDU errors to diagnostics 2024-11-24 19:43:42 -05:00
26d037048d ui: wizard: Show HTTP exception in diagnostics 2024-11-24 19:26:47 -05:00
5476e335b1 Move ProfileDownloadException to LPA 2024-11-24 19:20:47 -05:00
426e5c0197 util: Ignore spaces in JSON string 2024-11-24 17:45:11 -05:00
74d7da35dc ui: wizard: Quick and dirty JSON pretty-printer 2024-11-24 17:29:51 -05:00
07072667db ui: wizard: Add error diagnostics
We finally have it!!!
2024-11-24 17:10:46 -05:00
895cbdd53d lpa: Track last HTTP response on failure
We'll have a "error diagnosis" page for the new download wizard.

We'll probably want to do this for APDU too.
2024-11-24 15:56:44 -05:00
1a3fd621d9 EuiccChannelManagerService: move applyCompletionTransform() to companion object 2024-11-24 15:34:36 -05:00
74489a9ae0 EuiccChannelManagerservice: Fix completion event in returned flows 2024-11-24 13:25:11 -05:00
d68a7172de EuiccChannelManagerService: Fix support for multiple subscribers
We have to use another SharedFlow here. Otherwise, the flow transforms
break our ability to subscribe to it more than once, which is needed for
UI state to preserve across recreate events.
2024-11-24 13:14:16 -05:00
5b079c95ac ui: wizard: Implement the download process 2024-11-24 11:23:27 -05:00
f2c233fe1c EuiccChannelManagerService: Introduce IDs for tasks 2024-11-24 10:42:02 -05:00
3507c17834 EuiccChannalManagerService: manually buffer the returned flow 2024-11-24 10:18:54 -05:00
b2abe5ee84 ui: wizard: Make download details nullable 2024-11-20 21:03:42 -05:00
67c9612627 ui: wizard: Restrict inputs to single lines 2024-11-20 21:00:50 -05:00
39b40f9b0d ui: wizard: Lay out the download progress UI 2024-11-20 20:57:35 -05:00
f236b40cd4 lpac-jni: Add lookup from progress to state 2024-11-19 20:49:34 -05:00
e7a0482281 ui: wizard: Save current state to bundle 2024-11-19 20:40:53 -05:00
81f34f9b1c ui: wizard: Sort by slot ID 2024-11-19 20:14:30 -05:00
8c73615fbb ui: wizard: Implement input by scanning / gallery 2024-11-19 20:11:37 -05:00
9cf95ad47c ui: Add a input details fragment for download wizard 2024-11-19 18:38:59 -05:00
723ec70730 ui: Use prev button action for back pressed 2024-11-18 21:06:46 -05:00
dbdadd33b3 ui: Add slide-in and slide-out animation for wizard steps 2024-11-18 21:02:12 -05:00
92b7b46598 ui: Lay out the method select fragment for wizard 2024-11-18 20:54:42 -05:00
0c519af376 ui: Update slot select prompt text 2024-11-18 20:19:28 -05:00
aaca9e807a ui: Show free space when selecting slot 2024-11-18 20:01:43 -05:00
98e16ee5aa ui: Hook up prev / next buttons for new download wizard 2024-11-18 19:57:01 -05:00
b9d5c1c5bb chore: simplify dot-idea gitignore (#68)
Reviewed-on: PeterCxy/OpenEUICC#68
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-11-18 23:39:09 +01:00
c4b513fc0a ui: Save selected slot as state in DownloadWizardActivity 2024-11-17 22:00:03 -05:00
6458f54db2 ui: Ensure EuiccChannelManager is available in slot select fragment 2024-11-17 21:42:41 -05:00
87f36f4166 ui: Expose more info in slot select fragment 2024-11-17 21:41:40 -05:00
4fb59a4b01 ui: Fixup strings for eSIM slot selection 2024-11-17 19:17:29 -05:00
16636988b0 ui: Fixup loaded state 2024-11-17 19:15:42 -05:00
93e7297caa ui: Implement single selection for new wizard 2024-11-17 19:14:00 -05:00
1087a676d4 ui: Fix slot item alignment in new wizard 2024-11-17 19:04:41 -05:00
375d13b7c4 ui: Start designing UI for selectiing slot in the new download flow
incomplete
2024-11-17 17:32:42 -05:00
a3d59a0761 feat: ignore tls certificate (#66)
Reviewed-on: PeterCxy/OpenEUICC#66
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-11-17 03:43:38 +01:00
5f0dbe3098 ui: Hide developer settings behind 7 clicks 2024-11-16 20:59:36 -05:00
efa9b8bfa4 ui: Set up progress bar for the new wizard 2024-11-16 20:37:43 -05:00
47d5c3881c ui: Add skeleton of an experimental new download flow
This doesn't work yet at all, and is hidden behind an experimental
settings switch.
2024-11-16 18:34:45 -05:00
e9f4d3d1f9 fix: unified alert dialog style (#65)
see https://gitea.angry.im/PeterCxy/OpenEUICC/search/branch/master?q=.app.AlertDialog

Reviewed-on: PeterCxy/OpenEUICC#65
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-11-14 14:59:13 +01:00
506b0e530a feat: low nvram alert (#62)
If free nvram available is less 30 kib, then alert dialog

Reviewed-on: PeterCxy/OpenEUICC#62
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-11-14 14:02:27 +01:00
e8db3d1206 chore: simplify CompatibilityCheckActivity logical (#61)
Reviewed-on: PeterCxy/OpenEUICC#61
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-11-13 22:47:35 +01:00
071304349a fix: crash with disable com.android.stk app (#60)
```console
pm disable-user com.android.stk
```

after running this command, the app will crash when launched

Reviewed-on: PeterCxy/OpenEUICC#60
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-11-12 02:42:25 +01:00
6f8aef8ea8 EuiccChannelManager: Remove last trace of blocking methods 2024-11-10 20:56:56 -05:00
8e806c3ae5 EuiccChannelManager: slot -> logicalSlot 2024-11-10 20:55:12 -05:00
42c870192c Remove last trace of findEuiccChannelBySlotBlocking() public usage 2024-11-10 20:53:35 -05:00
9201ee416e OpenEuiccService: Remove more useless stuff 2024-11-10 20:45:48 -05:00
7105c43ae4 EuiccChannelManager: Remove findEuiccChannelByPort() as public method 2024-11-10 20:42:21 -05:00
d846f0cdc4 LPAUtils: Remove usage of findEuiccChannelByPort() 2024-11-10 20:40:05 -05:00
5dacb75717 EuiccChannelManager: Remove some unused methods 2024-11-10 20:35:01 -05:00
f28867ef2e OpenEuiccService: Remove traces of EuiccChannel usage 2024-11-10 20:31:09 -05:00
7215a2351b OpenEuiccService: Switch onSwitchToSubscriptionWithPort() to use the new service 2024-11-10 20:29:25 -05:00
837c34ba70 Add convience "Done" subscriber method for Flow<ForegroundTaskState> 2024-11-10 17:11:55 -05:00
fe6d4264e3 OpenEuiccService: switch onDeleteSubscription to use
EuiccChannelManagerService
2024-11-10 17:00:41 -05:00
13085ec202 Add findAvailablePorts() to EuiccChannelManager
For use with OpenEuiccService
2024-11-10 15:57:32 -05:00
9d8e58a95d refactor: open sim toolkit logical (#58)
Reviewed-on: PeterCxy/OpenEUICC#58
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-11-09 01:10:55 +01:00
22ec3e3baf OpenEuiccService: Start migrating to withEuiccChannel() 2024-11-03 10:53:24 -05:00
32f5e3f71a PrivilegedTelephonyUtils: Nuke direct EuiccChannel usage 2024-11-02 21:36:08 -04:00
04debd62d5 MainActivity: Fixup ViewPager update 2024-11-02 20:58:56 -04:00
0ef435956c EuiccChannelManager: retire enumerateEuiccChannels() 2024-11-02 19:09:57 -04:00
573dce56a6 EuiccChannelManager: Stop emitting real EuiccChannel for USB 2024-11-02 19:06:31 -04:00
272ab953e0 PrivilegedTelephonyUtils: Switch to flowEuiccPorts() 2024-11-02 18:09:12 -04:00
6257a03058 DirectProfileDownloadActivity: use flowEuiccPorts() 2024-11-02 17:16:43 -04:00
5e5210ae2d MainActivity: switch to flowEuiccPorts() 2024-11-02 16:54:30 -04:00
87eb497f40 feat: open stk from menu (#57)
Reviewed-on: PeterCxy/OpenEUICC#57
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-11-02 19:29:37 +01:00
1dc5004681 feat: enhanced visual hints for available slots (#54)
Reviewed-on: PeterCxy/OpenEUICC#54
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-11-02 19:27:42 +01:00
2ece6af174 Add EuiccChannelManager.flowEuiccPorts()
This is to prepare for refactoring EuiccChannel usage out everywhere
2024-10-29 20:18:23 -04:00
59b4b9e4ab Fix EuiccInfoActivity crash 2024-10-28 21:10:01 -04:00
826c120ca5 EuiccInfoActivity: support back button 2024-10-27 15:58:33 -04:00
5cefbc24f5 OpenEuiccService: fixup 2024-10-27 15:57:46 -04:00
f285eacd55 Show channel access mode and removable status 2024-10-27 15:17:00 -04:00
481b9ce196 Show slot ID in EuiccInfoActivity 2024-10-27 11:24:22 -04:00
ce7fb29c14 Display supported certificates (GSMA Test or Prod) in EuiccInfoActivity 2024-10-27 11:22:10 -04:00
c2cc8ceb2a feat: EuiccInfoActivity 2024-10-27 11:04:45 -04:00
3d4704e77b Remove more EuiccChannel usage in PrivilegedEuiccManagementFragment 2024-10-26 22:15:02 -04:00
6a2d4d66dd Move EuiccChannelManagerService to withEuiccChannel() 2024-10-26 21:52:33 -04:00
8ac46bd778 Move findEuiccChannelBySlot to non-blocking 2024-10-26 21:46:13 -04:00
0961ef70f4 New withEuiccChannel() variant with logical slot ID 2024-10-26 21:45:14 -04:00
3b868e4f9a Move some fragments to withEuiccChannel() 2024-10-26 21:41:56 -04:00
95b24e6151 Add withEuiccChannel helper for EuiccChannelFragment 2024-10-26 21:29:09 -04:00
ef62274057 Wrappers shouldn't hold references indefinitely 2024-10-26 15:49:38 -04:00
76e8fbd56b Use wrappers to enforce that withEuiccChannel can't leak references 2024-10-26 15:46:43 -04:00
d54fcf2589 refactor: Make EuiccChannel abstract
This allows wrapping to control reference lifetime outside of
EuiccChannelManager.
2024-10-26 15:32:31 -04:00
7cb872a664 Add new withEuiccChannel() method to EuiccChannelManager 2024-10-26 15:32:31 -04:00
65c9a7dc39 fix: refer url (#53)
Reviewed-on: PeterCxy/OpenEUICC#53
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2024-10-23 04:17:48 +02:00
132 changed files with 4580 additions and 1430 deletions

View file

@ -38,11 +38,12 @@ jobs:
- name: Build Debug Bundle
run: ./gradlew --no-daemon :app-unpriv:bundleJmpDebug
- name: Copy Artifacts
run: find . -name 'app*-debug.apk' -exec cp {} . \;
- name: Upload Artifacts
uses: https://gitea.angry.im/actions/upload-artifact@v3
with:
name: Debug APKs
compression-level: 0
path: |
app-unpriv/build/outputs/apk/jmp/debug/app-unpriv-jmp-debug.apk
app-unpriv/build/outputs/bundle/jmpDebug/app-unpriv-jmp-debug.aab
path: app*-debug.apk

29
.gitignore vendored
View file

@ -1,20 +1,11 @@
*.iml
.gradle
/local.properties
/keystore.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/deploymentTargetDropDown.xml
.DS_Store
/build
/.gradle
/captures
.externalNativeBuild
.cxx
local.properties
/libs/**/build
/buildSrc/build
/app-deps/libs
# Configuration files
/keystore.properties
/local.properties
# macOS
.DS_Store

14
.idea/.gitignore vendored
View file

@ -1,3 +1,13 @@
# Default ignored files
/shelf/
/shelf
/caches
/libraries
/assetWizardSettings.xml
/deploymentTargetDropDown.xml
/gradle.xml
/misc.xml
/modules.xml
/navEditor.xml
/runConfigurations.xml
/workspace.xml
**/*.iml

1
.idea/.name Normal file
View file

@ -0,0 +1 @@
OpenEUICC

View file

@ -1,16 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="1.7">
<module name="OpenEUICC.app" target="17" />
<module name="OpenEUICC.app-common" target="17" />
<module name="OpenEUICC.app-deps" target="17" />
<module name="OpenEUICC.app-unpriv" target="17" />
<module name="OpenEUICC.buildSrc" target="17" />
<module name="OpenEUICC.buildSrc.main" target="17" />
<module name="OpenEUICC.buildSrc.test" target="17" />
<module name="OpenEUICC.libs.hidden-apis-shim" target="17" />
<module name="OpenEUICC.libs.lpac-jni" target="17" />
</bytecodeTargetLevel>
<bytecodeTargetLevel target="1.7" />
</component>
</project>

View file

@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<compositeConfiguration>
<compositeBuild compositeDefinitionSource="SCRIPT">
<builds>
<build path="$PROJECT_DIR$/buildSrc" name="buildSrc">
<projects>
<project path="$PROJECT_DIR$/buildSrc" />
</projects>
</build>
</builds>
</compositeBuild>
</compositeConfiguration>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="/usr/share/java/gradle" />
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/app-common" />
<option value="$PROJECT_DIR$/app-deps" />
<option value="$PROJECT_DIR$/app-unpriv" />
<option value="$PROJECT_DIR$/buildSrc" />
<option value="$PROJECT_DIR$/libs" />
<option value="$PROJECT_DIR$/libs/hidden-apis-shim" />
<option value="$PROJECT_DIR$/libs/hidden-apis-stub" />
<option value="$PROJECT_DIR$/libs/lpac-jni" />
</set>
</option>
<option name="resolveExternalAnnotations" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>

View file

@ -1,25 +0,0 @@
<project version="4">
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="app/src/main/res/drawable/ic_add.xml" value="0.2015" />
<entry key="app/src/main/res/layout/activity_main.xml" value="0.19375" />
<entry key="app/src/main/res/layout/euicc_profile.xml" value="0.19375" />
<entry key="app/src/main/res/layout/fragment_euicc.xml" value="0.19375" />
<entry key="app/src/main/res/layout/fragment_profile_download.xml" value="0.19375" />
<entry key="app/src/main/res/layout/fragment_profile_rename.xml" value="0.19375" />
<entry key="app/src/main/res/menu/activity_main.xml" value="0.19375" />
<entry key="app/src/main/res/menu/activity_main_slot_spinner.xml" value="0.19375" />
<entry key="app/src/main/res/menu/fragment_profile_download.xml" value="0.19375" />
<entry key="app/src/main/res/menu/fragment_profile_rename.xml" value="0.19375" />
<entry key="app/src/main/res/menu/profile_options.xml" value="0.19375" />
</map>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

View file

View file

@ -20,14 +20,23 @@
android:label="@string/profile_notifications" />
<activity
android:name="im.angry.openeuicc.ui.DirectProfileDownloadActivity"
android:label="@string/profile_download"
android:theme="@style/Theme.AppCompat.Translucent" />
android:name="im.angry.openeuicc.ui.EuiccInfoActivity"
android:label="@string/euicc_info" />
<activity
android:name="im.angry.openeuicc.ui.LogsActivity"
android:label="@string/pref_advanced_logs" />
<activity
android:exported="true"
android:name="im.angry.openeuicc.ui.wizard.DownloadWizardActivity"
android:label="@string/download_wizard" />
<activity-alias
android:exported="true"
android:name="im.angry.openeuicc.ui.DirectProfileDownloadActivity"
android:targetActivity="im.angry.openeuicc.ui.wizard.DownloadWizardActivity" />
<activity
android:name="com.journeyapps.barcodescanner.CaptureActivity"
android:screenOrientation="fullSensor"

View file

@ -0,0 +1,5 @@
package im.angry.openeuicc.core
interface ApduInterfaceAtrProvider {
val atr: ByteArray?
}

View file

@ -6,6 +6,7 @@ import android.hardware.usb.UsbInterface
import android.hardware.usb.UsbManager
import android.se.omapi.SEService
import android.util.Log
import im.angry.openeuicc.common.R
import im.angry.openeuicc.core.usb.UsbApduInterface
import im.angry.openeuicc.core.usb.getIoEndpoints
import im.angry.openeuicc.util.*
@ -33,14 +34,17 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
Log.i(DefaultEuiccChannelManager.TAG, "Trying OMAPI for physical slot ${port.card.physicalSlotIndex}")
try {
return EuiccChannel(
return EuiccChannelImpl(
context.getString(R.string.omapi),
port,
intrinsicChannelName = null,
OmapiApduInterface(
seService!!,
port,
context.preferenceRepository.verboseLoggingFlow
),
context.preferenceRepository.verboseLoggingFlow
context.preferenceRepository.verboseLoggingFlow,
context.preferenceRepository.ignoreTLSCertificateFlow,
).also {
Log.i(DefaultEuiccChannelManager.TAG, "Is OMAPI channel, setting MSS to 60")
it.lpa.setEs10xMss(60)
@ -61,15 +65,18 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha
if (bulkIn == null || bulkOut == null) return null
val conn = usbManager.openDevice(usbDevice) ?: return null
if (!conn.claimInterface(usbInterface, true)) return null
return EuiccChannel(
return EuiccChannelImpl(
context.getString(R.string.usb),
FakeUiccPortInfoCompat(FakeUiccCardInfoCompat(EuiccChannelManager.USB_CHANNEL_ID)),
intrinsicChannelName = usbDevice.productName,
UsbApduInterface(
conn,
bulkIn,
bulkOut,
context.preferenceRepository.verboseLoggingFlow
),
context.preferenceRepository.verboseLoggingFlow
context.preferenceRepository.verboseLoggingFlow,
context.preferenceRepository.ignoreTLSCertificateFlow,
)
}

View file

@ -10,7 +10,10 @@ import im.angry.openeuicc.di.AppContainer
import im.angry.openeuicc.util.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
@ -88,44 +91,24 @@ open class DefaultEuiccChannelManager(
}
}
override fun findEuiccChannelBySlotBlocking(logicalSlotId: Int): EuiccChannel? =
runBlocking {
withContext(Dispatchers.IO) {
if (logicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
return@withContext usbChannel
}
protected suspend fun findEuiccChannelByLogicalSlot(logicalSlotId: Int): EuiccChannel? =
withContext(Dispatchers.IO) {
if (logicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
return@withContext usbChannel
}
for (card in uiccCards) {
for (port in card.ports) {
if (port.logicalSlotIndex == logicalSlotId) {
return@withContext tryOpenEuiccChannel(port)
}
for (card in uiccCards) {
for (port in card.ports) {
if (port.logicalSlotIndex == logicalSlotId) {
return@withContext tryOpenEuiccChannel(port)
}
}
null
}
null
}
override fun findEuiccChannelByPhysicalSlotBlocking(physicalSlotId: Int): EuiccChannel? =
runBlocking {
withContext(Dispatchers.IO) {
if (physicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
return@withContext usbChannel
}
for (card in uiccCards) {
if (card.physicalSlotIndex != physicalSlotId) continue
for (port in card.ports) {
tryOpenEuiccChannel(port)?.let { return@withContext it }
}
}
null
}
}
override suspend fun findAllEuiccChannelsByPhysicalSlot(physicalSlotId: Int): List<EuiccChannel>? {
private suspend fun findAllEuiccChannelsByPhysicalSlot(physicalSlotId: Int): List<EuiccChannel>? {
if (physicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
return usbChannel?.let { listOf(it) }
}
@ -138,12 +121,7 @@ open class DefaultEuiccChannelManager(
return null
}
override fun findAllEuiccChannelsByPhysicalSlotBlocking(physicalSlotId: Int): List<EuiccChannel>? =
runBlocking {
findAllEuiccChannelsByPhysicalSlot(physicalSlotId)
}
override suspend fun findEuiccChannelByPort(physicalSlotId: Int, portId: Int): EuiccChannel? =
private suspend fun findEuiccChannelByPort(physicalSlotId: Int, portId: Int): EuiccChannel? =
withContext(Dispatchers.IO) {
if (physicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
return@withContext usbChannel
@ -154,26 +132,82 @@ open class DefaultEuiccChannelManager(
}
}
override fun findEuiccChannelByPortBlocking(physicalSlotId: Int, portId: Int): EuiccChannel? =
runBlocking {
findEuiccChannelByPort(physicalSlotId, portId)
override suspend fun findFirstAvailablePort(physicalSlotId: Int): Int =
withContext(Dispatchers.IO) {
if (physicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
return@withContext 0
}
findAllEuiccChannelsByPhysicalSlot(physicalSlotId)?.getOrNull(0)?.portId ?: -1
}
override suspend fun waitForReconnect(physicalSlotId: Int, portId: Int, timeoutMillis: Long) {
if (physicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) return
override suspend fun findAvailablePorts(physicalSlotId: Int): List<Int> =
withContext(Dispatchers.IO) {
if (physicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
return@withContext listOf(0)
}
// If there is already a valid channel, we close it proactively
// Sometimes the current channel can linger on for a bit even after it should have become invalid
channelCache.find { it.slotId == physicalSlotId && it.portId == portId }?.apply {
if (valid) close()
findAllEuiccChannelsByPhysicalSlot(physicalSlotId)?.map { it.portId } ?: listOf()
}
override suspend fun <R> withEuiccChannel(
physicalSlotId: Int,
portId: Int,
fn: suspend (EuiccChannel) -> R
): R {
val channel = findEuiccChannelByPort(physicalSlotId, portId)
?: throw EuiccChannelManager.EuiccChannelNotFoundException()
val wrapper = EuiccChannelWrapper(channel)
try {
return withContext(Dispatchers.IO) {
fn(wrapper)
}
} finally {
wrapper.invalidateWrapper()
}
}
override suspend fun <R> withEuiccChannel(
logicalSlotId: Int,
fn: suspend (EuiccChannel) -> R
): R {
val channel = findEuiccChannelByLogicalSlot(logicalSlotId)
?: throw EuiccChannelManager.EuiccChannelNotFoundException()
val wrapper = EuiccChannelWrapper(channel)
try {
return withContext(Dispatchers.IO) {
fn(wrapper)
}
} finally {
wrapper.invalidateWrapper()
}
}
override suspend fun waitForReconnect(physicalSlotId: Int, portId: Int, timeoutMillis: Long) {
if (physicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
usbChannel?.close()
usbChannel = null
} else {
// If there is already a valid channel, we close it proactively
// Sometimes the current channel can linger on for a bit even after it should have become invalid
channelCache.find { it.slotId == physicalSlotId && it.portId == portId }?.apply {
if (valid) close()
}
}
withTimeout(timeoutMillis) {
while (true) {
try {
// tryOpenEuiccChannel() will automatically dispose of invalid channels
// and recreate when needed
val channel = findEuiccChannelByPort(physicalSlotId, portId)!!
val channel = if (physicalSlotId == EuiccChannelManager.USB_CHANNEL_ID) {
// tryOpenUsbEuiccChannel() will always try to reopen the channel, even if
// a USB channel already exists
tryOpenUsbEuiccChannel()
usbChannel!!
} else {
// tryOpenEuiccChannel() will automatically dispose of invalid channels
// and recreate when needed
findEuiccChannelByPort(physicalSlotId, portId)!!
}
check(channel.valid) { "Invalid channel" }
break
} catch (e: Exception) {
@ -184,34 +218,42 @@ open class DefaultEuiccChannelManager(
}
}
override suspend fun enumerateEuiccChannels(): List<EuiccChannel> =
withContext(Dispatchers.IO) {
uiccCards.flatMap { info ->
info.ports.mapNotNull { port ->
tryOpenEuiccChannel(port)?.also {
Log.d(
TAG,
"Found eUICC on slot ${info.physicalSlotIndex} port ${port.portIndex}"
)
}
override fun flowInternalEuiccPorts(): Flow<Pair<Int, Int>> = flow {
uiccCards.forEach { info ->
info.ports.forEach { port ->
tryOpenEuiccChannel(port)?.also {
Log.d(
TAG,
"Found eUICC on slot ${info.physicalSlotIndex} port ${port.portIndex}"
)
emit(Pair(info.physicalSlotIndex, port.portIndex))
}
}
}
}.flowOn(Dispatchers.IO)
override suspend fun enumerateUsbEuiccChannel(): Pair<UsbDevice?, EuiccChannel?> =
override fun flowAllOpenEuiccPorts(): Flow<Pair<Int, Int>> =
merge(flowInternalEuiccPorts(), flow {
if (tryOpenUsbEuiccChannel().second) {
emit(Pair(EuiccChannelManager.USB_CHANNEL_ID, 0))
}
})
override suspend fun tryOpenUsbEuiccChannel(): Pair<UsbDevice?, Boolean> =
withContext(Dispatchers.IO) {
usbManager.deviceList.values.forEach { device ->
Log.i(TAG, "Scanning USB device ${device.deviceId}:${device.vendorId}")
val iface = device.getSmartCardInterface() ?: return@forEach
// If we don't have permission, tell UI code that we found a candidate device, but we
// need permission to be able to do anything with it
if (!usbManager.hasPermission(device)) return@withContext Pair(device, null)
if (!usbManager.hasPermission(device)) return@withContext Pair(device, false)
Log.i(TAG, "Found CCID interface on ${device.deviceId}:${device.vendorId}, and has permission; trying to open channel")
try {
val channel = euiccChannelFactory.tryOpenUsbEuiccChannel(device, iface)
if (channel != null && channel.lpa.valid) {
usbChannel = channel
return@withContext Pair(device, channel)
return@withContext Pair(device, true)
}
} catch (e: Exception) {
// Ignored -- skip forward
@ -219,7 +261,7 @@ open class DefaultEuiccChannelManager(
}
Log.i(TAG, "No valid eUICC channel found on USB device ${device.deviceId}:${device.vendorId}")
}
return@withContext Pair(null, null)
return@withContext Pair(null, false)
}
override fun invalidate() {

View file

@ -1,26 +1,32 @@
package im.angry.openeuicc.core
import im.angry.openeuicc.util.*
import kotlinx.coroutines.flow.Flow
import net.typeblog.lpac_jni.ApduInterface
import net.typeblog.lpac_jni.LocalProfileAssistant
import net.typeblog.lpac_jni.impl.HttpInterfaceImpl
import net.typeblog.lpac_jni.impl.LocalProfileAssistantImpl
class EuiccChannel(
val port: UiccPortInfoCompat,
apduInterface: ApduInterface,
verboseLoggingFlow: Flow<Boolean>
) {
val slotId = port.card.physicalSlotIndex // PHYSICAL slot
val logicalSlotId = port.logicalSlotIndex
val portId = port.portIndex
interface EuiccChannel {
val type: String
val lpa: LocalProfileAssistant =
LocalProfileAssistantImpl(apduInterface, HttpInterfaceImpl(verboseLoggingFlow))
val port: UiccPortInfoCompat