feat: show unfiltered profile list in developer options (#73)
All checks were successful
/ build-debug (push) Successful in 4m9s
All checks were successful
/ build-debug (push) Successful in 4m9s
resolves #40 #30 Reviewed-on: #73 Co-authored-by: septs <github@septs.pw> Co-committed-by: septs <github@septs.pw>
This commit is contained in:
parent
92daa56f1a
commit
6bb1a16aee
6 changed files with 35 additions and 5 deletions
|
@ -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<Boolean>
|
||||
|
||||
private lateinit var unfilteredProfileListFlow: StateFlow<Boolean>
|
||||
|
||||
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 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,13 +76,16 @@ class SettingsFragment: PreferenceFragmentCompat() {
|
|||
findPreference<CheckBoxPreference>("pref_developer_experimental_download_wizard")
|
||||
?.bindBooleanFlow(preferenceRepository.experimentalDownloadWizardFlow, PreferenceKeys.EXPERIMENTAL_DOWNLOAD_WIZARD)
|
||||
|
||||
findPreference<CheckBoxPreference>("pref_developer_unfiltered_profile_list")
|
||||
?.bindBooleanFlow(preferenceRepository.unfilteredProfileListFlow, PreferenceKeys.UNFILTERED_PROFILE_LIST)
|
||||
|
||||
findPreference<CheckBoxPreference>("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")
|
||||
|
|
|
@ -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<Boolean> =
|
||||
dataStore.data.map { it[PreferenceKeys.EXPERIMENTAL_DOWNLOAD_WIZARD] ?: false }
|
||||
|
||||
val unfilteredProfileListFlow: Flow<Boolean> =
|
||||
dataStore.data.map { it[PreferenceKeys.UNFILTERED_PROFILE_LIST] ?: false }
|
||||
|
||||
val ignoreTLSCertificateFlow: Flow<Boolean> =
|
||||
dataStore.data.map { it[PreferenceKeys.IGNORE_TLS_CERTIFICATE] ?: false }
|
||||
|
||||
|
|
|
@ -151,6 +151,8 @@
|
|||
<string name="pref_developer">Developer Options</string>
|
||||
<string name="pref_developer_experimental_download_wizard">Experimental Download Wizard</string>
|
||||
<string name="pref_developer_experimental_download_wizard_desc">Enable the experimental new download wizard. Note that it is not fully working yet.</string>
|
||||
<string name="pref_developer_unfiltered_profile_list">Show unfiltered profile list</string>
|
||||
<string name="pref_developer_unfiltered_profile_list_desc">Display any profile class in the list</string>
|
||||
<string name="pref_developer_ignore_tls_certificate">Ignore SM-DP+ TLS certificate</string>
|
||||
<string name="pref_developer_ignore_tls_certificate_desc">Ignore SM-DP+ TLS certificate, allow any RSP</string>
|
||||
<string name="pref_info">Info</string>
|
||||
|
|
|
@ -55,6 +55,12 @@
|
|||
app:title="@string/pref_developer_experimental_download_wizard"
|
||||
app:summary="@string/pref_developer_experimental_download_wizard_desc" />
|
||||
|
||||
<CheckBoxPreference
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="pref_developer_unfiltered_profile_list"
|
||||
app:summary="@string/pref_developer_unfiltered_profile_list_desc"
|
||||
app:title="@string/pref_developer_unfiltered_profile_list" />
|
||||
|
||||
<CheckBoxPreference
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="pref_developer_ignore_tls_certificate"
|
||||
|
|
|
@ -13,6 +13,7 @@ import im.angry.openeuicc.core.EuiccChannelManager
|
|||
import im.angry.openeuicc.service.EuiccChannelManagerService.Companion.waitDone
|
||||
import im.angry.openeuicc.util.*
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlin.IllegalStateException
|
||||
|
||||
|
@ -190,7 +191,12 @@ class OpenEuiccService : EuiccService(), OpenEuiccContextMarker {
|
|||
slotId,
|
||||
port
|
||||
) { channel ->
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue