浏览代码

OpenEuiccService: prevent crashing when AOSP queries an unmapped slot

To properly fix this we need to temporarily enable disabled slots when
they are requested by AOSP. For now let's just stop OpenEUICC from
crashing.
Peter Cai 1 年之前
父节点
当前提交
8b38a5a58d
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      app/src/main/java/im/angry/openeuicc/service/OpenEuiccService.kt

+ 6 - 1
app/src/main/java/im/angry/openeuicc/service/OpenEuiccService.kt

@@ -131,7 +131,12 @@ class OpenEuiccService : EuiccService(), OpenEuiccContextMarker {
             return GetEuiccProfileInfoListResult(RESULT_FIRST_USER, arrayOf(), true)
         }
 
-        val channel = findChannel(slotId)!!
+        // TODO: Temporarily enable the slot to access its profiles if it is currently unmapped
+        val channel = findChannel(slotId) ?: return GetEuiccProfileInfoListResult(
+            RESULT_FIRST_USER,
+            arrayOf(),
+            true
+        )
         val profiles = channel.lpa.profiles.operational.map {
             EuiccProfileInfo.Builder(it.iccid).apply {
                 setProfileName(it.name)