CompatibilityCheck: show unknown status when "secure element is not present"
All checks were successful
/ build-debug (push) Successful in 4m3s

Some devices "optimize" their OMAPI by reporting this status when both
slots are empty. Even just inserting one SIM would fix this error for
both slots.

In this case, we should not imply that the device is incompatible.
This commit is contained in:
Peter Cai 2024-02-19 16:58:33 -05:00
parent 048764d305
commit 252000660a
5 changed files with 28 additions and 1 deletions

View file

@ -64,6 +64,9 @@ class CompatibilityCheckActivity: AppCompatActivity() {
CompatibilityCheck.State.FAILURE -> {
root.findViewById<View>(R.id.compatibility_check_error).visibility = View.VISIBLE
}
CompatibilityCheck.State.FAILURE_UNKNOWN -> {
root.findViewById<View>(R.id.compatibility_check_unknown).visibility = View.VISIBLE
}
else -> {
root.findViewById<View>(R.id.compatibility_check_progress_bar).visibility = View.VISIBLE
}

View file

@ -9,6 +9,7 @@ import im.angry.easyeuicc.R
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext
import java.io.IOException
fun getCompatibilityChecks(context: Context): List<CompatibilityCheck> =
listOf(
@ -38,6 +39,7 @@ abstract class CompatibilityCheck(context: Context) {
NOT_STARTED,
IN_PROGRESS,
SUCCESS,
FAILURE_UNKNOWN, // The check technically failed, but no conclusion can be drawn
FAILURE
}
@ -49,7 +51,7 @@ abstract class CompatibilityCheck(context: Context) {
val description: String
get() = when {
state == State.FAILURE && this::failureDescription.isInitialized -> failureDescription
(state == State.FAILURE || state == State.FAILURE_UNKNOWN) && this::failureDescription.isInitialized -> failureDescription
else -> defaultDescription
}
@ -139,6 +141,14 @@ internal class IsdrChannelAccessCheck(private val context: Context): Compatibili
// ref: https://android.googlesource.com/platform/frameworks/base/+/4fe64fb4712a99d5da9c9a0eb8fd5169b252e1e1/omapi/java/android/se/omapi/Session.java#305
// SecurityException is only thrown when Channel is constructed, which means everything else needs to succeed
Pair(it.slotIndex, State.SUCCESS)
} catch (e: IOException) {
e.printStackTrace()
if (e.message?.contains("Secure Element is not present") == true) {
failureDescription = context.getString(R.string.compatibility_check_isdr_channel_desc_unknown)
Pair(it.slotIndex, State.FAILURE_UNKNOWN)
} else {
Pair(it.slotIndex, State.FAILURE)
}
} catch (e: Exception) {
e.printStackTrace()
Pair(it.slotIndex, State.FAILURE)

View file

@ -0,0 +1,5 @@
<vector android:autoMirrored="true" android:height="24dp"
android:tint="?attr/colorControlNormal" android:viewportHeight="24"
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M11,18h2v-2h-2v2zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM12,6c-2.21,0 -4,1.79 -4,4h2c0,-1.1 0.9,-2 2,-2s2,0.9 2,2c0,2 -3,1.75 -3,5h2c0,-2.25 3,-2.5 3,-5 0,-2.21 -1.79,-4 -4,-4z"/>
</vector>

View file

@ -60,6 +60,14 @@
android:layout_width="32dp"
android:layout_height="32dp" />
<ImageView
android:id="@+id/compatibility_check_unknown"
android:src="@drawable/ic_question_outline"
android:visibility="gone"
android:layout_gravity="center"
android:layout_width="32dp"
android:layout_height="32dp" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -13,6 +13,7 @@
<string name="compatibility_check_omapi_connectivity_fail_sim_number">Only the following SIM slots are accessible via OMAPI: %s.</string>
<string name="compatibility_check_isdr_channel">ISD-R Channel Access</string>
<string name="compatibility_check_isdr_channel_desc">Does your device support opening an ISD-R (management) channel to eSIMs via OMAPI?</string>
<string name="compatibility_check_isdr_channel_desc_unknown">Cannot determine whether ISD-R access through OMAPI is supported. You might want to retry with SIM cards inserted (any SIM card will do) if not already.</string>
<string name="compatibility_check_isdr_channel_desc_partial_fail">OMAPI access to ISD-R is only possible on the following SIM slots: %s.</string>
<string name="compatibility_check_known_broken">Known Broken?</string>
<string name="compatibility_check_known_broken_desc">Making sure your device is not known to have bugs associated with removable eSIMs.</string>