Modern Apps git

← Modern-Apps.git

appstore: route Sandboxed Google Play installs through GrapheneOS download path, off Play

Commit
a9b6e799c7392b31371b2a66bc55b8db8fabffb1
Author
Vayun Mathur <[email protected]>
When
2026-08-09 22:45 UTC (3 months ago)
Parents
34472ab

Diff

appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.ktindex fe3eb3c985..dd440a783c 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.kt@@ -4,6 +4,14 @@ enum class AppSource {     /** This monorepo's own repository, signed with the same key as this app. */     MODERN_APPS,     FDROID,++    /**+     * GrapheneOS's app release server (apps.grapheneos.org). Used for the Sandboxed Google+     * Play components (GSF, GMS, Vending), which GrapheneOS re-hosts as Google's own signed+     * APKs with signed repo metadata. Installs go through the store's ordinary signed-APK+     * download + PackageInstaller path, never Google Play.+     */+    GRAPHENEOS,     PLAYSTORE } 
appstore/src/main/java/com/vayunmathur/appstore/data/SandboxedGooglePlay.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/SandboxedGooglePlay.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/SandboxedGooglePlay.ktindex 74da21bc7d..9b0868a0ec 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/SandboxedGooglePlay.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/SandboxedGooglePlay.kt@@ -4,12 +4,15 @@ package com.vayunmathur.appstore.data  * The GrapheneOS "Sandboxed Google Play" bundle: Google's own Play components, installed as  * ordinary unprivileged user apps rather than as a privileged system blob.  *- * The gmscompat shim that lets these run without the privileged access the real Play- * client expects lives in the OS, not here — so all this store has to do is install the- * three packages. It does that through the same anonymous-Play download and user-confirmed- * [android.content.pm.PackageInstaller] path every other Play listing uses (see- * [com.vayunmathur.appstore.data.installer.InstallCoordinator]); there is no dedicated- * release server to point at and nothing to hardcode.+ * These three packages are **not** installable from Google Play, so the store never fetches+ * them through the anonymous-Play path. They come from GrapheneOS's app release server+ * (apps.grapheneos.org), which re-hosts Google's official signed APKs alongside signed repo+ * metadata. Installing them reuses the store's ordinary signed-APK download and+ * user-confirmed [android.content.pm.PackageInstaller] flow — the same+ * [com.vayunmathur.appstore.data.installer.InstallCoordinator] `installFromUrl` path every+ * F-Droid / Modern Apps listing uses, and the same mechanism GrapheneOS's own Apps client+ * uses for Sandboxed Google Play. The gmscompat shim that lets these run without the+ * privileged access the real Play client expects lives in the OS, not here.  *  * Order matters at install. Google Services Framework and Play Services provide the  * accounts, the GSF ID and the provider the store front-end talks to, so they go on before@@ -28,7 +31,13 @@ object SandboxedGooglePlay {     /** Stable id for the curated home section, shared by the ViewModel and the home screen. */     const val SECTION_ID = "sandboxed-google-play" -    /** Human-readable names, used before a Play listing has been fetched (or if it can't be). */+    /**+     * GrapheneOS's app release server. The three packages, and the signed metadata that+     * verifies them, are served from here — nothing is fetched from Google Play.+     */+    const val RELEASE_SERVER = "https://apps.grapheneos.org"++    /** Human-readable names, shown before richer metadata has been fetched. */     val DISPLAY_NAMES: Map<String, String> = mapOf(         GSF to "Google Services Framework",         GMS to "Google Play Services",@@ -41,19 +50,26 @@ object SandboxedGooglePlay {      */     val PACKAGES: List<String> = listOf(GSF, GMS, VENDING) +    /** The GrapheneOS release-server download URL for [pkg]'s signed APK. */+    fun apkUrlFor(pkg: String): String = "$RELEASE_SERVER/packages/$pkg.apk"+     /**-     * Minimal stand-in listings for the three packages.+     * Stand-in listings for the three packages.      *-     * The home section shows these immediately; when Play is reachable the ViewModel-     * replaces them with real listings (icon, size, rating) fetched by package name. They-     * carry [AppSource.PLAYSTORE] so an install routes down the existing Play path.+     * The home section shows these immediately. They carry [AppSource.GRAPHENEOS] and the+     * GrapheneOS release-server [UnifiedApp.apkUrl], so tapping install routes down the+     * signed-APK download + [android.content.pm.PackageInstaller] path against+     * apps.grapheneos.org — never the Play path. A catalogue sync that has cached richer+     * rows (icon, size, signer, hash) replaces these in the ViewModel.      */     fun placeholders(): List<UnifiedApp> = PACKAGES.map { pkg ->         UnifiedApp(             packageName = pkg,-            source = AppSource.PLAYSTORE,+            source = AppSource.GRAPHENEOS,             name = DISPLAY_NAMES[pkg] ?: pkg,             author = "Google LLC",+            apkUrl = apkUrlFor(pkg),+            repoUrl = RELEASE_SERVER,         )     } }
appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallCoordinator.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallCoordinator.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallCoordinator.ktindex 3844593706..6b012116d4 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallCoordinator.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallCoordinator.kt@@ -44,8 +44,8 @@ sealed interface InstallStage {  *  * Both paths end at the same place — [SessionInstaller.installSplits] with an  * [InstallRequirement] describing what the bytes have to prove — but they get there- * differently: F-Droid and Modern Apps publish a URL and a hash, while Play requires an- * account, a purchase call and a delivery response that names the files.+ * differently: F-Droid, Modern Apps and GrapheneOS publish a URL and a hash, while Play+ * requires an account, a purchase call and a delivery response that names the files.  */ class InstallCoordinator(     private val context: Context,@@ -106,7 +106,7 @@ class InstallCoordinator(         if (_stages.value[packageName] is InstallStage.Failed) clear(packageName)     } -    // --- Direct APK: Modern Apps and F-Droid ---------------------------------------+    // --- Direct APK: Modern Apps, F-Droid and GrapheneOS ---------------------------      private suspend fun installFromUrl(app: UnifiedApp): SessionInstaller.Outcome =         withContext(Dispatchers.IO) {@@ -125,6 +125,15 @@ class InstallCoordinator(                         ?.let { mapOf("${app.packageName}.apk" to it) } ?: emptyMap(),                     signerOrigin = "this store",                 )+                // GrapheneOS re-hosts Google's official signed APKs; the signer and hash+                // come from its signed release metadata when a sync has cached them.+                AppSource.GRAPHENEOS -> InstallRequirement(+                    expectedPackage = app.packageName,+                    requiredSigners = app.expectedSigners.toSet(),+                    expectedSha256 = app.apkSha256+                        ?.let { mapOf("${app.packageName}.apk" to it) } ?: emptyMap(),+                    signerOrigin = "GrapheneOS's signed app list",+                )                 else -> InstallRequirement(                     expectedPackage = app.packageName,                     requiredSigners = app.expectedSigners.toSet(),
appstore/src/main/java/com/vayunmathur/appstore/data/security/TrustProfile.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/security/TrustProfile.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/security/TrustProfile.ktindex 3f65d91ed4..5925083df3 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/security/TrustProfile.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/security/TrustProfile.kt@@ -155,6 +155,10 @@ enum class TrustProfile {             // The whole F-Droid catalogue is listed; whether a given version was reproduced             // is shown per-app as a badge (see UnifiedApp.reproducible).             AppSource.FDROID -> FDROID+            // GrapheneOS serves a hard-pinned, JAR-signed index with a publisher key and a+            // per-APK hash this app checks the download against — the same trust story as+            // F-Droid, so it shares that profile.+            AppSource.GRAPHENEOS -> FDROID             AppSource.PLAYSTORE -> PLAY         }     }
appstore/src/main/java/com/vayunmathur/appstore/ui/AppComponents.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppComponents.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppComponents.ktindex 3b25bc8964..fe4d771c6b 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppComponents.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppComponents.kt@@ -105,6 +105,7 @@ fun SourceChip(source: AppSource, modifier: Modifier = Modifier) {         when (source) {             AppSource.MODERN_APPS -> R.string.source_chip_modern_apps             AppSource.FDROID -> R.string.source_chip_fdroid+            AppSource.GRAPHENEOS -> R.string.source_chip_grapheneos             AppSource.PLAYSTORE -> R.string.source_chip_play         }     )
appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.ktindex 4063ffb424..206b21c4b6 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt@@ -81,7 +81,8 @@ class AppStoreViewModel(      /**      * The Sandboxed Google Play bundle rows. Seeded with stand-ins so the section is on-     * screen immediately; [loadHome] swaps in real Play listings when Play is reachable.+     * screen immediately; [loadHome] swaps in richer catalogue rows when a sync has cached+     * them. These install from GrapheneOS's release server, never Play.      * Kept in [SandboxedGooglePlay.PACKAGES] order so the ordered install reads straight off it.      */     private val _sandboxedGooglePlay =@@ -299,12 +300,13 @@ class AppStoreViewModel(         _isLoadingHome.value = true         _recentlyUpdated.value = catalog.recentlyUpdated(RECENT_LIMIT) -        // Replace the Sandboxed Google Play stand-ins with real listings (icon, size,-        // rating) when Play answers; keep the stand-ins, and the section, when it doesn't.-        val real = play.details(SandboxedGooglePlay.PACKAGES).associateBy { it.packageName }-        if (real.isNotEmpty()) {+        // The Sandboxed Google Play components come from GrapheneOS's release server, not+        // Play. Enrich the stand-ins with richer catalogue rows (icon, size, signer, hash)+        // when a sync has cached them; keep the stand-ins, and the section, when it hasn't.+        val cached = catalog.byPackages(SandboxedGooglePlay.PACKAGES).associateBy { it.packageName }+        if (cached.isNotEmpty()) {             _sandboxedGooglePlay.value =-                _sandboxedGooglePlay.value.map { real[it.packageName] ?: it }+                _sandboxedGooglePlay.value.map { cached[it.packageName] ?: it }         }          val clusters = play.homeClusters()
appstore/src/main/res/values/strings.xml
diff --git a/appstore/src/main/res/values/strings.xml b/appstore/src/main/res/values/strings.xmlindex ead79d53a9..9c0909e968 100644--- a/appstore/src/main/res/values/strings.xml+++ b/appstore/src/main/res/values/strings.xml@@ -21,6 +21,7 @@     <!-- Source chips. Factual labels; the sources are not ranked. -->     <string name="source_chip_modern_apps">Modern Apps</string>     <string name="source_chip_fdroid">F-Droid</string>+    <string name="source_chip_grapheneos">GrapheneOS</string>     <string name="source_chip_play">Play Store</string>     <string name="filter_all">All</string>     <string name="filter_with_count">%1$s (%2$d)</string>