Browse Source

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 year ago
parent
commit
8b38a5a58d

+ 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)
             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 {
         val profiles = channel.lpa.profiles.operational.map {
             EuiccProfileInfo.Builder(it.iccid).apply {
             EuiccProfileInfo.Builder(it.iccid).apply {
                 setProfileName(it.name)
                 setProfileName(it.name)