diff --git a/app-common/src/main/java/im/angry/openeuicc/service/EuiccChannelManagerService.kt b/app-common/src/main/java/im/angry/openeuicc/service/EuiccChannelManagerService.kt index f177f1a..c9a252a 100644 --- a/app-common/src/main/java/im/angry/openeuicc/service/EuiccChannelManagerService.kt +++ b/app-common/src/main/java/im/angry/openeuicc/service/EuiccChannelManagerService.kt @@ -16,10 +16,8 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.onCompletion -import kotlinx.coroutines.flow.takeWhile import kotlinx.coroutines.flow.transformWhile import kotlinx.coroutines.launch import kotlinx.coroutines.withContext @@ -131,13 +129,9 @@ class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker { /** * Launch a potentially blocking foreground task in this service's lifecycle context. * This function does not block, but returns a Flow that emits ForegroundTaskState - * updates associated with this task. The last update the returned flow will emit is - * always ForegroundTaskState.Done. - * + * updates associated with this task. * The task closure is expected to update foregroundTaskState whenever appropriate. * If a foreground task is already running, this function returns null. - * - * The function will set the state back to Idle once it sees ForegroundTaskState.Done. */ private fun launchForegroundTask( title: String, @@ -182,9 +176,6 @@ class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker { // We should be the only task running, so we can subscribe to foregroundTaskState // until we encounter ForegroundTaskState.Done. - // Then, we complete the returned flow, but we also set the state back to Idle. - // The state update back to Idle won't show up in the returned stream, because - // it has been completed by that point. return foregroundTaskState.transformWhile { // Also update our notification when we see an update withContext(Dispatchers.Main) { @@ -195,14 +186,6 @@ class EuiccChannelManagerService : LifecycleService(), OpenEuiccContextMarker { }.onCompletion { foregroundTaskState.value = ForegroundTaskState.Idle } } - val isForegroundTaskRunning: Boolean - get() = foregroundTaskState.value != ForegroundTaskState.Idle - - suspend fun waitForForegroundTask() { - foregroundTaskState.takeWhile { it != ForegroundTaskState.Idle } - .collect() - } - fun launchProfileDownloadTask( slotId: Int, portId: Int, 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 14d958d..fc2aa5c 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 @@ -155,7 +155,6 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener, lifecycleScope.launch { ensureEuiccChannelManager() - euiccChannelManagerService.waitForForegroundTask() if (!this@EuiccManagementFragment::disableSafeguardFlow.isInitialized) { disableSafeguardFlow = diff --git a/app-common/src/main/java/im/angry/openeuicc/ui/MainActivity.kt b/app-common/src/main/java/im/angry/openeuicc/ui/MainActivity.kt index 17c99ff..1307513 100644 --- a/app-common/src/main/java/im/angry/openeuicc/ui/MainActivity.kt +++ b/app-common/src/main/java/im/angry/openeuicc/ui/MainActivity.kt @@ -134,8 +134,6 @@ open class MainActivity : BaseEuiccAccessActivity(), OpenEuiccContextMarker { loadingProgress.visibility = View.VISIBLE viewPager.visibility = View.GONE tabs.visibility = View.GONE - // Prevent concurrent access with any running foreground task - euiccChannelManagerService.waitForForegroundTask() val knownChannels = withContext(Dispatchers.IO) { euiccChannelManager.enumerateEuiccChannels().onEach { diff --git a/app-common/src/main/java/im/angry/openeuicc/ui/ProfileDownloadFragment.kt b/app-common/src/main/java/im/angry/openeuicc/ui/ProfileDownloadFragment.kt index 35825bf..99ac003 100644 --- a/app-common/src/main/java/im/angry/openeuicc/ui/ProfileDownloadFragment.kt +++ b/app-common/src/main/java/im/angry/openeuicc/ui/ProfileDownloadFragment.kt @@ -160,12 +160,6 @@ class ProfileDownloadFragment : BaseMaterialDialogFragment(), lifecycleScope.launch(Dispatchers.IO) { ensureEuiccChannelManager() - if (euiccChannelManagerService.isForegroundTaskRunning) { - withContext(Dispatchers.Main) { - dismiss() - } - return@launch - } // Fetch remaining NVRAM val str = channel.lpa.euiccInfo2?.freeNvram?.also {