Modern Apps git

← Modern-Apps.git

euicc: fix lpa deep link crash on opaque URI

Commit
711c62c846b08baa345d641aa40ec8004f104fe9
Author
Vayun Mathur <[email protected]>
When
2026-11-07 05:55 UTC (29 days ago)
Parents
cf7e3f8
AddEsimActivity called Uri.getQueryParameter on the intent data
before checking the scheme. For a raw lpa:<code> deep link the URI
is opaque, so getQueryParameter throws
UnsupportedOperationException (This isn't a hierarchical URI) and
the activity crashes on launch instead of opening the download
flow its manifest advertises.

Check the scheme first: lpa URIs read schemeSpecificPart, other
URIs read the carddata query parameter. Found by a Robolectric
activity test added with the euicc coverage tests.

(cherry picked from commit 04daf0dfe6d8931545bda1749dcbc0cdb1cfc596)

Diff

euicc/src/main/java/com/vayunmathur/euicc/platform/AddEsimActivity.kt
diff --git a/euicc/src/main/java/com/vayunmathur/euicc/platform/AddEsimActivity.kt b/euicc/src/main/java/com/vayunmathur/euicc/platform/AddEsimActivity.ktindex 8cd4422903..1e2b163fc8 100644--- a/euicc/src/main/java/com/vayunmathur/euicc/platform/AddEsimActivity.kt+++ b/euicc/src/main/java/com/vayunmathur/euicc/platform/AddEsimActivity.kt@@ -36,13 +36,14 @@ class AddEsimActivity : ComponentActivity() {         super.onCreate(savedInstanceState)         enableEdgeToEdge()         // Universal link (`...?carddata=<code>`) or raw `lpa:<code>` deep link.-        val carddata = intent?.data?.getQueryParameter(EsimLink.CARDDATA_PARAM)?.trim().orEmpty()-        val rawLpa = if (intent?.data?.scheme.equals("lpa", ignoreCase = true)) {-            intent?.data?.schemeSpecificPart?.trim().orEmpty()+        // An `lpa:` URI is opaque, and getQueryParameter throws on opaque URIs,+        // so the scheme decides which accessor is safe before either is called.+        val data = intent?.data+        val code = if (data?.scheme.equals("lpa", ignoreCase = true)) {+            data?.schemeSpecificPart?.trim().orEmpty()         } else {-            ""+            data?.getQueryParameter(EsimLink.CARDDATA_PARAM)?.trim().orEmpty()         }-        val code = carddata.ifEmpty { rawLpa }         val start: Route =             if (looksLikeActivationCode(code)) Route.Download(code) else Route.AddSim         setContent { DynamicTheme { Navigation(viewModel, start) } }