From bc4b64111621b5ad9b54d94cb43fdbcd2d1af5cd Mon Sep 17 00:00:00 2001 From: septs Date: Sat, 2 Aug 2025 13:46:29 +0800 Subject: [PATCH 01/10] feat: es10x mss as preference --- .../openeuicc/core/DefaultEuiccChannelFactory.kt | 14 ++++++++------ .../im/angry/openeuicc/util/PreferenceUtils.kt | 3 +++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt b/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt index 87a0eea..73637dd 100644 --- a/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt +++ b/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt @@ -7,6 +7,8 @@ import im.angry.openeuicc.common.R import im.angry.openeuicc.core.usb.UsbApduInterface import im.angry.openeuicc.core.usb.UsbCcidContext import im.angry.openeuicc.util.* +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.runBlocking import java.lang.IllegalArgumentException open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccChannelFactory { @@ -35,8 +37,8 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha DefaultEuiccChannelManager.TAG, "Trying OMAPI for physical slot ${port.card.physicalSlotIndex}" ) - try { - return EuiccChannelImpl( + return try { + EuiccChannelImpl( context.getString(R.string.channel_type_omapi), port, intrinsicChannelName = null, @@ -49,8 +51,9 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha context.preferenceRepository.verboseLoggingFlow, context.preferenceRepository.ignoreTLSCertificateFlow, ).also { - Log.i(DefaultEuiccChannelManager.TAG, "Is OMAPI channel, setting MSS to 60") - it.lpa.setEs10xMss(60) + val mss = runBlocking { context.preferenceRepository.es10xMssFlow.first() } + Log.i(DefaultEuiccChannelManager.TAG, "Is OMAPI channel, setting MSS to $mss") + it.lpa.setEs10xMss(mss.toByte()) } } catch (_: IllegalArgumentException) { // Failed @@ -58,9 +61,8 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha DefaultEuiccChannelManager.TAG, "OMAPI APDU interface unavailable for physical slot ${port.card.physicalSlotIndex} with ISD-R AID: ${isdrAid.encodeHex()}." ) + null } - - return null } override fun tryOpenUsbEuiccChannel( diff --git a/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt b/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt index 5f4aec4..0a3a931 100644 --- a/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt +++ b/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt @@ -5,6 +5,7 @@ import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.booleanPreferencesKey import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.intPreferencesKey import androidx.datastore.preferences.core.stringPreferencesKey import androidx.datastore.preferences.preferencesDataStore import androidx.fragment.app.Fragment @@ -38,6 +39,7 @@ internal object PreferenceKeys { val IGNORE_TLS_CERTIFICATE = booleanPreferencesKey("ignore_tls_certificate") val EUICC_MEMORY_RESET = booleanPreferencesKey("euicc_memory_reset") val ISDR_AID_LIST = stringPreferencesKey("isdr_aid_list") + val ES10X_MSS = intPreferencesKey("es10x_mss") } const val EUICC_DEFAULT_ISDR_AID = "A0000005591010FFFFFFFF8900000100" @@ -86,6 +88,7 @@ open class PreferenceRepository(private val context: Context) { PreferenceConstants.DEFAULT_AID_LIST, { Base64.getEncoder().encodeToString(it.encodeToByteArray()) }, { Base64.getDecoder().decode(it).decodeToString() }) + val es10xMssFlow = bindFlow(PreferenceKeys.ES10X_MSS, 60) protected fun bindFlow( key: Preferences.Key, From 42e7cb801948f6f72a050e8a314afcb902d2e128 Mon Sep 17 00:00:00 2001 From: septs Date: Mon, 4 Aug 2025 11:51:08 +0800 Subject: [PATCH 02/10] feat: global es10x mss settings --- .../im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt | 8 +------- .../im/angry/openeuicc/core/DefaultEuiccChannelManager.kt | 6 ++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt b/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt index 73637dd..24d7b99 100644 --- a/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt +++ b/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt @@ -7,8 +7,6 @@ import im.angry.openeuicc.common.R import im.angry.openeuicc.core.usb.UsbApduInterface import im.angry.openeuicc.core.usb.UsbCcidContext import im.angry.openeuicc.util.* -import kotlinx.coroutines.flow.first -import kotlinx.coroutines.runBlocking import java.lang.IllegalArgumentException open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccChannelFactory { @@ -50,11 +48,7 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha isdrAid, context.preferenceRepository.verboseLoggingFlow, context.preferenceRepository.ignoreTLSCertificateFlow, - ).also { - val mss = runBlocking { context.preferenceRepository.es10xMssFlow.first() } - Log.i(DefaultEuiccChannelManager.TAG, "Is OMAPI channel, setting MSS to $mss") - it.lpa.setEs10xMss(mss.toByte()) - } + ) } catch (_: IllegalArgumentException) { // Failed Log.w( diff --git a/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelManager.kt b/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelManager.kt index 6b336cd..56f38e0 100644 --- a/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelManager.kt +++ b/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelManager.kt @@ -99,6 +99,12 @@ open class DefaultEuiccChannelManager( val channel = tryOpenChannelFirstValidAid { euiccChannelFactory.tryOpenEuiccChannel(port, it) } + if (channel != null) { + val mss = context.preferenceRepository.es10xMssFlow.first() + Log.i(TAG, "Set ${channel.type} channel, ES10x MSS to $mss") + channel.lpa.setEs10xMss(mss.toByte()) + } + if (channel != null) { channelCache.add(channel) return channel From d8ef0415b20cedd5bff1146001766a8356405eb3 Mon Sep 17 00:00:00 2001 From: septs Date: Mon, 4 Aug 2025 17:14:44 +0800 Subject: [PATCH 03/10] chore: add preference item --- .../im/angry/openeuicc/ui/SettingsFragment.kt | 20 +++++++++++++++++-- .../angry/openeuicc/util/PreferenceUtils.kt | 2 +- app-common/src/main/res/values/strings.xml | 10 ++++++++++ app-common/src/main/res/xml/pref_settings.xml | 8 ++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/app-common/src/main/java/im/angry/openeuicc/ui/SettingsFragment.kt b/app-common/src/main/java/im/angry/openeuicc/ui/SettingsFragment.kt index 6554142..8e1ff6d 100644 --- a/app-common/src/main/java/im/angry/openeuicc/ui/SettingsFragment.kt +++ b/app-common/src/main/java/im/angry/openeuicc/ui/SettingsFragment.kt @@ -8,6 +8,7 @@ import android.provider.Settings import android.widget.Toast import androidx.lifecycle.lifecycleScope import androidx.preference.CheckBoxPreference +import androidx.preference.ListPreference import androidx.preference.Preference import androidx.preference.PreferenceCategory import androidx.preference.PreferenceFragmentCompat @@ -16,7 +17,6 @@ import im.angry.openeuicc.util.* import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking open class SettingsFragment: PreferenceFragmentCompat() { private lateinit var developerPref: PreferenceCategory @@ -84,6 +84,9 @@ open class SettingsFragment: PreferenceFragmentCompat() { requirePreference("pref_developer_euicc_memory_reset") .bindBooleanFlow(preferenceRepository.euiccMemoryResetFlow) + requirePreference("pref_developer_es10x_mss") + .bindIntFlow(preferenceRepository.es10xMssFlow, 63) + requirePreference("pref_developer_isdr_aid_list").apply { intent = Intent(requireContext(), IsdrAidListActivity::class.java) } @@ -138,13 +141,26 @@ open class SettingsFragment: PreferenceFragmentCompat() { } setOnPreferenceChangeListener { _, newValue -> - runBlocking { + lifecycleScope.launch { flow.updatePreference(newValue as Boolean) } true } } + private fun ListPreference.bindIntFlow(flow: PreferenceFlowWrapper, defaultValue: Int) { + lifecycleScope.launch { + flow.collect { value = it.toString() } + } + + setOnPreferenceChangeListener { _, newValue -> + lifecycleScope.launch { + flow.updatePreference((newValue as String).toIntOrNull() ?: defaultValue) + } + true + } + } + protected fun mergePreferenceOverlay(overlayKey: String, targetKey: String) { val overlayCat = requirePreference(overlayKey) val targetCat = requirePreference(targetKey) diff --git a/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt b/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt index 0a3a931..f72377b 100644 --- a/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt +++ b/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt @@ -88,7 +88,7 @@ open class PreferenceRepository(private val context: Context) { PreferenceConstants.DEFAULT_AID_LIST, { Base64.getEncoder().encodeToString(it.encodeToByteArray()) }, { Base64.getDecoder().decode(it).decodeToString() }) - val es10xMssFlow = bindFlow(PreferenceKeys.ES10X_MSS, 60) + val es10xMssFlow = bindFlow(PreferenceKeys.ES10X_MSS, 63) protected fun bindFlow( key: Preferences.Key, diff --git a/app-common/src/main/res/values/strings.xml b/app-common/src/main/res/values/strings.xml index e09da9f..ae0700b 100644 --- a/app-common/src/main/res/values/strings.xml +++ b/app-common/src/main/res/values/strings.xml @@ -200,6 +200,16 @@ Accept any TLS certificate used by the RSP server Allow erasing eUICC This is a dangerous operation and hidden by default. As an alternative, you can delete all profiles manually. + ES10x MSS + Global ES10x MSS + + High Speed + Compatibility Mode + + + 255 + 63 + Customize ISD-R AID list Some brands of removable eUICCs may use their own non-standard ISD-R AID, rendering them inaccessible to third-party apps. We can attempt to use non-standard AIDs added in this list, but there is no guarantee that they will work. Info diff --git a/app-common/src/main/res/xml/pref_settings.xml b/app-common/src/main/res/xml/pref_settings.xml index 690a120..9dc84ca 100644 --- a/app-common/src/main/res/xml/pref_settings.xml +++ b/app-common/src/main/res/xml/pref_settings.xml @@ -81,6 +81,14 @@ app:summary="@string/pref_developer_euicc_memory_reset_desc" app:title="@string/pref_developer_euicc_memory_reset" /> + + Date: Sun, 10 Aug 2025 22:03:25 +0200 Subject: [PATCH 04/10] feat: 16k page sizes (#211) see https://developer.android.com/guide/practices/page-sizes Reviewed-on: https://gitea.angry.im/PeterCxy/OpenEUICC/pulls/211 Co-authored-by: septs Co-committed-by: septs --- libs/lpac-jni/src/main/jni/Application.mk | 3 ++- libs/lpac-jni/src/main/jni/lpac-jni.mk | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/lpac-jni/src/main/jni/Application.mk b/libs/lpac-jni/src/main/jni/Application.mk index 2112196..c1d3766 100644 --- a/libs/lpac-jni/src/main/jni/Application.mk +++ b/libs/lpac-jni/src/main/jni/Application.mk @@ -1,4 +1,5 @@ APP_ABI := all APP_SHORT_COMMANDS := true APP_CFLAGS := -Wno-compound-token-split-by-macro -APP_LDFLAGS := -Wl,--build-id=none -z muldefs \ No newline at end of file +APP_LDFLAGS := -Wl,--build-id=none -z muldefs +APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true diff --git a/libs/lpac-jni/src/main/jni/lpac-jni.mk b/libs/lpac-jni/src/main/jni/lpac-jni.mk index c0bcee7..dad173c 100644 --- a/libs/lpac-jni/src/main/jni/lpac-jni.mk +++ b/libs/lpac-jni/src/main/jni/lpac-jni.mk @@ -1,4 +1,5 @@ LOCAL_PATH := $(call my-dir) +LOCAL_LDFLAGS += "-Wl,-z,max-page-size=16384" # function to find all *.c files under a directory define all-c-files-under From deb0a372b14caacdf5d3e509135efb9b19c95f10 Mon Sep 17 00:00:00 2001 From: septs Date: Sun, 10 Aug 2025 22:07:10 +0200 Subject: [PATCH 05/10] feat: allow copy app version and source code url (#216) Reviewed-on: https://gitea.angry.im/PeterCxy/OpenEUICC/pulls/216 Co-authored-by: septs Co-committed-by: septs --- app-common/src/main/res/xml/pref_settings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app-common/src/main/res/xml/pref_settings.xml b/app-common/src/main/res/xml/pref_settings.xml index 690a120..17505e1 100644 --- a/app-common/src/main/res/xml/pref_settings.xml +++ b/app-common/src/main/res/xml/pref_settings.xml @@ -96,12 +96,14 @@ Date: Sun, 10 Aug 2025 22:07:25 +0200 Subject: [PATCH 06/10] fix: aid list (#217) Reviewed-on: https://gitea.angry.im/PeterCxy/OpenEUICC/pulls/217 Co-authored-by: septs Co-committed-by: septs --- .../src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt b/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt index 5f4aec4..464aeee 100644 --- a/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt +++ b/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt @@ -50,9 +50,12 @@ internal object PreferenceConstants { # eUICC standard $EUICC_DEFAULT_ISDR_AID - # eSTK.me + # ESTKme AUX (deprecated, use SE0 instead) A06573746B6D65FFFFFFFF4953442D52 + # ESTKme SE0 + A06573746B6D65FFFF4953442D522030 + # eSIM.me A0000005591010000000008900000300 From a8b7482afb98236c591912dc24524da7543bbf59 Mon Sep 17 00:00:00 2001 From: septs Date: Sun, 10 Aug 2025 22:08:31 +0200 Subject: [PATCH 07/10] feat: version name suffix (#215) see https://developer.android.com/build/build-variants Reviewed-on: https://gitea.angry.im/PeterCxy/OpenEUICC/pulls/215 Co-authored-by: septs Co-committed-by: septs --- app-unpriv/build.gradle.kts | 3 +++ app/build.gradle.kts | 3 +++ .../src/main/kotlin/im/angry/openeuicc/build/Versioning.kt | 6 +++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app-unpriv/build.gradle.kts b/app-unpriv/build.gradle.kts index 66a60b4..d59fe71 100644 --- a/app-unpriv/build.gradle.kts +++ b/app-unpriv/build.gradle.kts @@ -27,6 +27,9 @@ android { } buildTypes { + defaultConfig { + versionNameSuffix = "-unpriv" + } release { isMinifyEnabled = false proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b9c2100..69e0db5 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -23,6 +23,9 @@ android { } buildTypes { + defaultConfig { + versionNameSuffix = "-priv" + } release { isMinifyEnabled = false proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") diff --git a/buildSrc/src/main/kotlin/im/angry/openeuicc/build/Versioning.kt b/buildSrc/src/main/kotlin/im/angry/openeuicc/build/Versioning.kt index 24f0235..ef07c43 100644 --- a/buildSrc/src/main/kotlin/im/angry/openeuicc/build/Versioning.kt +++ b/buildSrc/src/main/kotlin/im/angry/openeuicc/build/Versioning.kt @@ -16,7 +16,7 @@ val Project.gitVersionCode: Int standardOutput = stdout } stdout.toString("utf-8").trim('\n').toInt() - } catch (e: Exception) { + } catch (_: Exception) { 0 } @@ -29,7 +29,7 @@ val Project.gitVersionName: String standardOutput = stdout } stdout.toString("utf-8").trim('\n') - } catch (e: Exception) { + } catch (_: Exception) { "Unknown" } @@ -38,7 +38,7 @@ class MyVersioningPlugin: Plugin { target.configure { defaultConfig { versionCode = target.gitVersionCode - versionName = target.gitVersionName + versionName = target.gitVersionName.removePrefix("unpriv-") } applicationVariants.all { From 4c4fa058ae6b2993bd5a227d8277aaab201bc400 Mon Sep 17 00:00:00 2001 From: septs Date: Sat, 2 Aug 2025 13:46:29 +0800 Subject: [PATCH 08/10] feat: es10x mss as preference --- .../openeuicc/core/DefaultEuiccChannelFactory.kt | 14 ++++++++------ .../im/angry/openeuicc/util/PreferenceUtils.kt | 3 +++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt b/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt index 87a0eea..73637dd 100644 --- a/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt +++ b/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt @@ -7,6 +7,8 @@ import im.angry.openeuicc.common.R import im.angry.openeuicc.core.usb.UsbApduInterface import im.angry.openeuicc.core.usb.UsbCcidContext import im.angry.openeuicc.util.* +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.runBlocking import java.lang.IllegalArgumentException open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccChannelFactory { @@ -35,8 +37,8 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha DefaultEuiccChannelManager.TAG, "Trying OMAPI for physical slot ${port.card.physicalSlotIndex}" ) - try { - return EuiccChannelImpl( + return try { + EuiccChannelImpl( context.getString(R.string.channel_type_omapi), port, intrinsicChannelName = null, @@ -49,8 +51,9 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha context.preferenceRepository.verboseLoggingFlow, context.preferenceRepository.ignoreTLSCertificateFlow, ).also { - Log.i(DefaultEuiccChannelManager.TAG, "Is OMAPI channel, setting MSS to 60") - it.lpa.setEs10xMss(60) + val mss = runBlocking { context.preferenceRepository.es10xMssFlow.first() } + Log.i(DefaultEuiccChannelManager.TAG, "Is OMAPI channel, setting MSS to $mss") + it.lpa.setEs10xMss(mss.toByte()) } } catch (_: IllegalArgumentException) { // Failed @@ -58,9 +61,8 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha DefaultEuiccChannelManager.TAG, "OMAPI APDU interface unavailable for physical slot ${port.card.physicalSlotIndex} with ISD-R AID: ${isdrAid.encodeHex()}." ) + null } - - return null } override fun tryOpenUsbEuiccChannel( diff --git a/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt b/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt index 464aeee..069eb8e 100644 --- a/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt +++ b/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt @@ -5,6 +5,7 @@ import androidx.datastore.core.DataStore import androidx.datastore.preferences.core.Preferences import androidx.datastore.preferences.core.booleanPreferencesKey import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.intPreferencesKey import androidx.datastore.preferences.core.stringPreferencesKey import androidx.datastore.preferences.preferencesDataStore import androidx.fragment.app.Fragment @@ -38,6 +39,7 @@ internal object PreferenceKeys { val IGNORE_TLS_CERTIFICATE = booleanPreferencesKey("ignore_tls_certificate") val EUICC_MEMORY_RESET = booleanPreferencesKey("euicc_memory_reset") val ISDR_AID_LIST = stringPreferencesKey("isdr_aid_list") + val ES10X_MSS = intPreferencesKey("es10x_mss") } const val EUICC_DEFAULT_ISDR_AID = "A0000005591010FFFFFFFF8900000100" @@ -89,6 +91,7 @@ open class PreferenceRepository(private val context: Context) { PreferenceConstants.DEFAULT_AID_LIST, { Base64.getEncoder().encodeToString(it.encodeToByteArray()) }, { Base64.getDecoder().decode(it).decodeToString() }) + val es10xMssFlow = bindFlow(PreferenceKeys.ES10X_MSS, 60) protected fun bindFlow( key: Preferences.Key, From cbf9d3ea4193ba333da392601c1e6c866883977f Mon Sep 17 00:00:00 2001 From: septs Date: Mon, 4 Aug 2025 11:51:08 +0800 Subject: [PATCH 09/10] feat: global es10x mss settings --- .../im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt | 8 +------- .../im/angry/openeuicc/core/DefaultEuiccChannelManager.kt | 6 ++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt b/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt index 73637dd..24d7b99 100644 --- a/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt +++ b/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelFactory.kt @@ -7,8 +7,6 @@ import im.angry.openeuicc.common.R import im.angry.openeuicc.core.usb.UsbApduInterface import im.angry.openeuicc.core.usb.UsbCcidContext import im.angry.openeuicc.util.* -import kotlinx.coroutines.flow.first -import kotlinx.coroutines.runBlocking import java.lang.IllegalArgumentException open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccChannelFactory { @@ -50,11 +48,7 @@ open class DefaultEuiccChannelFactory(protected val context: Context) : EuiccCha isdrAid, context.preferenceRepository.verboseLoggingFlow, context.preferenceRepository.ignoreTLSCertificateFlow, - ).also { - val mss = runBlocking { context.preferenceRepository.es10xMssFlow.first() } - Log.i(DefaultEuiccChannelManager.TAG, "Is OMAPI channel, setting MSS to $mss") - it.lpa.setEs10xMss(mss.toByte()) - } + ) } catch (_: IllegalArgumentException) { // Failed Log.w( diff --git a/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelManager.kt b/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelManager.kt index 6b336cd..56f38e0 100644 --- a/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelManager.kt +++ b/app-common/src/main/java/im/angry/openeuicc/core/DefaultEuiccChannelManager.kt @@ -99,6 +99,12 @@ open class DefaultEuiccChannelManager( val channel = tryOpenChannelFirstValidAid { euiccChannelFactory.tryOpenEuiccChannel(port, it) } + if (channel != null) { + val mss = context.preferenceRepository.es10xMssFlow.first() + Log.i(TAG, "Set ${channel.type} channel, ES10x MSS to $mss") + channel.lpa.setEs10xMss(mss.toByte()) + } + if (channel != null) { channelCache.add(channel) return channel From ee40a5ec57771b11471bdb3d9fc29f5efd57e86a Mon Sep 17 00:00:00 2001 From: septs Date: Mon, 4 Aug 2025 17:14:44 +0800 Subject: [PATCH 10/10] chore: add preference item --- .../im/angry/openeuicc/ui/SettingsFragment.kt | 20 +++++++++++++++++-- .../angry/openeuicc/util/PreferenceUtils.kt | 2 +- app-common/src/main/res/values/strings.xml | 10 ++++++++++ app-common/src/main/res/xml/pref_settings.xml | 8 ++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/app-common/src/main/java/im/angry/openeuicc/ui/SettingsFragment.kt b/app-common/src/main/java/im/angry/openeuicc/ui/SettingsFragment.kt index 6554142..8e1ff6d 100644 --- a/app-common/src/main/java/im/angry/openeuicc/ui/SettingsFragment.kt +++ b/app-common/src/main/java/im/angry/openeuicc/ui/SettingsFragment.kt @@ -8,6 +8,7 @@ import android.provider.Settings import android.widget.Toast import androidx.lifecycle.lifecycleScope import androidx.preference.CheckBoxPreference +import androidx.preference.ListPreference import androidx.preference.Preference import androidx.preference.PreferenceCategory import androidx.preference.PreferenceFragmentCompat @@ -16,7 +17,6 @@ import im.angry.openeuicc.util.* import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch -import kotlinx.coroutines.runBlocking open class SettingsFragment: PreferenceFragmentCompat() { private lateinit var developerPref: PreferenceCategory @@ -84,6 +84,9 @@ open class SettingsFragment: PreferenceFragmentCompat() { requirePreference("pref_developer_euicc_memory_reset") .bindBooleanFlow(preferenceRepository.euiccMemoryResetFlow) + requirePreference("pref_developer_es10x_mss") + .bindIntFlow(preferenceRepository.es10xMssFlow, 63) + requirePreference("pref_developer_isdr_aid_list").apply { intent = Intent(requireContext(), IsdrAidListActivity::class.java) } @@ -138,13 +141,26 @@ open class SettingsFragment: PreferenceFragmentCompat() { } setOnPreferenceChangeListener { _, newValue -> - runBlocking { + lifecycleScope.launch { flow.updatePreference(newValue as Boolean) } true } } + private fun ListPreference.bindIntFlow(flow: PreferenceFlowWrapper, defaultValue: Int) { + lifecycleScope.launch { + flow.collect { value = it.toString() } + } + + setOnPreferenceChangeListener { _, newValue -> + lifecycleScope.launch { + flow.updatePreference((newValue as String).toIntOrNull() ?: defaultValue) + } + true + } + } + protected fun mergePreferenceOverlay(overlayKey: String, targetKey: String) { val overlayCat = requirePreference(overlayKey) val targetCat = requirePreference(targetKey) diff --git a/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt b/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt index 069eb8e..2fef3db 100644 --- a/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt +++ b/app-common/src/main/java/im/angry/openeuicc/util/PreferenceUtils.kt @@ -91,7 +91,7 @@ open class PreferenceRepository(private val context: Context) { PreferenceConstants.DEFAULT_AID_LIST, { Base64.getEncoder().encodeToString(it.encodeToByteArray()) }, { Base64.getDecoder().decode(it).decodeToString() }) - val es10xMssFlow = bindFlow(PreferenceKeys.ES10X_MSS, 60) + val es10xMssFlow = bindFlow(PreferenceKeys.ES10X_MSS, 63) protected fun bindFlow( key: Preferences.Key, diff --git a/app-common/src/main/res/values/strings.xml b/app-common/src/main/res/values/strings.xml index e09da9f..ae0700b 100644 --- a/app-common/src/main/res/values/strings.xml +++ b/app-common/src/main/res/values/strings.xml @@ -200,6 +200,16 @@ Accept any TLS certificate used by the RSP server Allow erasing eUICC This is a dangerous operation and hidden by default. As an alternative, you can delete all profiles manually. + ES10x MSS + Global ES10x MSS + + High Speed + Compatibility Mode + + + 255 + 63 + Customize ISD-R AID list Some brands of removable eUICCs may use their own non-standard ISD-R AID, rendering them inaccessible to third-party apps. We can attempt to use non-standard AIDs added in this list, but there is no guarantee that they will work. Info diff --git a/app-common/src/main/res/xml/pref_settings.xml b/app-common/src/main/res/xml/pref_settings.xml index 17505e1..831b04d 100644 --- a/app-common/src/main/res/xml/pref_settings.xml +++ b/app-common/src/main/res/xml/pref_settings.xml @@ -81,6 +81,14 @@ app:summary="@string/pref_developer_euicc_memory_reset_desc" app:title="@string/pref_developer_euicc_memory_reset" /> + +