Modern Apps git

← Modern-Apps.git

appstore: consolidate code for modern-apps and fdroid main repo

Commit
afc71d49fe799c23e8eb4668f1f7ff280ffab2a6
Author
Vayun Mathur <[email protected]>
When
2026-08-05 02:09 UTC (4 months ago)
Parents
d61ff08

Diff

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 3f1ff6eb2d..32a518c82b 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/AppDatabase.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/AppDatabase.kt@@ -89,7 +89,7 @@ fun UnifiedApp.toEntity(): CachedAppEntity = CachedAppEntity(     apkUrl = apkUrl,     targetSdk = targetSdk,     reproducible = reproducible,-    repoUrl = repoUrl?.removeSuffix("/") ?: DefaultRepos.FDROID_MAIN,+    repoUrl = repoUrl?.removeSuffix("/") ?: DefaultRepos.FDROID.url,     lastUpdated = lastUpdated,     expectedSigners = expectedSigners.joinToString(",").ifBlank { null },     apkSha256 = apkSha256,
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 316ebaec67..fe3eb3c985 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.kt@@ -1,7 +1,7 @@ package com.vayunmathur.appstore.data  enum class AppSource {-    /** This monorepo's own GitHub releases, signed with the same key as this app. */+    /** This monorepo's own repository, signed with the same key as this app. */     MODERN_APPS,     FDROID,     PLAYSTORE@@ -79,37 +79,52 @@ data class InstalledInfo(     val lastUpdateTime: Long = 0L, ) +/** A fixed, signed F-Droid-format repository consumed by this store. */+data class RepoDescriptor(+    val url: String,+    val displayName: String,+    val pinnedFingerprint: String,+    val source: AppSource,+    val supportsReproducibilityFeed: Boolean,+)+ /**- * The one and only F-Droid repository this store will talk to.+ * The only repositories this store will talk to.  *  * Third-party F-Droid-format repos (IzzyOnDroid and friends) are deliberately not  * supported and cannot be added: they republish binaries built by the upstream developer  * rather than building from source, so an app from one carries the developer's release  * pipeline *and* the mirror operator in its trusted set, with no published source to- * check the binary against. The f-droid.org archive is excluded for a different reason —+ * check the binary against. The f-droid.org archive is excluded for a different reason:  * it exists to serve superseded versions, which is the opposite of what we want.  */ object DefaultRepos {-    const val FDROID_MAIN = "https://f-droid.org/repo"+    val FDROID = RepoDescriptor(+        url = "https://f-droid.org/repo",+        displayName = "F-Droid",+        pinnedFingerprint =+            "43238d512c1e5eb2d6569f4a3afbf5523418b82e0a3ed1552770abb9a9c9ccab",+        source = AppSource.FDROID,+        supportsReproducibilityFeed = true,+    )++    val MODERN_APPS = RepoDescriptor(+        url = "https://ma.vayunmathur.com/fdroid/repo",+        displayName = "Modern Apps",+        pinnedFingerprint =+            "176fcb2525573e5be8e1cb3a496dd97b137e81ca5b887a1d32cb894b4e5717b4",+        source = AppSource.MODERN_APPS,+        supportsReproducibilityFeed = false,+    )++    val ALL: List<RepoDescriptor> = listOf(FDROID, MODERN_APPS)++    /** Cache key written by the retired GitHub releases provider. */+    const val LEGACY_MODERN_APPS_REPO_KEY = "https://github.com/vayun-mathur/Modern-Apps" } -/** The Modern-Apps monorepo's own GitHub release channel. */+/** The Modern-Apps monorepo's project page. */ object ModernAppsRepo {     const val OWNER_REPO = "vayun-mathur/Modern-Apps"     const val PROJECT_URL = "https://github.com/$OWNER_REPO"-    const val LATEST_RELEASE_API = "https://api.github.com/repos/$OWNER_REPO/releases/latest"--    /** Asset published by `release.sh` alongside the APKs; see [ModernAppsProvider]. */-    const val INDEX_ASSET = "index.json"--    /** File listing for a tag, used to recover package names on pre-index releases. */-    fun treeApi(tag: String) =-        "https://api.github.com/repos/$OWNER_REPO/git/trees/$tag?recursive=1"--    /** Two lines: versionCode, versionName. Injected into every module by `release.sh`. */-    fun versionTxt(tag: String) =-        "https://raw.githubusercontent.com/$OWNER_REPO/$tag/version.txt"--    /** Pseudo repo URL, used as the `repoUrl` key for cached rows. */-    const val REPO_KEY = PROJECT_URL }
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 ebfb87c66f..cf23803398 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/CatalogRepository.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/CatalogRepository.kt@@ -23,7 +23,7 @@ data class SyncReport( }  /**- * The offline catalogue: the F-Droid index and the Modern Apps release list, as cached in+ * The offline catalogue: the F-Droid and Modern Apps repository indexes, as cached in  * Room, plus the sync that refreshes them.  *  * Play is deliberately absent — it has no downloadable catalogue and is queried live (see@@ -40,8 +40,8 @@ class CatalogRepository(     scope: CoroutineScope, ) {     private val appContext = context.applicationContext-    private val fdroidProvider = FDroidAppProvider(db, appContext)-    private val modernProvider = ModernAppsProvider(appContext)+    private val fdroidProvider = FDroidAppProvider(db, appContext, DefaultRepos.FDROID)+    private val modernProvider = FDroidAppProvider(db, appContext, DefaultRepos.MODERN_APPS)      val repos: StateFlow<List<RepoEntity>> =         db.repoDao().allFlow().stateIn(scope, SharingStarted.Eagerly, emptyList())@@ -142,7 +142,7 @@ class CatalogRepository(         val fdroid = runCatching { fdroidProvider.syncIntoDb() }.getOrNull()          onProgress(SyncStep.MODERN_APPS)-        val modern = runCatching { modernProvider.syncIntoDb(db) }.getOrNull()+        val modern = runCatching { modernProvider.syncIntoDb() }.getOrNull()          SyncReport(             fdroidCount = fdroid,@@ -151,27 +151,21 @@ class CatalogRepository(         )     } -    /**-     * There is exactly one supported F-Droid repository and it cannot be changed, so this-     * both seeds it and prunes anything else a previous version may have stored.-     */+    /** Seed the fixed repository set and prune rows left by older configurations. */     private suspend fun ensureDefaultRepos() {         val existing = db.repoDao().all()-        existing.filter { it.url != DefaultRepos.FDROID_MAIN && it.url != ModernAppsRepo.REPO_KEY }-            .forEach {-                db.repoDao().deleteByUrl(it.url)-                db.cachedAppDao().deleteByRepo(it.url)-            }-        if (existing.none { it.url == DefaultRepos.FDROID_MAIN }) {-            db.repoDao().upsert(-                RepoEntity(-                    url = DefaultRepos.FDROID_MAIN,-                    name = "F-Droid",-                    enabled = true,-                    fingerprint = FDroidRepository.FDROID_SIGNING_CERT_SHA256,-                )-            )+        val supportedUrls = DefaultRepos.ALL.mapTo(mutableSetOf()) { it.url }+        existing.filterNot { it.url in supportedUrls }.forEach {+            db.repoDao().deleteByUrl(it.url)+            db.cachedAppDao().deleteByRepo(it.url)         }+        DefaultRepos.ALL.filter { descriptor ->+            existing.none { it.url == descriptor.url }+        }.forEach { db.repoDao().upsert(it.toEntity()) }++        // The retired GitHub provider never inserted a RepoEntity, so pruning rows cannot+        // discover its pseudo-key. This cleanup is cheap, idempotent, and safe to retain.+        db.cachedAppDao().deleteByRepo(DefaultRepos.LEGACY_MODERN_APPS_REPO_KEY)     }      private companion object {
appstore/src/main/java/com/vayunmathur/appstore/data/FDroidAppProvider.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidAppProvider.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidAppProvider.ktindex 32ce31b8cf..0cf680b91f 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidAppProvider.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidAppProvider.kt@@ -5,24 +5,18 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext  /**- * F-Droid, from a single hard-pinned repository.+ * Imports one hard-pinned F-Droid-format repository into the shared offline catalogue.  *- * **One repository only** — [DefaultRepos.FDROID_MAIN], with its index signing certificate- * hard-pinned. Third-party F-Droid-format repos are not supported and cannot be added,- * because they ship binaries the upstream developer built.- *- * The whole catalogue is imported (newest version of every app). F-Droid's reproducibility- * feed ([ReproducibleBuilds]) is consulted only to *badge* the versions that were- * independently reproduced bit-for-bit — it no longer decides what is listed. That feed is- * best-effort: if it can't be fetched, apps are simply imported without the badge rather- * than the sync failing. The signed-index gate still fails closed, so the catalogue is- * never replaced with entries whose hashes and signer keys weren't authenticated.- *- * Reads go through [CatalogRepository], which queries the cache table this writes.+ * The whole catalogue is imported (newest version of every app). For repositories that+ * support it, F-Droid's reproducibility feed ([ReproducibleBuilds]) is consulted only to+ * badge versions independently reproduced bit-for-bit. That feed is best-effort; signed-index+ * verification always fails closed, so unauthenticated hashes and signer keys never replace+ * cached rows.  */ class FDroidAppProvider(     private val db: AppDatabase,     private val appContext: Context,+    private val descriptor: RepoDescriptor, ) {      /** Number of packages tagged reproducible on the last sync. */@@ -30,18 +24,14 @@ class FDroidAppProvider(     var lastReproducibleCount: Int = 0         private set -    /**-     * Refresh from f-droid.org and replace this source's rows. Throws if the signed index-     * can't be obtained — the caller surfaces that instead of silently serving a stale or-     * unauthenticated catalogue. A missing reproducibility feed is not fatal.-     */+    /** Refresh [descriptor] and replace only that repository's cached rows. */     suspend fun syncIntoDb(): Int = withContext(Dispatchers.IO) {         val result = fetchVerifiedIndex()-        val repo = db.repoDao().all().find { it.url == DefaultRepos.FDROID_MAIN }-        db.cachedAppDao().deleteByRepo(DefaultRepos.FDROID_MAIN)+        val repo = db.repoDao().all().find { it.url == descriptor.url }+        db.cachedAppDao().deleteByRepo(descriptor.url)         db.cachedAppDao().upsertAll(result.apps.map { it.toEntity() })         db.repoDao().upsert(-            (repo ?: RepoEntity(DefaultRepos.FDROID_MAIN, "F-Droid", true)).copy(+            (repo ?: descriptor.toEntity()).copy(                 fingerprint = result.signerSha256,                 lastSync = System.currentTimeMillis(),             )@@ -50,16 +40,20 @@ class FDroidAppProvider(     }      private suspend fun fetchVerifiedIndex(): FDroidRepository.IndexResult {-        // Reproducibility verdicts are best-effort: a fetch failure just means nothing gets-        // the badge this sync, not that the catalogue disappears.-        val verified = runCatching { ReproducibleBuilds.fetch(appContext) }.getOrNull()+        val verified = if (descriptor.supportsReproducibilityFeed) {+            runCatching { ReproducibleBuilds.fetch(appContext) }.getOrNull()+        } else {+            null+        }         var reproduced = 0         val result = FDroidRepository.fetchRepoIndex(             context = appContext,-            repoUrl = DefaultRepos.FDROID_MAIN,-            pinnedFingerprint = FDroidRepository.FDROID_SIGNING_CERT_SHA256,+            repoUrl = descriptor.url,+            pinnedFingerprint = descriptor.pinnedFingerprint,+            source = descriptor.source,         ) { pkg, versionCode ->-            val ok = verified?.contains(pkg, versionCode) == true+            val ok = descriptor.supportsReproducibilityFeed &&+                verified?.contains(pkg, versionCode) == true             if (ok) reproduced++             ok         }@@ -67,3 +61,10 @@ class FDroidAppProvider(         return result     } }++fun RepoDescriptor.toEntity(): RepoEntity = RepoEntity(+    url = url,+    name = displayName,+    enabled = true,+    fingerprint = pinnedFingerprint,+)
appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.ktindex 20b11c3069..f13c45158a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.kt@@ -5,66 +5,49 @@ import android.util.JsonReader import android.util.JsonToken import com.vayunmathur.appstore.data.security.ApkCertificates import com.vayunmathur.appstore.data.security.SignedJarIndex+import com.vayunmathur.library.network.NetworkClient import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext import org.json.JSONObject import java.io.File import java.net.HttpURLConnection import java.net.URL+import javax.net.ssl.HttpsURLConnection  /**  * F-Droid repo client. Avoids OOM on the ~100MB index by downloading to a file and  * streaming-parsing with android.util.JsonReader rather than holding a whole object tree.  * Filters targetSdk < AppProvider.MIN_TARGET_SDK.  *- * **The index is always taken from the repo's signed JAR** (`entry.jar` for index-v2,- * `index-v1.jar` for the legacy format) and the signing certificate is pinned per repo.- * The plain `index-v2.json` endpoint is deliberately *not* used as a fallback: without a+ * **The index is always authenticated through the repo's signed `entry.jar`**, and the+ * signing certificate is pinned per repo. The plain `index-v2.json` endpoint is deliberately+ * *not* used as a fallback: without a  * signature the per-APK `sha256` and `signer` values this parser extracts would be  * attacker-controlled, and pinning them would be security theatre.  */ object FDroidRepository { -    /**-     * SHA-256 of the certificate f-droid.org signs its index with (CN=Ciaran Gultnieks).-     * Hard-pinned rather than trust-on-first-use because there is exactly one supported-     * repository, so there is no reason to ever accept an unknown key for it.-     */-    const val FDROID_SIGNING_CERT_SHA256 =-        "43238d512c1e5eb2d6569f4a3afbf5523418b82e0a3ed1552770abb9a9c9ccab"-     /** Parsed index plus the repo signing certificate it was authenticated with. */     data class IndexResult(val apps: List<UnifiedApp>, val signerSha256: String)      /**      * Fetch and verify [repoUrl]'s index.      *-     * [pinnedFingerprint] null means trust-on-first-use, and the caller must persist-     * [IndexResult.signerSha256]. Every app's newest version is imported; [isReproducible]+     * Every app's newest version is imported with [source]; [isReproducible]      * only *tags* whether that version was independently reproduced (surfaced as a badge),      * it never drops a version or a package.      */     suspend fun fetchRepoIndex(         context: Context,         repoUrl: String,-        pinnedFingerprint: String?,+        pinnedFingerprint: String,+        source: AppSource,         isReproducible: (packageName: String, versionCode: Long) -> Boolean,     ): IndexResult = withContext(Dispatchers.IO) {         val base = repoUrl.trimEnd('/')         val work = File(context.cacheDir, "fdroid-index/${base.hashCode()}").apply { mkdirs() }         try {-            val errors = mutableListOf<String>()-            try {-                return@withContext fetchV2(base, pinnedFingerprint, work, isReproducible)-            } catch (e: Exception) {-                errors += "index-v2: ${e.message}"-            }-            try {-                return@withContext fetchV1(base, pinnedFingerprint, work, isReproducible)-            } catch (e: Exception) {-                errors += "index-v1: ${e.message}"-            }-            throw java.io.IOException("Could not load a signed index from $base (${errors.joinToString("; ")})")+            fetchV2(base, pinnedFingerprint, source, work, isReproducible)         } finally {             work.deleteRecursively()         }@@ -77,7 +60,8 @@ object FDroidRepository {      */     private fun fetchV2(         base: String,-        pinnedFingerprint: String?,+        pinnedFingerprint: String,+        source: AppSource,         work: File,         isReproducible: (String, Long) -> Boolean,     ): IndexResult {@@ -101,43 +85,39 @@ object FDroidRepository {         }          return IndexResult(-            apps = AppProvider.filterTargetSdk(parseV2Streaming(indexFile, base, isReproducible)),+            apps = AppProvider.filterTargetSdk(+                parseV2Streaming(indexFile, base, source, isReproducible)+            ),             signerSha256 = verified.signerSha256,         )     } -    /** Legacy format: the whole index is inside the signed JAR. */-    private fun fetchV1(-        base: String,-        pinnedFingerprint: String?,-        work: File,-        isReproducible: (String, Long) -> Boolean,-    ): IndexResult {-        val jar = File(work, "index-v1.jar")-        downloadToFile("$base/index-v1.jar", jar)-        val indexFile = File(work, "index-v1.json")-        val signer = SignedJarIndex.extractVerified(jar, "index-v1.json", pinnedFingerprint, indexFile)-        return IndexResult(-            apps = AppProvider.filterTargetSdk(parseV1Streaming(indexFile, base, isReproducible)),-            signerSha256 = signer,-        )-    }-     internal fun downloadToFile(url: String, outFile: File) {-        val conn = (URL(url).openConnection() as HttpURLConnection).apply {+        val rawConnection = URL(url).openConnection()+        val sslSocketFactory = NetworkClient.defaultSslSocketFactory+        if (sslSocketFactory != null && rawConnection is HttpsURLConnection) {+            rawConnection.sslSocketFactory = sslSocketFactory+        }+        val conn = (rawConnection as HttpURLConnection).apply {             connectTimeout = 30000             readTimeout = 120000             setRequestProperty("Accept", "application/json")             setRequestProperty("User-Agent", "ModernAppStore/1.0")             instanceFollowRedirects = true         }-        if (conn.responseCode !in 200..299) throw java.io.IOException("HTTP ${conn.responseCode} for $url")-        conn.inputStream.use { input ->-            outFile.outputStream().use { out ->-                val buf = ByteArray(32 * 1024)-                var n: Int-                while (input.read(buf).also { n = it } != -1) out.write(buf, 0, n)+        try {+            if (conn.responseCode !in 200..299) {+                throw java.io.IOException("HTTP ${conn.responseCode} for $url")             }+            conn.inputStream.use { input ->+                outFile.outputStream().use { out ->+                    val buf = ByteArray(32 * 1024)+                    var n: Int+                    while (input.read(buf).also { n = it } != -1) out.write(buf, 0, n)+                }+            }+        } finally {+            conn.disconnect()         }     } @@ -146,6 +126,7 @@ object FDroidRepository {     private fun parseV2Streaming(         file: File,         repoBase: String,+        source: AppSource,         isReproducible: (String, Long) -> Boolean,     ): List<UnifiedApp> {         val result = mutableListOf<UnifiedApp>()@@ -159,7 +140,7 @@ object FDroidRepository {                         while (r.hasNext()) {                             val pkg = r.nextName()                             try {-                                val app = parsePackageV2(r, pkg, repoBase, isReproducible)+                                val app = parsePackageV2(r, pkg, repoBase, source, isReproducible)                                 if (app != null) result.add(app)                             } catch (_: Exception) {                                 try { r.skipValue() } catch (_: Exception) {}@@ -179,6 +160,7 @@ object FDroidRepository {         reader: JsonReader,         packageName: String,         repoBase: String,+        source: AppSource,         isReproducible: (String, Long) -> Boolean,     ): UnifiedApp? {         // reader at BEGIN_OBJECT of package@@ -342,7 +324,7 @@ object FDroidRepository {         val apkUrl = latestFileName.let { repoBase + "/" + it.trimStart('/') }         return UnifiedApp(             packageName = packageName,-            source = AppSource.FDROID,+            source = source,             expectedSigners = latestSigners,             apkSha256 = latestSha256,             reproducible = isReproducible(packageName, latestVersionCode),@@ -370,273 +352,6 @@ object FDroidRepository {         )     } -    // ---- Streaming V1 parser (apps[] + packages{ pkg:[...] }) ------    private fun parseV1Streaming(-        file: File,-        repoBase: String,-        isReproducible: (String, Long) -> Boolean,-    ): List<UnifiedApp> {-        val appsMeta = mutableMapOf<String, V1AppMeta>()-        val packagesMap = mutableMapOf<String, V1PackageLatest>()-        JsonReader(file.reader()).use { r ->-            r.isLenient = true-            r.beginObject()-            while (r.hasNext()) {-                when (r.nextName()) {-                    "apps" -> {-                        r.beginArray()-                        while (r.hasNext()) {-                            try {-                                val meta = parseV1AppMeta(r)-                                if (meta != null) appsMeta[meta.packageName] = meta-                            } catch (_: Exception) {-                                try { r.skipValue() } catch (_: Exception) {}-                            }-                        }-                        r.endArray()-                    }-                    "packages" -> {-                        r.beginObject()-                        while (r.hasNext()) {-                            val pkgName = r.nextName()-                            try {-                                val latest = parseV1PackagesArray(r)-                                if (latest != null) packagesMap[pkgName] = latest-                            } catch (_: Exception) {-                                try { r.skipValue() } catch (_: Exception) {}-                            }-                        }-                        r.endObject()-                    }-                    else -> r.skipValue()-                }-            }-            r.endObject()-        }--        val result = mutableListOf<UnifiedApp>()-        for ((pkg, meta) in appsMeta) {-            // No version at all means no catalogue entry.-            val latest = packagesMap[pkg] ?: continue-            result.add(-                UnifiedApp(-                    packageName = pkg,-                    source = AppSource.FDROID,-                    name = meta.name ?: pkg.substringAfterLast('.'),-                    summary = meta.summary ?: "",-                    description = meta.description ?: "",-                    iconUrl = meta.icon?.let { "$repoBase/icons/$it" },-                    // v1 localised media is stored per-locale under the package's own-                    // directory, so the locale the names came from is part of the path.-                    featureGraphic = meta.featureGraphic?.let {-                        "$repoBase/$pkg/${meta.localeDir}/$it"-                    },-                    screenshots = meta.phoneScreenshots.map {-                        "$repoBase/$pkg/${meta.localeDir}/phoneScreenshots/$it"-                    },-                    antiFeatures = meta.antiFeatures,-                    author = meta.authorName,-                    categories = meta.categories,-                    versionName = latest?.versionName,-                    versionCode = latest?.versionCode ?: 0L,-                    sizeBytes = latest?.size ?: 0L,-                    apkUrl = latest?.apkName?.let { repoBase + "/" + it.trimStart('/') },-                    targetSdk = latest?.targetSdk,-                    reproducible = latest?.let { isReproducible(pkg, it.versionCode) } ?: false,-                    expectedSigners = listOfNotNull(latest?.signer),-                    // v1 states the hash algorithm; only pin it when it really is SHA-256.-                    apkSha256 = latest?.hash?.takeIf { latest?.hashType.equals("sha256", true) },-                    website = meta.webSite,-                    sourceCode = meta.sourceCode,-                    license = meta.license,-                    addedTimestamp = meta.added,-                    lastUpdated = meta.lastUpdated,-                    repoUrl = repoBase-                )-            )-        }-        return result-    }--    private data class V1AppMeta(-        val packageName: String,-        val name: String?,-        val summary: String?,-        val description: String?,-        val icon: String?,-        val authorName: String?,-        val categories: List<String>,-        val webSite: String?,-        val sourceCode: String?,-        val license: String?,-        val added: Long,-        val lastUpdated: Long,-        val antiFeatures: List<String> = emptyList(),-        val featureGraphic: String? = null,-        val phoneScreenshots: List<String> = emptyList(),-        /** Locale the media above came from; it is a path segment in v1. */-        val localeDir: String = "en-US",-    )--    /** The subset of a v1 `localized` block this store shows. */-    private data class V1Localized(-        val locale: String,-        val featureGraphic: String?,-        val phoneScreenshots: List<String>,-    )--    private data class V1PackageLatest(-        val apkName: String?,-        val versionName: String?,-        val versionCode: Long,-        val size: Long,-        val targetSdk: Int?,-        val hash: String?,-        val hashType: String?,-        val signer: String?-    )--    private fun parseV1AppMeta(reader: JsonReader): V1AppMeta? {-        var packageName: String? = null-        var name: String? = null-        var summary: String? = null-        var description: String? = null-        var icon: String? = null-        var authorName: String? = null-        var categories: List<String> = emptyList()-        var webSite: String? = null-        var sourceCode: String? = null-        var license: String? = null-        var added: Long = 0L-        var lastUpdated: Long = 0L-        var antiFeatures: List<String> = emptyList()-        var localized: V1Localized? = null--        reader.beginObject()-        while (reader.hasNext()) {-            when (reader.nextName()) {-                "packageName" -> packageName = nextStringOrNull(reader)-                "name" -> name = nextStringOrNull(reader)-                "summary" -> summary = nextStringOrNull(reader)-                "description" -> description = nextStringOrNull(reader)-                "icon" -> icon = nextStringOrNull(reader)-                "authorName" -> authorName = nextStringOrNull(reader)-                "categories" -> categories = readStringArray(reader)-                "webSite" -> webSite = nextStringOrNull(reader)-                "sourceCode" -> sourceCode = nextStringOrNull(reader)-                "license" -> license = nextStringOrNull(reader)-                "added" -> added = nextLongOrNull(reader) ?: 0L-                "lastUpdated" -> lastUpdated = nextLongOrNull(reader) ?: 0L-                // v1 lists anti-features as plain strings, unlike v2's id -> reason map.-                "antiFeatures" -> antiFeatures = readStringArray(reader)-                "localized" -> localized = readV1Localized(reader)-                else -> reader.skipValue()-            }-        }-        reader.endObject()-        val pkg = packageName ?: return null-        return V1AppMeta(-            pkg, name, summary, description, icon, authorName, categories, webSite,-            sourceCode, license, added, lastUpdated,-            antiFeatures = antiFeatures,-            featureGraphic = localized?.featureGraphic,-            phoneScreenshots = localized?.phoneScreenshots ?: emptyList(),-            localeDir = localized?.locale ?: "en-US",-        )-    }--    /**-     * v1 `localized`: `{ "en-US": { "phoneScreenshots": ["1.png"], "featureGraphic": … } }`.-     *-     * Takes the first locale that actually carries media rather than insisting on en-US,-     * since an app localised only into, say, German still has usable screenshots.-     */-    private fun readV1Localized(reader: JsonReader): V1Localized? {-        if (reader.peek() != JsonToken.BEGIN_OBJECT) {-            reader.skipValue()-            return null-        }-        var best: V1Localized? = null-        reader.beginObject()-        while (reader.hasNext()) {-            val locale = reader.nextName()-            if (reader.peek() != JsonToken.BEGIN_OBJECT) {-                reader.skipValue()-                continue-            }-            var feature: String? = null-            var shots: List<String> = emptyList()-            reader.beginObject()-            while (reader.hasNext()) {-                when (reader.nextName()) {-                    "featureGraphic" -> feature = nextStringOrNull(reader)-                    "phoneScreenshots" -> shots = readStringArray(reader)-                    else -> reader.skipValue()-                }-            }-            reader.endObject()-            val candidate = V1Localized(locale, feature, shots)-            val hasMedia = feature != null || shots.isNotEmpty()-            // en-US wins outright; otherwise the first locale with anything to show.-            if (hasMedia && (locale == "en-US" || best == null)) {-                best = candidate-                if (locale == "en-US") {-                    // Keep draining so the object closes cleanly.-                    while (reader.hasNext()) { reader.nextName(); reader.skipValue() }-                }-            }-        }-        reader.endObject()-        return best-    }--    private fun parseV1PackagesArray(-        reader: JsonReader,-    ): V1PackageLatest? {-        // Array of package versions; keep the one with the highest versionCode rather than-        // relying on array order.-        var best: V1PackageLatest? = null-        reader.beginArray()-        while (reader.hasNext()) {-            try {-                reader.beginObject()-                var apkName: String? = null-                var versionName: String? = null-                var versionCode: Long = 0L-                var size: Long = 0L-                var targetSdk: Int? = null-                var hash: String? = null-                var hashType: String? = null-                var signer: String? = null-                while (reader.hasNext()) {-                    when (reader.nextName()) {-                        "apkName" -> apkName = nextStringOrNull(reader)-                        "versionName" -> versionName = nextStringOrNull(reader)-                        "versionCode" -> versionCode = nextLongOrNull(reader) ?: 0L-                        "size" -> size = nextLongOrNull(reader) ?: 0L-                        "targetSdkVersion" -> targetSdk = nextIntOrNull(reader)-                        "hash" -> hash = nextStringOrNull(reader)-                        "hashType" -> hashType = nextStringOrNull(reader)-                        "signer" -> signer = nextStringOrNull(reader)-                        else -> reader.skipValue()-                    }-                }-                reader.endObject()-                if (best == null || versionCode > best.versionCode) {-                    best = V1PackageLatest(-                        apkName, versionName, versionCode, size, targetSdk, hash, hashType, signer-                    )-                }-            } catch (_: Exception) {-                try { reader.endObject() } catch (_: Exception) {}-                try { reader.skipValue() } catch (_: Exception) {}-            }-        }-        reader.endArray()-        return best-    }-     // ---- Helpers ----      private fun readLocalizedString(reader: JsonReader): String? {
appstore/src/main/java/com/vayunmathur/appstore/data/ModernAppsProvider.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/ModernAppsProvider.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/ModernAppsProvider.ktdeleted file mode 100644index fcbba458b2..0000000000--- a/appstore/src/main/java/com/vayunmathur/appstore/data/ModernAppsProvider.kt+++ /dev/null@@ -1,259 +0,0 @@-package com.vayunmathur.appstore.data--import android.content.Context-import kotlinx.coroutines.Dispatchers-import kotlinx.coroutines.withContext-import kotlinx.serialization.SerialName-import kotlinx.serialization.Serializable-import kotlinx.serialization.json.Json-import java.net.HttpURLConnection-import java.net.URL--/**- * The monorepo's own apps, sourced straight from its GitHub releases.- *- * `release.sh` attaches every module's release APK to the tagged GitHub release, together- * with an `index.json` describing them — the APK filenames alone can't be mapped back to- * package names, since `:games:chess` builds `chess-release.apk` but installs as- * `com.vayunmathur.games.chess`.- *- * Releases cut before `index.json` existed are still usable: [fetchFromGitTree] derives- * the same information from the tag itself, by listing the repo tree for that tag and- * turning each module path into its applicationId (`games/chess` →- * `com.vayunmathur.games.chess`, which holds for every module in the repo). Version comes- * from `version.txt` at the tag and per-asset SHA-256 from GitHub's own `digest` field, so- * the fallback is exact rather than a guess.- *- * **Neither path is signed, and neither needs to be.** Every APK from this source is- * checked at install time against the certificate *this store app itself* is signed with- * (see [com.vayunmathur.appstore.data.security.ApkCertificates.selfSigners]). A tampered- * index, a compromised GitHub account, or a hostile CDN can change which bytes are- * offered, but cannot produce bytes that will install: that needs the release signing- * key, which is the sole trust root here.- *- * Reads go through [CatalogRepository], which queries the cache table this writes.- */-class ModernAppsProvider(private val appContext: Context) {--    private val json = Json { ignoreUnknownKeys = true; isLenient = true }--    private suspend fun fetchAll(): List<UnifiedApp> = withContext(Dispatchers.IO) {-        val release = json.decodeFromString(-            GithubRelease.serializer(),-            httpGetString(ModernAppsRepo.LATEST_RELEASE_API, accept = GITHUB_ACCEPT),-        )-        val indexAsset = release.assets.firstOrNull { it.name == ModernAppsRepo.INDEX_ASSET }-        val apps = if (indexAsset != null) {-            fetchFromIndex(release, indexAsset)-        } else {-            fetchFromGitTree(release)-        }-        AppProvider.filterTargetSdk(apps).distinctBy { it.packageName }-    }--    /** Preferred path: the release states its own contents. */-    private fun fetchFromIndex(release: GithubRelease, indexAsset: GithubAsset): List<UnifiedApp> {-        val index = json.decodeFromString(-            ModernAppsIndex.serializer(),-            httpGetString(indexAsset.downloadUrl, accept = "application/json"),-        )-        val assets = release.assets.associateBy { it.name }-        return index.apps.mapNotNull { entry ->-            val asset = assets[entry.apk] ?: return@mapNotNull null-            entryToApp(-                packageName = entry.packageName,-                label = entry.label,-                asset = asset,-                versionCode = entry.versionCode ?: index.versionCode,-                versionName = entry.versionName ?: index.versionName ?: release.tagName,-                targetSdk = entry.targetSdk,-                sha256 = entry.sha256 ?: asset.sha256(),-                summary = entry.summary.orEmpty(),-                description = entry.description.orEmpty(),-                publishedAt = release.publishedAtMillis(),-            )-        }-    }--    /**-     * Fallback for releases published before `index.json` existed.-     *-     * Every module in the repo has `applicationId = "com.vayunmathur." + <module path with-     * dots>`, and each builds `<leaf>-release.apk`, so the tag's file listing is enough to-     * recover the mapping exactly. Where a leaf name is ambiguous (`openassistant` is both-     * an app and an `sdk/` library) the shallowest path wins, which is the app; a wrong-     * guess could not install anything anyway, because [InstallVerifier] rejects an APK-     * whose declared package differs from the one requested.-     */-    private fun fetchFromGitTree(release: GithubRelease): List<UnifiedApp> {-        val tag = release.tagName.ifBlank { throw java.io.IOException("Release has no tag") }-        val tree = json.decodeFromString(-            GitTree.serializer(),-            httpGetString(ModernAppsRepo.treeApi(tag), accept = GITHUB_ACCEPT),-        )-        val modules = tree.tree.asSequence()-            .map { it.path }-            .filter { it.endsWith("/build.gradle.kts") && !it.startsWith("build-logic") }-            .map { it.removeSuffix("/build.gradle.kts") }-            .toList()--        // leaf -> shallowest module path with that leaf-        val byLeaf = HashMap<String, String>()-        for (module in modules.sortedBy { it.count { c -> c == '/' } }) {-            byLeaf.putIfAbsent(module.substringAfterLast('/'), module)-        }--        // release.sh injects one version across every module; version.txt at the tag-        // records it, and GitHub's asset list carries no versionCode of its own.-        val (versionCode, versionName) = readVersionTxt(tag) ?: (0L to tag)--        return release.assets.mapNotNull { asset ->-            if (!asset.name.endsWith(APK_SUFFIX)) return@mapNotNull null-            val leaf = asset.name.removeSuffix(APK_SUFFIX)-            val module = byLeaf[leaf] ?: return@mapNotNull null-            entryToApp(-                packageName = "com.vayunmathur." + module.replace('/', '.'),-                label = leaf.replaceFirstChar { it.uppercase() },-                asset = asset,-                versionCode = versionCode,-                versionName = versionName,-                // Unknown without reading the APK; null passes filterTargetSdk, and the-                // whole repo targets well above the floor anyway.-                targetSdk = null,-                sha256 = asset.sha256(),-                summary = "",-                description = "",-                publishedAt = release.publishedAtMillis(),-            )-        }-    }--    /** `version.txt` is two lines: versionCode, then versionName. */-    private fun readVersionTxt(tag: String): Pair<Long, String>? = try {-        val lines = httpGetString(ModernAppsRepo.versionTxt(tag), accept = "text/plain")-            .lineSequence().map { it.trim() }.filter { it.isNotEmpty() }.toList()-        val code = lines.getOrNull(0)?.toLongOrNull()-        val name = lines.getOrNull(1)-        if (code != null && name != null) code to name else null-    } catch (_: Exception) {-        null-    }--    private fun entryToApp(-        packageName: String,-        label: String,-        asset: GithubAsset,-        versionCode: Long,-        versionName: String,-        targetSdk: Int?,-        sha256: String?,-        summary: String,-        description: String,-        publishedAt: Long,-    ) = UnifiedApp(-        packageName = packageName,-        source = AppSource.MODERN_APPS,-        name = label,-        summary = summary,-        description = description,-        author = AUTHOR,-        versionName = versionName,-        versionCode = versionCode,-        sizeBytes = asset.size,-        apkUrl = asset.downloadUrl,-        targetSdk = targetSdk,-        license = LICENSE,-        website = ModernAppsRepo.PROJECT_URL,-        sourceCode = ModernAppsRepo.PROJECT_URL,-        repoUrl = ModernAppsRepo.REPO_KEY,-        apkSha256 = sha256,-        lastUpdated = publishedAt,-    )--    /** Refresh from GitHub and replace this source's rows in the shared cache table. */-    suspend fun syncIntoDb(db: AppDatabase): Int = withContext(Dispatchers.IO) {-        val apps = fetchAll()-        db.cachedAppDao().deleteByRepo(ModernAppsRepo.REPO_KEY)-        db.cachedAppDao().upsertAll(apps.map { it.toEntity() })-        apps.size-    }--    private fun httpGetString(url: String, accept: String): String {-        val conn = (URL(url).openConnection() as HttpURLConnection).apply {-            connectTimeout = 20_000-            readTimeout = 60_000-            instanceFollowRedirects = true-            setRequestProperty("Accept", accept)-            setRequestProperty("User-Agent", USER_AGENT)-        }-        try {-            if (conn.responseCode !in 200..299) {-                throw java.io.IOException("HTTP ${conn.responseCode} for $url")-            }-            return conn.inputStream.use { it.readBytes().toString(Charsets.UTF_8) }-        } finally {-            conn.disconnect()-        }-    }--    companion object {-        private const val GITHUB_ACCEPT = "application/vnd.github+json"-        private const val USER_AGENT = "ModernAppStore/1.0"-        private const val AUTHOR = "Vayun Mathur"-        private const val LICENSE = "GPL-3.0-only"-        private const val APK_SUFFIX = "-release.apk"-    }-}--// --- Wire formats ---------------------------------------------------------------------@Serializable-private data class GithubRelease(-    @SerialName("tag_name") val tagName: String = "",-    @SerialName("published_at") val publishedAt: String? = null,-    val assets: List<GithubAsset> = emptyList(),-) {-    /** GitHub returns ISO-8601 UTC ("2026-08-01T12:00:00Z"); 0 if absent or unparseable. */-    fun publishedAtMillis(): Long = publishedAt?.let {-        runCatching { java.time.Instant.parse(it).toEpochMilli() }.getOrNull()-    } ?: 0L-}--@Serializable-private data class GithubAsset(-    val name: String = "",-    @SerialName("browser_download_url") val downloadUrl: String = "",-    val size: Long = 0L,-    /** GitHub returns `"sha256:<hex>"`; absent on older releases. */-    val digest: String? = null,-) {-    fun sha256(): String? = digest?.removePrefix("sha256:")?.takeIf { it.length == 64 }-}--@Serializable-private data class GitTree(val tree: List<GitTreeEntry> = emptyList())--@Serializable-private data class GitTreeEntry(val path: String = "")--@Serializable-private data class ModernAppsIndex(-    val versionCode: Long = 0L,-    val versionName: String? = null,-    val apps: List<ModernAppEntry> = emptyList(),-)--@Serializable-private data class ModernAppEntry(-    val packageName: String,-    val label: String,-    /** Release asset filename, e.g. `chess-release.apk`. */-    val apk: String,-    val sha256: String? = null,-    val size: Long = 0L,-    val versionCode: Long? = null,-    val versionName: String? = null,-    val targetSdk: Int? = null,-    val summary: String? = null,-    val description: String? = null,-)
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 0d82dd8bdd..d99beda162 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt@@ -22,6 +22,8 @@ import androidx.work.WorkerParameters import com.vayunmathur.appstore.MainActivity import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.play.PlayRepository+import com.vayunmathur.library.network.NetworkClient+import com.vayunmathur.library.network.TrustBundle import com.vayunmathur.library.room.buildDatabase import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.SupervisorJob@@ -47,6 +49,8 @@ class UpdateCheckWorker( ) : CoroutineWorker(context, params) {      override suspend fun doWork(): Result = try {+        // WorkManager can cold-start the process without MainActivity initializing TLS.+        NetworkClient.init(context, TrustBundle.STANDARD)         val scope = CoroutineScope(SupervisorJob())         val db = context.buildDatabase<AppDatabase>(             dbName = DB_NAME,
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 ba4d055815..27feb1158f 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@@ -10,6 +10,7 @@ import com.vayunmathur.appstore.data.play.CertUtil import com.vayunmathur.appstore.data.play.PlayRepository import com.vayunmathur.appstore.data.security.InstallRequirement import com.vayunmathur.appstore.data.security.VerificationResult+import com.vayunmathur.library.network.NetworkClient import kotlinx.coroutines.CancellationException import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.MutableStateFlow@@ -19,6 +20,7 @@ import kotlinx.coroutines.withContext import java.io.File import java.net.HttpURLConnection import java.net.URL+import javax.net.ssl.HttpsURLConnection  /**  * Where an install has got to.@@ -141,7 +143,12 @@ class InstallCoordinator(         }      private fun download(url: String, target: File, expectedSize: Long, onProgress: (Float) -> Unit) {-        val conn = (URL(url).openConnection() as HttpURLConnection).apply {+        val rawConnection = URL(url).openConnection()+        val sslSocketFactory = NetworkClient.defaultSslSocketFactory+        if (sslSocketFactory != null && rawConnection is HttpsURLConnection) {+            rawConnection.sslSocketFactory = sslSocketFactory+        }+        val conn = (rawConnection as HttpURLConnection).apply {             connectTimeout = 20_000             readTimeout = 60_000             instanceFollowRedirects = true
appstore/src/main/java/com/vayunmathur/appstore/data/security/SignedJarIndex.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/security/SignedJarIndex.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/security/SignedJarIndex.ktindex 67b0721294..11cadaa892 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/security/SignedJarIndex.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/security/SignedJarIndex.kt@@ -5,8 +5,7 @@ import java.security.cert.X509Certificate import java.util.jar.JarFile  /**- * Verifies an F-Droid repository index, which ships as a JAR signed with the repo's key- * (`entry.jar` for index-v2, `index-v1.jar` for the legacy format).+ * Verifies the signed `entry.jar` that authenticates an F-Droid repository's index-v2.  *  * This is the check that makes everything downstream mean anything: the per-APK SHA-256  * and `signer` fingerprints only bind the APK to the index, so an index we haven't@@ -31,11 +30,9 @@ object SignedJarIndex {      /**      * Read [entryName] out of the signed [jar], enforcing that it is covered by the JAR-     * signature. When [pinnedFingerprint] is non-null the signing certificate must match-     * it; when null the caller is doing trust-on-first-use and should persist the-     * returned [Verified.signerSha256].+     * signature. The signing certificate must match [pinnedFingerprint].      */-    fun readVerified(jar: File, entryName: String, pinnedFingerprint: String?): Verified {+    fun readVerified(jar: File, entryName: String, pinnedFingerprint: String): Verified {         var content = ByteArray(0)         val fingerprint = consumeVerified(jar, entryName, pinnedFingerprint) { input ->             content = input.readBytes()@@ -43,30 +40,10 @@ object SignedJarIndex {         return Verified(content, fingerprint)     } -    /**-     * Streaming form of [readVerified] for entries too large to hold in memory — the-     * full F-Droid `index-v1.json` runs to hundreds of megabytes. Writes the entry to-     * [dest] and returns the signing certificate fingerprint. [dest] is deleted if-     * verification fails, so a rejected index is never left behind to be parsed.-     */-    fun extractVerified(-        jar: File,-        entryName: String,-        pinnedFingerprint: String?,-        dest: File,-    ): String = try {-        consumeVerified(jar, entryName, pinnedFingerprint) { input ->-            dest.outputStream().use { input.copyTo(it) }-        }-    } catch (t: Throwable) {-        dest.delete()-        throw t-    }-     private fun consumeVerified(         jar: File,         entryName: String,-        pinnedFingerprint: String?,+        pinnedFingerprint: String,         consume: (java.io.InputStream) -> Unit,     ): String {         JarFile(jar, true).use { jarFile ->@@ -86,7 +63,7 @@ object SignedJarIndex {                 ?: throw VerificationException("$entryName has no X.509 signer")              val fingerprint = ApkCertificates.sha256(signer.encoded)-            if (pinnedFingerprint != null && !fingerprint.equals(pinnedFingerprint, true)) {+            if (!fingerprint.equals(pinnedFingerprint, true)) {                 throw VerificationException(                     "Repository signing key changed: pinned " +                         "${ApkCertificates.abbreviate(pinnedFingerprint)}, " +
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 e04d85766d..3f65d91ed4 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@@ -123,6 +123,7 @@ enum class TrustProfile {     val ourChecks: List<Int>         get() = when (this) {             MODERN_APPS -> listOf(+                R.string.trust_modern_apps_check_index_signed,                 R.string.trust_modern_apps_check_key,                 R.string.trust_modern_apps_check_hash,             )
appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.ktindex cd97e3d38d..89f62947de 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/SourcesPage.kt@@ -19,7 +19,6 @@ import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.DefaultRepos-import com.vayunmathur.appstore.data.FDroidRepository import com.vayunmathur.appstore.data.ModernAppsRepo import com.vayunmathur.appstore.data.security.ApkCertificates import com.vayunmathur.appstore.util.AppStoreViewModel@@ -49,7 +48,7 @@ fun SourcesPage( ) {     val repos by viewModel.repos.collectAsState()     val home by viewModel.home.collectAsState()-    val fdroid = repos.find { it.url == DefaultRepos.FDROID_MAIN }+    val fdroid = repos.find { it.url == DefaultRepos.FDROID.url }      Scaffold(         topBar = {@@ -111,10 +110,10 @@ fun SourcesPage(             item {                 SourceCard(                     title = stringResource(R.string.source_fdroid),-                    subtitle = DefaultRepos.FDROID_MAIN,+                    subtitle = DefaultRepos.FDROID.url,                     pinLabel = stringResource(R.string.source_fdroid_pin),                     pins = setOfNotNull(-                        fdroid?.fingerprint ?: FDroidRepository.FDROID_SIGNING_CERT_SHA256+                        fdroid?.fingerprint ?: DefaultRepos.FDROID.pinnedFingerprint                     ),                     lastSync = fdroid?.lastSync ?: 0L,                 )
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 ad36e9da5a..754a51bd78 100644--- a/appstore/src/main/res/values/strings.xml+++ b/appstore/src/main/res/values/strings.xml@@ -150,8 +150,9 @@     <string name="trust_modern_apps_summary">Built in the same repo as this store and signed with the same key, which your phone can check against the copy of the store you are holding.</string>     <string name="trust_modern_apps_practice_open">All of it is open source, in one public repository</string>     <string name="trust_modern_apps_practice_one_key">Every app ships from one tagged release, signed with one key</string>+    <string name="trust_modern_apps_check_index_signed">The repository index is signed and checked against this store\'s own pinned key</string>     <string name="trust_modern_apps_check_key">Signed by this app\'s own key, read straight from your phone at install time</string>-    <string name="trust_modern_apps_check_hash">The file matches the hash published with the release on GitHub</string>+    <string name="trust_modern_apps_check_hash">The file matches the hash in the repository\'s signed index</string>     <string name="trust_modern_apps_limits">One developer, one key, no independent review and nobody rebuilding the source to confirm the app matches it. There is no scanning and no way to pull a bad release off phones that already took it.</string>      <string name="trust_fdroid_title">F-Droid</string>
appstore/src/test/java/com/vayunmathur/appstore/data/security/SignedJarIndexTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/data/security/SignedJarIndexTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/data/security/SignedJarIndexTest.ktindex d6fbf6f33d..806e76c0c1 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/data/security/SignedJarIndexTest.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/data/security/SignedJarIndexTest.kt@@ -9,7 +9,6 @@ import kotlin.test.AfterTest import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith-import kotlin.test.assertFalse import kotlin.test.assertTrue  /**@@ -25,6 +24,7 @@ import kotlin.test.assertTrue  */ class SignedJarIndexTest { +    private val pinnedFingerprint = "0".repeat(64)     private val temp: File = File.createTempFile("signedjar", "dir").let {         it.delete(); it.mkdirs(); it     }@@ -69,7 +69,7 @@ class SignedJarIndexTest {     fun aJarWithNoManifestIsRejected() {         val jar = unsignedJarWithoutManifest("entry.json" to """{"repo":1}""")         val e = assertFailsWith<SignedJarIndex.VerificationException> {-            SignedJarIndex.readVerified(jar, "entry.json", null)+            SignedJarIndex.readVerified(jar, "entry.json", pinnedFingerprint)         }         assertTrue(e.message!!.contains("not signed"), e.message!!)     }@@ -80,7 +80,7 @@ class SignedJarIndexTest {         // and simply reports no certificates, so "no certificates" has to mean "reject".         val jar = jarWithManifestButNoSignature("entry.json" to """{"repo":1}""")         val e = assertFailsWith<SignedJarIndex.VerificationException> {-            SignedJarIndex.readVerified(jar, "entry.json", null)+            SignedJarIndex.readVerified(jar, "entry.json", pinnedFingerprint)         }         assertTrue(e.message!!.contains("not covered by the JAR signature"), e.message!!)     }@@ -89,7 +89,7 @@ class SignedJarIndexTest {     fun aMissingEntryIsRejected() {         val jar = jarWithManifestButNoSignature("something-else.json" to "{}")         val e = assertFailsWith<SignedJarIndex.VerificationException> {-            SignedJarIndex.readVerified(jar, "entry.json", null)+            SignedJarIndex.readVerified(jar, "entry.json", pinnedFingerprint)         }         assertTrue(e.message!!.contains("does not contain"), e.message!!)     }@@ -100,38 +100,18 @@ class SignedJarIndexTest {         f.writeBytes(ByteArray(512) { 0x41 })         // Not a VerificationException — the point is that it throws rather than returning         // unverified content, and the caller treats any throw as a failed sync.-        assertFailsWith<Exception> { SignedJarIndex.readVerified(f, "entry.json", null) }+        assertFailsWith<Exception> {+            SignedJarIndex.readVerified(f, "entry.json", pinnedFingerprint)+        }     }      @Test     fun anEmptyFileIsRejected() {         val f = File(temp, "empty.jar")         f.writeBytes(ByteArray(0))-        assertFailsWith<Exception> { SignedJarIndex.readVerified(f, "entry.json", null) }-    }--    // --- extractVerified must not leave a rejected index on disk -----    @Test-    fun extractVerifiedDeletesItsOutputWhenVerificationFails() {-        val jar = jarWithManifestButNoSignature("entry.json" to """{"repo":1}""")-        val dest = File(temp, "extracted.json")-        assertFailsWith<SignedJarIndex.VerificationException> {-            SignedJarIndex.extractVerified(jar, "entry.json", null, dest)-        }-        // A surviving file would be an unverified index sitting where the parser looks.-        assertFalse(dest.exists(), "rejected index was left on disk at $dest")-    }--    @Test-    fun extractVerifiedDeletesAPreexistingOutputWhenVerificationFails() {-        val jar = jarWithManifestButNoSignature("entry.json" to """{"repo":1}""")-        val dest = File(temp, "stale.json")-        dest.writeText("""{"stale":"previous sync"}""")-        assertFailsWith<SignedJarIndex.VerificationException> {-            SignedJarIndex.extractVerified(jar, "entry.json", null, dest)+        assertFailsWith<Exception> {+            SignedJarIndex.readVerified(f, "entry.json", pinnedFingerprint)         }-        assertFalse(dest.exists(), "stale index survived a failed verification")     }      // --- fingerprint helpers used to report pin mismatches ---