appstore: remove TV filter chip, limit by device instead
- Commit
165a13dabbdd1ffd4cd24dc6c855ac70e716759a- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-02 02:45 UTC (4 days ago)
- Parents
466f38f
The 'TV' category was offered as a filter chip in the home category row (phone and TV), so phone users could manually limit the store to TV apps and the chip duplicated what the device already knows. TV limiting is now automatic only: whether catalogue results are limited to TV-compatible apps depends only on the app running on a TV. CatalogRepository.categories() drops the 'TV' category on every device, and the home category rows (CategoryRow, TvCategoryChips) never render it, so there is no TV filter affordance anywhere; the search and library source-filter chips are untouched. The device signal is the existing leanback check (DeviceAttributesProvider.isTv: leanback feature and no touchscreen), exposed as a fakeable isTvDevice constructor seam so tests can pin both behaviours. The modernApps flow, which previously bypassed the TV filter every other catalogue read applies, now goes through filterTv() as well. No TV filter strings existed (the chip label was the F-Droid category name), so there were no strings to remove; the 'TV' category still marks listings as TV-compatible in the data layer. Tests: CatalogTvLimitTest fakes the device signal — TV device gets only TV-compatible results (allBySource/byCategory/search/ byPackage/modernApps), phone gets all results, and 'TV' is never offered as a category on either. HomeScreenTest and TvStoreHomeScreenTest pin that no TV chip renders while other categories and the All chip still do; SearchScreenTest keeps pinning the source filter. Verified: ./gradlew :appstore:lint :appstore:lintVitalRelease :appstore:testDevUnitTest — BUILD SUCCESSFUL (lint green).
Diff
appstore/AGENTS.md
diff --git a/appstore/AGENTS.md b/appstore/AGENTS.mdindex 995086ee28..f80fb391e8 100644--- a/appstore/AGENTS.md+++ b/appstore/AGENTS.md@@ -14,6 +14,7 @@ _Install: ./install appstore (dev by default)._ **Purpose:** Security-first app store — six sources (own repo, curated mirror, F-Droid, GrapheneOS, Accrescent, Play) with every download signature-checked and a plain-language security tier per app (who could push a malicious update). **Key features:** - Multi-source catalogs: F-Droid (reproducible-builds only), Accrescent (Signify trust), anonymous Play (no Google account), GrapheneOS bundle one-tap+- Top filters filter by source (search/library) or category (home); there is no TV filter chip — catalogue results are limited to TV-compatible apps only when the device itself is a TV (`DeviceAttributesProvider.isTv`, applied by `CatalogRepository` on every read) - Install pipeline: `InstallCoordinator` → `SessionInstaller` → `InstallStatusReceiver`, verified by `InstallVerifier` (APK certs, signed-jar index, source stamps) before the system installer sees anything - `UpdateCheckWorker` background checks; outdated-target-API apps refused, not hidden **Architecture / data-flow:** `ui/` home/search/detail/library/updates/sources/trust (+ `ui/dialogs/` stateless dialog contents for the `Route.UninstallDialog` / TV `UninstallDialog` routes) → `platform/AppStoreViewModel` (+ per-area `*Ops`, `AppStoreUiContract`) → `data/` providers per source (`*Repository`, Play/F-Droid/Accrescent clients) + `data/installer/` + `data/security/`; `domain/SearchRanking` is pure ranking.
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 32d4bba1e5..6b2bdcaca6 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/CatalogRepository.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/CatalogRepository.kt@@ -52,6 +52,17 @@ class CatalogRepository( context: Context, private val db: AppDatabase, scope: CoroutineScope,+ /**+ * Whether this device is a TV — the only thing that may limit catalogue+ * results to TV-compatible apps. Defaults to the device's leanback+ * feature set (see [com.vayunmathur.appstore.data.accrescent.DeviceAttributesProvider.isTv]);+ * tests fake it to pin the TV and phone behaviours.+ */+ private val isTvDevice: () -> Boolean = {+ com.vayunmathur.appstore.data.accrescent.DeviceAttributesProvider(+ context.applicationContext,+ ).isTv()+ }, ) { private val appContext = context.applicationContext private val fdroidProvider = FDroidAppProvider(db, appContext, DefaultRepos.FDROID)@@ -64,9 +75,7 @@ class CatalogRepository( * without a reboot, and every catalogue read below consults it for TV-compat * filtering. */- private val isTv: Boolean by lazy {- com.vayunmathur.appstore.data.accrescent.DeviceAttributesProvider(appContext).isTv()- }+ private val isTv: Boolean by lazy { isTvDevice() } private fun List<UnifiedApp>.filterTv(): List<UnifiedApp> = AppProvider.filterTvCompatible(isTv, this)@@ -87,7 +96,7 @@ class CatalogRepository( /** This repo's own apps. Small, always shown in full, so it stays a live flow. */ val modernApps: StateFlow<List<UnifiedApp>> = db.cachedAppDao().bySourceFlow(AppSource.MODERN_APPS.name)- .map { rows -> rows.map { it.toUnifiedApp() } }+ .map { rows -> rows.map { it.toUnifiedApp() }.filterTv() } .stateIn(scope, SharingStarted.Eagerly, emptyList()) fun sourceOf(packageName: String): AppSource? =@@ -137,8 +146,10 @@ class CatalogRepository( } /**- * Categories present in the catalogue, most-populated first. On a TV the "TV" category- * is dropped: every listing shown there is already TV-compatible.+ * Categories present in the catalogue, most-populated first. The "TV" category+ * is never offered as a filter: whether results are limited to TV-compatible+ * apps depends only on this device being a TV (see [filterTv]), never on a+ * chip the user taps. */ suspend fun categories(): List<String> = withContext(Dispatchers.IO) { runCatching {@@ -146,7 +157,7 @@ class CatalogRepository( .flatMap { it.split(",") } .map { it.trim() } .filter { it.isNotBlank() }- .filterNot { isTv && it.equals(TV_CATEGORY, ignoreCase = true) }+ .filterNot { it.equals(TV_CATEGORY, ignoreCase = true) } .groupingBy { it } .eachCount() .entries@@ -323,7 +334,7 @@ class CatalogRepository( private companion object { /** SQLite's default host-parameter ceiling; `IN (:packages)` binds one each. */ const val SQLITE_VARIABLE_LIMIT = 900- /** The F-Droid category that marks a TV build. */+ /** The F-Droid category that marks a TV build; never a filter chip. */ const val TV_CATEGORY = "TV" } }
appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.ktindex 42fdcbdfd9..f409e0e741 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/HomePage.kt@@ -117,6 +117,9 @@ internal fun CategoryRow( selected: String?, onSelect: (String?) -> Unit, ) {+ // The "TV" category is never a chip: TV limiting is automatic on a TV+ // device (CatalogRepository), not a filter the user picks.+ val visible = categories.filterNot { it.equals("TV", ignoreCase = true) } LazyRow( Modifier.fillMaxWidth(), contentPadding = PaddingValues(horizontal = 16.dp, vertical = 4.dp),@@ -129,7 +132,7 @@ internal fun CategoryRow( label = { Text(stringResource(R.string.filter_all)) }, ) }- items(categories, key = { it }) { category ->+ items(visible, key = { it }) { category -> FilterChip( selected = selected == category, onClick = { onSelect(if (selected == category) null else category) },
appstore/src/main/java/com/vayunmathur/appstore/ui/tv/TvStoreHome.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/tv/TvStoreHome.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/tv/TvStoreHome.ktindex 20085cb69b..cbaa1f8888 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/tv/TvStoreHome.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/tv/TvStoreHome.kt@@ -157,7 +157,10 @@ private fun TvCategoryChips( ) { // FlowRow would want the experimental layout API; a fixed 6-per-row chunk // reads the same on a TV and keeps the imports stable. The All chip leads.- val cells = listOf<String?>(null) + categories.take(CATEGORY_CHIP_LIMIT)+ // The "TV" category is never a chip: TV limiting is automatic on a TV+ // device (CatalogRepository), not a filter the user picks.+ val visible = categories.filterNot { it.equals("TV", ignoreCase = true) }+ val cells = listOf<String?>(null) + visible.take(CATEGORY_CHIP_LIMIT) Column(modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(10.dp)) { cells.chunked(CATEGORY_CHIPS_PER_ROW).forEach { chunk -> Row(horizontalArrangement = Arrangement.spacedBy(10.dp)) {
appstore/src/test/java/com/vayunmathur/appstore/data/CatalogTvLimitTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/data/CatalogTvLimitTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/data/CatalogTvLimitTest.ktnew file mode 100644index 0000000000..a1a4354a84--- /dev/null+++ b/appstore/src/test/java/com/vayunmathur/appstore/data/CatalogTvLimitTest.kt@@ -0,0 +1,133 @@+package com.vayunmathur.appstore.data++import androidx.room3.Room+import androidx.sqlite.driver.bundled.BundledSQLiteDriver+import androidx.test.core.app.ApplicationProvider+import android.content.Context+import kotlin.test.AfterTest+import kotlin.test.BeforeTest+import kotlin.test.Test+import kotlin.test.assertEquals+import kotlin.test.assertNull+import kotlinx.coroutines.CoroutineScope+import kotlinx.coroutines.Dispatchers+import kotlinx.coroutines.cancel+import kotlinx.coroutines.flow.first+import kotlinx.coroutines.test.runTest+import org.junit.runner.RunWith+import org.robolectric.RobolectricTestRunner++/**+ * Automatic TV limiting: whether catalogue results are limited to+ * TV-compatible apps depends only on the device being a TV, never on a+ * filter the user picks. The device signal is faked here; on a real device+ * it is the leanback feature set (DeviceAttributesProvider.isTv).+ */+@RunWith(RobolectricTestRunner::class)+class CatalogTvLimitTest {++ private lateinit var db: AppDatabase+ private lateinit var scope: CoroutineScope++ private fun entity(+ pkg: String,+ name: String = pkg,+ categories: List<String> = emptyList(),+ tvCompatible: Boolean? = null,+ requiredFeatures: List<String> = emptyList(),+ ) = UnifiedApp(+ packageName = pkg,+ source = AppSource.FDROID,+ name = name,+ categories = categories,+ tvCompatible = tvCompatible,+ requiredFeatures = requiredFeatures,+ ).toEntity()++ @BeforeTest+ fun setUp() {+ val ctx = ApplicationProvider.getApplicationContext<Context>()+ db = Room.inMemoryDatabaseBuilder(ctx, AppDatabase::class.java)+ .setDriver(BundledSQLiteDriver())+ .allowMainThreadQueries()+ .build()+ scope = CoroutineScope(Dispatchers.Unconfined)+ }++ @AfterTest+ fun tearDown() {+ scope.cancel()+ db.close()+ }++ private fun repo(isTv: Boolean): CatalogRepository {+ val ctx = ApplicationProvider.getApplicationContext<Context>()+ return CatalogRepository(ctx, db, scope) { isTv }+ }++ private suspend fun seed() {+ db.cachedAppDao().upsertAll(+ listOf(+ entity("com.example.tv", name = "TvApp", categories = listOf("TV", "Games"), tvCompatible = true),+ entity("com.example.phone", name = "PhoneApp", categories = listOf("Games"), tvCompatible = false),+ entity("com.example.unknown", name = "UnknownApp", categories = listOf("Tools")),+ entity(+ "com.example.telephony", name = "TelephonyApp",+ requiredFeatures = listOf("android.hardware.telephony"),+ ),+ )+ )+ }++ @Test+ fun `tv device gets only tv-compatible results`() = runTest {+ val tv = repo(isTv = true)+ seed()+ assertEquals(+ setOf("com.example.tv", "com.example.unknown"),+ tv.allBySource(AppSource.FDROID).map { it.packageName }.toSet(),+ )+ assertEquals(listOf("com.example.tv"), tv.byCategory("TV").map { it.packageName })+ assertEquals(setOf("com.example.tv"), tv.searchLocal("TvApp").map { it.packageName }.toSet())+ assertNull(tv.byPackage("com.example.phone"))+ assertEquals("com.example.tv", tv.byPackage("com.example.tv")?.packageName)+ }++ @Test+ fun `phone device gets all results`() = runTest {+ val phone = repo(isTv = false)+ seed()+ assertEquals(+ setOf("com.example.tv", "com.example.phone", "com.example.unknown", "com.example.telephony"),+ phone.allBySource(AppSource.FDROID).map { it.packageName }.toSet(),+ )+ assertEquals("com.example.phone", phone.byPackage("com.example.phone")?.packageName)+ }++ @Test+ fun `tv category is never offered as a filter on either device`() = runTest {+ seed()+ assertEquals(listOf("Games", "Tools"), repo(isTv = false).categories())+ assertEquals(listOf("Games", "Tools"), repo(isTv = true).categories())+ }++ @Test+ fun `modernApps flow is tv-limited only on a tv device`() = runTest {+ db.cachedAppDao().upsertAll(+ listOf(+ entity("com.example.tv", name = "TvApp", tvCompatible = true)+ .copy(source = AppSource.MODERN_APPS.name, repoUrl = DefaultRepos.MODERN_APPS.url),+ entity("com.example.phone", name = "PhoneApp", tvCompatible = false)+ .copy(source = AppSource.MODERN_APPS.name, repoUrl = DefaultRepos.MODERN_APPS.url),+ )+ )+ assertEquals(+ listOf("com.example.tv"),+ repo(isTv = true).modernApps.first { it.isNotEmpty() }.map { it.packageName },+ )+ assertEquals(+ setOf("com.example.tv", "com.example.phone"),+ repo(isTv = false).modernApps.first { it.isNotEmpty() }.map { it.packageName }.toSet(),+ )+ }+}
appstore/src/test/java/com/vayunmathur/appstore/tv/TvStoreHomeScreenTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/tv/TvStoreHomeScreenTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/tv/TvStoreHomeScreenTest.ktindex 3bb11ba9f8..514fc91071 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/tv/TvStoreHomeScreenTest.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/tv/TvStoreHomeScreenTest.kt@@ -95,6 +95,22 @@ class TvStoreHomeScreenTest { rule.onNodeWithText("Tools").assertIsDisplayed() } + @Test+ fun `tv category is not offered as a filter chip`() {+ rule.setContent {+ TvStoreHomeScreen(+ state = TvHomeUiState(+ sections = listOf(section(apps = listOf(app("com.example.a", "Alpha")))),+ categories = listOf("TV", "Games"),+ ),+ onSelectCategory = {},+ )+ }++ rule.onNodeWithText("TV").assertDoesNotExist()+ rule.onNodeWithText("Games").assertIsDisplayed()+ }+ @Test fun `sync status line shows`() { val state = TvHomeUiState(
appstore/src/test/java/com/vayunmathur/appstore/ui/HomeScreenTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/ui/HomeScreenTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/ui/HomeScreenTest.ktindex 762c192a96..fa1cb9b4a5 100644--- a/appstore/src/test/java/com/vayunmathur/appstore/ui/HomeScreenTest.kt+++ b/appstore/src/test/java/com/vayunmathur/appstore/ui/HomeScreenTest.kt@@ -105,6 +105,20 @@ class HomeScreenTest { assertEquals(listOf<String?>("Games"), selected) } + @Test+ fun `tv category is not offered as a filter chip`() {+ rule.setContent {+ HomeScreen(+ state = HomeUiState(categories = listOf("TV", "Games")),+ actions = HomeActions.Noop,+ )+ }++ rule.onNodeWithText("TV").assertDoesNotExist()+ rule.onNodeWithText("Games").assertIsDisplayed()+ rule.onNodeWithText("All").assertIsDisplayed()+ }+ @Test fun `list-layout section renders rows`() { val state = HomeUiState(