diff --git a/app-common/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt b/app-common/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt index 6ab6935..b7462e2 100644 --- a/app-common/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt +++ b/app-common/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt @@ -65,6 +65,8 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener, // This gives us access to the "latest" state without having to launch coroutines private lateinit var disableSafeguardFlow: StateFlow + private lateinit var unfilteredProfileListFlow: StateFlow + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setHasOptionsMenu(true) @@ -185,15 +187,22 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener, ensureEuiccChannelManager() euiccChannelManagerService.waitForForegroundTask() - if (!this@EuiccManagementFragment::disableSafeguardFlow.isInitialized) { + if (!::disableSafeguardFlow.isInitialized) { disableSafeguardFlow = preferenceRepository.disableSafeguardFlow.stateIn(lifecycleScope) } + if (!::unfilteredProfileListFlow.isInitialized) { + unfilteredProfileListFlow = + preferenceRepository.unfilteredProfileListFlow.stateIn(lifecycleScope) + } val profiles = withEuiccChannel { channel -> logicalSlotId = channel.logicalSlotId euiccChannelManager.notifyEuiccProfilesChanged(channel.logicalSlotId) - channel.lpa.profiles.operational + if (unfilteredProfileListFlow.value) + channel.lpa.profiles + else + channel.lpa.profiles.operational } withContext(Dispatchers.Main) { @@ -302,7 +311,7 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener, companion object { fun fromInt(value: Int) = - Type.values().first { it.value == value } + entries.first { it.value == value } } } } 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 89963cb..9c071bd 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 @@ -76,13 +76,16 @@ class SettingsFragment: PreferenceFragmentCompat() { findPreference("pref_developer_experimental_download_wizard") ?.bindBooleanFlow(preferenceRepository.experimentalDownloadWizardFlow, PreferenceKeys.EXPERIMENTAL_DOWNLOAD_WIZARD) + findPreference("pref_developer_unfiltered_profile_list") + ?.bindBooleanFlow(preferenceRepository.unfilteredProfileListFlow, PreferenceKeys.UNFILTERED_PROFILE_LIST) + findPreference("pref_ignore_tls_certificate") ?.bindBooleanFlow(preferenceRepository.ignoreTLSCertificateFlow, PreferenceKeys.IGNORE_TLS_CERTIFICATE) } override fun onStart() { super.onStart() - setupRootViewInsets(requireView().requireViewById(androidx.preference.R.id.recycler_view)) + setupRootViewInsets(requireView().requireViewById(R.id.recycler_view)) } @Suppress("UNUSED_PARAMETER") 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 505630e..ae5e3b8 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 @@ -32,6 +32,7 @@ object PreferenceKeys { // ---- Developer Options ---- val DEVELOPER_OPTIONS_ENABLED = booleanPreferencesKey("developer_options_enabled") val EXPERIMENTAL_DOWNLOAD_WIZARD = booleanPreferencesKey("experimental_download_wizard") + val UNFILTERED_PROFILE_LIST = booleanPreferencesKey("unfiltered_profile_list") val IGNORE_TLS_CERTIFICATE = booleanPreferencesKey("ignore_tls_certificate") } @@ -63,6 +64,9 @@ class PreferenceRepository(context: Context) { val experimentalDownloadWizardFlow: Flow = dataStore.data.map { it[PreferenceKeys.EXPERIMENTAL_DOWNLOAD_WIZARD] ?: false } + val unfilteredProfileListFlow: Flow = + dataStore.data.map { it[PreferenceKeys.UNFILTERED_PROFILE_LIST] ?: false } + val ignoreTLSCertificateFlow: Flow = dataStore.data.map { it[PreferenceKeys.IGNORE_TLS_CERTIFICATE] ?: false } diff --git a/app-common/src/main/res/values/strings.xml b/app-common/src/main/res/values/strings.xml index a3067dd..73b1938 100644 --- a/app-common/src/main/res/values/strings.xml +++ b/app-common/src/main/res/values/strings.xml @@ -151,6 +151,8 @@ Developer Options Experimental Download Wizard Enable the experimental new download wizard. Note that it is not fully working yet. + Show unfiltered profile list + Display any profile class in the list Ignore SM-DP+ TLS certificate Ignore SM-DP+ TLS certificate, allow any RSP Info diff --git a/app-common/src/main/res/xml/pref_settings.xml b/app-common/src/main/res/xml/pref_settings.xml index d43c84b..60646bc 100644 --- a/app-common/src/main/res/xml/pref_settings.xml +++ b/app-common/src/main/res/xml/pref_settings.xml @@ -55,6 +55,12 @@ app:title="@string/pref_developer_experimental_download_wizard" app:summary="@string/pref_developer_experimental_download_wizard_desc" /> + + - val profiles = channel.lpa.profiles.operational.map { + val filteredProfiles = + if (runBlocking { preferenceRepository.unfilteredProfileListFlow.first() }) + channel.lpa.profiles + else + channel.lpa.profiles.operational + val profiles = filteredProfiles.map { EuiccProfileInfo.Builder(it.iccid).apply { setProfileName(it.name) setNickname(it.displayName)