appstore: split home rows per repo, remove GrapheneOS source
- Commit
755977ed805100c23348c9edfb9360e87de505b8- Author
- vayun-mathur <[email protected]>
- When
- 2026-10-08 22:46 UTC (1 month ago)
- Parents
8fc80a4
Diff
appstore/AGENTS.md
diff --git a/appstore/AGENTS.md b/appstore/AGENTS.mdindex bd4d89808f..0380e9d81b 100644--- a/appstore/AGENTS.md+++ b/appstore/AGENTS.md@@ -25,7 +25,6 @@ _Install: ./install appstore (dev by default)._ - com/vayunmathur/appstore/data/InstalledAppsRepository.kt - com/vayunmathur/appstore/data/PlayStoreLinks.kt - com/vayunmathur/appstore/data/RestrictedPackages.kt-- com/vayunmathur/appstore/data/SandboxedGooglePlay.kt - com/vayunmathur/appstore/data/SettingsRepository.kt - com/vayunmathur/appstore/data/UpdateCheckWorker.kt - com/vayunmathur/appstore/data/accrescent/AccrescentApi.kt@@ -35,9 +34,6 @@ _Install: ./install appstore (dev by default)._ - com/vayunmathur/appstore/data/accrescent/AccrescentTrustStore.kt - com/vayunmathur/appstore/data/accrescent/DeviceAttributesProvider.kt - com/vayunmathur/appstore/data/accrescent/SignifyNative.kt-- com/vayunmathur/appstore/data/grapheneos/GrapheneOSIndex.kt-- com/vayunmathur/appstore/data/grapheneos/GrapheneOSRepo.kt-- com/vayunmathur/appstore/data/grapheneos/GrapheneOSRepository.kt - com/vayunmathur/appstore/data/installer/InstallCoordinator.kt - com/vayunmathur/appstore/data/installer/InstallStatusReceiver.kt - com/vayunmathur/appstore/data/installer/PlayDownloader.kt
appstore/src/main/java/com/vayunmathur/appstore/data/AppDatabase.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/AppDatabase.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/AppDatabase.ktindex fcc5de969d..d08584b566 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/AppDatabase.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/AppDatabase.kt@@ -259,8 +259,12 @@ interface CachedAppDao { @Query("SELECT * FROM CachedAppEntity WHERE source = :source ORDER BY name ASC") fun bySourceFlow(source: String): Flow<List<CachedAppEntity>> - @Query("SELECT * FROM CachedAppEntity ORDER BY lastUpdated DESC LIMIT :limit")- suspend fun recentlyUpdated(limit: Int): List<CachedAppEntity>+ /**+ * Newest builds from one offline source only. Each repo gets its own home+ * row, so the catalogue is never asked for a cross-source "recent" mix.+ */+ @Query("SELECT * FROM CachedAppEntity WHERE source = :source ORDER BY lastUpdated DESC LIMIT :limit")+ suspend fun recentlyUpdatedBySource(source: String, limit: Int): List<CachedAppEntity> @Query( "SELECT * FROM CachedAppEntity WHERE ',' || categories || ',' LIKE '%,' || :category || ',%' " +
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 ab3e32dd02..ff40832cb8 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.kt@@ -6,14 +6,6 @@ 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, /**@@ -39,25 +31,16 @@ enum class AppSource { /** * Precedence when more than one source offers the same package, most preferred first. *- * GrapheneOS outranks Play deliberately: Play lists the Sandboxed Google Play- * components too, but only the build GrapheneOS re-hosts is the one the OS's gmscompat- * layer expects, so a Play-delivered Vending or GMS is the wrong artifact for the- * device even though it would install. Below that the order is a provenance- * preference rather than a security ranking (see+ * Below is a provenance preference rather than a security ranking (see * [com.vayunmathur.appstore.data.security.TrustProfile]): catalogue rows carry a * publisher key and a hash a download can be checked against, and Modern Apps rows are * signed with this store's own key. */ val PRIORITY: List<AppSource> =- listOf(GRAPHENEOS, MODERN_APPS, PROPRIETARY, FDROID, ACCRESCENT, PLAYSTORE)+ listOf(MODERN_APPS, PROPRIETARY, FDROID, ACCRESCENT, PLAYSTORE) /** * Sources the user may switch off, in the order the sources screen lists them.- *- * [GRAPHENEOS] is absent on purpose. It carries nothing but the Sandboxed Google Play- * components, which only exist on a device whose OS already ships the gmscompat layer- * they belong to, and which must never be updated from anywhere else — so a switch- * would either do nothing or strand three system packages on a stale build. */ val TOGGLEABLE: List<AppSource> = listOf(MODERN_APPS, PROPRIETARY, FDROID, PLAYSTORE, ACCRESCENT) }
appstore/src/main/java/com/vayunmathur/appstore/data/CatalogRepository.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/CatalogRepository.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/CatalogRepository.ktindex 065c9aedde..8646295b21 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/CatalogRepository.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/CatalogRepository.kt@@ -79,11 +79,13 @@ class CatalogRepository( runCatching { AppSource.valueOf(it) }.getOrNull() } - /** F-Droid's most recently published builds — the browse screen's "New and updated". */- suspend fun recentlyUpdated(limit: Int = 30): List<UnifiedApp> = withContext(Dispatchers.IO) {- runCatching { db.cachedAppDao().recentlyUpdated(limit).map { it.toUnifiedApp() } }- .getOrDefault(emptyList())- }+ /** Newest builds from one offline source: each repo gets its own home row. */+ suspend fun recentlyUpdatedBySource(source: AppSource, limit: Int = 30): List<UnifiedApp> =+ withContext(Dispatchers.IO) {+ runCatching {+ db.cachedAppDao().recentlyUpdatedBySource(source.name, limit).map { it.toUnifiedApp() }+ }.getOrDefault(emptyList())+ } suspend fun byCategory(category: String, limit: Int = 60): List<UnifiedApp> = withContext(Dispatchers.IO) {
appstore/src/main/java/com/vayunmathur/appstore/data/RestrictedPackages.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/RestrictedPackages.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/RestrictedPackages.ktindex 039680796b..cd5e8a2db7 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/RestrictedPackages.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/RestrictedPackages.kt@@ -6,10 +6,11 @@ import androidx.core.content.edit /** * Packages the OS will not let this store install, so it stops offering them updates. *- * GrapheneOS reserves a few Google packages for its own first-party package source. Committing- * a session for one fails with `INSTALL_FAILED_SESSION_INVALID: Only the first party package- * source and shell are allowed to install <package>`, which is not something the user can act- * on — so a pending update for it is a notification that can only ever be dismissed.+ * Some GrapheneOS-derived builds reserve Google packages for their own first-party+ * package source. Committing a session for one fails with+ * `INSTALL_FAILED_SESSION_INVALID: Only the first party package source and shell are+ * allowed to install <package>`, which is not something the user can act on — so a+ * pending update for it is a notification that can only ever be dismissed. * * [KNOWN] is consulted on GrapheneOS-derived builds only; on stock Android these are ordinary * updatable apps. [recordIfRestricted] adds whatever else the installer finds out the hard way,@@ -65,9 +66,7 @@ object RestrictedPackages { /** * Whether this is GrapheneOS or a build derived from it, such as Modern Apps OS. *- * Also gates the Sandboxed Google Play section: those packages only work alongside the- * gmscompat layer, which is part of the OS, so offering them on stock Android would offer- * an install that cannot function.+ * Gates which packages are left out of update checks via [forDevice]. */ fun isGrapheneOS(context: Context): Boolean = context.packageManager.hasSystemFeature(GRAPHENEOS_FEATURE)
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.ktdeleted file mode 100644index e7b2a3cedd..0000000000--- a/appstore/src/main/java/com/vayunmathur/appstore/data/SandboxedGooglePlay.kt+++ /dev/null@@ -1,77 +0,0 @@-package com.vayunmathur.appstore.data--import com.vayunmathur.appstore.data.grapheneos.GrapheneOSRepo--/**- * The GrapheneOS "Sandboxed Google Play" bundle: Google's own Play components, installed as- * ordinary unprivileged user apps rather than as a privileged system blob.- *- * These 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 a signed- * index — see [com.vayunmathur.appstore.data.grapheneos.GrapheneOSRepository], which is what- * supplies the download URLs, the expected signing certificates and the per-APK hashes.- * Installing them reuses the store's ordinary verify-then-commit- * [android.content.pm.PackageInstaller] flow. 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: Play Services provides the compatibility surface the store- * front-end talks to, so it goes on before Vending.- */-object SandboxedGooglePlay {- /**- * Google Services Framework — deliberately **not** installed.- *- * GrapheneOS refuses it outright, in PackageInstallerSession:- * `INSTALL_FAILED_SESSION_INVALID: GSF installation is not allowed`. Two reasons, both- * from the OS's own comments: gmscompat does not need GSF, and because GSF is- * preinstalled on real GMS Android other apps trust anything holding its package name- * without checking a signature — so allowing an arbitrary GSF would be a spoofing hole.- * GrapheneOS does not ship it as a preinstalled app either.- *- * Kept as a constant because the identity is still worth naming: [GsfVersionProvider]- * reads its version when spoofing Play device info, falling back to a default when — as- * here — it is absent.- */- 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, shown before the signed index has been fetched. */- val DISPLAY_NAMES: Map<String, String> = mapOf(- GMS to "Google Play Services",- VENDING to "Google Play Store",- )-- /**- * Install order: 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(GMS, VENDING)-- /**- * Stand-in listings for the three packages.- *- * The home section shows these immediately, before the network is reached. They carry no- * download: everything needed to install — version, file list, signer digests, per-APK- * hashes — comes from the signed index, and a row built without it would be a download- * nothing could be checked against. Until the sync lands, tapping install reports that- * the source published nothing, which is exactly what has happened.- */- fun placeholders(): List<UnifiedApp> = PACKAGES.map { pkg ->- UnifiedApp(- packageName = pkg,- source = AppSource.GRAPHENEOS,- name = DISPLAY_NAMES[pkg] ?: pkg,- author = "Google LLC",- repoUrl = GrapheneOSRepo.BASE_URL,- )- }-}
appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.ktindex c9a92da7c4..26843120ea 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt@@ -26,8 +26,6 @@ import com.vayunmathur.appstore.MainActivity import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.installer.InstallCoordinator import com.vayunmathur.appstore.data.accrescent.AccrescentRepository-import com.vayunmathur.appstore.data.grapheneos.GrapheneOSRepository-import com.vayunmathur.appstore.data.grapheneos.toUnifiedApp import com.vayunmathur.appstore.data.play.PlayRepository import com.vayunmathur.appstore.data.security.ApkCertificates import com.vayunmathur.library.network.NetworkClient@@ -85,7 +83,6 @@ class UpdateCheckWorker( val installedRepo: InstalledAppsRepository, val play: PlayRepository, val accrescent: AccrescentRepository,- val grapheneOS: GrapheneOSRepository, val settings: SettingsRepository, ) @@ -98,7 +95,6 @@ class UpdateCheckWorker( installedRepo = InstalledAppsRepository(context), play = PlayRepository(context), accrescent = AccrescentRepository(context, db),- grapheneOS = GrapheneOSRepository(context), settings = SettingsRepository(context, scope), ) val enabled = env.settings.readEnabledSources()@@ -121,11 +117,10 @@ class UpdateCheckWorker( val fromCatalog = env.catalog.updatesFor(installed) val fromPlay = playUpdates(env, enabled, installed) val fromAccrescent = accrescentUpdates(env, enabled, installed)- val fromGrapheneOS = grapheneOSUpdates(env, installed) // The surviving row's source decides which download-and-verify path the update takes, // so it has to be the same precedence the rest of the store uses.- return (fromCatalog + fromPlay + fromAccrescent + fromGrapheneOS)+ return (fromCatalog + fromPlay + fromAccrescent) .sortedBy { it.source.priority } .distinctBy { it.packageName } }@@ -135,17 +130,11 @@ class UpdateCheckWorker( enabled: Set<AppSource>, installed: List<InstalledInfo>, ): List<UnifiedApp> {- // Only Play can answer for packages the offline catalogues have never heard of — except- // the Sandboxed Google Play components, which Play also hosts but must never update- // here: only the builds GrapheneOS re-hosts are the ones this device can use. Their- // updates come from GrapheneOS's own signed index instead, below.+ // Only Play can answer for packages the offline catalogues have never heard of. if (AppSource.PLAYSTORE !in enabled) return emptyList() val index = env.catalog.packageIndex.value val unknown = installed- .filter {- it.packageName !in index &&- it.packageName !in SandboxedGooglePlay.PACKAGES- }+ .filter { it.packageName !in index } .map { it.packageName } val remote = env.play.details(unknown).associateBy { it.packageName } return installed.mapNotNull { inst ->@@ -179,22 +168,6 @@ class UpdateCheckWorker( } } - private suspend fun grapheneOSUpdates(- env: CheckEnv,- installed: List<InstalledInfo>,- ): List<UnifiedApp> {- // GrapheneOS: refresh its signed index and offer a newer build of each Sandboxed- // Google Play component that is installed. Skipped on stock Android, where these- // packages cannot work at all for want of the OS's gmscompat layer.- if (!RestrictedPackages.isGrapheneOS(context)) return emptyList()- return env.grapheneOS.refresh(SandboxedGooglePlay.PACKAGES).getOrNull().orEmpty()- .mapNotNull { entry ->- val current = installed.firstOrNull { it.packageName == entry.packageName }- ?: return@mapNotNull null- entry.toUnifiedApp().takeIf { it.versionCode > current.versionCode }- }- }- private suspend fun reportUpdates(env: CheckEnv, updates: List<UnifiedApp>) { val autoInstall = env.settings.readAutoInstallUpdates() @@ -220,13 +193,15 @@ class UpdateCheckWorker( ) } - private suspend fun autoInstall(eligible: List<UnifiedApp>, env: CheckEnv) {+ private suspend fun autoInstall(+ eligible: List<UnifiedApp>,+ env: CheckEnv,+ ) { autoInstall( eligible, env.db, env.play, env.accrescent,- env.grapheneOS, env.scope, ) }@@ -304,7 +279,6 @@ class UpdateCheckWorker( db: AppDatabase, play: PlayRepository, accrescent: AccrescentRepository,- grapheneOS: GrapheneOSRepository, scope: CoroutineScope, ) { runCatching { setForeground(installingForegroundInfo(apps.size)) }@@ -313,7 +287,6 @@ class UpdateCheckWorker( db = db, play = play, accrescent = accrescent,- grapheneOS = grapheneOS, scope = scope, ownSigningCertificates = { ApkCertificates.selfSigners(context) }, )
appstore/src/main/java/com/vayunmathur/appstore/data/grapheneos/GrapheneOSIndex.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/grapheneos/GrapheneOSIndex.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/grapheneos/GrapheneOSIndex.ktdeleted file mode 100644index d8c706b5e7..0000000000--- a/appstore/src/main/java/com/vayunmathur/appstore/data/grapheneos/GrapheneOSIndex.kt+++ /dev/null@@ -1,282 +0,0 @@-package com.vayunmathur.appstore.data.grapheneos--import android.content.Context-import android.os.Build-import android.util.DisplayMetrics-import com.vayunmathur.appstore.data.AppSource-import com.vayunmathur.appstore.data.UnifiedApp-import org.json.JSONArray-import org.json.JSONObject--/** One downloadable file of a package: the base APK or one of its splits. */-data class GrapheneOSApk(- val name: String,- /** Lowercase-hex SHA-256 of the **uncompressed** APK; the server serves it gzipped. */- val sha256: String,- /** Uncompressed size, which is what the install session is sized against. */- val size: Long,- /** Compressed size, which is what actually crosses the network. */- val gzSize: Long,-)--/** A package as this device should install it: one chosen variant, one chosen set of splits. */-data class GrapheneOSPackage(- val packageName: String,- val label: String,- val description: String,- val versionCode: Long,- val versionName: String,- /** Lowercase-hex SHA-256 digests of the certificates the APKs must be signed by. */- val signers: List<String>,- val iconUrl: String?,- val apks: List<GrapheneOSApk>,-) {- val totalSize: Long get() = apks.sumOf { it.size }-}--/**- * The listing row for this package.- *- * No `apkUrl`: the download is a set of splits at index-derived URLs, not one file, so- * `InstallCoordinator` reads the entry back out of the repository rather than being handed a- * URL. `expectedSigners` and `apkSha256` are set for the detail page's benefit; the install- * itself checks against every file's hash, not just the base APK's.- */-fun GrapheneOSPackage.toUnifiedApp(): UnifiedApp = UnifiedApp(- packageName = packageName,- source = AppSource.GRAPHENEOS,- name = label,- description = description,- summary = description.lineSequence().firstOrNull().orEmpty(),- iconUrl = iconUrl,- author = "Google LLC",- versionName = versionName,- versionCode = versionCode,- sizeBytes = totalSize,- containsSplit = apks.size > 1,- repoUrl = GrapheneOSRepo.BASE_URL,- expectedSigners = signers,- apkSha256 = apks.firstOrNull { it.name == BASE_APK }?.sha256,-)--private const val BASE_APK = "base.apk"--/**- * Reader for GrapheneOS's repository index.- *- * The index lists every published version of every package, for every SDK level, ABI, screen- * density and language. Picking from it is the client's job, and getting it wrong means- * either an install the device rejects or a download of hundreds of megabytes of splits it- * will never use — so the selection rules here deliberately mirror GrapheneOS's own client- * (`core/Repo.kt`): newest stable variant this SDK and ABI can run, then the base APK plus- * only the ABI, density and language splits this device needs.- *- * Nothing here decides trust. The caller verifies the signature over the whole document- * before parsing it, which is what makes the hashes and signer digests below worth reading.- */-object GrapheneOSIndex {-- private const val STABLE = "stable"- private const val CONFIG_SEPARATOR = "config."- private const val APK_SUFFIX = ".apk"-- private val ABI_QUALIFIERS = mapOf(- "armeabi-v7a" to "armeabi_v7a",- "arm64-v8a" to "arm64_v8a",- "x86" to "x86",- "x86_64" to "x86_64",- )-- private val DENSITY_QUALIFIERS = mapOf(- "ldpi" to DisplayMetrics.DENSITY_LOW,- "mdpi" to DisplayMetrics.DENSITY_MEDIUM,- "tvdpi" to DisplayMetrics.DENSITY_TV,- "hdpi" to DisplayMetrics.DENSITY_HIGH,- "xhdpi" to DisplayMetrics.DENSITY_XHIGH,- "xxhdpi" to DisplayMetrics.DENSITY_XXHIGH,- "xxxhdpi" to DisplayMetrics.DENSITY_XXXHIGH,- )-- /** Index timestamp, for the anti-rollback check. */- fun timestamp(index: JSONObject): Long = index.optLong("time", 0L)-- /**- * The subset of [wanted] this device can install, in [wanted]'s order.- *- * A package the index does not list, or lists with no variant this device can run, is- * simply absent from the result rather than an error: the caller shows what it can offer.- */- fun packagesFor(- context: Context,- index: JSONObject,- wanted: List<String>,- ): List<GrapheneOSPackage> {- val packages = index.optJSONObject("packages") ?: return emptyList()- return wanted.mapNotNull { name ->- packages.optJSONObject(name)?.let { parsePackage(context, name, it) }- }- }-- private fun parsePackage(- context: Context,- packageName: String,- json: JSONObject,- ): GrapheneOSPackage? {- val variants = json.optJSONObject("variants") ?: return null- val (versionCode, variant) = newestInstallableVariant(variants) ?: return null-- val apks = selectApks(context, variant)- if (apks.isNullOrEmpty()) return null-- val signers = json.optJSONArray("signatures").toStringList().map { it.lowercase() }- if (signers.isEmpty()) return null-- return GrapheneOSPackage(- packageName = packageName,- label = variant.optString("label", packageName),- description = variant.opt("description") as? String- ?: json.opt("description") as? String- ?: "",- versionCode = versionCode,- versionName = variant.opt("versionName") as? String ?: versionCode.toString(),- signers = signers,- iconUrl = (json.opt("iconType") as? String)- ?.let { GrapheneOSRepo.iconUrl(packageName, it) },- apks = apks,- )- }-- /**- * The newest stable variant this device can run, with its version code.- *- * Variants are keyed by version code and differ by SDK range and ABI, so several are- * usually publishable at once and only some are installable here. An unrunnable variant- * has to be skipped rather than clamped: installing a build outside its declared SDK- * range is exactly what the range exists to prevent.- */- private fun newestInstallableVariant(variants: JSONObject): Pair<Long, JSONObject>? {- var best: Pair<Long, JSONObject>? = null- for (key in variants.keys()) {- val candidate = installableVariant(variants, key) ?: continue- if (best == null || candidate.first > best.first) best = candidate- }- return best- }-- private fun installableVariant(variants: JSONObject, key: String): Pair<Long, JSONObject>? {- val versionCode = key.toLongOrNull() ?: return null- val variant = variants.optJSONObject(key) ?: return null- if (!isStableVariant(variant)) return null- if (!sdkSupports(variant)) return null- if (!abiSupports(variant)) return null- return versionCode to variant- }-- private fun isStableVariant(variant: JSONObject): Boolean =- variant.optString("channel", STABLE) == STABLE-- private fun sdkSupports(variant: JSONObject): Boolean {- if (Build.VERSION.SDK_INT < variant.optInt("minSdk", 0)) return false- return Build.VERSION.SDK_INT <= variant.optInt("maxSdk", Int.MAX_VALUE)- }-- private fun abiSupports(variant: JSONObject): Boolean {- val abis = variant.optJSONArray("abis")?.toStringList() ?: return true- return DEVICE_ABI in abis- }-- /**- * The files to download: the base APK plus the splits this device needs.- *- * Null when the four parallel arrays disagree on length, which would otherwise pair a- * file name with another file's hash — a silent mis-verification rather than a failure.- */- private fun selectApks(context: Context, variant: JSONObject): List<GrapheneOSApk>? {- val names = variant.optJSONArray("apks") ?: return null- val hashes = variant.optJSONArray("apkHashes") ?: return null- val sizes = variant.optJSONArray("apkSizes") ?: return null- val gzSizes = variant.optJSONArray("apkGzSizes") ?: return null- val count = names.length()- if (hashes.length() != count || sizes.length() != count || gzSizes.length() != count) {- return null- }-- val picker = ApkPicker(context, names, hashes, sizes, gzSizes, count)- return picker.select()- }-- private class ApkPicker(- context: Context,- private val names: JSONArray,- private val hashes: JSONArray,- private val sizes: JSONArray,- private val gzSizes: JSONArray,- private val count: Int,- ) {- private val languages = deviceLanguages(context)- private val targetDensity = context.resources.displayMetrics.densityDpi- private val kept = mutableListOf<GrapheneOSApk>()- private val byDensity = mutableMapOf<Int, MutableList<GrapheneOSApk>>()-- fun select(): List<GrapheneOSApk> {- for (i in 0 until count) {- classify(apkAt(i))- }- // One density split, not all of them: the closest at or above this screen, falling- // back to the largest published when the screen is denser than anything on offer.- if (byDensity.isNotEmpty()) {- val densities = byDensity.keys.sorted()- val chosen = densities.firstOrNull { it >= targetDensity } ?: densities.last()- kept += byDensity.getValue(chosen)- }- return kept- }-- private fun apkAt(i: Int): GrapheneOSApk = GrapheneOSApk(- name = names.optString(i),- sha256 = hashes.optString(i).lowercase(),- size = sizes.optLong(i),- gzSize = gzSizes.optLong(i),- )-- private fun classify(apk: GrapheneOSApk) {- val qualifier = configQualifier(apk.name)- if (qualifier == null) {- kept += apk- return- }- val density = qualifier.let { DENSITY_QUALIFIERS[it] }- if (density != null) {- byDensity.getOrPut(density) { mutableListOf() }.add(apk)- return- }- if (qualifier in ABI_QUALIFIERS.values) {- if (qualifier == DEVICE_ABI_QUALIFIER) kept += apk- return- }- if (qualifier in languages) kept += apk- }- }-- /** The part after the last `config.`, or null for a file that is not a config split. */- private fun configQualifier(name: String): String? {- val index = name.lastIndexOf(CONFIG_SEPARATOR)- if (index < 0 || !name.endsWith(APK_SUFFIX)) return null- return name.substring(index + CONFIG_SEPARATOR.length, name.length - APK_SUFFIX.length)- }-- private fun deviceLanguages(context: Context): Set<String> {- val locales = context.resources.configuration.locales- return (0 until locales.size()).mapTo(mutableSetOf()) { locales.get(it).language }- }-- private fun JSONArray?.toStringList(): List<String> {- if (this == null) return emptyList()- return (0 until length()).mapNotNull { optString(it).takeIf { s -> s.isNotEmpty() } }- }-- /** Secondary ABIs are deliberately not considered; they run worse than the primary one. */- private val DEVICE_ABI: String = Build.SUPPORTED_ABIS.firstOrNull().orEmpty()-- private val DEVICE_ABI_QUALIFIER: String? = ABI_QUALIFIERS[DEVICE_ABI]-}
appstore/src/main/java/com/vayunmathur/appstore/data/grapheneos/GrapheneOSRepo.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/grapheneos/GrapheneOSRepo.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/grapheneos/GrapheneOSRepo.ktdeleted file mode 100644index ab822ee1b5..0000000000--- a/appstore/src/main/java/com/vayunmathur/appstore/data/grapheneos/GrapheneOSRepo.kt+++ /dev/null@@ -1,39 +0,0 @@-package com.vayunmathur.appstore.data.grapheneos--/**- * Fixed trust anchors for the GrapheneOS Apps source, mirroring GrapheneOS's own client- * (`Apps/app/build.gradle.kts` and `core/RepoRetriever.kt`).- *- * These are the only values this store takes on faith for GrapheneOS: the release-server- * host and — the actual root of trust — the signify ed25519 public key the repository index- * must verify against. Everything the index then states (versions, file names, per-APK- * SHA-256, signing-certificate digests) is trusted only because the signature covered it.- */-object GrapheneOSRepo {-- const val BASE_URL = "https://apps.grapheneos.org"-- /** signify-format ed25519 public key the index signature is verified against. */- const val METADATA_PUBKEY = "RWQtZwEu1br1lMh911L3yPOs97cQb9LOks/ALBbqGl21ul695ocWR/ir"-- /** Index schema version. Bumping it is a breaking change GrapheneOS publishes separately. */- private const val METADATA_VERSION = 1-- /** Signing-key generation. Rotating the key above means bumping this with it. */- private const val KEY_VERSION = 0-- val METADATA_URL = "$BASE_URL/metadata.$METADATA_VERSION.$KEY_VERSION.sjson"-- /**- * Anti-rollback floor: the store refuses any index older than this, even on first run- * when nothing is stored yet. Matches GrapheneOS's own `MIN_TIMESTAMP`.- */- const val MIN_TIMESTAMP = 1_770_000_000L-- /** Where a package's APKs live. GrapheneOS serves them gzipped. */- fun apkUrl(manifestPackageName: String, versionCode: Long, apkName: String): String =- "$BASE_URL/packages/$manifestPackageName/$versionCode/$apkName.gz"-- fun iconUrl(manifestPackageName: String, iconType: String): String =- "$BASE_URL/packages/$manifestPackageName/icon.$iconType"-}
appstore/src/main/java/com/vayunmathur/appstore/data/grapheneos/GrapheneOSRepository.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/grapheneos/GrapheneOSRepository.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/grapheneos/GrapheneOSRepository.ktdeleted file mode 100644index 66c77ddca5..0000000000--- a/appstore/src/main/java/com/vayunmathur/appstore/data/grapheneos/GrapheneOSRepository.kt+++ /dev/null@@ -1,146 +0,0 @@-package com.vayunmathur.appstore.data.grapheneos--import android.content.Context-import com.vayunmathur.library.log.Log-import androidx.datastore.preferences.core.edit-import androidx.datastore.preferences.core.longPreferencesKey-import androidx.datastore.preferences.preferencesDataStore-import com.vayunmathur.appstore.data.security.Signify-import com.vayunmathur.library.network.NetworkClient-import kotlinx.coroutines.flow.first-import kotlinx.coroutines.sync.Mutex-import kotlinx.coroutines.sync.withLock-import org.json.JSONObject-import java.security.GeneralSecurityException--private val Context.grapheneOSDataStore by preferencesDataStore(name = "grapheneos_repo")-private val INDEX_TIMESTAMP_KEY = longPreferencesKey("index_timestamp")--/**- * The GrapheneOS Apps source: a signed index, and the packages this device can install from it.- *- * Trust comes entirely from one ed25519 signature over the index bytes ([Signify]) verified- * against the pinned [GrapheneOSRepo.METADATA_PUBKEY], plus a monotonic timestamp that can- * never go backwards. Every failure path leaves [packages] empty — fail closed — so a- * tampered, unsigned or rolled-back index yields nothing installable rather than an install- * with no signer or hash to check.- *- * That last part is the point of this class. The store used to build a download URL for the- * Sandboxed Google Play packages by hand and carry no signer or hash at all, which the- * verifier could only treat as "the source published nothing to check against" — while the- * UI claimed the same guarantees as F-Droid. Those guarantees are now real, and an index- * that fails to verify produces no download rather than an unchecked one.- */-class GrapheneOSRepository(private val context: Context) {-- private val mutex = Mutex()-- @Volatile- private var cached: List<GrapheneOSPackage> = emptyList()-- /** The last successfully verified listing, empty until [refresh] succeeds once. */- val packages: List<GrapheneOSPackage> get() = cached-- fun packageFor(packageName: String): GrapheneOSPackage? =- cached.firstOrNull { it.packageName == packageName }-- /**- * Fetch, verify and parse the index for [wanted].- *- * A failure keeps whatever was verified last rather than emptying the list: the previous- * answer was signed and is still true, and dropping it would take the section off the- * screen every time the network is down.- */- suspend fun refresh(wanted: List<String>): Result<List<GrapheneOSPackage>> = mutex.withLock {- try {- val (status, _, bytes) =- NetworkClient.performRequestBytesFull(GrapheneOSRepo.METADATA_URL)- if (status !in HTTP_OK_MIN..HTTP_OK_MAX) {- return@withLock Result.failure(- IllegalStateException("index fetch failed: HTTP $status")- )- }-- val (json, signature) = split(bytes)- ?: return@withLock Result.failure(- IllegalStateException("index is too short to carry a signature")- )-- // Verify over the exact bytes downloaded, before parsing them.- if (!Signify.verify(json, signature, GrapheneOSRepo.METADATA_PUBKEY)) {- return@withLock Result.failure(- SecurityException("index signature did not verify")- )- }-- val index = JSONObject(json.toString(Charsets.UTF_8))-- // Anti-rollback: never accept an index older than the newest one already seen,- // and never older than the pinned floor even on first run.- val floor = maxOf(readStoredTimestamp(), GrapheneOSRepo.MIN_TIMESTAMP)- val timestamp = GrapheneOSIndex.timestamp(index)- if (timestamp < floor) {- return@withLock Result.failure(- GeneralSecurityException("index timestamp $timestamp is older than $floor")- )- }- persistTimestamp(timestamp)-- val parsed = GrapheneOSIndex.packagesFor(context, index, wanted)- cached = parsed- Result.success(parsed)- } catch (expected: IllegalStateException) {- Log.status(TAG, "index fetch/verify failed", expected)- Result.failure(expected)- } catch (expected: java.io.IOException) {- Log.status(TAG, "index fetch/verify failed", expected)- Result.failure(expected)- } catch (expected: SecurityException) {- Log.status(TAG, "index fetch/verify failed", expected)- Result.failure(expected)- }- }-- /**- * Split the signed document into the bytes that were signed and the signature over them.- *- * The format is the JSON, a newline, 100 base64 characters and a final newline — see- * GrapheneOS's `core/RepoRetriever.kt`. The signature is a fixed-width trailer rather- * than a separate file, so it is sliced off by length.- */- private fun split(bytes: ByteArray): Pair<ByteArray, String>? {- if (bytes.size <= TRAILER_BYTES) return null- val json = bytes.copyOfRange(0, bytes.size - TRAILER_BYTES)- val signature = bytes- .copyOfRange(bytes.size - TRAILER_BYTES + 1, bytes.size - 1)- .toString(Charsets.UTF_8)- return json to signature- }-- private suspend fun readStoredTimestamp(): Long = try {- context.grapheneOSDataStore.data.first()[INDEX_TIMESTAMP_KEY] ?: 0L- } catch (expected: java.io.IOException) {- Log.status(TAG, "read stored timestamp", expected)- 0L- } catch (expected: IllegalStateException) {- Log.status(TAG, "read stored timestamp", expected)- 0L- }-- private suspend fun persistTimestamp(timestamp: Long) {- try {- context.grapheneOSDataStore.edit { it[INDEX_TIMESTAMP_KEY] = timestamp }- } catch (expected: java.io.IOException) {- Log.status(TAG, "persist timestamp", expected)- }- }-- private companion object {- const val TAG = "GrapheneOSRepository"-- /** Newline + 100 base64 signature characters + newline. */- const val TRAILER_BYTES = 102- private const val HTTP_OK_MIN = 200- private const val HTTP_OK_MAX = 299- }-}
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 d1707eae56..df4fb01cf9 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@@ -5,12 +5,9 @@ import com.vayunmathur.library.log.Log import com.vayunmathur.appstore.data.AppDatabase import com.vayunmathur.appstore.data.AppSource import com.vayunmathur.appstore.data.PinnedStampEntity-import com.vayunmathur.appstore.data.SandboxedGooglePlay import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.appstore.data.accrescent.AccrescentRepository import com.vayunmathur.appstore.data.accrescent.IncompatibleDeviceException-import com.vayunmathur.appstore.data.grapheneos.GrapheneOSRepo-import com.vayunmathur.appstore.data.grapheneos.GrapheneOSRepository import com.vayunmathur.appstore.data.play.CertUtil import com.vayunmathur.appstore.data.play.PlayRepository import com.vayunmathur.appstore.data.security.InstallRequirement@@ -29,7 +26,6 @@ import java.io.FilterInputStream import java.io.IOException import java.net.HttpURLConnection import java.net.URL-import java.util.zip.GZIPInputStream import javax.net.ssl.HttpsURLConnection /**@@ -54,15 +50,15 @@ 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, 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.+ * differently: F-Droid, Modern Apps and the proprietary mirror 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, private val db: AppDatabase, private val play: PlayRepository, private val accrescent: AccrescentRepository,- private val grapheneOS: GrapheneOSRepository, scope: CoroutineScope, private val ownSigningCertificates: () -> Set<String>, ) {@@ -109,7 +105,6 @@ class InstallCoordinator( val outcome = when (app.source) { AppSource.PLAYSTORE -> installFromPlay(app) AppSource.ACCRESCENT -> installFromAccrescent(app)- AppSource.GRAPHENEOS -> installFromGrapheneOS(app) else -> installFromUrl(app) } record(app.packageName, outcome.verification)@@ -203,7 +198,6 @@ class InstallCoordinator( url: String, target: File, expectedSize: Long,- gzipped: Boolean = false, onProgress: (Float) -> Unit, ) { val rawConnection = URL(url).openConnection()@@ -225,8 +219,6 @@ class InstallCoordinator( throw IOException("the server returned HTTP $code for ${target.name}") } - // Progress counts bytes off the network, so it stays honest for a gzipped body- // where the file on disk ends up several times larger than the transfer. val total = conn.contentLengthLong.takeIf { it > 0 } ?: expectedSize var downloaded = 0L val counting = object : FilterInputStream(conn.inputStream) {@@ -240,8 +232,7 @@ class InstallCoordinator( } } }- val input = if (gzipped) GZIPInputStream(counting) else counting- input.use { source ->+ counting.use { source -> target.outputStream().use { out -> source.copyTo(out, COPY_BUFFER_SIZE) }@@ -251,77 +242,6 @@ class InstallCoordinator( } } - // --- GrapheneOS -------------------------------------------------------------------- /**- * Install one of GrapheneOS's packages from its signed index.- *- * Everything the install is checked against — the file list, each file's SHA-256, and the- * certificates the APKs must be signed by — comes from the index this store verified the- * signature of, so a package the index does not vouch for is refused before anything is- * downloaded rather than installed unchecked.- *- * The files are served gzipped and the published hashes are of the uncompressed APKs, so- * they are decompressed on the way to disk and hashed there, under their index file names- * so the hash map lines up.- */- private suspend fun installFromGrapheneOS(app: UnifiedApp): SessionInstaller.Outcome =- withContext(Dispatchers.IO) {- // The index is fetched when the home screen loads, so tapping install before that- // lands - a cold start, or a refresh that failed while the network was down - would- // otherwise report that GrapheneOS does not vouch for a package it plainly does.- // Fetch it here rather than fail on the timing: refresh() is mutex-guarded, so a- // sync already in flight is awaited rather than duplicated.- val entry = grapheneOS.packageFor(app.packageName)- ?: run {- grapheneOS.refresh(SandboxedGooglePlay.PACKAGES)- grapheneOS.packageFor(app.packageName)- }- ?: return@withContext SessionInstaller.Outcome(- false,- VerificationResult.Rejected(- "GrapheneOS's signed app list does not vouch for this app"- ),- )-- val dir = File(context.cacheDir, "grapheneos/${app.packageName}").apply {- deleteRecursively()- mkdirs()- }-- val totalCompressed = entry.apks.sumOf { it.gzSize }.takeIf { it > 0 } ?: -1L- var doneCompressed = 0L- val files = entry.apks.map { apk ->- val file = File(dir, apk.name)- val start = doneCompressed- download(- url = GrapheneOSRepo.apkUrl(app.packageName, entry.versionCode, apk.name),- target = file,- expectedSize = apk.gzSize,- gzipped = true,- ) { fileFraction ->- if (totalCompressed > 0) {- val overall = (start + fileFraction * apk.gzSize) / totalCompressed- stage(app.packageName, InstallStage.Downloading(overall.coerceIn(0f, 1f)))- }- }- doneCompressed += apk.gzSize- file- }-- val requirement = InstallRequirement(- expectedPackage = app.packageName,- requiredSigners = entry.signers.toSet(),- expectedSha256 = entry.apks.associate { it.name to it.sha256 },- signerOrigin = "GrapheneOS's signed app list",- )-- stage(app.packageName, InstallStage.Verifying)- sessionInstaller.installSplits(- app.packageName, files, requirement, files.sumOf { it.length() }- )- }- // --- Accrescent ---------------------------------------------------------------- /**
appstore/src/main/java/com/vayunmathur/appstore/data/security/Signify.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/security/Signify.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/security/Signify.ktindex 17fb57e1f4..fcca8d5820 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/security/Signify.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/security/Signify.kt@@ -6,9 +6,8 @@ import com.vayunmathur.appstore.data.accrescent.SignifyNative /** * ed25519 verification of an OpenBSD-signify signature. *- * Two of this store's sources sign their index with signify — Accrescent's `repodata.N.json`- * and GrapheneOS's `metadata.N.N.sjson` — so the framing is parsed once here rather than- * twice.+ * Accrescent's `repodata.N.json` signs its index with signify, so the framing is+ * parsed once here. * * signify wire format (what this understands): * - A **public key** is a raw base64 blob of `2-byte algo id || 8-byte key id || 32-byte@@ -18,7 +17,7 @@ import com.vayunmathur.appstore.data.accrescent.SignifyNative * `untrusted comment:` line; a signature embedded in a signed document does not. * - The signature is over the **raw bytes of the signed file**. *- * This is the whole trust anchor for both sources, so it fails closed: any parsing or+ * This is the whole trust anchor for that source, so it fails closed: any parsing or * verification problem returns `false` rather than throwing or assuming success. * * The framing above is parsed here; the raw ed25519 check itself is [SignifyNative].
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 fca9724cf1..3b4b4902f4 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@@ -79,13 +79,6 @@ enum class TrustProfile { */ FDROID, - /**- * GrapheneOS's app release server, which re-hosts Google's own signed builds of the- * Sandboxed Google Play components behind a signify-signed index. Trust is the pinned- * release key, and per file the SHA-256 and signing certificate that index vouches for.- */- GRAPHENEOS,- /** Google Play, via an anonymous account. */ PLAY, @@ -109,7 +102,6 @@ enum class TrustProfile { get() = when (this) { MODERN_APPS -> R.string.trust_modern_apps_title FDROID -> R.string.source_chip_fdroid- GRAPHENEOS -> R.string.source_chip_grapheneos PLAY -> R.string.trust_play_title ACCRESCENT -> R.string.source_chip_accrescent PROPRIETARY -> R.string.source_chip_proprietary@@ -121,7 +113,6 @@ enum class TrustProfile { get() = when (this) { MODERN_APPS -> R.string.trust_modern_apps_summary FDROID -> R.string.trust_fdroid_summary- GRAPHENEOS -> R.string.trust_grapheneos_summary PLAY -> R.string.trust_play_summary ACCRESCENT -> R.string.trust_accrescent_summary PROPRIETARY -> R.string.trust_proprietary_summary@@ -139,11 +130,6 @@ enum class TrustProfile { R.string.trust_fdroid_practice_rebuild, R.string.trust_fdroid_practice_antifeatures, )- GRAPHENEOS -> listOf(- R.string.trust_grapheneos_practice_official,- R.string.trust_grapheneos_practice_signed_index,- R.string.trust_grapheneos_practice_matched,- ) PLAY -> listOf( R.string.trust_play_practice_identity, R.string.trust_play_practice_scanning,@@ -176,11 +162,6 @@ enum class TrustProfile { R.string.trust_fdroid_check_rebuilt, R.string.trust_fdroid_check_hash_and_key, )- GRAPHENEOS -> listOf(- R.string.trust_grapheneos_check_index_signed,- R.string.trust_grapheneos_check_rollback,- R.string.trust_grapheneos_check_hash_and_key,- ) PLAY -> listOf( R.string.trust_play_check_hash, R.string.trust_play_check_key,@@ -203,7 +184,6 @@ enum class TrustProfile { get() = when (this) { MODERN_APPS -> R.string.trust_modern_apps_limits FDROID -> R.string.trust_fdroid_limits- GRAPHENEOS -> R.string.trust_grapheneos_limits PLAY -> R.string.trust_play_limits ACCRESCENT -> R.string.trust_accrescent_limits PROPRIETARY -> R.string.trust_proprietary_limits@@ -215,7 +195,6 @@ 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- AppSource.GRAPHENEOS -> GRAPHENEOS AppSource.PLAYSTORE -> PLAY // Accrescent apps are signed by their developers, not by Accrescent; trust is the // ed25519-signed allowlist that pins each app's signing certificate + min version.
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 8a433d576d..0c4cbe969a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppComponents.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppComponents.kt@@ -101,7 +101,6 @@ 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 AppSource.ACCRESCENT -> R.string.source_chip_accrescent AppSource.PROPRIETARY -> R.string.source_chip_proprietary
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 97566b4b5a..52fa69a75f 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt@@ -25,7 +25,6 @@ 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.AppSection import com.vayunmathur.appstore.util.AppStoreViewModel@@ -33,7 +32,6 @@ import com.vayunmathur.appstore.util.HomeActions import com.vayunmathur.appstore.util.HomeUiState import com.vayunmathur.appstore.util.SectionLayout import com.vayunmathur.library.ui.AppScaffold-import com.vayunmathur.library.ui.Button import com.vayunmathur.library.ui.Card import com.vayunmathur.library.ui.CardDefaults import com.vayunmathur.library.ui.CircularProgressIndicator@@ -153,17 +151,7 @@ fun HomeScreen( state.sections.forEach { section -> item("${section.id}-header") {- 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)- }+ SectionHeader(section.title, section.subtitle) } when (section.layout) { SectionLayout.CAROUSEL -> item("${section.id}-body") {@@ -195,30 +183,6 @@ 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/ui/SearchPage.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/SearchPage.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/SearchPage.ktindex f0547a1691..ebd65c6b53 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/SearchPage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/SearchPage.kt@@ -159,7 +159,6 @@ internal fun SourceFilter.labelRes(): Int = when (this) { SourceFilter.MODERN_APPS -> R.string.source_chip_modern_apps SourceFilter.PROPRIETARY -> R.string.source_chip_proprietary SourceFilter.FDROID -> R.string.source_chip_fdroid- SourceFilter.GRAPHENEOS -> R.string.source_chip_grapheneos SourceFilter.PLAYSTORE -> R.string.source_chip_play SourceFilter.ACCRESCENT -> R.string.source_chip_accrescent }
appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreActionOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreActionOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreActionOps.ktindex c5e00e1eb8..94604134f7 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreActionOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreActionOps.kt@@ -38,24 +38,6 @@ internal fun AppStoreViewModel.installImpl(app: UnifiedApp) { } } -/**- * Install the Sandboxed Google Play bundle in dependency order.- *- * Sequential and awaited, like [updateAll]: Play Services provides the provider Vending- * talks to, so it 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.- */-internal fun AppStoreViewModel.installSandboxedGooglePlayImpl() {- viewModelScope.launch {- for (app in sandboxedGooglePlayFlow.value) {- installer.install(app)- }- delay(INSTALL_SETTLE_MS)- installedRepo.refresh()- }-}- internal fun AppStoreViewModel.openAppImpl(packageName: String) { val launchIntent = runCatching { context.packageManager.getLaunchIntentForPackage(packageName)
appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreDetailOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreDetailOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreDetailOps.ktindex 46780a5ece..dd253b337e 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreDetailOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreDetailOps.kt@@ -12,14 +12,6 @@ fun AppStoreViewModel.selectApp(app: UnifiedApp) { detailJob?.cancel() selectedAppFlow.value = app detailJob = viewModelScope.launch {- // Play lists the Sandboxed Google Play components too, so a search hit for one can- // arrive carrying AppSource.PLAYSTORE. Describe it from GrapheneOS regardless: that- // is the row an install would actually use, and the Play build is the wrong- // artifact for the device even though Play would happily deliver it.- sandboxedGooglePlayRow(app.packageName)?.let { sandboxed ->- selectedAppFlow.value = sandboxed- return@launch- } // The catalogue row wins whenever there is one, even if the user tapped a Play // tile for the same package. It is the row an install would actually use — it // carries the signer and hash an authenticated index published — so showing@@ -56,10 +48,6 @@ fun AppStoreViewModel.selectApp(app: UnifiedApp) { /** Open a package the store only knows by name, e.g. from a `market://` link. */ fun AppStoreViewModel.selectPackage(packageName: String) { viewModelScope.launch {- sandboxedGooglePlayRow(packageName)?.let {- selectApp(it)- return@launch- } val known = catalog.byPackage(packageName) if (known != null) { selectApp(known)@@ -83,12 +71,3 @@ fun AppStoreViewModel.clearSelection() { detailJob?.cancel() selectedAppFlow.value = null }--/**- * The GrapheneOS row for a Sandboxed Google Play component, or null for any other package.- *- * Carries whatever [loadHome] enriched the stand-in with, so this is the best row the store- * holds for GSF, GMS or Vending.- */-internal fun AppStoreViewModel.sandboxedGooglePlayRow(packageName: String): UnifiedApp? =- sandboxedGooglePlayFlow.value.firstOrNull { it.packageName == packageName }
appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreHomeOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreHomeOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreHomeOps.ktindex ca090f69f8..13c6f75ac2 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreHomeOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreHomeOps.kt@@ -2,15 +2,13 @@ package com.vayunmathur.appstore.util import com.vayunmathur.appstore.util.AppStoreViewModel.Companion.CAROUSEL_LIMIT import com.vayunmathur.appstore.util.AppStoreViewModel.Companion.PLAY_CLUSTER_LIMIT-import com.vayunmathur.appstore.util.AppStoreViewModel.Companion.RECENT_LIMIT+import com.vayunmathur.appstore.util.AppStoreViewModel.Companion.RECENT_PER_SOURCE_LIMIT import androidx.lifecycle.viewModelScope import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.AppSource import com.vayunmathur.appstore.data.DefaultRepos-import com.vayunmathur.appstore.data.SandboxedGooglePlay import com.vayunmathur.appstore.data.SyncStep import com.vayunmathur.appstore.data.UnifiedApp-import com.vayunmathur.appstore.data.grapheneos.toUnifiedApp import com.vayunmathur.library.util.AppMessages import kotlinx.coroutines.launch @@ -27,20 +25,32 @@ import kotlinx.coroutines.launch */ internal suspend fun AppStoreViewModel.loadHome(enabled: Set<AppSource> = enabledSources.value) { isLoadingHomeFlow.value = true- recentlyUpdatedFlow.value = catalog.recentlyUpdated(RECENT_LIMIT)-- // The Sandboxed Google Play components come from GrapheneOS's release server, not- // Play. Refreshing its signed index is what turns the stand-ins into installable- // rows: the version, file list, signer digests and per-APK hashes all come from- // there. A failed refresh leaves the stand-ins, and the section, exactly as they were.- if (sandboxedGooglePlayFlow.value.isNotEmpty()) {- grapheneOS.refresh(SandboxedGooglePlay.PACKAGES).getOrNull()?.let { packages ->- val byPackage = packages.associateBy { it.packageName }- sandboxedGooglePlayFlow.value = sandboxedGooglePlayFlow.value.map { row ->- byPackage[row.packageName]?.toUnifiedApp() ?: row- }+ val modernEnabled = AppSource.MODERN_APPS in enabled+ val fdroidEnabled = AppSource.FDROID in enabled+ val proprietaryEnabled = AppSource.PROPRIETARY in enabled+ if (modernEnabled || fdroidEnabled || proprietaryEnabled) {+ modernRecentFlow.value = if (modernEnabled) {+ catalog.recentlyUpdatedBySource(AppSource.MODERN_APPS, RECENT_PER_SOURCE_LIMIT)+ } else {+ emptyList()+ }+ fdroidRecentFlow.value = if (fdroidEnabled) {+ catalog.recentlyUpdatedBySource(AppSource.FDROID, RECENT_PER_SOURCE_LIMIT)+ } else {+ emptyList()+ }+ proprietaryRecentFlow.value = if (proprietaryEnabled) {+ catalog.recentlyUpdatedBySource(AppSource.PROPRIETARY, RECENT_PER_SOURCE_LIMIT)+ } else {+ emptyList() }+ } else {+ modernRecentFlow.value = emptyList()+ fdroidRecentFlow.value = emptyList()+ proprietaryRecentFlow.value = emptyList() }+ recentlyUpdatedFlow.value =+ modernRecentFlow.value + proprietaryRecentFlow.value + fdroidRecentFlow.value if (AppSource.PLAYSTORE !in enabled) { isLoadingHomeFlow.value = false@@ -72,9 +82,10 @@ internal suspend fun AppStoreViewModel.loadHome(enabled: Set<AppSource> = enable internal fun AppStoreViewModel.buildSections( modern: List<UnifiedApp>,+ modernRecent: List<UnifiedApp>,+ proprietaryRecent: List<UnifiedApp>,+ fdroidRecent: List<UnifiedApp>, playSections: List<AppSection>,- recent: List<UnifiedApp>,- sandboxed: List<UnifiedApp>, accrescent: List<UnifiedApp>, categoryApps: List<UnifiedApp>, category: String?,@@ -93,7 +104,18 @@ internal fun AppStoreViewModel.buildSections( ) return@buildList }- if (modern.isNotEmpty()) {+ // Each offline repo gets its own row — Modern Apps, the proprietary mirror and+ // F-Droid are never mixed into one "recent" list.+ if (modernRecent.isNotEmpty()) {+ add(+ AppSection(+ id = "modern-recent",+ title = context.getString(R.string.section_modern_apps_recent),+ apps = modernRecent,+ subtitle = context.getString(R.string.section_modern_apps_recent_subtitle),+ )+ )+ } else if (modern.isNotEmpty()) { add( AppSection( id = "modern",@@ -103,13 +125,13 @@ internal fun AppStoreViewModel.buildSections( ) ) }- if (sandboxed.isNotEmpty()) {+ if (proprietaryRecent.isNotEmpty()) { add( AppSection(- id = SandboxedGooglePlay.SECTION_ID,- title = context.getString(R.string.section_sandboxed_google_play),- apps = sandboxed,- subtitle = context.getString(R.string.section_sandboxed_google_play_subtitle),+ id = "proprietary-recent",+ title = context.getString(R.string.section_proprietary_recent),+ apps = proprietaryRecent,+ subtitle = context.getString(R.string.section_proprietary_recent_subtitle), ) ) }@@ -124,13 +146,13 @@ internal fun AppStoreViewModel.buildSections( ) ) }- if (recent.isNotEmpty()) {+ if (fdroidRecent.isNotEmpty()) { add( AppSection(- id = "recent",- title = context.getString(R.string.section_recently_updated),- apps = recent,- subtitle = context.getString(R.string.section_recently_updated_subtitle),+ id = "fdroid-recent",+ title = context.getString(R.string.section_fdroid_recent),+ apps = fdroidRecent,+ subtitle = context.getString(R.string.section_fdroid_recent_subtitle), ) ) }@@ -139,8 +161,8 @@ internal fun AppStoreViewModel.buildSections( /** * Populate the offline catalogues the first time the store is opened. *- * Nothing else fetches them on startup: [loadHome] only refreshes GrapheneOS's index, and- * the periodic [com.vayunmathur.appstore.work.UpdateCheckWorker] may be hours away. That+ * Nothing else fetches them on startup: the periodic+ * [com.vayunmathur.appstore.work.UpdateCheckWorker] may be hours away. That * left a fresh install showing an empty store until the user thought to pull to refresh. * * Keyed off the catalogue being empty rather than a "first run" flag, so it also recovers@@ -150,9 +172,11 @@ internal fun AppStoreViewModel.buildSections( */ internal fun AppStoreViewModel.syncIfNeverSynced(enabled: Set<AppSource>) { if (recentlyUpdatedFlow.value.isNotEmpty()) return- // Nothing to fetch if both offline sources are switched off; syncSources() would only+ // Nothing to fetch if all three offline sources are switched off; syncSources() would only // report "all sources off" at someone who never asked for a sync.- val offlineSources = setOf(DefaultRepos.FDROID.source, DefaultRepos.MODERN_APPS.source)+ val offlineSources = setOf(+ DefaultRepos.FDROID.source, DefaultRepos.MODERN_APPS.source, DefaultRepos.PROPRIETARY.source+ ) if (enabled.intersect(offlineSources).isEmpty()) return syncSources() }
appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreSearchOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreSearchOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreSearchOps.ktindex d9f70e127e..082a356219 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreSearchOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreSearchOps.kt@@ -47,10 +47,9 @@ internal fun AppStoreViewModel.setSearchImpl(query: String) { /** * Combine catalogue, Play and Accrescent hits, one row per package. *- * Where several sources offer a package, [AppSource.PRIORITY] decides which row survives —- * notably keeping the GrapheneOS row for the Sandboxed Google Play components rather than- * Play's listing of the same three packages. Sorting is stable, so each source's own- * relevance ordering is preserved within its rank, and [rank] re-sorts the result anyway.+ * Where several sources offer a package, [AppSource.PRIORITY] decides which row survives.+ * Sorting is stable, so each source's own relevance ordering is preserved within its+ * rank, and [rank] re-sorts the result anyway. */ internal fun AppStoreViewModel.merge(vararg lists: List<UnifiedApp>): List<UnifiedApp> = lists.asSequence()
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 f7e47ded87..bcfd58cf62 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.kt@@ -45,7 +45,6 @@ enum class SourceFilter(val source: AppSource?) { MODERN_APPS(AppSource.MODERN_APPS), PROPRIETARY(AppSource.PROPRIETARY), FDROID(AppSource.FDROID),- GRAPHENEOS(AppSource.GRAPHENEOS), PLAYSTORE(AppSource.PLAYSTORE), ACCRESCENT(AppSource.ACCRESCENT), }@@ -137,9 +136,6 @@ interface HomeActions : AppActions { fun selectCategory(category: String?) {} fun refresh() {} - /** Install the Sandboxed Google Play bundle in dependency order (GMS, then Vending). */- fun installSandboxedGooglePlay() {}- companion object { val Noop: HomeActions = object : HomeActions {} }
appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.ktindex ee6cde1290..4fb5a981e7 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.kt@@ -6,9 +6,7 @@ import com.vayunmathur.appstore.util.AppStoreViewModel.Companion.REPEATED_FAILUR import androidx.lifecycle.viewModelScope import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.AppSource-import com.vayunmathur.appstore.data.SandboxedGooglePlay import com.vayunmathur.appstore.data.UnifiedApp-import com.vayunmathur.appstore.data.grapheneos.toUnifiedApp import com.vayunmathur.appstore.data.installer.InstallFailureBatch import com.vayunmathur.appstore.data.security.VerificationResult import com.vayunmathur.library.util.AppMessages@@ -30,17 +28,11 @@ internal fun AppStoreViewModel.checkForUpdatesImpl() { // Only ask Play about packages neither offline source lists — for the rest the // catalogue already answered, and Play would just re-answer it over the network.- // The Sandboxed Google Play components are held back too: Play hosts newer builds- // of all three, but only GrapheneOS's are the ones this device can use, so their- // updates come from its signed index below instead. val index = catalog.packageIndex.value val installed = installedRepo.updatable.value if (AppSource.PLAYSTORE in enabled) { val playCandidates = installed- .filter {- it.packageName !in index &&- it.packageName !in SandboxedGooglePlay.PACKAGES- }+ .filter { it.packageName !in index } .map { it.packageName } val remote = play.details(playCandidates).associateBy { it.packageName }@@ -63,14 +55,6 @@ internal fun AppStoreViewModel.checkForUpdatesImpl() { .mapNotNull { inst -> accrescentUpdate(inst.packageName, inst.versionCode) } } - // GrapheneOS: its signed index is the only place a Sandboxed Google Play update- // can come from, which is why the three are held back from the Play list above.- grapheneOSUpdatesFlow.value = grapheneOS.packages.mapNotNull { entry ->- val current = installed.firstOrNull { it.packageName == entry.packageName }- ?: return@mapNotNull null- entry.toUnifiedApp().takeIf { it.versionCode > current.versionCode }- }- lastUpdateCheckFlow.value = System.currentTimeMillis() statusMessageFlow.value = "" isCheckingUpdatesFlow.value = false
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 e5076205d7..f674a56c22 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt@@ -16,14 +16,10 @@ 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.RestrictedPackages-import com.vayunmathur.appstore.data.SandboxedGooglePlay import com.vayunmathur.appstore.data.SettingsRepository import com.vayunmathur.appstore.data.SyncStep import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.appstore.data.accrescent.AccrescentRepository-import com.vayunmathur.appstore.data.grapheneos.GrapheneOSRepository-import com.vayunmathur.appstore.data.grapheneos.toUnifiedApp import com.vayunmathur.appstore.data.installer.InstallCoordinator import com.vayunmathur.appstore.data.installer.InstallEvents import com.vayunmathur.appstore.data.installer.InstallFailureBatch@@ -63,11 +59,10 @@ class AppStoreViewModel( internal val catalog = CatalogRepository(context, db, viewModelScope) internal val play = PlayRepository(context) internal val accrescent = AccrescentRepository(context, db)- internal val grapheneOS = GrapheneOSRepository(context) internal val installedRepo = InstalledAppsRepository(context) internal val settings = SettingsRepository(context, viewModelScope) internal val installer =- InstallCoordinator(context, db, play, accrescent, grapheneOS, viewModelScope) { ownSigningCertificates }+ InstallCoordinator(context, db, play, accrescent, viewModelScope) { ownSigningCertificates } /** Off-by-default: the periodic check may also download and install updates unattended. */ val autoInstallUpdates: StateFlow<Boolean> = settings.autoInstallUpdates@@ -94,6 +89,11 @@ class AppStoreViewModel( internal val playSectionsFlow = MutableStateFlow<List<AppSection>>(emptyList()) internal val recentlyUpdatedFlow = MutableStateFlow<List<UnifiedApp>>(emptyList()) + /** Newest builds per offline repo: each one gets its own home row. */+ internal val modernRecentFlow = MutableStateFlow<List<UnifiedApp>>(emptyList())+ internal val proprietaryRecentFlow = MutableStateFlow<List<UnifiedApp>>(emptyList())+ internal val fdroidRecentFlow = MutableStateFlow<List<UnifiedApp>>(emptyList())+ /** Accrescent listings for the home carousel, from the gRPC listing API. */ internal val accrescentAppsFlow = MutableStateFlow<List<UnifiedApp>>(emptyList()) @@ -103,20 +103,6 @@ class AppStoreViewModel( */ internal val accrescentPackagesFlow = MutableStateFlow<Set<String>>(emptySet()) - /**- * The Sandboxed Google Play bundle rows. Seeded with stand-ins so the section is on- * screen immediately; [loadHome] replaces them with rows built from GrapheneOS's signed- * index. These install from GrapheneOS's release server, never Play.- * Kept in [SandboxedGooglePlay.PACKAGES] order so the ordered install reads straight off it.- *- * Empty on stock Android. These packages only work alongside the gmscompat layer, which- * is part of the OS, so on a device without it the section would offer three installs- * that cannot function.- */- internal val sandboxedGooglePlayFlow = MutableStateFlow(- if (RestrictedPackages.isGrapheneOS(context)) SandboxedGooglePlay.placeholders()- else emptyList()- ) internal val categoriesFlow = MutableStateFlow<List<String>>(emptyList()) internal val selectedCategoryFlow = MutableStateFlow<String?>(null) internal val categoryAppsFlow = MutableStateFlow<List<UnifiedApp>>(emptyList())@@ -133,7 +119,6 @@ class AppStoreViewModel( internal val catalogUpdatesFlow = MutableStateFlow<List<UnifiedApp>>(emptyList()) internal val playUpdatesFlow = MutableStateFlow<List<UnifiedApp>>(emptyList()) internal val accrescentUpdatesFlow = MutableStateFlow<List<UnifiedApp>>(emptyList())- internal val grapheneOSUpdatesFlow = MutableStateFlow<List<UnifiedApp>>(emptyList()) private val libraryFilterFlow = MutableStateFlow(SourceFilter.ALL) @@ -180,11 +165,10 @@ class AppStoreViewModel( catalogUpdatesFlow, playUpdatesFlow, accrescentUpdatesFlow,- grapheneOSUpdatesFlow, installedRepo.apps,- ) { catalogUpdates, playUpdates, accrescentUpdates, grapheneOSUpdates, installed ->+ ) { catalogUpdates, playUpdates, accrescentUpdates, installed -> val installedVersions = installed.associate { it.packageName to it.versionCode }- (catalogUpdates + playUpdates + accrescentUpdates + grapheneOSUpdates)+ (catalogUpdates + playUpdates + accrescentUpdates) // The surviving row's source decides which download-and-verify path the update // takes, so it has to be the same precedence search and the library use. .sortedBy { it.source.priority }@@ -201,16 +185,25 @@ class AppStoreViewModel( private val sections: StateFlow<List<AppSection>> = combine( catalog.modernApps,+ combine(+ modernRecentFlow,+ proprietaryRecentFlow,+ fdroidRecentFlow,+ ) { modernRecent, proprietaryRecent, fdroidRecent ->+ Triple(modernRecent, proprietaryRecent, fdroidRecent)+ }, playSectionsFlow,- recentlyUpdatedFlow,- sandboxedGooglePlayFlow, combine( categoryAppsFlow, selectedCategoryFlow, accrescentAppsFlow, ) { apps, category, accrescent -> Triple(apps, category, accrescent) },- ) { modern, playSections, recent, sandboxed, (categoryApps, category, accrescentApps) ->- buildSections(modern, playSections, recent, sandboxed, accrescentApps, categoryApps, category)+ ) { modern, (modernRecent, proprietaryRecent, fdroidRecent), playSections,+ (categoryApps, category, accrescentApps) ->+ buildSections(+ modern, modernRecent, proprietaryRecent, fdroidRecent,+ playSections, accrescentApps, categoryApps, category,+ ) }.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList()) val home: StateFlow<HomeUiState> = combine(@@ -306,20 +299,15 @@ class AppStoreViewModel( libraryFilterFlow, ) { rows, index, playPackages, accrescentPackages, filter -> // Source attribution, highest priority first:- // 1. GrapheneOS's Sandboxed Google Play components (GSF/GMS/Vending) are Google's- // APKs re-hosted by GrapheneOS and installed from its release server, so they- // are attributed to GrapheneOS — never Play — even though Play lists them too.- // 2. Whatever the offline catalogue (F-Droid / Modern Apps) recorded.- // 3. Accrescent, for packages its signed allowlist vouches for.- // 4. Play, but only for packages Play confirmed it hosts (see playInstalledPackagesFlow).+ // 1. Whatever the offline catalogue (F-Droid / Modern Apps / Proprietary) recorded.+ // 2. Accrescent, for packages its signed allowlist vouches for.+ // 3. Play, but only for packages Play confirmed it hosts (see playInstalledPackagesFlow). // A package no source vouches for — sideloaded, or from a store we don't track — is // left out entirely rather than mislabelled as Play.- fun sourceOf(pkg: String): AppSource? = when {- pkg in SandboxedGooglePlay.PACKAGES -> AppSource.GRAPHENEOS- else -> index[pkg]?.source?.let { runCatching { AppSource.valueOf(it) }.getOrNull() }+ fun sourceOf(pkg: String): AppSource? =+ index[pkg]?.source?.let { runCatching { AppSource.valueOf(it) }.getOrNull() } ?: AppSource.ACCRESCENT.takeIf { pkg in accrescentPackages } ?: AppSource.PLAYSTORE.takeIf { pkg in playPackages }- } val all = rows.installed.mapNotNull { info -> sourceOf(info.packageName)?.let { info.toUnifiedApp(it) }@@ -396,10 +384,10 @@ class AppStoreViewModel( /** * Ask Play which installed packages it actually hosts, for library attribution. *- * Only packages neither offline source lists and that aren't GrapheneOS components are- * worth asking about — the rest are already attributed. Play returning nothing (no- * account, no network) leaves the previous answer in place rather than emptying the- * library, so a transient failure can't hide apps Play was known to host.+ * Only packages no offline source lists are worth asking about — the rest are+ * already attributed. Play returning nothing (no account, no network) leaves the+ * previous answer in place rather than emptying the library, so a transient+ * failure can't hide apps Play was known to host. */ private suspend fun refreshPlayInstalledPackages( enabled: Set<AppSource> = enabledSources.value,@@ -411,7 +399,7 @@ class AppStoreViewModel( val index = catalog.packageIndex.value val candidates = installedRepo.apps.value .map { it.packageName }- .filter { it !in index && it !in SandboxedGooglePlay.PACKAGES }+ .filter { it !in index } if (candidates.isEmpty()) { playInstalledPackagesFlow.value = emptySet() return@@ -500,16 +488,6 @@ class AppStoreViewModel( override fun dismissInstallFailure(packageName: String) = installer.dismissFailure(packageName) - /**- * Install the Sandboxed Google Play bundle in dependency order.- *- * Sequential and awaited, like [updateAll]: Play Services provides the provider Vending- * talks to, so it 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() = installSandboxedGooglePlayImpl()- override fun openApp(packageName: String) = openAppImpl(packageName) override fun uninstallApp(packageName: String) = uninstallAppImpl(packageName)@@ -591,7 +569,8 @@ class AppStoreViewModel( internal companion object { internal const val SEARCH_DEBOUNCE_MS = 350L internal const val INSTALL_SETTLE_MS = 1_500L- internal const val RECENT_LIMIT = 30+ /** Per-repo cap for the three home rows; the three lists stay additive. */+ internal const val RECENT_PER_SOURCE_LIMIT = 20 internal const val CAROUSEL_LIMIT = 20 internal const val PLAY_CLUSTER_LIMIT = 4
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 618955eb0b..0f9747d0af 100644--- a/appstore/src/main/res/values/strings.xml+++ b/appstore/src/main/res/values/strings.xml@@ -23,7 +23,6 @@ <!-- Source chips. Factual labels; the sources are not ranked. --> <string name="source_chip_modern_apps" translatable="false">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="source_chip_accrescent">Accrescent</string> <string name="source_chip_proprietary">Proprietary</string>@@ -34,11 +33,13 @@ <string name="section_modern_apps">From Modern Apps</string> <string name="section_modern_apps_subtitle">Built in this repo and signed with the same key as this store</string> <string name="section_play_top_charts">Top on the Play Store</string>- <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_modern_apps_recent">New from Modern Apps</string>+ <string name="section_modern_apps_recent_subtitle">The newest builds from this repo</string>+ <string name="section_proprietary_recent">New in Proprietary</string>+ <string name="section_proprietary_recent_subtitle">The newest builds from the Play mirror</string>+ <string name="section_fdroid_recent">New on F-Droid</string>+ <string name="section_fdroid_recent_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="section_accrescent">On Accrescent</string> <string name="section_accrescent_subtitle">Developer-signed apps from Accrescent\'s signed app list</string> <string name="action_install_all">Install all</string>@@ -211,14 +212,6 @@ <string name="trust_fdroid_check_rebuilt">Versions F-Droid\'s second build server reproduced bit-for-bit are badged as reproducible</string> <string name="trust_fdroid_check_hash_and_key">The hash and the signing key both come from the signed list</string> <string name="trust_fdroid_limits">F-Droid holds the signing key, not the developer, so its build servers can sign anything. Nobody checks what an app does, only that it matches its source. Updates wait to be rebuilt, which can take days or weeks, security fixes included.</string>- <string name="trust_grapheneos_summary">Google\'s own signed builds of the Sandboxed Google Play components, re-hosted by GrapheneOS behind a signed list naming each file\'s hash and signing key.</string>- <string name="trust_grapheneos_practice_official">The files are Google\'s own signed builds, re-hosted unchanged rather than rebuilt</string>- <string name="trust_grapheneos_practice_signed_index">GrapheneOS signs the list of versions, file hashes and expected signing keys with its release key</string>- <string name="trust_grapheneos_practice_matched">Only the builds that match the compatibility layer your OS ships are offered</string>- <string name="trust_grapheneos_check_index_signed">That signed list is checked against a key built into this store</string>- <string name="trust_grapheneos_check_rollback">A list older than the last one seen is refused, so an old build cannot be pushed back onto you</string>- <string name="trust_grapheneos_check_hash_and_key">Every downloaded file matches the hash and the signing key that list names for it</string>- <string name="trust_grapheneos_limits">These are Google\'s closed-source apps. Nothing is built from published source and nothing is reproducible, so what is proven is that you received the file GrapheneOS listed, not anything about what that file does. The source carries only the Sandboxed Google Play components.</string> <string name="trust_play_title">Google Play</string> <string name="trust_play_summary">Reviewed, scanned and signed by Google, who verify who the developer is and can pull an app from every phone at once.</string> <string name="trust_play_practice_identity">Developers have to prove who they are, with a real name and address on file</string>
appstore/src/screenshotTest/kotlin/com/vayunmathur/appstore/ui/MetadataPreviews.kt
diff --git a/appstore/src/screenshotTest/kotlin/com/vayunmathur/appstore/ui/MetadataPreviews.kt b/appstore/src/screenshotTest/kotlin/com/vayunmathur/appstore/ui/MetadataPreviews.ktindex 04acfb58ef..1addc532c1 100644--- a/appstore/src/screenshotTest/kotlin/com/vayunmathur/appstore/ui/MetadataPreviews.kt+++ b/appstore/src/screenshotTest/kotlin/com/vayunmathur/appstore/ui/MetadataPreviews.kt@@ -76,15 +76,21 @@ class MetadataPreviews { state = HomeUiState( sections = listOf( AppSection(- id = "modern",- title = "From Modern Apps",- subtitle = "Built in this repo and signed with the same key as this store",+ id = "modern-recent",+ title = "New from Modern Apps",+ subtitle = "The newest builds from this repo", apps = MODERN, ), AppSection(- id = "recent",- title = "New and updated",- subtitle = "The newest builds F-Droid has reproduced",+ id = "proprietary-recent",+ title = "New in Proprietary",+ subtitle = "The newest builds from the Play mirror",+ apps = PROPRIETARY,+ ),+ AppSection(+ id = "fdroid-recent",+ title = "New on F-Droid",+ subtitle = "The newest builds on F-Droid", apps = FDROID, layout = SectionLayout.LIST, ),@@ -253,6 +259,16 @@ private val FDROID = listOf( ), ) +private val PROPRIETARY = listOf(+ UnifiedApp(+ packageName = "com.whatsapp",+ source = AppSource.PROPRIETARY,+ name = "WhatsApp",+ summary = "Messaging and calling, privately mirrored from Play",+ author = "WhatsApp LLC",+ ),+)+ /** A search that hit all three sources, which is the point of the screen. */ private val SEARCH_HITS = listOf( UnifiedApp(