浏览代码

PrivilegedTelephonyUtils: do not disable profiles on external eUICCs

Peter Cai 2 年之前
父节点
当前提交
41a53816f8
共有 1 个文件被更改,包括 11 次插入3 次删除
  1. 11 3
      app/src/main/java/im/angry/openeuicc/util/PrivilegedTelephonyUtils.kt

+ 11 - 3
app/src/main/java/im/angry/openeuicc/util/PrivilegedTelephonyUtils.kt

@@ -19,9 +19,11 @@ fun TelephonyManager.setDsdsEnabled(euiccManager: EuiccChannelManager, enabled:
         euiccManager.enumerateEuiccChannels()
     }
 
-    // Disable all eSIM profiles before performing a DSDS switch
+    // Disable all eSIM profiles before performing a DSDS switch (only for internal eSIMs)
     euiccManager.knownChannels.forEach {
-        it.lpa.disableActiveProfileWithUndo()
+        if (!it.removable) {
+            it.lpa.disableActiveProfileWithUndo()
+        }
     }
 
     switchMultiSimConfig(if (enabled) { 2 } else { 1 })
@@ -42,7 +44,13 @@ fun TelephonyManager.updateSimSlotMapping(
 
     val undo = unmapped.mapNotNull { mapping ->
         euiccManager.findEuiccChannelByPortBlocking(mapping.physicalSlotIndex, mapping.portIndex)?.let { channel ->
-            return@mapNotNull channel.lpa.disableActiveProfileWithUndo()
+            if (!channel.removable) {
+                return@mapNotNull channel.lpa.disableActiveProfileWithUndo()
+            } else {
+                // Do not do anything for external eUICCs -- we can't really trust them to work properly
+                // with no profile enabled.
+                return@mapNotNull null
+            }
         }
     }