diff --git a/app-common/src/main/AndroidManifest.xml b/app-common/src/main/AndroidManifest.xml index 464ae0f..6edaaf1 100644 --- a/app-common/src/main/AndroidManifest.xml +++ b/app-common/src/main/AndroidManifest.xml @@ -7,7 +7,6 @@ - - val refresh = preferenceRepository.refreshAfterSwitchFlow.first() - val response = channel.lpa.switchProfile(iccid, enable, refresh) - if (response || !refresh) { - Pair(response, refresh) - } else { - // refresh failed, but refresh was requested - // Sometimes, we *can* enable or disable the profile, but we cannot - // send the refresh command to the modem because the profile somehow - // makes the modem "busy". In this case, we can still switch by setting - // refresh to false, but then the switch cannot take effect until the - // user resets the modem manually by toggling airplane mode or rebooting. - Pair( - channel.lpa.switchProfile(iccid, enable, refresh = false), - false - ) - } + val (res, refreshed) = euiccChannelManager.withEuiccChannel( + slotId, + portId + ) { channel -> + if (!channel.lpa.switchProfile(iccid, enable, refresh = true)) { + // Sometimes, we *can* enable or disable the profile, but we cannot + // send the refresh command to the modem because the profile somehow + // makes the modem "busy". In this case, we can still switch by setting + // refresh to false, but then the switch cannot take effect until the + // user resets the modem manually by toggling airplane mode or rebooting. + Pair(channel.lpa.switchProfile(iccid, enable, refresh = false), false) + } else { + Pair(true, true) } + } - if (!response) { + if (!res) { throw RuntimeException("Could not switch profile") } 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 d137e90..b085286 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 @@ -78,9 +78,6 @@ open class SettingsFragment: PreferenceFragmentCompat() { requirePreference("pref_developer_ignore_tls_certificate") .bindBooleanFlow(preferenceRepository.ignoreTLSCertificateFlow) - requirePreference("pref_developer_refresh_after_switch") - .bindBooleanFlow(preferenceRepository.refreshAfterSwitchFlow) - requirePreference("pref_developer_euicc_memory_reset") .bindBooleanFlow(preferenceRepository.euiccMemoryResetFlow) } diff --git a/app-common/src/main/java/im/angry/openeuicc/ui/wizard/DownloadWizardActivity.kt b/app-common/src/main/java/im/angry/openeuicc/ui/wizard/DownloadWizardActivity.kt index 9e312d4..a9f868f 100644 --- a/app-common/src/main/java/im/angry/openeuicc/ui/wizard/DownloadWizardActivity.kt +++ b/app-common/src/main/java/im/angry/openeuicc/ui/wizard/DownloadWizardActivity.kt @@ -3,7 +3,6 @@ package im.angry.openeuicc.ui.wizard import android.app.assist.AssistContent import android.os.Bundle import android.view.View -import android.view.WindowManager import android.view.inputmethod.InputMethodManager import android.widget.Button import android.widget.ProgressBar @@ -252,14 +251,6 @@ class DownloadWizardActivity: BaseEuiccAccessActivity() { supportFragmentManager.beginTransaction().setCustomAnimations(enterAnim, exitAnim) .replace(R.id.step_fragment_container, nextFrag) .commit() - - // Sync screen on state - if (nextFrag.keepScreenOn) { - window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) - } else { - window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) - } - refreshButtons() } @@ -289,8 +280,6 @@ class DownloadWizardActivity: BaseEuiccAccessActivity() { protected val state: DownloadWizardState get() = (requireActivity() as DownloadWizardActivity).state - open val keepScreenOn = false - abstract val hasNext: Boolean abstract val hasPrev: Boolean abstract fun createNextFragment(): DownloadWizardStepFragment? diff --git a/app-common/src/main/java/im/angry/openeuicc/ui/wizard/DownloadWizardProgressFragment.kt b/app-common/src/main/java/im/angry/openeuicc/ui/wizard/DownloadWizardProgressFragment.kt index 342a687..1b816d4 100644 --- a/app-common/src/main/java/im/angry/openeuicc/ui/wizard/DownloadWizardProgressFragment.kt +++ b/app-common/src/main/java/im/angry/openeuicc/ui/wizard/DownloadWizardProgressFragment.kt @@ -59,9 +59,6 @@ class DownloadWizardProgressFragment : DownloadWizardActivity.DownloadWizardStep private val adapter = ProgressItemAdapter() - // We don't want to turn off the screen during a download - override val keepScreenOn = true - private var isDone = false override val hasNext: Boolean 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 c69c5e4..34d1cfd 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 @@ -31,7 +31,6 @@ internal object PreferenceKeys { // ---- Developer Options ---- val DEVELOPER_OPTIONS_ENABLED = booleanPreferencesKey("developer_options_enabled") - val REFRESH_AFTER_SWITCH = booleanPreferencesKey("refresh_after_switch") val UNFILTERED_PROFILE_LIST = booleanPreferencesKey("unfiltered_profile_list") val IGNORE_TLS_CERTIFICATE = booleanPreferencesKey("ignore_tls_certificate") val EUICC_MEMORY_RESET = booleanPreferencesKey("euicc_memory_reset") @@ -49,7 +48,6 @@ open class PreferenceRepository(private val context: Context) { val verboseLoggingFlow = bindFlow(PreferenceKeys.VERBOSE_LOGGING, false) // ---- Developer Options ---- - val refreshAfterSwitchFlow = bindFlow(PreferenceKeys.REFRESH_AFTER_SWITCH, true) val developerOptionsEnabledFlow = bindFlow(PreferenceKeys.DEVELOPER_OPTIONS_ENABLED, false) val unfilteredProfileListFlow = bindFlow(PreferenceKeys.UNFILTERED_PROFILE_LIST, false) val ignoreTLSCertificateFlow = bindFlow(PreferenceKeys.IGNORE_TLS_CERTIFICATE, false) @@ -62,12 +60,15 @@ open class PreferenceRepository(private val context: Context) { class PreferenceFlowWrapper private constructor( private val context: Context, private val key: Preferences.Key, - inner: Flow, + inner: Flow ) : Flow by inner { - internal constructor(context: Context, key: Preferences.Key, defaultValue: T) : - this(context, key, context.dataStore.data.map { it[key] ?: defaultValue }) + internal constructor(context: Context, key: Preferences.Key, defaultValue: T) : this( + context, + key, + context.dataStore.data.map { it[key] ?: defaultValue } + ) suspend fun updatePreference(value: T) { context.dataStore.edit { it[key] = value } } -} +} \ No newline at end of file diff --git a/app-common/src/main/java/im/angry/openeuicc/util/Utils.kt b/app-common/src/main/java/im/angry/openeuicc/util/Utils.kt index 046657f..5a559f9 100644 --- a/app-common/src/main/java/im/angry/openeuicc/util/Utils.kt +++ b/app-common/src/main/java/im/angry/openeuicc/util/Utils.kt @@ -54,9 +54,6 @@ interface OpenEuiccContextMarker { val appContainer: AppContainer get() = openEuiccApplication.appContainer - val preferenceRepository: PreferenceRepository - get() = appContainer.preferenceRepository - val telephonyManager: TelephonyManager get() = appContainer.telephonyManager } diff --git a/app-common/src/main/res/values-ja/strings.xml b/app-common/src/main/res/values-ja/strings.xml index 35fd400..644e564 100644 --- a/app-common/src/main/res/values-ja/strings.xml +++ b/app-common/src/main/res/values-ja/strings.xml @@ -143,7 +143,6 @@ ログ アプリの最新デバッグログを表示します 開発者オプション - プロファイルを切り替えた後にモデムに更新コマンドを送信するかどうか。クラッシュが発生する場合は、これを無効にしてみてください。 フィルタリングされていないプロファイル一覧を表示 非運用のプロファイルも含めます SM-DP+ TLS 証明書を無視する @@ -163,5 +162,4 @@ 消去する eUICC の消去を可能にする この操作は、デフォルトでは非表示になっている危険な操作です。代わりに、すべての構成ファイルを手動で削除することもできます。 - モデムに更新コマンドを送信 diff --git a/app-common/src/main/res/values-zh-rCN/strings.xml b/app-common/src/main/res/values-zh-rCN/strings.xml index 2e069bd..789b532 100644 --- a/app-common/src/main/res/values-zh-rCN/strings.xml +++ b/app-common/src/main/res/values-zh-rCN/strings.xml @@ -145,7 +145,6 @@ 语言 选择 App 语言 开发者选项 - 切换配置文件后是否向基带发送刷新命令。如果发现崩溃,请尝试禁用此功能。 显示未经过滤的配置文件列表 在配置文件列表中包括非生产环境的配置文件 无视 SM-DP+ 的 TLS 证书 @@ -163,5 +162,4 @@ 擦除 允许擦除 eUICC 此操作是默认隐藏的危险操作。作为替代方案,您可以手动删除所有配置文件。 - 向基带发送刷新命令 \ No newline at end of file diff --git a/app-common/src/main/res/values-zh-rTW/strings.xml b/app-common/src/main/res/values-zh-rTW/strings.xml index 729893c..53be571 100644 --- a/app-common/src/main/res/values-zh-rTW/strings.xml +++ b/app-common/src/main/res/values-zh-rTW/strings.xml @@ -145,7 +145,6 @@ 語言 選擇 App 語言 開發人員選項 - 切換設定檔後是否向基帶發送刷新命令。如果發現崩潰,請嘗試停用此功能。 顯示未經過濾的設定檔列表 在設定檔列表中包括非生產環境的設定檔 忽略 SM-DP+ 的 TLS 證書 @@ -163,5 +162,4 @@ 擦除 允許擦除 eUICC 此操作是預設隱藏的危險操作。作為替代方案,您可以手動刪除所有設定檔。 - 向基帶發送刷新命令 \ No newline at end of file diff --git a/app-common/src/main/res/values/strings.xml b/app-common/src/main/res/values/strings.xml index a366b88..8146f54 100644 --- a/app-common/src/main/res/values/strings.xml +++ b/app-common/src/main/res/values/strings.xml @@ -181,8 +181,6 @@ Logs View recent debug logs of the application Developer Options - Send refresh command to modem - Whether to send a refresh command to the modem after switching profiles. Try disabling this if you see crashes. Show unfiltered profile list Include non-production profiles in the list Ignore SM-DP+ TLS certificate diff --git a/app-common/src/main/res/xml/pref_settings.xml b/app-common/src/main/res/xml/pref_settings.xml index ce700f5..7d25118 100644 --- a/app-common/src/main/res/xml/pref_settings.xml +++ b/app-common/src/main/res/xml/pref_settings.xml @@ -57,12 +57,6 @@ app:title="@string/pref_developer" app:iconSpaceReserved="false"> - - com.android.stk/.StkMainHide com.android.stk/.StkListActivity com.android.stk/.StkLauncherListActivity - com.android.stk/.StkSelectionActivity com.android.stk/.StkMain1 com.android.stk/.PrimaryStkMain com.android.stk/.StkLauncherActivity com.android.stk/.StkLauncherActivity_Chn - com.android.stk/.StkLauncherActivity1 com.android.stk/.StkLauncherActivityI com.android.stk/.OppoStkLauncherActivity1 com.android.stk/.OplusStkLauncherActivity1 diff --git a/app/src/main/java/im/angry/openeuicc/core/PrivilegedEuiccChannelFactory.kt b/app/src/main/java/im/angry/openeuicc/core/PrivilegedEuiccChannelFactory.kt index d9bceda..6dccda9 100644 --- a/app/src/main/java/im/angry/openeuicc/core/PrivilegedEuiccChannelFactory.kt +++ b/app/src/main/java/im/angry/openeuicc/core/PrivilegedEuiccChannelFactory.kt @@ -10,8 +10,9 @@ import java.lang.IllegalArgumentException class PrivilegedEuiccChannelFactory(context: Context) : DefaultEuiccChannelFactory(context), PrivilegedEuiccContextMarker { - override val openEuiccMarkerContext: Context - get() = context + private val tm by lazy { + (context.applicationContext as OpenEuiccApplication).appContainer.telephonyManager + } @Suppress("NAME_SHADOWING") override suspend fun tryOpenEuiccChannel(port: UiccPortInfoCompat): EuiccChannel? { @@ -34,7 +35,7 @@ class PrivilegedEuiccChannelFactory(context: Context) : DefaultEuiccChannelFacto intrinsicChannelName = null, TelephonyManagerApduInterface( port, - telephonyManager, + tm, context.preferenceRepository.verboseLoggingFlow ), context.preferenceRepository.verboseLoggingFlow, diff --git a/app/src/main/java/im/angry/openeuicc/util/PrivilegedUtils.kt b/app/src/main/java/im/angry/openeuicc/util/PrivilegedUtils.kt index 6418581..21c8002 100644 --- a/app/src/main/java/im/angry/openeuicc/util/PrivilegedUtils.kt +++ b/app/src/main/java/im/angry/openeuicc/util/PrivilegedUtils.kt @@ -10,9 +10,16 @@ import java.util.concurrent.Executors import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine -interface PrivilegedEuiccContextMarker : OpenEuiccContextMarker { - override val preferenceRepository: PrivilegedPreferenceRepository - get() = appContainer.preferenceRepository as PrivilegedPreferenceRepository +interface PrivilegedEuiccContextMarker { + val privilegedEuiccMarkerContext: Context + get() = when (this) { + is Context -> this + is Fragment -> requireContext() + else -> throw RuntimeException("PrivilegedEuiccContextMarker shall only be used on Fragments or UI types that derive from Context") + } + + val preferenceRepository: PrivilegedPreferenceRepository + get() = privilegedEuiccMarkerContext.preferenceRepository as PrivilegedPreferenceRepository } suspend fun Context.bindServiceSuspended(intent: Intent, flags: Int): Pair Unit> =