appstore: add Sandboxed Google Play curated section with ordered install
- Commit
b058bf360bd754704db0fa72bfed60432faba5f9- Author
- Vayun Mathur <[email protected]>
- When
- 2026-08-09 22:04 UTC (3 months ago)
- Parents
a192979
Diff
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.ktnew file mode 100644index 0000000000..74da21bc7d--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/SandboxedGooglePlay.kt@@ -0,0 +1,59 @@+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.+ *+ * 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+ * Vending — the same order GrapheneOS installs them in.+ */+object SandboxedGooglePlay {+ /** Google Services Framework — the account/provider layer the rest builds on. */+ const val GSF = "com.google.android.gsf"++ /** Google Play Services — the bulk of the compatibility surface apps call into. */+ const val GMS = "com.google.android.gms"++ /** Google Play Store (Vending) — the store client, installed last. */+ const val VENDING = "com.android.vending"++ /** 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). */+ val DISPLAY_NAMES: Map<String, String> = mapOf(+ GSF to "Google Services Framework",+ GMS to "Google Play Services",+ VENDING to "Google Play Store",+ )++ /**+ * Install order: framework and services first, the store that depends on them last.+ * The curated section and the ordered install both read this, so the two never drift.+ */+ val PACKAGES: List<String> = listOf(GSF, GMS, VENDING)++ /**+ * Minimal 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.+ */+ fun placeholders(): List<UnifiedApp> = PACKAGES.map { pkg ->+ UnifiedApp(+ packageName = pkg,+ source = AppSource.PLAYSTORE,+ name = DISPLAY_NAMES[pkg] ?: pkg,+ author = "Google LLC",+ )+ }+}
appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.ktindex 5071d5df23..9e5d856962 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt@@ -24,11 +24,13 @@ import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import com.vayunmathur.appstore.R+import com.vayunmathur.appstore.data.SandboxedGooglePlay import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.appstore.util.AppStoreViewModel import com.vayunmathur.appstore.util.HomeActions import com.vayunmathur.appstore.util.HomeUiState import com.vayunmathur.appstore.util.SectionLayout+import com.vayunmathur.library.ui.Button import com.vayunmathur.library.ui.Card import com.vayunmathur.library.ui.CardDefaults import com.vayunmathur.library.ui.CircularProgressIndicator@@ -135,7 +137,17 @@ fun HomeScreen( state.sections.forEach { section -> item("${section.id}-header") {- SectionHeader(section.title, section.subtitle)+ if (section.id == SandboxedGooglePlay.SECTION_ID) {+ SandboxedGooglePlayHeader(+ title = section.title,+ subtitle = section.subtitle,+ allInstalled = section.apps.isNotEmpty() &&+ section.apps.all { it.packageName in state.installedPackages },+ onInstallAll = actions::installSandboxedGooglePlay,+ )+ } else {+ SectionHeader(section.title, section.subtitle)+ } } when (section.layout) { SectionLayout.CAROUSEL -> item("${section.id}-body") {@@ -164,6 +176,30 @@ fun HomeScreen( } } +@Composable+private fun SandboxedGooglePlayHeader(+ title: String,+ subtitle: String?,+ allInstalled: Boolean,+ onInstallAll: () -> Unit,+) {+ Row(+ Modifier.fillMaxWidth(),+ verticalAlignment = Alignment.CenterVertically,+ ) {+ SectionHeader(title, subtitle, Modifier.weight(1f))+ Button(+ onClick = onInstallAll,+ enabled = !allInstalled,+ modifier = Modifier.padding(end = 16.dp),+ ) {+ IconDownload()+ Spacer(Modifier.width(8.dp))+ Text(stringResource(R.string.action_install_all))+ }+ }+}+ @Composable private fun StatusLine(message: String, isSyncing: Boolean) { Row(
appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.kt b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.ktindex 3695f6ac2a..8a1c9b2b9a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.kt@@ -132,6 +132,9 @@ interface HomeActions : AppActions { fun selectCategory(category: String?) {} fun refresh() {} + /** Install the Sandboxed Google Play bundle in dependency order (GSF, GMS, Vending). */+ fun installSandboxedGooglePlay() {}+ companion object { val Noop: HomeActions = object : HomeActions {} }
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 78a9f8bfa1..4063ffb424 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt@@ -15,6 +15,7 @@ import com.vayunmathur.appstore.data.CatalogRepository import com.vayunmathur.appstore.data.InstalledAppsRepository import com.vayunmathur.appstore.data.InstalledInfo import com.vayunmathur.appstore.data.PlayStoreLinks+import com.vayunmathur.appstore.data.SandboxedGooglePlay import com.vayunmathur.appstore.data.SettingsRepository import com.vayunmathur.appstore.data.SyncStep import com.vayunmathur.appstore.data.UnifiedApp@@ -77,6 +78,14 @@ class AppStoreViewModel( private val _playSections = MutableStateFlow<List<AppSection>>(emptyList()) private val _recentlyUpdated = MutableStateFlow<List<UnifiedApp>>(emptyList())++ /**+ * 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.+ * Kept in [SandboxedGooglePlay.PACKAGES] order so the ordered install reads straight off it.+ */+ private val _sandboxedGooglePlay =+ MutableStateFlow(SandboxedGooglePlay.placeholders()) private val _categories = MutableStateFlow<List<String>>(emptyList()) private val _selectedCategory = MutableStateFlow<String?>(null) private val _categoryApps = MutableStateFlow<List<UnifiedApp>>(emptyList())@@ -131,10 +140,10 @@ class AppStoreViewModel( catalog.modernApps, _playSections, _recentlyUpdated,- _categoryApps,- _selectedCategory,- ) { modern, playSections, recent, categoryApps, category ->- buildSections(modern, playSections, recent, categoryApps, category)+ _sandboxedGooglePlay,+ combine(_categoryApps, _selectedCategory) { apps, category -> apps to category },+ ) { modern, playSections, recent, sandboxed, (categoryApps, category) ->+ buildSections(modern, playSections, recent, sandboxed, categoryApps, category) }.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList()) val home: StateFlow<HomeUiState> = combine(@@ -290,6 +299,14 @@ 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()) {+ _sandboxedGooglePlay.value =+ _sandboxedGooglePlay.value.map { real[it.packageName] ?: it }+ }+ val clusters = play.homeClusters() _playSections.value = clusters .filter { it.apps.isNotEmpty() }@@ -317,6 +334,7 @@ class AppStoreViewModel( modern: List<UnifiedApp>, playSections: List<AppSection>, recent: List<UnifiedApp>,+ sandboxed: List<UnifiedApp>, categoryApps: List<UnifiedApp>, category: String?, ): List<AppSection> = buildList {@@ -344,6 +362,17 @@ class AppStoreViewModel( ) ) }+ if (sandboxed.isNotEmpty()) {+ add(+ AppSection(+ id = SandboxedGooglePlay.SECTION_ID,+ title = context.getString(R.string.section_sandboxed_google_play),+ apps = sandboxed,+ layout = SectionLayout.LIST,+ subtitle = context.getString(R.string.section_sandboxed_google_play_subtitle),+ )+ )+ } addAll(playSections) if (recent.isNotEmpty()) { add(@@ -541,6 +570,24 @@ class AppStoreViewModel( override fun dismissInstallFailure(packageName: String) = installer.dismissFailure(packageName) + /**+ * Install the Sandboxed Google Play bundle in dependency order.+ *+ * Sequential and awaited, like [updateAll]: GSF and GMS provide the accounts and the+ * provider Vending talks to, so they must land first, and each first-time install shows+ * its own PackageInstaller confirmation — firing them at once would bury the user in+ * prompts and let the store client install before the services it needs.+ */+ override fun installSandboxedGooglePlay() {+ viewModelScope.launch {+ for (app in _sandboxedGooglePlay.value) {+ installer.install(app)+ }+ delay(INSTALL_SETTLE_MS)+ installedRepo.refresh()+ }+ }+ override fun openApp(packageName: String) { val launchIntent = runCatching { context.packageManager.getLaunchIntentForPackage(packageName)
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 5f4aace043..ead79d53a9 100644--- a/appstore/src/main/res/values/strings.xml+++ b/appstore/src/main/res/values/strings.xml@@ -33,6 +33,9 @@ <string name="section_recently_updated">New and updated</string> <string name="section_recently_updated_subtitle">The newest builds on F-Droid</string> <string name="section_category_subtitle">Apps from the offline catalogue in this category</string>+ <string name="section_sandboxed_google_play">Sandboxed Google Play</string>+ <string name="section_sandboxed_google_play_subtitle">Google\'s Play components as ordinary, unprivileged apps</string>+ <string name="action_install_all">Install all</string> <string name="home_empty_title">Nothing here yet</string> <string name="home_empty_message">Sync your sources to fill this up, or search for an app by name.</string> <string name="updates_banner_subtitle">Tap to review and install</string>