浏览代码

fix: Try to disable the current profile before switching

Peter Cai 1 年之前
父节点
当前提交
ff427759d7
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      app-common/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt

+ 6 - 0
app-common/src/main/java/im/angry/openeuicc/ui/EuiccManagementFragment.kt

@@ -130,6 +130,12 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener,
         lifecycleScope.launch {
             beginTrackedOperation {
                 val res = if (enable) {
+                    channel.lpa.profiles.find { it.isEnabled }?.let {
+                        Log.i(TAG, "Profile ${it.iccid} is enabled; disabling before switching to new profile")
+                        // Don't refresh -- we'll refresh later when enabling.
+                        // Also ignore errors -- this is only a hard error if the enabling step fails.
+                        channel.lpa.disableProfile(it.iccid, false)
+                    }
                     channel.lpa.enableProfile(iccid)
                 } else {
                     channel.lpa.disableProfile(iccid)