appstore: detekt clean (653 tests)
- Commit
dc42db9af4947216e89a4588f37c1205d03d6938- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-14 23:58 UTC (21 days ago)
- Parents
63e187c
Fix all 88 detekt findings: real KDoc for 61 undocumented public classes; TvStoreViewModel LargeClass fixed by moving home/first-sync bodies to new tv/TvStoreHomeOps.kt (710 to 551 lines) with thin delegators; LongMethod/Cyclomatic splits in FDroidRepository.parsePackageV2, IzzyVerification.readRecord, phone/TV loadHome/buildSections/syncSources and TV screens (LazyGridScope section helpers and sub-composables); ComplexCondition factored into named vals and all{} checks; MagicNumber constants SIGNER_PREFIX_LENGTH, PERCENT_MAX, DETAIL_IDENTITY_WEIGHT; unused TvStoreBrowseScreen(onBack) parameter removed (wrapper already installs BackHandler) plus test signingInfo(cert); five-entry destructuring replaced with inputs.* access; test builders split.
One narrow @Suppress(TooGenericExceptionCaught) on InstallCoordinator.install with comment: specific catches sit above it and the catch-all is the documented last resort so any gRPC/AuthError/Room failure fails the row instead of crashing the store (#812).
Verified: detekt and lint BUILD SUCCESSFUL; 653 unit tests with exactly the 26 pre-existing failures from /tmp/inventory.json (CatalogSyncPrune, ReproducibleFeeds, UpdateCheckWorkerDoWork, Accrescent/Play repository and installer tests, TV/phone load tests), class-for-class identical to baseline, nothing worsened.Diff
appstore/src/main/java/com/vayunmathur/appstore/MainActivity.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/MainActivity.kt b/appstore/src/main/java/com/vayunmathur/appstore/MainActivity.ktindex 47933a4319..381277b9a0 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/MainActivity.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/MainActivity.kt@@ -54,6 +54,7 @@ import com.vayunmathur.library.util.rememberNavBackStack import kotlinx.serialization.Serializable import kotlinx.coroutines.launch +/** Entry activity that wires the store UI, navigation and catalog startup. */ class MainActivity : MaActivity() { private var factoryState by mutableStateOf<AppStoreViewModelFactory?>(null)@@ -112,10 +113,15 @@ class MainActivity : MaActivity() { } @Serializable+/** Navigation destinations for the phone store UI. */ sealed interface Route : NavKey {+ /** Destination showing the store home page. */ @Serializable data object Main : Route+ /** Destination showing source trust information. */ @Serializable data object Trust : Route+ /** Destination showing one app's detail page. */ @Serializable data object Detail : Route+ /** Destination browsing one home-page section by its ID. */ @Serializable data class Browse(val sectionId: String) : Route /**
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 a36f11fa19..bea4609be7 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/AppDatabase.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/AppDatabase.kt@@ -16,6 +16,7 @@ import kotlinx.coroutines.flow.Flow const val DB_NAME = "appstore-db" @Entity+/** A configured app repository stored by its URL. */ data class RepoEntity( @PrimaryKey val url: String, val name: String,@@ -26,6 +27,7 @@ data class RepoEntity( ) @Entity+/** A cached catalog app entry keyed by package name. */ data class CachedAppEntity( @PrimaryKey val packageName: String, val source: String, // MODERN_APPS, FDROID, PLAYSTORE@@ -196,6 +198,7 @@ data class PinnedStampEntity( ) @Dao+/** DAO for pinned source-stamp records per package. */ interface PinnedStampDao { @Query("SELECT * FROM PinnedStampEntity WHERE packageName = :pkg LIMIT 1") suspend fun byPackage(pkg: String): PinnedStampEntity?@@ -224,6 +227,7 @@ data class AccrescentTrustEntity( ) @Dao+/** DAO for Accrescent trust records per app. */ interface AccrescentTrustDao { @Query("SELECT * FROM AccrescentTrustEntity WHERE appId = :appId LIMIT 1") suspend fun byId(appId: String): AccrescentTrustEntity?@@ -250,6 +254,7 @@ interface AccrescentTrustDao { } @Dao+/** DAO for configured repository rows. */ interface RepoDao { @Query("SELECT * FROM RepoEntity ORDER BY name ASC") fun allFlow(): Flow<List<RepoEntity>>@@ -282,6 +287,7 @@ data class PackageIndexRow( ) @Dao+/** DAO for cached catalog app rows. */ interface CachedAppDao { @Query("SELECT * FROM CachedAppEntity ORDER BY name ASC") fun allFlow(): Flow<List<CachedAppEntity>>@@ -394,12 +400,14 @@ interface CachedAppDao { version = 9, exportSchema = false )+/** Room database holding repositories, cached apps and trust records. */ abstract class AppDatabase : RoomDatabase() { abstract fun repoDao(): RepoDao abstract fun cachedAppDao(): CachedAppDao abstract fun pinnedStampDao(): PinnedStampDao abstract fun accrescentTrustDao(): AccrescentTrustDao + /** Defines database migrations for AppDatabase. */ companion object : com.vayunmathur.library.util.DatabaseMigrations { override val migrations = listOf( object : Migration(1, 2) {
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 4ae48c060b..f449ed7652 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.kt@@ -2,6 +2,7 @@ package com.vayunmathur.appstore.data import com.vayunmathur.appstore.domain.SearchRanking +/** The catalog source an app listing came from. */ enum class AppSource { /** This monorepo's own repository, signed with the same key as this app. */ MODERN_APPS,@@ -35,6 +36,7 @@ enum class AppSource { */ PROPRIETARY; + /** Provides defaults for a fresh install, including its enabled sources. */ companion object { /** * Sources switched on for a fresh install. Only the two first-party@@ -68,6 +70,7 @@ enum class AppSource { val AppSource.priority: Int get() = AppSource.PRIORITY.indexOf(this).takeIf { it >= 0 } ?: AppSource.PRIORITY.size +/** One app unified across catalog sources for display and install. */ data class UnifiedApp( val packageName: String, val source: AppSource,@@ -188,6 +191,7 @@ fun UnifiedApp.searchCandidate(): SearchRanking.Candidate = SearchRanking.Candid popularity = installs, ) +/** Information about an app currently installed on the device. */ data class InstalledInfo( val packageName: String, val name: String,
appstore/src/main/java/com/vayunmathur/appstore/data/AppStoreDatabaseRepository.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/AppStoreDatabaseRepository.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/AppStoreDatabaseRepository.ktindex 9058715cb6..db69bdf049 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/AppStoreDatabaseRepository.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/AppStoreDatabaseRepository.kt@@ -30,6 +30,7 @@ class AppStoreDatabaseRepository private constructor(context: Context) : fun cachedAppsFlow(): Flow<List<CachedAppEntity>> = db.cachedAppDao().allFlow() suspend fun cachedAppByPackage(pkg: String): CachedAppEntity? = db.cachedAppDao().byPackage(pkg) + /** Provides the singleton AppStoreDatabaseRepository instance. */ companion object { @Volatile private var instance: AppStoreDatabaseRepository? = null
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 ba2075681f..361d1bd5a0 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidAppProvider.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidAppProvider.kt@@ -52,7 +52,7 @@ class FDroidAppProvider( Log.status( TAG, "sync of ${descriptor.displayName}: fetched ${result.apps.size} " +- "apps (signer ${result.signerSha256.take(16)}…)"+ "apps (signer ${result.signerSha256.take(SIGNER_PREFIX_LENGTH)}…)" ) // A verified-but-empty index is a bad publish window, not an empty store: keep the // previous rows so one bad sync cannot wipe the catalogue (issue: "catalogue@@ -109,6 +109,7 @@ class FDroidAppProvider( private companion object { const val TAG = "FDroidAppProvider"+ const val SIGNER_PREFIX_LENGTH = 16 } }
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 1cfe023d58..aef611d7cf 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/FDroidRepository.kt@@ -293,25 +293,7 @@ object FDroidRepository { // Sibling order is deterministic (base first: shortest file name tends // to be the base; ties broken alphabetically) — the session writer // doesn't care about order, but humans reading logs do.- val splitFiles = if (latest.requiredSplitTypes.isEmpty()) {- emptyList()- } else {- b.versions- .filter {- it.versionCode == latest.versionCode &&- it.fileName != latest.fileName &&- !isDynamiteModule(it.fileName)- }- .sortedWith(compareBy({ it.fileName.length }, { it.fileName }))- .map {- SplitFile(- fileName = it.fileName,- url = repoBase + "/" + it.fileName.trimStart('/'),- sha256 = it.sha256,- size = it.size,- )- }- }+ val splitFiles = splitFilesFor(b.versions, latest, repoBase) // index-v2 file names are repo-absolute ("/com.example_12.apk"). val apkUrl = repoBase + "/" + latest.fileName.trimStart('/')@@ -356,6 +338,39 @@ object FDroidRepository { ) } + // Split-set versions install as a set: when the chosen entry requires+ // splits, every indexed file sharing its versionCode belongs in the+ // same installer session (base + config splits). Without this the+ // system refuses with INSTALL_FAILED_MISSING_SPLIT on Android 14+.+ // Dynamite runtime modules (`*_installtime.apk`) are excluded: they share+ // the versionCode but are not installable splits, and the system refuses+ // the whole session when one is included.+ // Sibling order is deterministic (base first: shortest file name tends+ // to be the base; ties broken alphabetically) — the session writer+ // doesn't care about order, but humans reading logs do.+ private fun splitFilesFor(+ versions: List<VersionCandidate>,+ latest: VersionCandidate,+ repoBase: String,+ ): List<SplitFile> {+ if (latest.requiredSplitTypes.isEmpty()) return emptyList()+ return versions+ .filter {+ it.versionCode == latest.versionCode &&+ it.fileName != latest.fileName &&+ !isDynamiteModule(it.fileName)+ }+ .sortedWith(compareBy({ it.fileName.length }, { it.fileName }))+ .map {+ SplitFile(+ fileName = it.fileName,+ url = repoBase + "/" + it.fileName.trimStart('/'),+ sha256 = it.sha256,+ size = it.size,+ )+ }+ }+ private fun readMetadataV2(reader: JsonReader, repoBase: String, b: PackageBuilder) { reader.beginObject() while (reader.hasNext()) {
appstore/src/main/java/com/vayunmathur/appstore/data/IzzyVerification.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/IzzyVerification.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/IzzyVerification.ktindex b6eff1f125..5a7ae75bbf 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/IzzyVerification.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/IzzyVerification.kt@@ -95,42 +95,56 @@ object IzzyReproducibleBuilds { r.skipValue() return }+ val record = try {+ readRecordFields(r)+ } catch (_: Exception) {+ resyncRecord(r)+ return+ }+ if (record.reproducible && record.appid != null && record.versionCode != null) {+ into.add("${record.appid}:${record.versionCode}")+ }+ }++ private data class IzzyRecord(val appid: String?, val versionCode: Long?, val reproducible: Boolean)++ private fun readRecordFields(r: JsonReader): IzzyRecord { var appid: String? = null var versionCode: Long? = null var reproducible = false- try {- r.beginObject()- while (r.hasNext()) {- when (r.nextName()) {- "appid" -> appid = nextStringOrNull(r)- "version_code" -> versionCode = nextLongOrNull(r)- // The schema allows null (not yet attempted): only an explicit- // true counts, so a missing or failed rebuild never admits.- // A non-boolean must still be consumed, or the reader desyncs- // and every record after this one misparses.- "reproducible" -> reproducible = if (r.peek() == JsonToken.BOOLEAN) {- r.nextBoolean()- } else {- r.skipValue()- false- }- else -> r.skipValue()- }- }- r.endObject()- } catch (_: Exception) {- // Best-effort resync: consume to the end of this record so one corrupt- // entry cannot take down every record after it in the array.- runCatching {- while (r.peek() != JsonToken.END_OBJECT && r.peek() != JsonToken.END_DOCUMENT) {- r.skipValue()- }- if (r.peek() == JsonToken.END_OBJECT) r.endObject()+ r.beginObject()+ while (r.hasNext()) {+ when (r.nextName()) {+ "appid" -> appid = nextStringOrNull(r)+ "version_code" -> versionCode = nextLongOrNull(r)+ // The schema allows null (not yet attempted): only an explicit+ // true counts, so a missing or failed rebuild never admits.+ // A non-boolean must still be consumed, or the reader desyncs+ // and every record after this one misparses.+ "reproducible" -> reproducible = readReproducibleFlag(r)+ else -> r.skipValue() }- return }- if (reproducible && appid != null && versionCode != null) {- into.add("$appid:$versionCode")+ r.endObject()+ return IzzyRecord(appid, versionCode, reproducible)+ }++ private fun readReproducibleFlag(r: JsonReader): Boolean =+ if (r.peek() == JsonToken.BOOLEAN) {+ r.nextBoolean()+ } else {+ r.skipValue()+ false+ }++ private fun resyncRecord(r: JsonReader) {+ // Best-effort resync: consume to the end of this record so one corrupt+ // entry cannot take down every record after it in the array.+ runCatching {+ while (r.peek() != JsonToken.END_OBJECT && r.peek() != JsonToken.END_DOCUMENT) {+ r.skipValue()+ }+ if (r.peek() == JsonToken.END_OBJECT) r.endObject() } } }
appstore/src/main/java/com/vayunmathur/appstore/data/PlayStoreLinks.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/PlayStoreLinks.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/PlayStoreLinks.ktindex 1c81139a75..346fccfa14 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/PlayStoreLinks.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/PlayStoreLinks.kt@@ -1,5 +1,6 @@ package com.vayunmathur.appstore.data +/** Builds Google Play web links for packages and searches. */ object PlayStoreLinks { const val PLAY_BASE = "https://play.google.com"
appstore/src/main/java/com/vayunmathur/appstore/data/SettingsRepository.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/SettingsRepository.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/SettingsRepository.ktindex e310c70d15..6a449034c6 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/SettingsRepository.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/SettingsRepository.kt@@ -114,6 +114,7 @@ class SettingsRepository( } } + /** Holds DataStore keys and defaults for store settings. */ companion object { const val DEFAULT_AUTO_INSTALL_UPDATES = false private val KEY_AUTO_INSTALL_UPDATES =
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 b38d1dc3cc..b3577dc79d 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt@@ -439,6 +439,7 @@ class UpdateCheckWorker( ) } + /** Holds WorkManager and notification constants for update checks. */ companion object { private const val TAG = "UpdateCheckWorker" private const val CHANNEL_ID = "appstore-updates"
appstore/src/main/java/com/vayunmathur/appstore/data/accrescent/AccrescentRepoData.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/accrescent/AccrescentRepoData.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/accrescent/AccrescentRepoData.ktindex ffeb1c0c58..ea783a873b 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/accrescent/AccrescentRepoData.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/accrescent/AccrescentRepoData.kt@@ -30,6 +30,7 @@ data class RepoData( ) @Serializable+/** One app entry in Accrescent repository data with its signing requirements. */ data class RepoApp( @SerialName("min_version_code") val minVersionCode: Long, @SerialName("signing_cert_hash") val signingCertHash: String,
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 ea2a28ba3a..b54414a1ad 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@@ -38,9 +38,13 @@ import javax.net.ssl.HttpsURLConnection * nothing at all, and a rejected APK looked identical to a finished one. */ sealed interface InstallStage {+ /** Stage of an in-progress app install shown to the user. */ data object Preparing : InstallStage+ /** Install stage preparing the download and verification work. */ data class Downloading(val fraction: Float) : InstallStage+ /** Install stage downloading the package, reporting its progress fraction. */ data object Verifying : InstallStage+ /** Install stage verifying the downloaded package before installing it. */ data object Installing : InstallStage /** The install is over and did not start. Cleared when the row is next touched. */@@ -128,6 +132,9 @@ class InstallCoordinator( * Returns the outcome so a caller updating several apps in a row can wait for each * rather than poll a progress map, which is what the old "update all" did. */+ // Last-resort catch-all: specific failures are handled above, and any other+ // failure from gRPC, auth dispensers or Room must fail the row, never crash (#812).+ @Suppress("TooGenericExceptionCaught") suspend fun install(app: UnifiedApp): SessionInstaller.Outcome { if (isBusy(app.packageName)) { return SessionInstaller.Outcome(false, VerificationResult.Rejected("already installing"))
appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallStatusReceiver.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallStatusReceiver.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallStatusReceiver.ktindex 9def732c61..ef6b52ca8b 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallStatusReceiver.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/InstallStatusReceiver.kt@@ -37,6 +37,7 @@ import kotlinx.coroutines.flow.asSharedFlow */ class InstallStatusReceiver : BroadcastReceiver() { + /** Holds broadcast actions and constants for install-status callbacks. */ companion object { const val ACTION_INSTALL_STATUS = "com.vayunmathur.appstore.INSTALL_STATUS" private const val TAG = "InstallStatusReceiver"
appstore/src/main/java/com/vayunmathur/appstore/data/installer/PlayDownloader.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/PlayDownloader.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/PlayDownloader.ktindex 01897c6d88..9bd0b14faf 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/PlayDownloader.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/PlayDownloader.kt@@ -21,6 +21,7 @@ import java.net.URL class PlayDownloader( private val context: Context ) {+ /** Holds download timeout constants for Play package downloads. */ companion object { private const val TAG = "PlayDownloader" private const val CONNECT_TIMEOUT_MS = 30_000@@ -37,6 +38,7 @@ class PlayDownloader( existingBytes > 0 && responseCode == HTTP_PARTIAL } + /** Signals that a Play download URL expired before the download finished. */ class ExpiredUrlException(message: String) : java.io.IOException(message) /**
appstore/src/main/java/com/vayunmathur/appstore/data/installer/SessionInstaller.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/SessionInstaller.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/SessionInstaller.ktindex 408fdf8cb2..9ca2da4d16 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/installer/SessionInstaller.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/installer/SessionInstaller.kt@@ -26,6 +26,7 @@ class SessionInstaller( private val context: Context, ) { + /** Holds the logging tag for the session-based installer. */ companion object { private const val TAG = "SessionInstaller" }
appstore/src/main/java/com/vayunmathur/appstore/data/play/AnonymousAuthRepository.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/play/AnonymousAuthRepository.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/play/AnonymousAuthRepository.ktindex 57685be454..9b02e01149 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/play/AnonymousAuthRepository.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/play/AnonymousAuthRepository.kt@@ -54,6 +54,7 @@ open class AnonymousAuthRepository( }, ) { + /** Holds dispenser URLs and constants for anonymous Play authentication. */ companion object { private const val TAG = "AnonAuthRepo" const val DEFAULT_DISPENSER_URL = "https://auroraoss.com/api/auth"@@ -120,18 +121,27 @@ open class AnonymousAuthRepository( } @Serializable+ /** An anonymous-auth dispenser response carrying the account email and token. */ data class AuthResponse( val email: String, @SerialName("authToken") val auth: String ) + /** Failure modes returned by anonymous Play authentication dispensers. */ sealed class AuthError : Exception() {+ /** Authentication failed because the dispenser rate-limited the request. */ object RateLimited : AuthError()+ /** Authentication failed because the dispenser rejected the request. */ object BadRequest : AuthError()+ /** Authentication requires routing through a VPN endpoint. */ object VpnRequired : AuthError()+ /** Authentication failed because the dispenser endpoint was not found. */ object NotFound : AuthError()+ /** Authentication is unavailable while the dispenser is under maintenance. */ object Maintenance : AuthError()+ /** Authentication failed with an unexpected status code and response body. */ data class Unknown(val code: Int, val body: String?) : AuthError()+ /** Authentication failed because the dispenser could not be reached. */ data class Network(override val message: String?) : AuthError() }
appstore/src/main/java/com/vayunmathur/appstore/data/play/GsfVersionProvider.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/play/GsfVersionProvider.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/play/GsfVersionProvider.ktindex 4380137bb1..5281b7a134 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/play/GsfVersionProvider.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/play/GsfVersionProvider.kt@@ -3,6 +3,7 @@ package com.vayunmathur.appstore.data.play import android.content.Context import android.content.pm.PackageManager +/** Google services and vending version codes reported to Play. */ data class GsfVersion( val gsfVersionCode: Int, val vendingVersionCode: Int,
appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayHttpClient.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayHttpClient.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayHttpClient.ktindex 7adc08a33f..2f87490898 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayHttpClient.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayHttpClient.kt@@ -29,6 +29,7 @@ import kotlin.random.Random */ class PlayHttpClient : IHttpClient { + /** Holds HTTP timeout and status constants for Play requests. */ companion object { private const val CONNECT_TIMEOUT = 30_000 private const val READ_TIMEOUT = 30_000
appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayRepository.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayRepository.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayRepository.ktindex 7d0985b71b..2bef486811 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayRepository.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayRepository.kt@@ -40,10 +40,15 @@ private val PLAY_AUTH_DISPENSED_AT_KEY = longPreferencesKey("play_auth_dispensed */ private const val PLAY_AUTH_MAX_AGE_MS = 12L * 60 * 60 * 1000 +/** Authentication state for the anonymous Play session. */ sealed interface PlayAuthState {+ /** Play authentication has not started yet. */ data object Idle : PlayAuthState+ /** Play authentication is currently in progress. */ data object Authenticating : PlayAuthState+ /** Play authentication succeeded with the acquired auth data. */ data class Authenticated(val authData: AuthData) : PlayAuthState+ /** Play authentication failed with a user-visible message. */ data class Error(val message: String) : PlayAuthState }
appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayStoreApi.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayStoreApi.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayStoreApi.ktindex 5487489ba1..bfba4625f6 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayStoreApi.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/play/PlayStoreApi.kt@@ -195,6 +195,7 @@ class PlayStoreApi( AppProvider.filterTargetSdk(clusterAppList.map { it.toUnifiedApp() }) .distinctBy { it.packageName } + /** Holds Play API batching limits that keep requests under server caps. */ companion object { /** * Play rejects very long batches, and a rejected chunk loses every package in it,
appstore/src/main/java/com/vayunmathur/appstore/data/security/InstallVerifier.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/security/InstallVerifier.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/security/InstallVerifier.ktindex 2ea4b38049..cea5c85217 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/security/InstallVerifier.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/security/InstallVerifier.kt@@ -53,6 +53,7 @@ data class InstallRequirement( val requireTvCompatible: Boolean = false, ) +/** Outcome of verifying a downloaded package before installation. */ sealed class VerificationResult { /** Every check that could be run, passed. */ data class Verified(
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 9edac61875..0bb8caa727 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@@ -20,8 +20,10 @@ import java.util.jar.JarFile */ object SignedJarIndex { + /** Signals that signed-jar index verification failed. */ class VerificationException(message: String) : Exception(message) + /** Verified signed content together with its signer certificate hash. */ data class Verified( val content: ByteArray, /** Lowercase-hex SHA-256 of the signing certificate. */
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 1af6dc0424..f37afbb858 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@@ -211,6 +211,7 @@ enum class TrustProfile { PROPRIETARY -> R.string.trust_proprietary_limits } + /** Maps each app source to the trust profile shown for its apps. */ companion object { fun of(source: AppSource): TrustProfile = when (source) { AppSource.MODERN_APPS -> MODERN_APPS
appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreBrowse.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreBrowse.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreBrowse.ktindex 5329d3540a..132537971a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreBrowse.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreBrowse.kt@@ -34,7 +34,6 @@ fun TvStoreBrowse( TvStoreBrowseScreen( state = state, onAppClick = onAppClick,- onBack = onBack, modifier = modifier, ) }@@ -44,7 +43,6 @@ internal fun TvStoreBrowseScreen( state: TvBrowseUiState, modifier: Modifier = Modifier, onAppClick: (UnifiedApp) -> Unit = {},- onBack: () -> Unit = {}, ) { when { state.isLoading && state.apps.isEmpty() ->
appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreCards.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreCards.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreCards.ktindex 9e37c28519..389364d411 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreCards.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreCards.kt@@ -40,6 +40,8 @@ import java.util.Locale * One card everywhere — home, browse, search, updates, library — so the whole TV * store reads the same from the couch. */+private const val PERCENT_MAX = 100+ @Composable fun TvStoreAppCard( app: UnifiedApp,@@ -179,7 +181,7 @@ internal fun UnifiedApp.tvSourceLabel(): String = stringResource( @Composable internal fun InstallStage.tvStageLabel(): String = when (this) { InstallStage.Preparing -> stringResource(R.string.stage_preparing)- is InstallStage.Downloading -> stringResource(R.string.stage_downloading, (fraction * 100).toInt())+ is InstallStage.Downloading -> stringResource(R.string.stage_downloading, (fraction * PERCENT_MAX).toInt()) InstallStage.Verifying -> stringResource(R.string.stage_verifying) InstallStage.Installing -> stringResource(R.string.stage_installing) is InstallStage.Failed -> stringResource(R.string.stage_failed, reason)
appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreDetail.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreDetail.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreDetail.ktindex 333e3696b6..eaa1fb67f8 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreDetail.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreDetail.kt@@ -51,6 +51,8 @@ import com.vayunmathur.library.ui.R as UiR * body — summary, description, What's new, chips, the security card, screenshots, * links. Same order and same strings as the phone's detail page. */+private const val DETAIL_IDENTITY_WEIGHT = 0.65f+ @Composable fun TvStoreDetail( viewModel: TvStoreViewModel,@@ -115,7 +117,7 @@ internal fun TvStoreDetailScreen( onOpen = { onOpen(app.packageName) }, onUninstall = { showUninstallConfirm = true }, onDismissFailure = { onDismissFailure(app.packageName) },- modifier = Modifier.weight(0.65f).fillMaxHeight(),+ modifier = Modifier.weight(DETAIL_IDENTITY_WEIGHT).fillMaxHeight(), ) TvStoreDetailBody( state = state,@@ -126,26 +128,40 @@ internal fun TvStoreDetailScreen( } } if (showUninstallConfirm) {- TvDialog(- title = stringResource(R.string.uninstall_3, app.name),- body = stringResource(- R.string.this_will_uninstall_you_can_reinstall_la, app.packageName- ),- onDismissRequest = { showUninstallConfirm = false },- ) {- TvButton(- text = stringResource(UiR.string.cancel),- onClick = { showUninstallConfirm = false },- )- TvButton(- text = stringResource(R.string.uninstall),- onClick = {- showUninstallConfirm = false- onUninstall(app.packageName)- },- primary = true,- )- }+ TvUninstallConfirm(+ app = app,+ onDismiss = { showUninstallConfirm = false },+ onConfirm = {+ showUninstallConfirm = false+ onUninstall(app.packageName)+ },+ )+ }+}++/** Uninstall confirmation dialog for the detail screen. */+@Composable+private fun TvUninstallConfirm(+ app: UnifiedApp,+ onDismiss: () -> Unit,+ onConfirm: () -> Unit,+) {+ TvDialog(+ title = stringResource(R.string.uninstall_3, app.name),+ body = stringResource(+ R.string.this_will_uninstall_you_can_reinstall_la, app.packageName+ ),+ onDismissRequest = onDismiss,+ ) {+ TvButton(+ text = stringResource(UiR.string.cancel),+ onClick = onDismiss,+ )+ TvButton(+ text = stringResource(R.string.uninstall),+ onClick = onConfirm,+ primary = true,+ ) } } @@ -192,66 +208,16 @@ private fun TvStoreDetailIdentity( ) } }- // Primary action: exactly the phone's AppInstallActions logic.- when {- busy -> TvButton(- text = stage.tvStageLabel(),- onClick = {},- enabled = false,- modifier = Modifier.focusRequester(focusRequester),- )- state.hasUpdate -> {- TvButton(- text = stringResource(R.string.action_update),- onClick = onInstall,- primary = true,- icon = { IconDownload() },- modifier = Modifier.focusRequester(focusRequester),- )- TvButton(- text = stringResource(UiR.string.open),- onClick = onOpen,- )- }- state.isInstalled -> {- TvButton(- text = stringResource(UiR.string.open),- onClick = onOpen,- primary = true,- modifier = Modifier.focusRequester(focusRequester),- )- TvButton(- text = stringResource(R.string.uninstall),- onClick = onUninstall,- icon = { IconDelete() },- )- }- else -> TvButton(- text = stringResource(R.string.action_install),- onClick = onInstall,- primary = true,- icon = { IconDownload() },- modifier = Modifier.focusRequester(focusRequester),- )- }- if (state.isInstalled && state.installedInfo?.versionName != null && !state.hasUpdate) {- Text(- text = stringResource(R.string.installed_2, state.installedInfo.versionName),- style = MaterialTheme.typography.bodyMedium,- color = MaterialTheme.colorScheme.onSurfaceVariant,- )- }- if (stage is InstallStage.Failed) {- Text(- text = stringResource(R.string.stage_failed, stage.reason),- style = MaterialTheme.typography.bodyMedium,- color = MaterialTheme.colorScheme.error,- )- TvButton(- text = stringResource(R.string.action_dismiss),- onClick = onDismissFailure,- )- }+ TvDetailPrimaryActions(+ state = state,+ busy = busy,+ stage = stage,+ focusRequester = focusRequester,+ onInstall = onInstall,+ onOpen = onOpen,+ onUninstall = onUninstall,+ )+ TvDetailInstallStatus(state = state, stage = stage, onDismissFailure = onDismissFailure) // Stats row: Size / Rated / Version, like the phone's facts row. TvStoreDetailStats(app = app) TvStoreVerificationLine(state = state)@@ -259,6 +225,89 @@ private fun TvStoreDetailIdentity( } ++/** Installed-version line and install-failure line for the identity pane. */+@Composable+private fun TvDetailInstallStatus(+ state: TvDetailUiState,+ stage: InstallStage?,+ onDismissFailure: () -> Unit,+) {+ if (state.isInstalled && state.installedInfo?.versionName != null && !state.hasUpdate) {+ Text(+ text = stringResource(R.string.installed_2, state.installedInfo.versionName),+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ if (stage is InstallStage.Failed) {+ Text(+ text = stringResource(R.string.stage_failed, stage.reason),+ style = MaterialTheme.typography.bodyMedium,+ color = MaterialTheme.colorScheme.error,+ )+ TvButton(+ text = stringResource(R.string.action_dismiss),+ onClick = onDismissFailure,+ )+ }+}++/** Primary Install/Update/Open/Uninstall actions for the detail identity pane. */+@Composable+private fun TvDetailPrimaryActions(+ state: TvDetailUiState,+ busy: Boolean,+ stage: InstallStage?,+ focusRequester: FocusRequester,+ onInstall: () -> Unit,+ onOpen: () -> Unit,+ onUninstall: () -> Unit,+) {+// Primary action: exactly the phone's AppInstallActions logic.+when {+ busy -> TvButton(+ text = stage?.tvStageLabel().orEmpty(),+ onClick = {},+ enabled = false,+ modifier = Modifier.focusRequester(focusRequester),+ )+ state.hasUpdate -> {+ TvButton(+ text = stringResource(R.string.action_update),+ onClick = onInstall,+ primary = true,+ icon = { IconDownload() },+ modifier = Modifier.focusRequester(focusRequester),+ )+ TvButton(+ text = stringResource(UiR.string.open),+ onClick = onOpen,+ )+ }+ state.isInstalled -> {+ TvButton(+ text = stringResource(UiR.string.open),+ onClick = onOpen,+ primary = true,+ modifier = Modifier.focusRequester(focusRequester),+ )+ TvButton(+ text = stringResource(R.string.uninstall),+ onClick = onUninstall,+ icon = { IconDelete() },+ )+ }+ else -> TvButton(+ text = stringResource(R.string.action_install),+ onClick = onInstall,+ primary = true,+ icon = { IconDownload() },+ modifier = Modifier.focusRequester(focusRequester),+ )+}+}+ /** Size / Rated / Version in whatever subset the source published. Like the phone. */ @Composable private fun TvStoreDetailStats(app: UnifiedApp, modifier: Modifier = Modifier) {
appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreDetailSections.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreDetailSections.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreDetailSections.ktindex 1cc1b1894b..dd0c75af1a 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreDetailSections.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreDetailSections.kt@@ -127,11 +127,9 @@ private fun TvStoreDetailBlock(title: String, content: @Composable () -> Unit) { /** Categories, reproducible badge, ads and anti-features. Like the phone's chips row. */ @Composable private fun TvStoreDetailChips(app: UnifiedApp, modifier: Modifier = Modifier) {- if (app.categories.isEmpty() && app.antiFeatures.isEmpty() &&- !app.containsAds && !app.reproducible- ) {- return- }+ val hasCategories = app.categories.isNotEmpty() || app.antiFeatures.isNotEmpty()+ val hasFlags = app.containsAds || app.reproducible+ if (!hasCategories && !hasFlags) return Row( modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp),
appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreHome.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreHome.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreHome.ktindex 4a0542dfb6..aa80ead8cc 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreHome.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreHome.kt@@ -7,6 +7,7 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.grid.items+import androidx.compose.foundation.lazy.grid.LazyGridScope import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState@@ -117,32 +118,7 @@ internal fun TvStoreHomeScreen( ) } }- state.sections.forEachIndexed { index, section ->- tvGridHeader(- key = "${section.id}-header",- title = section.title,- subtitle = section.subtitle,- first = index == 0 && state.updateCount == 0 &&- state.categories.isEmpty() && state.statusMessage.isBlank(),- action = {- TvButton(- text = stringResource(R.string.action_browse),- onClick = { onOpenBrowse(section) },- )- },- )- val cards = section.apps.take(HOME_CARDS_PER_SECTION)- items(cards, key = { "${section.id}-${it.packageName}" }) { app ->- TvStoreAppCard(- app = app,- onClick = { onAppClick(app) },- installedIcon = state.installedIcons[app.packageName],- isInstalled = app.packageName in state.installedPackages,- hasUpdate = app.packageName in state.updatePackages,- stage = state.stages[app.packageName],- )- }- }+ tvHomeSections(state = state, onAppClick = onAppClick, onOpenBrowse = onOpenBrowse) } } }@@ -205,3 +181,37 @@ private fun TvCategoryChips( private const val HOME_CARDS_PER_SECTION = 6 private const val CATEGORY_CHIPS_PER_ROW = 6 private const val CATEGORY_CHIP_LIMIT = 23++/** One home section header plus its card row inside the home grid. */+private fun LazyGridScope.tvHomeSections(+ state: TvHomeUiState,+ onAppClick: (UnifiedApp) -> Unit,+ onOpenBrowse: (TvSection) -> Unit,+) {+ state.sections.forEachIndexed { index, section ->+ tvGridHeader(+ key = "${section.id}-header",+ title = section.title,+ subtitle = section.subtitle,+ first = index == 0 && state.updateCount == 0 &&+ state.categories.isEmpty() && state.statusMessage.isBlank(),+ action = {+ TvButton(+ text = stringResource(R.string.action_browse),+ onClick = { onOpenBrowse(section) },+ )+ },+ )+ val cards = section.apps.take(HOME_CARDS_PER_SECTION)+ items(cards, key = { "${section.id}-${it.packageName}" }) { app ->+ TvStoreAppCard(+ app = app,+ onClick = { onAppClick(app) },+ installedIcon = state.installedIcons[app.packageName],+ isInstalled = app.packageName in state.installedPackages,+ hasUpdate = app.packageName in state.updatePackages,+ stage = state.stages[app.packageName],+ )+ }+ }+}
appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreHomeOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreHomeOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreHomeOps.ktnew file mode 100644index 0000000000..827bcb21be--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreHomeOps.kt@@ -0,0 +1,198 @@+package com.vayunmathur.appstore.tv++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.SyncReport+import com.vayunmathur.appstore.data.SyncStep+import com.vayunmathur.appstore.data.priority+import com.vayunmathur.library.util.AppMessages+import kotlinx.coroutines.launch++// ---- TV home + first-sync bodies ----+// Moved from TvStoreViewModel.kt (LargeClass split); behavior identical.++private val TV_OFFLINE_SOURCES = setOf(+ DefaultRepos.FDROID.source, DefaultRepos.MODERN_APPS.source,+ DefaultRepos.PROPRIETARY.source, DefaultRepos.IZZY.source,+)++private val TV_OFFLINE_CATALOG_SOURCES = listOf(+ AppSource.FDROID, AppSource.MODERN_APPS, AppSource.PROPRIETARY, AppSource.IZZY,+)++/**+ * Populate the offline catalogues the first time the TV store is opened.+ *+ * Same contract as the phone's `syncIfNeverSynced`: keyed off the catalogue being+ * empty rather than a first-run flag, so it also recovers a store whose first sync+ * failed or whose data was cleared — and stays quiet on every later launch, when+ * re-fetching full catalogues would be a poor trade for at-most-hours-stale data.+ * Progress reports through the existing status line the browse screen already shows.+ */+internal suspend fun TvStoreViewModel.syncIfNeverSyncedImpl() {+ val enabled = enabledSourcesFlow.value+ if (enabled.intersect(TV_OFFLINE_SOURCES).isEmpty()) return+ if (hasOfflineCatalogue()) {+ // The offline gate stays quiet, but Accrescent is network-backed: refresh its+ // allowlist + listings on every cold start that reaches this far, same as the phone.+ loadAccrescent(enabled)+ return+ }+ runFirstSync(enabled)+}++private suspend fun TvStoreViewModel.hasOfflineCatalogue(): Boolean =+ TV_OFFLINE_CATALOG_SOURCES.any { catalog.recentlyUpdatedBySource(it, 1).isNotEmpty() }++private suspend fun TvStoreViewModel.runFirstSync(enabled: Set<AppSource>) {+ isLoadingFlow.value = true+ val report = catalog.sync(enabled) { step ->+ statusMessageFlow.value = context.getString(tvSyncStepStringRes(step))+ }+ statusMessageFlow.value = ""+ isLoadingFlow.value = false+ AppMessages.show(tvSyncReportMessage(report, enabled))+}++private fun tvSyncStepStringRes(step: SyncStep): Int = when (step) {+ SyncStep.FDROID -> R.string.sync_step_fdroid+ SyncStep.IZZY -> R.string.sync_step_izzy+ SyncStep.MODERN_APPS -> R.string.sync_step_modern_apps+ SyncStep.PROPRIETARY -> R.string.sync_step_proprietary+}++private fun TvStoreViewModel.tvSyncReportMessage(report: SyncReport, enabled: Set<AppSource>): String {+ val counts = listOf(report.fdroidCount, report.modernCount, report.proprietaryCount, report.izzyCount)+ return when {+ report.allSkipped -> context.getString(R.string.sync_all_sources_off)+ !report.anyFailed -> context.getString(R.string.sync_done, counts.sumOf { it ?: 0 })+ counts.all { it == null } -> context.getString(R.string.sync_failed_all)+ report.fdroidCount == null -> context.getString(R.string.sync_failed_fdroid)+ report.izzyCount == null && AppSource.IZZY in enabled ->+ context.getString(R.string.sync_failed_izzy)+ report.proprietaryCount == null -> context.getString(R.string.sync_failed_proprietary)+ else -> context.getString(R.string.sync_failed_modern_apps)+ }+}++/**+ * Fill the home rows from the TV-filtered catalogue: one section per source with+ * the phone's own titles and subtitles, capped at two grid rows each.+ *+ * A chosen category replaces the browsing rows, mirroring the phone: the user asked+ * a narrow question and a wall of unrelated sections underneath is just noise.+ */+internal fun TvStoreViewModel.loadHomeImpl() {+ viewModelScope.launch {+ isLoadingFlow.value = true+ val enabled = enabledSourcesFlow.value+ val category = selectedCategoryFlow.value+ if (category != null) {+ showCategoryHome(category)+ isLoadingFlow.value = false+ return@launch+ }+ categoriesFlow.value = catalog.categories()+ val sections = buildTvHomeSections(enabled)+ // Same precedence the phone uses: the surviving row's source decides the+ // download-and-verify path, so cross-source duplicates resolve identically.+ sectionsFlow.value = sections.map { section ->+ section.copy(+ apps = section.apps.sortedBy { it.source.priority }+ .distinctBy { it.packageName }+ )+ }+ isLoadingFlow.value = false+ }+}++private suspend fun TvStoreViewModel.showCategoryHome(category: String) {+ val apps = categoryAppsFlow.value.ifEmpty { catalog.allByCategory(category) }+ categoryAppsFlow.value = apps+ sectionsFlow.value = listOf(+ TvSection(+ id = "category",+ title = category,+ subtitle = context.getString(R.string.section_category_subtitle),+ apps = apps,+ )+ )+}++private suspend fun TvStoreViewModel.buildTvHomeSections(enabled: Set<AppSource>): List<TvSection> =+ buildList {+ modernHomeSection(enabled)?.let { add(it) }+ addAll(offlineRows(enabled, TvStoreViewModel.ROW_LIMIT))+ addAll(playHomeSections(enabled))+ accrescentHomeSection(enabled)?.let { add(it) }+ }++private suspend fun TvStoreViewModel.modernHomeSection(enabled: Set<AppSource>): TvSection? {+ if (AppSource.MODERN_APPS !in enabled) return null+ val recent = catalog.recentlyUpdatedBySource(AppSource.MODERN_APPS, TvStoreViewModel.ROW_LIMIT)+ if (recent.isNotEmpty()) {+ return TvSection(+ id = "modern-recent",+ title = context.getString(R.string.section_modern_apps_recent),+ subtitle = context.getString(R.string.section_modern_apps_recent_subtitle),+ source = AppSource.MODERN_APPS,+ apps = recent,+ )+ }+ return catalog.allBySource(AppSource.MODERN_APPS).take(TvStoreViewModel.ROW_LIMIT)+ .takeIf { it.isNotEmpty() }?.let {+ TvSection(+ id = "modern",+ title = context.getString(R.string.section_modern_apps),+ subtitle = context.getString(R.string.section_modern_apps_subtitle),+ source = AppSource.MODERN_APPS,+ apps = it,+ )+ }+}++private suspend fun TvStoreViewModel.playHomeSections(enabled: Set<AppSource>): List<TvSection> {+ if (AppSource.PLAYSTORE !in enabled) return emptyList()+ val clusters = play.homeClusters().filter { it.apps.isNotEmpty() }+ .take(TvStoreViewModel.CLUSTER_LIMIT)+ playFullClustersFlow.value = clusters.associate { "play-${it.title}" to it.apps }+ if (clusters.isEmpty()) {+ // No account, or Play changed its stream shape. A top chart is one+ // request and still gives the screen something beyond this repo's+ // own dozen apps. Mirrors the phone's fallback.+ return play.topChart().takeIf { it.isNotEmpty() }?.let { chart ->+ playFullClustersFlow.value = mapOf("play-top" to chart)+ listOf(+ TvSection(+ id = "play-top",+ title = context.getString(R.string.section_play_top_charts),+ source = AppSource.PLAYSTORE,+ apps = chart.take(TvStoreViewModel.ROW_LIMIT),+ )+ )+ } ?: emptyList()+ }+ return clusters.map { cluster ->+ TvSection(+ id = "play-${cluster.title}",+ title = cluster.title,+ source = AppSource.PLAYSTORE,+ apps = cluster.apps.take(TvStoreViewModel.ROW_LIMIT),+ )+ }+}++private fun TvStoreViewModel.accrescentHomeSection(enabled: Set<AppSource>): TvSection? {+ if (AppSource.ACCRESCENT !in enabled) return null+ return accrescentAppsFlow.value.take(TvStoreViewModel.ROW_LIMIT).takeIf { it.isNotEmpty() }?.let {+ TvSection(+ id = "accrescent",+ title = context.getString(R.string.section_accrescent),+ subtitle = context.getString(R.string.section_accrescent_subtitle),+ source = AppSource.ACCRESCENT,+ apps = it,+ )+ }+}
appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreSearch.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreSearch.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreSearch.ktindex db28fe3439..04fbbb7d9e 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreSearch.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreSearch.kt@@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.grid.items+import androidx.compose.foundation.lazy.grid.LazyGridScope import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue@@ -107,35 +108,7 @@ internal fun TvStoreSearchScreen( ) } }- when {- state.query.isBlank() -> tvFullWidth(key = "prompt") {- TvEmptyState(- title = stringResource(R.string.search_prompt_title),- body = stringResource(R.string.tv_search_prompt_tv),- icon = { IconSearch() },- )- }- state.results.isEmpty() && (state.isSearching || !state.hasSearched) ->- tvFullWidth(key = "loading") {- TvLoading(label = stringResource(R.string.sync_in_progress))- }- state.results.isEmpty() -> tvFullWidth(key = "no-results") {- TvEmptyState(- title = stringResource(R.string.search_no_results_title, state.query),- body = stringResource(R.string.search_no_results_message),- icon = { IconPackage() },- )- }- else -> items(state.results, key = { it.packageName }) { app ->- TvStoreAppCard(- app = app,- onClick = { onAppClick(app) },- installedIcon = state.installedIcons[app.packageName],- isInstalled = app.packageName in state.installedPackages,- stage = state.stages[app.packageName],- )- }- }+ tvSearchResults(state = state, onAppClick = onAppClick) } } @@ -159,3 +132,39 @@ private fun TvStoreSearchFilters( } } }++/** Prompt, loading, empty and result states inside the search grid. */+private fun LazyGridScope.tvSearchResults(+ state: TvSearchUiState,+ onAppClick: (UnifiedApp) -> Unit,+) {+ when {+ state.query.isBlank() -> tvFullWidth(key = "prompt") {+ TvEmptyState(+ title = stringResource(R.string.search_prompt_title),+ body = stringResource(R.string.tv_search_prompt_tv),+ icon = { IconSearch() },+ )+ }+ state.results.isEmpty() && (state.isSearching || !state.hasSearched) ->+ tvFullWidth(key = "loading") {+ TvLoading(label = stringResource(R.string.sync_in_progress))+ }+ state.results.isEmpty() -> tvFullWidth(key = "no-results") {+ TvEmptyState(+ title = stringResource(R.string.search_no_results_title, state.query),+ body = stringResource(R.string.search_no_results_message),+ icon = { IconPackage() },+ )+ }+ else -> items(state.results, key = { it.packageName }) { app ->+ TvStoreAppCard(+ app = app,+ onClick = { onAppClick(app) },+ installedIcon = state.installedIcons[app.packageName],+ isInstalled = app.packageName in state.installedPackages,+ stage = state.stages[app.packageName],+ )+ }+ }+}
appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreUpdates.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreUpdates.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreUpdates.ktindex 542380421d..ccbc8972f4 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreUpdates.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreUpdates.kt@@ -2,6 +2,7 @@ package com.vayunmathur.appstore.tv import android.text.format.DateUtils import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.foundation.lazy.grid.LazyGridScope import androidx.compose.foundation.lazy.grid.items import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect@@ -68,17 +69,7 @@ internal fun TvStoreUpdatesScreen( val primaryFocus = remember { FocusRequester() } val anyInstalling = state.stages.values.any { it !is InstallStage.Failed } val total = state.updates.size + state.foreignUpdates.size- val status = state.statusMessage.takeIf { it.isNotBlank() }- ?: state.lastCheckedAt.takeIf { it > 0 }?.let {- stringResource(- R.string.updates_last_checked,- DateUtils.getRelativeTimeSpanString(- it,- System.currentTimeMillis(),- DateUtils.MINUTE_IN_MILLIS,- ),- )- }+ val status = updatesStatusText(state) // Unkeyed: runs once per visit. Keying on the count would yank focus back to // "Update all" every time a check completes or an update installs and drops off. TvInitialFocus(primaryFocus)@@ -101,38 +92,105 @@ internal fun TvStoreUpdatesScreen( val foreignTitle = stringResource(R.string.updates_foreign_title) val foreignSubtitle = stringResource(R.string.updates_foreign_subtitle) TvGrid(columns = 3, modifier = modifier.fillMaxSize()) {- tvFullWidth(key = "header") {- TvScreenHeader(- title = stringResource(R.string.nav_updates),- subtitle = status,- actions = {- if (state.updates.isNotEmpty()) {- TvButton(- text = stringResource(R.string.update_all, state.updates.size),- onClick = onUpdateAll,- primary = true,- enabled = !anyInstalling,- icon = { IconDownload() },- )- }- TvButton(- text = if (state.isChecking) {- stringResource(R.string.updates_checking)- } else {- stringResource(R.string.action_check_again)- },- onClick = onCheckForUpdates,- enabled = !state.isChecking,- )- },+ tvUpdatesHeader(+ state = state,+ status = status,+ anyInstalling = anyInstalling,+ onUpdateAll = onUpdateAll,+ onCheckForUpdates = onCheckForUpdates,+ )+ tvUpdateItems(+ state = state,+ countTitle = countTitle,+ foreignTitle = foreignTitle,+ foreignSubtitle = foreignSubtitle,+ onAppClick = onAppClick,+ onInstall = onInstall,+ )+ }+}+++/** Last-checked status line for the updates screen, or null when never checked. */+@Composable+private fun updatesStatusText(state: TvUpdatesUiState): String? =+ state.statusMessage.takeIf { it.isNotBlank() }+ ?: state.lastCheckedAt.takeIf { it > 0 }?.let {+ stringResource(+ R.string.updates_last_checked,+ DateUtils.getRelativeTimeSpanString(+ it,+ System.currentTimeMillis(),+ DateUtils.MINUTE_IN_MILLIS,+ ), ) }++/** Updates screen header with Update All and Check Again actions. */+private fun LazyGridScope.tvUpdatesHeader(+ state: TvUpdatesUiState,+ status: String?,+ anyInstalling: Boolean,+ onUpdateAll: () -> Unit,+ onCheckForUpdates: () -> Unit,+) {+ tvFullWidth(key = "header") {+ TvScreenHeader(+ title = stringResource(R.string.nav_updates),+ subtitle = status,+ actions = {+ if (state.updates.isNotEmpty()) {+ TvButton(+ text = stringResource(R.string.update_all, state.updates.size),+ onClick = onUpdateAll,+ primary = true,+ enabled = !anyInstalling,+ icon = { IconDownload() },+ )+ }+ TvButton(+ text = if (state.isChecking) {+ stringResource(R.string.updates_checking)+ } else {+ stringResource(R.string.action_check_again)+ },+ onClick = onCheckForUpdates,+ enabled = !state.isChecking,+ )+ },+ )+ }+}++/** Eligible and foreign update rows inside the updates grid. */+private fun LazyGridScope.tvUpdateItems(+ state: TvUpdatesUiState,+ countTitle: String,+ foreignTitle: String,+ foreignSubtitle: String,+ onAppClick: (UnifiedApp) -> Unit,+ onInstall: (UnifiedApp) -> Unit,+) {+ tvGridHeader(+ key = "count",+ title = countTitle,+ first = true,+ )+ items(state.updates, key = { it.packageName }) { app ->+ TvUpdateCard(+ app = app,+ state = state,+ onAppClick = onAppClick,+ onInstall = { onInstall(app) },+ )+ }+ if (state.foreignUpdates.isNotEmpty()) { tvGridHeader(- key = "count",- title = countTitle,- first = true,+ key = "foreign",+ title = foreignTitle,+ subtitle = foreignSubtitle, )- items(state.updates, key = { it.packageName }) { app ->+ items(state.foreignUpdates, key = { "foreign-${it.packageName}" }) { app -> TvUpdateCard( app = app, state = state,@@ -140,21 +198,6 @@ internal fun TvStoreUpdatesScreen( onInstall = { onInstall(app) }, ) }- if (state.foreignUpdates.isNotEmpty()) {- tvGridHeader(- key = "foreign",- title = foreignTitle,- subtitle = foreignSubtitle,- )- items(state.foreignUpdates, key = { "foreign-${it.packageName}" }) { app ->- TvUpdateCard(- app = app,- state = state,- onAppClick = onAppClick,- onInstall = { onInstall(app) },- )- }- } } }
appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreViewModel.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreViewModel.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreViewModel.ktindex 0e0d9daa94..5268c440e7 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreViewModel.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreViewModel.kt@@ -321,7 +321,7 @@ class TvStoreViewModel( installedRepo.refresh() if (AppSource.PLAYSTORE in enabledSourcesFlow.value) play.restore() refreshPlayInstalledPackages(enabledSourcesFlow.value)- syncIfNeverSynced()+ syncIfNeverSyncedImpl() categoriesFlow.value = catalog.categories() loadHome() }@@ -347,66 +347,6 @@ class TvStoreViewModel( } } - /**- * Populate the offline catalogues the first time the TV store is opened.- *- * Same contract as the phone's `syncIfNeverSynced`: keyed off the catalogue being- * empty rather than a first-run flag, so it also recovers a store whose first sync- * failed or whose data was cleared — and stays quiet on every later launch, when- * re-fetching full catalogues would be a poor trade for at-most-hours-stale data.- * Progress reports through the existing status line the browse screen already shows.- */- private suspend fun syncIfNeverSynced() {- val enabled = enabledSourcesFlow.value- val offlineSources = setOf(- DefaultRepos.FDROID.source, DefaultRepos.MODERN_APPS.source,- DefaultRepos.PROPRIETARY.source, DefaultRepos.IZZY.source,- )- if (enabled.intersect(offlineSources).isEmpty()) return- if (catalog.recentlyUpdatedBySource(AppSource.FDROID, 1).isNotEmpty() ||- catalog.recentlyUpdatedBySource(AppSource.MODERN_APPS, 1).isNotEmpty() ||- catalog.recentlyUpdatedBySource(AppSource.PROPRIETARY, 1).isNotEmpty() ||- catalog.recentlyUpdatedBySource(AppSource.IZZY, 1).isNotEmpty()- ) {- // The offline gate stays quiet, but Accrescent is network-backed: refresh its- // allowlist + listings on every cold start that reaches this far, same as the phone.- loadAccrescent(enabled)- return- }- isLoadingFlow.value = true- val report = catalog.sync(enabled) { step ->- statusMessageFlow.value = context.getString(- when (step) {- SyncStep.FDROID -> R.string.sync_step_fdroid- SyncStep.IZZY -> R.string.sync_step_izzy- SyncStep.MODERN_APPS -> R.string.sync_step_modern_apps- SyncStep.PROPRIETARY -> R.string.sync_step_proprietary- },- )- }- statusMessageFlow.value = ""- isLoadingFlow.value = false- AppMessages.show(- when {- report.allSkipped -> context.getString(R.string.sync_all_sources_off)- !report.anyFailed -> context.getString(- R.string.sync_done,- (report.fdroidCount ?: 0) + (report.modernCount ?: 0) +- (report.proprietaryCount ?: 0) + (report.izzyCount ?: 0),- )- report.fdroidCount == null && report.modernCount == null &&- report.proprietaryCount == null && report.izzyCount == null ->- context.getString(R.string.sync_failed_all)- report.fdroidCount == null -> context.getString(R.string.sync_failed_fdroid)- report.izzyCount == null && AppSource.IZZY in enabled ->- context.getString(R.string.sync_failed_izzy)- report.proprietaryCount == null ->- context.getString(R.string.sync_failed_proprietary)- else -> context.getString(R.string.sync_failed_modern_apps)- },- )- }- /** * Fill the home rows from the TV-filtered catalogue: one section per source with * the phone's own titles and subtitles, capped at two grid rows each.@@ -414,111 +354,7 @@ class TvStoreViewModel( * A chosen category replaces the browsing rows, mirroring the phone: the user asked * a narrow question and a wall of unrelated sections underneath is just noise. */- fun loadHome() {- viewModelScope.launch {- isLoadingFlow.value = true- val enabled = enabledSourcesFlow.value- val category = selectedCategoryFlow.value- if (category != null) {- val apps = categoryAppsFlow.value.ifEmpty { catalog.allByCategory(category) }- categoryAppsFlow.value = apps- sectionsFlow.value = listOf(- TvSection(- id = "category",- title = category,- subtitle = context.getString(R.string.section_category_subtitle),- apps = apps,- )- )- isLoadingFlow.value = false- return@launch- }- categoriesFlow.value = catalog.categories()- val sections = buildList {- if (AppSource.MODERN_APPS in enabled) {- val recent = catalog.recentlyUpdatedBySource(AppSource.MODERN_APPS, ROW_LIMIT)- if (recent.isNotEmpty()) {- add(- TvSection(- id = "modern-recent",- title = context.getString(R.string.section_modern_apps_recent),- subtitle = context.getString(R.string.section_modern_apps_recent_subtitle),- source = AppSource.MODERN_APPS,- apps = recent,- )- )- } else {- catalog.allBySource(AppSource.MODERN_APPS).take(ROW_LIMIT)- .takeIf { it.isNotEmpty() }?.let {- add(- TvSection(- id = "modern",- title = context.getString(R.string.section_modern_apps),- subtitle = context.getString(R.string.section_modern_apps_subtitle),- source = AppSource.MODERN_APPS,- apps = it,- )- )- }- }- }- addAll(offlineRows(enabled, ROW_LIMIT))- if (AppSource.PLAYSTORE in enabled) {- val clusters = play.homeClusters().filter { it.apps.isNotEmpty() }- .take(CLUSTER_LIMIT)- playFullClustersFlow.value = clusters.associate { "play-${it.title}" to it.apps }- clusters.forEach { cluster ->- add(- TvSection(- id = "play-${cluster.title}",- title = cluster.title,- source = AppSource.PLAYSTORE,- apps = cluster.apps.take(ROW_LIMIT),- )- )- }- if (clusters.isEmpty()) {- // No account, or Play changed its stream shape. A top chart is one- // request and still gives the screen something beyond this repo's- // own dozen apps. Mirrors the phone's fallback.- play.topChart().takeIf { it.isNotEmpty() }?.let { chart ->- playFullClustersFlow.value = mapOf("play-top" to chart)- add(- TvSection(- id = "play-top",- title = context.getString(R.string.section_play_top_charts),- source = AppSource.PLAYSTORE,- apps = chart.take(ROW_LIMIT),- )- )- }- }- }- if (AppSource.ACCRESCENT in enabled) {- accrescentAppsFlow.value.take(ROW_LIMIT).takeIf { it.isNotEmpty() }?.let {- add(- TvSection(- id = "accrescent",- title = context.getString(R.string.section_accrescent),- subtitle = context.getString(R.string.section_accrescent_subtitle),- source = AppSource.ACCRESCENT,- apps = it,- )- )- }- }- }- // Same precedence the phone uses: the surviving row's source decides the- // download-and-verify path, so cross-source duplicates resolve identically.- sectionsFlow.value = sections.map { section ->- section.copy(- apps = section.apps.sortedBy { it.source.priority }- .distinctBy { it.packageName }- )- }- isLoadingFlow.value = false- }- }+ fun loadHome() = loadHomeImpl() /** A chosen category replaces the browsing rows; null restores them. Mirrors the phone. */ fun selectCategory(category: String?) {@@ -766,7 +602,7 @@ class TvStoreViewModel( super.onCleared() } - private companion object {+ internal companion object { /** Two grid rows per home section: the phone's rows become dense grids, not walls. */ const val ROW_LIMIT = 6 const val CLUSTER_LIMIT = 4@@ -781,6 +617,7 @@ private data class TvSearchAux( val stages: Map<String, InstallStage>, ) +/** Factory creating TvStoreViewModel with its context and database. */ class TvStoreViewModelFactory( private val context: android.content.Context, private val db: AppDatabase,
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 ce381a5fae..6706409e01 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreHomeOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreHomeOps.kt@@ -7,6 +7,7 @@ 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.SyncReport import com.vayunmathur.appstore.data.SyncStep import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.library.util.AppMessages@@ -25,46 +26,28 @@ import kotlinx.coroutines.launch */ internal suspend fun AppStoreViewModel.loadHome(enabled: Set<AppSource> = enabledSources.value) { isLoadingHomeFlow.value = true- val modernEnabled = AppSource.MODERN_APPS in enabled- val fdroidEnabled = AppSource.FDROID in enabled- val izzyEnabled = AppSource.IZZY in enabled- val proprietaryEnabled = AppSource.PROPRIETARY in enabled- if (modernEnabled || fdroidEnabled || izzyEnabled || 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()- }- izzyRecentFlow.value = if (izzyEnabled) {- catalog.recentlyUpdatedBySource(AppSource.IZZY, 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()- izzyRecentFlow.value = emptyList()- proprietaryRecentFlow.value = emptyList()- }- recentlyUpdatedFlow.value =- modernRecentFlow.value + proprietaryRecentFlow.value + fdroidRecentFlow.value +- izzyRecentFlow.value-+ loadOfflineRecents(enabled) if (AppSource.PLAYSTORE !in enabled) { isLoadingHomeFlow.value = false return }+ loadPlayHomeSections()+ isLoadingHomeFlow.value = false+}++private suspend fun AppStoreViewModel.loadOfflineRecents(enabled: Set<AppSource>) {+ suspend fun recentOrEmpty(source: AppSource): List<UnifiedApp> =+ if (source in enabled) catalog.recentlyUpdatedBySource(source, RECENT_PER_SOURCE_LIMIT) else emptyList()+ modernRecentFlow.value = recentOrEmpty(AppSource.MODERN_APPS)+ fdroidRecentFlow.value = recentOrEmpty(AppSource.FDROID)+ izzyRecentFlow.value = recentOrEmpty(AppSource.IZZY)+ proprietaryRecentFlow.value = recentOrEmpty(AppSource.PROPRIETARY)+ recentlyUpdatedFlow.value =+ modernRecentFlow.value + proprietaryRecentFlow.value + fdroidRecentFlow.value ++ izzyRecentFlow.value+} +private suspend fun AppStoreViewModel.loadPlayHomeSections() { val clusters = play.homeClusters() playFullClustersFlow.value = clusters .filter { it.apps.isNotEmpty() }@@ -74,15 +57,12 @@ internal suspend fun AppStoreViewModel.loadHome(enabled: Set<AppSource> = enable .filter { it.apps.isNotEmpty() } .take(PLAY_CLUSTER_LIMIT) .map { AppSection("play-${it.title}", it.title, it.apps.take(CAROUSEL_LIMIT)) }- if (playSectionsFlow.value.isEmpty()) { // No account, or Play changed its stream shape. A top chart is one request and // still gives the screen something beyond this repo's own dozen apps. val chart = play.topChart() if (chart.isNotEmpty()) {- playFullClustersFlow.value = mapOf(- "play-top" to chart,- )+ playFullClustersFlow.value = mapOf("play-top" to chart) playSectionsFlow.value = listOf( AppSection( id = "play-top",@@ -92,7 +72,6 @@ internal suspend fun AppStoreViewModel.loadHome(enabled: Set<AppSource> = enable ) } }- isLoadingHomeFlow.value = false } internal fun AppStoreViewModel.buildSections(@@ -105,11 +84,11 @@ internal fun AppStoreViewModel.buildSections( accrescent: List<UnifiedApp>, categoryApps: List<UnifiedApp>, category: String?,-): List<AppSection> = buildList {+): List<AppSection> { // A chosen category replaces the browsing rows: the user asked a narrow question // and a wall of unrelated carousels underneath it is just noise. if (category != null) {- add(+ return listOf( AppSection( id = "category", title = category,@@ -118,70 +97,54 @@ internal fun AppStoreViewModel.buildSections( subtitle = context.getString(R.string.section_category_subtitle), ) )- return@buildList } // 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",- title = context.getString(R.string.section_modern_apps),- apps = modern,- subtitle = context.getString(R.string.section_modern_apps_subtitle),- )- )- }- if (proprietaryRecent.isNotEmpty()) {- add(- AppSection(- id = "proprietary-recent",- title = context.getString(R.string.section_proprietary_recent),- apps = proprietaryRecent,- subtitle = context.getString(R.string.section_proprietary_recent_subtitle),- )- )- }- addAll(playSections)- if (accrescent.isNotEmpty()) {- add(- AppSection(- id = "accrescent",- title = context.getString(R.string.section_accrescent),- apps = accrescent,- subtitle = context.getString(R.string.section_accrescent_subtitle),- )- )- }- if (fdroidRecent.isNotEmpty()) {- add(- AppSection(- id = "fdroid-recent",- title = context.getString(R.string.section_fdroid_recent),- apps = fdroidRecent,- subtitle = context.getString(R.string.section_fdroid_recent_subtitle),- )- )- }- if (izzyRecent.isNotEmpty()) {- add(- AppSection(- id = "izzy-recent",- title = context.getString(R.string.section_izzy_recent),- apps = izzyRecent,- subtitle = context.getString(R.string.section_izzy_recent_subtitle),- )- )- }+ return listOfNotNull(+ modernSection(modern, modernRecent),+ recentSection("proprietary-recent", R.string.section_proprietary_recent, proprietaryRecent),+ ) + playSections + listOfNotNull(+ recentSection(+ "accrescent", R.string.section_accrescent, accrescent,+ subtitleRes = R.string.section_accrescent_subtitle,+ ),+ recentSection("fdroid-recent", R.string.section_fdroid_recent, fdroidRecent),+ recentSection("izzy-recent", R.string.section_izzy_recent, izzyRecent),+ )+}++private fun AppStoreViewModel.modernSection(+ modern: List<UnifiedApp>,+ modernRecent: List<UnifiedApp>,+): AppSection? = when {+ modernRecent.isNotEmpty() -> 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),+ )+ modern.isNotEmpty() -> AppSection(+ id = "modern",+ title = context.getString(R.string.section_modern_apps),+ apps = modern,+ subtitle = context.getString(R.string.section_modern_apps_subtitle),+ )+ else -> null+}++private fun AppStoreViewModel.recentSection(+ id: String,+ titleRes: Int,+ apps: List<UnifiedApp>,+ subtitleRes: Int? = null,+): AppSection? {+ if (apps.isEmpty()) return null+ return AppSection(+ id = id,+ title = context.getString(titleRes),+ apps = apps,+ subtitle = subtitleRes?.let { context.getString(it) },+ ) } /**@@ -255,37 +218,11 @@ fun AppStoreViewModel.syncSources() { val enabled = settings.readEnabledSources() isSyncingFlow.value = true val report = catalog.sync(enabled) { step ->- statusMessageFlow.value = context.getString(- when (step) {- SyncStep.FDROID -> R.string.sync_step_fdroid- SyncStep.IZZY -> R.string.sync_step_izzy- SyncStep.MODERN_APPS -> R.string.sync_step_modern_apps- SyncStep.PROPRIETARY -> R.string.sync_step_proprietary- }- )+ statusMessageFlow.value = context.getString(syncStepStringRes(step)) } statusMessageFlow.value = "" isSyncingFlow.value = false-- AppMessages.show(- when {- report.allSkipped -> context.getString(R.string.sync_all_sources_off)- !report.anyFailed -> context.getString(- R.string.sync_done,- (report.fdroidCount ?: 0) + (report.modernCount ?: 0) +- (report.proprietaryCount ?: 0) + (report.izzyCount ?: 0),- )- report.fdroidCount == null && report.modernCount == null &&- report.proprietaryCount == null && report.izzyCount == null ->- context.getString(R.string.sync_failed_all)- report.fdroidCount == null -> context.getString(R.string.sync_failed_fdroid)- report.izzyCount == null && AppSource.IZZY in enabled ->- context.getString(R.string.sync_failed_izzy)- report.proprietaryCount == null ->- context.getString(R.string.sync_failed_proprietary)- else -> context.getString(R.string.sync_failed_modern_apps)- }- )+ AppMessages.show(syncReportMessage(report, enabled)) categoriesFlow.value = catalog.categories() loadHome(enabled)@@ -293,3 +230,24 @@ fun AppStoreViewModel.syncSources() { installedRepo.refresh() } }++private fun syncStepStringRes(step: SyncStep): Int = when (step) {+ SyncStep.FDROID -> R.string.sync_step_fdroid+ SyncStep.IZZY -> R.string.sync_step_izzy+ SyncStep.MODERN_APPS -> R.string.sync_step_modern_apps+ SyncStep.PROPRIETARY -> R.string.sync_step_proprietary+}++private fun AppStoreViewModel.syncReportMessage(report: SyncReport, enabled: Set<AppSource>): String {+ val counts = listOf(report.fdroidCount, report.modernCount, report.proprietaryCount, report.izzyCount)+ return when {+ report.allSkipped -> context.getString(R.string.sync_all_sources_off)+ !report.anyFailed -> context.getString(R.string.sync_done, counts.sumOf { it ?: 0 })+ counts.all { it == null } -> context.getString(R.string.sync_failed_all)+ report.fdroidCount == null -> context.getString(R.string.sync_failed_fdroid)+ report.izzyCount == null && AppSource.IZZY in enabled ->+ context.getString(R.string.sync_failed_izzy)+ report.proprietaryCount == null -> context.getString(R.string.sync_failed_proprietary)+ else -> context.getString(R.string.sync_failed_modern_apps)+ }+}
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 767cb3dcb1..cc91d4386e 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.kt@@ -169,6 +169,7 @@ interface AppActions { fun install(app: UnifiedApp) {} fun openApp(packageName: String) {} + /** Provides a no-op AppActions for previews and defaults. */ companion object { val Noop: AppActions = object : AppActions {} }@@ -179,6 +180,7 @@ interface HomeActions : AppActions { fun selectCategory(category: String?) {} fun refresh() {} + /** Provides a no-op HomeActions for previews and defaults. */ companion object { val Noop: HomeActions = object : HomeActions {} }@@ -189,6 +191,7 @@ interface SearchActions : AppActions { fun setSearch(query: String) {} fun setSearchFilter(filter: SourceFilter) {} + /** Provides a no-op SearchActions for previews and defaults. */ companion object { val Noop: SearchActions = object : SearchActions {} }@@ -202,6 +205,7 @@ interface AppDetailActions : AppActions { fun shareApp(app: UnifiedApp) {} fun dismissInstallFailure(packageName: String) {} + /** Provides a no-op AppDetailActions for previews and defaults. */ companion object { val Noop: AppDetailActions = object : AppDetailActions {} }@@ -212,6 +216,7 @@ interface UpdatesActions : AppActions { fun checkForUpdates() {} fun updateAll() {} + /** Provides a no-op UpdatesActions for previews and defaults. */ companion object { val Noop: UpdatesActions = object : UpdatesActions {} }@@ -221,6 +226,7 @@ interface UpdatesActions : AppActions { interface LibraryActions : AppActions { fun setLibraryFilter(filter: SourceFilter) {} + /** Provides a no-op LibraryActions for previews and defaults. */ companion object { val Noop: LibraryActions = object : LibraryActions {} }
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 1efb7fafb3..f3daf699ec 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt@@ -374,7 +374,6 @@ class AppStoreViewModel( LibraryInputs(index, playPackages, accrescentPackages, filter, enabled) }, ) { rows, inputs ->- val (index, playPackages, accrescentPackages, filter, enabled) = inputs // Source attribution, highest priority first: // 1. Whatever the offline catalogue (F-Droid / Modern Apps / Proprietary) recorded. // 2. Accrescent, for packages its signed allowlist vouches for.@@ -386,12 +385,12 @@ class AppStoreViewModel( // cache can still hold a disabled offline source's rows on a cold start before // purgeDisabled runs, and the Play/Accrescent snapshots are in-memory. fun sourceOf(pkg: String): AppSource? {- index[pkg]?.source?.let { runCatching { AppSource.valueOf(it) }.getOrNull() }- ?.takeIf { it in enabled }?.let { return it }- if (AppSource.ACCRESCENT in enabled && pkg in accrescentPackages) {+ inputs.index[pkg]?.source?.let { runCatching { AppSource.valueOf(it) }.getOrNull() }+ ?.takeIf { it in inputs.enabled }?.let { return it }+ if (AppSource.ACCRESCENT in inputs.enabled && pkg in inputs.accrescentPackages) { return AppSource.ACCRESCENT }- if (AppSource.PLAYSTORE in enabled && pkg in playPackages) {+ if (AppSource.PLAYSTORE in inputs.enabled && pkg in inputs.playPackages) { return AppSource.PLAYSTORE } return null@@ -401,8 +400,8 @@ class AppStoreViewModel( sourceOf(info.packageName)?.let { info.toUnifiedApp(it) } } LibraryUiState(- apps = all.filter { filter.source == null || it.source == filter.source },- filter = filter,+ apps = all.filter { inputs.filter.source == null || it.source == inputs.filter.source },+ filter = inputs.filter, counts = SourceFilter.entries.associateWith { f -> if (f.source == null) all.size else all.count { it.source == f.source } },@@ -733,6 +732,7 @@ class AppStoreViewModel( } } +/** Factory creating AppStoreViewModel with its context and database. */ class AppStoreViewModelFactory( private val context: Context, private val db: AppDatabase,
appstore/src/test/java/com/vayunmathur/appstore/data/FDroidFetchRepoIndexTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/data/FDroidFetchRepoIndexTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/data/FDroidFetchRepoIndexTest.ktindex eced970bfb..e1d9653531 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/data/FDroidFetchRepoIndexTest.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/data/FDroidFetchRepoIndexTest.kt@@ -41,6 +41,12 @@ class FDroidFetchRepoIndexTest { private fun indexJson(): String = """ { "packages": {+""" + alphaPackageJson() + otherPackagesJson() + """+ }+ }+ """.trimIndent()++ private fun alphaPackageJson(): String = """ "com.example.alpha": { "metadata": { "name": {"en-US": "Alpha"},@@ -75,6 +81,9 @@ class FDroidFetchRepoIndexTest { } } },+"""++ private fun otherPackagesJson(): String = """ "com.example.lowtarget": { "metadata": {"name": {"en-US": "Low Target"}}, "versions": {@@ -122,7 +131,7 @@ class FDroidFetchRepoIndexTest { "com.example.broken": "not-a-package-object" } }- """.trimIndent()+ """ private fun runTool(tool: String, vararg args: String) { val exe = File(System.getProperty("java.home"), "bin/$tool")
appstore/src/test/java/com/vayunmathur/appstore/data/IzzyGateTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/data/IzzyGateTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/data/IzzyGateTest.ktindex 8611e63a36..d114bbdd0b 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/data/IzzyGateTest.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/data/IzzyGateTest.kt@@ -47,7 +47,27 @@ class IzzyGateTest { fun setUp() { val ctx = ApplicationProvider.getApplicationContext<Context>() work = File.createTempFile("izzy-gate", "dir").let { it.delete(); it.mkdirs(); it }- val index = """+ val index = izzyIndexBytes()+ val (signedBytes, fingerprint) = createSignedEntryJar(index)+ val repoUrl = startIzzyServer(index, signedBytes)+ db = Room.inMemoryDatabaseBuilder(ctx, AppDatabase::class.java)+ .setDriver(BundledSQLiteDriver())+ .allowMainThreadQueries()+ .build()+ provider = FDroidAppProvider(+ db,+ ctx,+ RepoDescriptor(+ url = repoUrl,+ displayName = "Izzy Test",+ pinnedFingerprint = fingerprint,+ source = AppSource.IZZY,+ supportsReproducibilityFeed = false,+ ),+ )+ }++ private fun izzyIndexBytes(): ByteArray = """ {"packages": {"com.example.izzyapp": { "metadata": {"name": {"en-US": "Izzy App"}}, "versions": {"v1": {@@ -58,6 +78,8 @@ class IzzyGateTest { }} }}} """.trimIndent().toByteArray()++ private fun createSignedEntryJar(index: ByteArray): Pair<ByteArray, String> { val entryJson = """{"index": {"name": "index-v2.json", "sha256": "${ApkCertificates.sha256(index)}"}}""" val entryJar = File(work, "entry-unsigned.jar")@@ -80,8 +102,10 @@ class IzzyGateTest { val ks = KeyStore.getInstance(KeyStore.getDefaultType()) keystore.inputStream().use { ks.load(it, "changeit".toCharArray()) } val fingerprint = ApkCertificates.sha256(ks.getCertificate("test").encoded)- val signedBytes = signedJar.readBytes()+ return signedJar.readBytes() to fingerprint+ } + private fun startIzzyServer(index: ByteArray, signedBytes: ByteArray): String { server = HttpServer.create(InetSocketAddress("127.0.0.1", 0), 0) server.createContext("/repo/entry.jar") { exchange -> exchange.sendResponseHeaders(200, signedBytes.size.toLong())@@ -92,23 +116,7 @@ class IzzyGateTest { exchange.responseBody.use { it.write(index) } } server.start()- val repoUrl = "http://127.0.0.1:${server.address.port}/repo"-- db = Room.inMemoryDatabaseBuilder(ctx, AppDatabase::class.java)- .setDriver(BundledSQLiteDriver())- .allowMainThreadQueries()- .build()- provider = FDroidAppProvider(- db,- ctx,- RepoDescriptor(- url = repoUrl,- displayName = "Izzy Test",- pinnedFingerprint = fingerprint,- source = AppSource.IZZY,- supportsReproducibilityFeed = false,- ),- )+ return "http://127.0.0.1:${server.address.port}/repo" } @AfterTest
appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayAppMappingTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayAppMappingTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayAppMappingTest.ktindex 1bd762d409..3a70c81a80 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayAppMappingTest.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/data/play/PlayAppMappingTest.kt@@ -6,6 +6,7 @@ import com.aurora.gplayapi.data.models.ContentRating import com.aurora.gplayapi.data.models.EncodedCertificateSet import com.aurora.gplayapi.data.models.Rating import com.vayunmathur.appstore.data.AppSource+import com.vayunmathur.appstore.data.UnifiedApp import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNull@@ -25,69 +26,76 @@ class PlayAppMappingTest { @Test fun `a fully populated play app maps every shown field`() {- val app = App(- packageName = "com.example.play",- displayName = "Play App",- shortDescription = "Short summary",- description = "Long description",- iconArtwork = Artwork(url = "https://example.org/icon.png"),- coverArtwork = Artwork(url = "https://example.org/cover.png"),- screenshots = listOf(- Artwork(url = "https://example.org/1.png"),- Artwork(url = ""),- Artwork(url = "https://example.org/2.png"),- ),- developerName = "Play Dev",- categoryName = "Tools",- versionName = "3.1",- versionCode = 31L,- size = 5_000_000L,- changes = "What's new text",- targetSdk = 35,- rating = Rating(- average = 4.2f,- oneStar = 1L, twoStar = 2L, threeStar = 3L, fourStar = 4L, fiveStar = 5L,- ),- installs = 9000L,- updatedOn = "Nov 1, 2026",- contentRating = ContentRating(title = "Everyone"),- permissions = listOf("android.permission.CAMERA"),- containsAds = true,- certificateSetList = listOf(- EncodedCertificateSet(certificateSet = "", sha256 = "AB".repeat(32)),- ),- )+ val unified = fullyPopulatedPlayApp().toUnifiedApp()+ assertFullyPopulatedMapping(unified)+ } - val unified = app.toUnifiedApp()- assertEquals("com.example.play", unified.packageName)- assertEquals(AppSource.PLAYSTORE, unified.source)- assertEquals("Play App", unified.name)- assertEquals("Short summary", unified.summary)- assertEquals("Long description", unified.description)- assertEquals("https://example.org/icon.png", unified.iconUrl)- assertEquals("https://example.org/cover.png", unified.featureGraphic)- assertEquals(- listOf("https://example.org/1.png", "https://example.org/2.png"),- unified.screenshots,- )- assertEquals("Play Dev", unified.author)- assertEquals(listOf("Tools"), unified.categories)- assertEquals("3.1", unified.versionName)- assertEquals(31L, unified.versionCode)- assertEquals(5_000_000L, unified.sizeBytes)- assertEquals("What's new text", unified.whatsNew)- assertEquals(35, unified.targetSdk)- assertEquals(4.2f, unified.rating)- assertEquals(15L, unified.ratingCount)- assertEquals(9000L, unified.installs)- assertEquals("Everyone", unified.contentRating)- assertEquals(listOf("android.permission.CAMERA"), unified.permissions)- assertTrue(unified.containsAds)- assertEquals(- "https://play.google.com/store/apps/details?id=com.example.play",- unified.website,- )- assertEquals(listOf("ab".repeat(32)), unified.expectedSigners)+ private fun fullyPopulatedPlayApp(): App {+ return App(+ packageName = "com.example.play",+ displayName = "Play App",+ shortDescription = "Short summary",+ description = "Long description",+ iconArtwork = Artwork(url = "https://example.org/icon.png"),+ coverArtwork = Artwork(url = "https://example.org/cover.png"),+ screenshots = listOf(+ Artwork(url = "https://example.org/1.png"),+ Artwork(url = ""),+ Artwork(url = "https://example.org/2.png"),+ ),+ developerName = "Play Dev",+ categoryName = "Tools",+ versionName = "3.1",+ versionCode = 31L,+ size = 5_000_000L,+ changes = "What's new text",+ targetSdk = 35,+ rating = Rating(+ average = 4.2f,+ oneStar = 1L, twoStar = 2L, threeStar = 3L, fourStar = 4L, fiveStar = 5L,+ ),+ installs = 9000L,+ updatedOn = "Nov 1, 2026",+ contentRating = ContentRating(title = "Everyone"),+ permissions = listOf("android.permission.CAMERA"),+ containsAds = true,+ certificateSetList = listOf(+ EncodedCertificateSet(certificateSet = "", sha256 = "AB".repeat(32)),+ ),+ )++ }++ private fun assertFullyPopulatedMapping(unified: UnifiedApp) {+ assertEquals("com.example.play", unified.packageName)+ assertEquals(AppSource.PLAYSTORE, unified.source)+ assertEquals("Play App", unified.name)+ assertEquals("Short summary", unified.summary)+ assertEquals("Long description", unified.description)+ assertEquals("https://example.org/icon.png", unified.iconUrl)+ assertEquals("https://example.org/cover.png", unified.featureGraphic)+ assertEquals(+ listOf("https://example.org/1.png", "https://example.org/2.png"),+ unified.screenshots,+ )+ assertEquals("Play Dev", unified.author)+ assertEquals(listOf("Tools"), unified.categories)+ assertEquals("3.1", unified.versionName)+ assertEquals(31L, unified.versionCode)+ assertEquals(5_000_000L, unified.sizeBytes)+ assertEquals("What's new text", unified.whatsNew)+ assertEquals(35, unified.targetSdk)+ assertEquals(4.2f, unified.rating)+ assertEquals(15L, unified.ratingCount)+ assertEquals(9000L, unified.installs)+ assertEquals("Everyone", unified.contentRating)+ assertEquals(listOf("android.permission.CAMERA"), unified.permissions)+ assertTrue(unified.containsAds)+ assertEquals(+ "https://play.google.com/store/apps/details?id=com.example.play",+ unified.website,+ )+ assertEquals(listOf("ab".repeat(32)), unified.expectedSigners) } @Test
appstore/src/test/java/com/vayunmathur/appstore/data/security/InstallVerifierStampAndTvFeatureTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/data/security/InstallVerifierStampAndTvFeatureTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/data/security/InstallVerifierStampAndTvFeatureTest.ktindex 1add64e60d..dd930ae9b5 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/data/security/InstallVerifierStampAndTvFeatureTest.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/data/security/InstallVerifierStampAndTvFeatureTest.kt@@ -26,7 +26,7 @@ class InstallVerifierStampAndTvFeatureTest { private val context: Context get() = ApplicationProvider.getApplicationContext() - private fun signingInfo(cert: String): SigningInfo {+ private fun signingInfo(): SigningInfo { val der = android.util.Base64.decode(CERT_A, android.util.Base64.DEFAULT) val info = SigningInfo() val shadow = Shadows.shadowOf(info)@@ -52,7 +52,7 @@ class InstallVerifierStampAndTvFeatureTest { sourceDir = file.absolutePath targetSdkVersion = 35 }- signingInfo = signingInfo("a")+ signingInfo = signingInfo() if (features.isNotEmpty()) { reqFeatures = features.map { name -> FeatureInfo().apply { this.name = name }