Modern Apps git

← Modern-Apps.git

appstore: skip foreign installs in Update All, add per-app ignore (#885)

Commit
aa66835adb8c59e55bc4f369ebac955c6261940e
Author
Vayun Mathur <[email protected]>
When
2026-10-31 19:17 UTC (1 month ago)
Parents
b7aa576
Update All used to attempt every pending update, including apps
another store (or adb) installed. Each of those costs a system
confirmation dialog or a doomed failure, slowing the whole run
while the user waits for it to fail.

The ownership signal is the OS's own installer record, read at
scan time into InstalledInfo: installingPackageName plus, on API
34+, updateOwnerPackageName (which survives another store
touching the package later). No local history table is needed —
PackageManager fills the record for every install, including ones
predating this feature — and once this store updates a package
itself, even by explicit tap, the record names this store and the
next Update All picks it up. The pure comparison lives in
domain/UpdateEligibility (unit-tested); data/UpdateOwnership is
the thin PackageManager bridge, and data/partitionUpdates merges
candidates exactly as before then splits them into eligible,
foreign and ignored.

Update All now runs the eligible batch only. Foreign rows stay
listed under their own header, each still updatable by an explicit
tap, so skipping is never a dead end. A per-app ignore toggle
(persisted in SettingsRepository, detail page switch on phone and
TV) excludes packages from Update All, the update count and home
badge, and worker notifications; the updates screen lists ignored
rows under their own collapsed header with a one-tap unignore.

Alternatives rejected: a locally kept install-history table
needs backfilling and drifts from the OS record; hiding foreign
updates entirely would strand users who want them updated here.

User-visible effect: Update All only touches apps this store
installed; the updates tab gains Installed-elsewhere and Ignored
sections; each detail page gains an ignore switch.

Verification: :appstore:compileDevKotlin and :appstore:testDevUnitTest
pass (UpdateEligibilityTest, UpdateListsTest cover ownership,
precedence, staleness and ignore partitioning). Phone and TV UI
wiring and on-device update flows still need on-device testing.

Diff

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 58521a060e..4ae48c060b 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/AppModels.kt@@ -196,6 +196,16 @@ data class InstalledInfo(     val enabled: Boolean = true,     /** When the package was last updated on this device, ms since epoch. */     val lastUpdateTime: Long = 0L,+    /**+     * Last installer of record (`installingPackageName`), null for adb installs.+     * Drives "Update all" skipping packages this store has never touched (#885).+     */+    val installerPackage: String? = null,+    /**+     * Update owner on API 34+ (`updateOwnerPackageName`), null below that or when+     * unset. Survives another store touching the package after us.+     */+    val updateOwnerPackage: String? = null, )  /** A fixed, signed F-Droid-format repository consumed by this store. */
appstore/src/main/java/com/vayunmathur/appstore/data/InstalledAppsRepository.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/InstalledAppsRepository.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/InstalledAppsRepository.ktindex 950370d080..095cb4a1f2 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/InstalledAppsRepository.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/InstalledAppsRepository.kt@@ -67,12 +67,25 @@ class InstalledAppsRepository(private val context: Context) {      private fun PackageManager.readInstalledInfo(ai: ApplicationInfo): InstalledInfo? = try {         val pi = getPackageInfo(ai.packageName, 0)+        // The OS fills this in for every install — including ones that predate the+        // skip/ignore feature — so no local history table needs backfilling (#885).+        // Null (adb installs, some system packages) never equals our package name,+        // which is exactly the "not managed by us" signal the caller wants.+        val source = runCatching { getInstallSourceInfo(ai.packageName) }.getOrNull()         InstalledInfo(             packageName = ai.packageName,             name = getApplicationLabel(ai).toString(),             versionName = pi.versionName,             versionCode = pi.longVersionCode,             lastUpdateTime = pi.lastUpdateTime,+            installerPackage = source?.installingPackageName,+            updateOwnerPackage = if (android.os.Build.VERSION.SDK_INT >=+                android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE+            ) {+                source?.updateOwnerPackageName+            } else {+                null+            },         )     } catch (_: Exception) {         null
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..ecc2c3684b 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/SettingsRepository.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/SettingsRepository.kt@@ -33,6 +33,7 @@ class SettingsRepository( ) {     private val _autoInstallUpdates = MutableStateFlow(DEFAULT_AUTO_INSTALL_UPDATES)     private val _enabledSources = MutableStateFlow(AppSource.DEFAULT_ENABLED)+    private val _ignoredUpdates = MutableStateFlow(emptySet<String>())      /**      * Whether the periodic update check may also download and install updates on its own,@@ -54,6 +55,16 @@ class SettingsRepository(      */     val enabledSources: StateFlow<Set<AppSource>> = _enabledSources.asStateFlow() +    /**+     * Packages the user asked never to be offered updates for (#885).+     *+     * Excluded from "Update all", the update count/badge, and update+     * notifications — but an explicit tap on the app's own Update button still+     * installs, so ignoring is never a dead end. Persisted as a plain string+     * set; an uninstalled package's entry is harmless and pruned on read.+     */+    val ignoredUpdates: StateFlow<Set<String>> = _ignoredUpdates.asStateFlow()+     init {         scope.launch {             context.settingsDataStore.data@@ -61,10 +72,19 @@ class SettingsRepository(                 .collect { prefs ->                     _autoInstallUpdates.value = prefs.autoInstallUpdates()                     _enabledSources.value = prefs.enabledSources()+                    _ignoredUpdates.value = prefs[KEY_IGNORED_UPDATES].orEmpty()                 }         }     } +    suspend fun setUpdateIgnored(packageName: String, ignored: Boolean) {+        context.settingsDataStore.edit { prefs ->+            val current = prefs[KEY_IGNORED_UPDATES].orEmpty()+            prefs[KEY_IGNORED_UPDATES] =+                if (ignored) current + packageName else current - packageName+        }+    }+     suspend fun setAutoInstallUpdates(enabled: Boolean) {         context.settingsDataStore.edit { it[KEY_AUTO_INSTALL_UPDATES] = enabled }     }@@ -92,6 +112,12 @@ class SettingsRepository(     /** One-shot read of [enabledSources], for the same cold-started callers. */     suspend fun readEnabledSources(): Set<AppSource> = read().enabledSources() +    /**+     * One-shot read of [ignoredUpdates], for the same cold-started callers — the+     * [UpdateCheckWorker] filters ignored packages out of notifications.+     */+    suspend fun readIgnoredUpdates(): Set<String> = read()[KEY_IGNORED_UPDATES].orEmpty()+     private suspend fun read(): Preferences =         context.settingsDataStore.data             .catch { e -> if (e is IOException) emit(emptyPreferences()) else throw e }@@ -120,5 +146,7 @@ class SettingsRepository(             booleanPreferencesKey("auto_install_updates")         private val KEY_DISABLED_SOURCES =             stringSetPreferencesKey("disabled_sources")+        private val KEY_IGNORED_UPDATES =+            stringSetPreferencesKey("ignored_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 9b86cd207e..4815288f16 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateCheckWorker.kt@@ -101,6 +101,9 @@ class UpdateCheckWorker(             settings = SettingsRepository(context, scope),         )         val enabled = env.settings.readEnabledSources()+        // Ignored packages are excluded from the notification set the same way+        // the screens exclude them from the count and badge (#885).+        val ignored = env.settings.readIgnoredUpdates()          // Drop disabled sources' cached rows before the index is read: the last sync         // may predate the toggle, and nothing else purges on this path (#845).@@ -110,6 +113,7 @@ class UpdateCheckWorker(         if (AppSource.PLAYSTORE in enabled) env.play.restore()          val updates = collectUpdates(env, enabled)+            .filterNot { it.packageName in ignored }         reportUpdates(env, updates)          env.accrescent.shutdown()
appstore/src/main/java/com/vayunmathur/appstore/data/UpdateLists.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateLists.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateLists.ktnew file mode 100644index 0000000000..e436733da8--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateLists.kt@@ -0,0 +1,66 @@+package com.vayunmathur.appstore.data++/**+ * One update check's candidates, split by what "Update all" may touch (#885).+ *+ * The merge itself is unchanged (source precedence, device re-check); only the+ * tail partitions. [eligible] is what a bulk run attempts. [foreign] is newer+ * versions of packages another store (or adb) installed — a bulk run skips+ * these rather than spending a system confirmation dialog (or a doomed+ * failure) on each one, but an explicit tap still installs them. [ignored] is+ * what the user asked never to be offered; it is excluded everywhere except+ * the ignored section that offers unignoring.+ */+data class PartitionedUpdates(+    val eligible: List<UnifiedApp> = emptyList(),+    val foreign: List<UnifiedApp> = emptyList(),+    val ignored: List<UnifiedApp> = emptyList(),+) {+    /**+     * Everything the store may still draw as an update: the bulk run's targets+     * plus the individually-updatable foreign rows. Ignored packages are in+     * neither — that exclusion is what keeps them out of the count, the badge+     * and the notifications.+     */+    val actionable: List<UnifiedApp>+        get() = (eligible + foreign).sortedBy { it.name.lowercase() }+}++/**+ * Merge raw per-source candidates the way the screens always have, then+ * partition for bulk updates. Pure Kotlin (no Android) so it unit-tests+ * without Robolectric.+ */+fun partitionUpdates(+    pending: List<UnifiedApp>,+    installed: Map<String, InstalledInfo>,+    enabled: Set<AppSource>,+    ignoredPackages: Set<String>,+    ownPackage: String,+): PartitionedUpdates {+    val fresh = pending+        // A disabled source contributes nothing, even if its in-memory snapshot+        // has not been cleared yet (issue #845).+        .filter { it.source in enabled }+        // The surviving row's source decides which download-and-verify path the+        // update takes, so this stays the same precedence search uses.+        .sortedBy { it.source.priority }+        .distinctBy { it.packageName }+        // Re-check against what is on the device rather than trusting the+        // lists: the Play half is a snapshot from the last network check.+        .filter { app ->+            val installedVersion = installed[app.packageName]?.versionCode ?: return@filter false+            app.versionCode > installedVersion+        }+        .sortedBy { it.name.lowercase() }+    val (ignoredList, rest) = fresh.partition { it.packageName in ignoredPackages }+    val (foreign, eligible) = rest.partition { app ->+        val info = installed.getValue(app.packageName)+        !com.vayunmathur.appstore.domain.UpdateEligibility.installedByStore(+            info.installerPackage,+            info.updateOwnerPackage,+            ownPackage,+        )+    }+    return PartitionedUpdates(eligible = eligible, foreign = foreign, ignored = ignoredList)+}
appstore/src/main/java/com/vayunmathur/appstore/data/UpdateOwnership.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateOwnership.kt b/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateOwnership.ktnew file mode 100644index 0000000000..3b964b3632--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/data/UpdateOwnership.kt@@ -0,0 +1,47 @@+package com.vayunmathur.appstore.data++import android.content.Context+import android.content.pm.InstallSourceInfo+import android.os.Build+import com.vayunmathur.appstore.domain.UpdateEligibility++/**+ * Whether an installed package counts as managed by this store for bulk updates.+ *+ * "Update all" must not attempt packages this store has never installed: each one+ * costs a system confirmation dialog (or a doomed failure) and slows the whole run+ * while the user waits for it to fail. The signal is the OS's own installer record+ * rather than a locally kept history: PackageManager fills it in for every+ * install, including ones that predate this feature, so there is nothing to+ * backfill — and once this store updates a package itself (even by explicit tap),+ * the record names this store and the next "Update all" picks it up.+ *+ * The pure comparison lives in [UpdateEligibility] (unit-tested); this object is+ * only the thin PackageManager read over it.+ */+object UpdateOwnership {++    /**+     * True when this store installed [packageName] last, or owns its updates on+     * API 34+. Unknown packages (not installed, or an unreadable record such as an+     * adb install the OS reports nothing for) read as not managed.+     */+    fun installedByStore(context: Context, packageName: String): Boolean {+        val self = context.packageName+        val source = runCatching {+            context.packageManager.getInstallSourceInfo(packageName)+        }.getOrNull() ?: return false+        return UpdateEligibility.installedByStore(+            source.installingPackageName,+            source.updateOwnerOrNull(),+            self,+        )+    }++    private fun InstallSourceInfo.updateOwnerOrNull(): String? =+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {+            runCatching { updateOwnerPackageName }.getOrNull()+        } else {+            null+        }+}
appstore/src/main/java/com/vayunmathur/appstore/domain/UpdateEligibility.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/domain/UpdateEligibility.kt b/appstore/src/main/java/com/vayunmathur/appstore/domain/UpdateEligibility.ktnew file mode 100644index 0000000000..9f67d2b8bb--- /dev/null+++ b/appstore/src/main/java/com/vayunmathur/appstore/domain/UpdateEligibility.kt@@ -0,0 +1,31 @@+package com.vayunmathur.appstore.domain++/**+ * Whether an installed package counts as managed by this store for bulk updates.+ *+ * "Update all" must not attempt packages this store has never installed: each one+ * costs a system confirmation dialog (or a doomed failure) and slows the whole run.+ * The signal is the OS's own installer record — [android.content.pm.PackageManager]+ * fills it in for every install, including ones that predate this feature, so no+ * local history table is needed to backfill it:+ * - [installerPackage] (`installingPackageName`): the last installer of record.+ *   This store's own installs always carry it (explicit on API 34+ via+ *   `setInstallerPackageName`, filled from the calling UID below that).+ * - [updateOwnerPackage] (`updateOwnerPackageName`, API 34+): the update owner,+ *   which survives another store touching the package after us.+ *+ * Edge cases fall out of the comparison rather than special cases:+ * - sideloaded via adb: installer is null, never equal to us — skipped.+ * - Play-installed: installer is `com.android.vending` — skipped.+ * - installed by us before this feature existed: the OS record still names us.+ * - user explicitly taps Update on a skipped app: the single-install path never+ *   consults this, so it still works.+ */+object UpdateEligibility {++    fun installedByStore(+        installerPackage: String?,+        updateOwnerPackage: String?,+        ownPackage: String,+    ): Boolean = installerPackage == ownPackage || updateOwnerPackage == ownPackage+}
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 38a4918a95..52cfbfd0f7 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreDetail.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreDetail.kt@@ -37,6 +37,7 @@ import com.vayunmathur.library.tv.TvButton import com.vayunmathur.library.tv.TvDialog import com.vayunmathur.library.tv.TvEmptyState import com.vayunmathur.library.tv.TvInitialFocus+import com.vayunmathur.library.tv.TvSwitchRow import com.vayunmathur.library.tv.tvContentStart import com.vayunmathur.library.ui.IconBack import com.vayunmathur.library.ui.IconDelete@@ -67,6 +68,7 @@ fun TvStoreDetail(         onOpenInBrowser = viewModel::openInBrowser,         onOpenInPlayStore = viewModel::openInPlayStore,         onDismissFailure = viewModel::dismissInstallFailure,+        onSetIgnored = viewModel::setUpdateIgnored,         onBack = onBack,         modifier = modifier,     )@@ -82,6 +84,7 @@ internal fun TvStoreDetailScreen(     onOpenInBrowser: (String) -> Unit = {},     onOpenInPlayStore: (String) -> Unit = {},     onDismissFailure: (String) -> Unit = {},+    onSetIgnored: (String, Boolean) -> Unit = { _, _ -> },     onBack: () -> Unit = {}, ) {     val app = state.app@@ -115,6 +118,7 @@ internal fun TvStoreDetailScreen(                 onOpen = { onOpen(app.packageName) },                 onUninstall = { showUninstallConfirm = true },                 onDismissFailure = { onDismissFailure(app.packageName) },+                onSetIgnored = { onSetIgnored(app.packageName, it) },                 modifier = Modifier.weight(0.65f).fillMaxHeight(),             )             TvStoreDetailBody(@@ -161,6 +165,7 @@ private fun TvStoreDetailIdentity(     onOpen: () -> Unit,     onUninstall: () -> Unit,     onDismissFailure: () -> Unit,+    onSetIgnored: (Boolean) -> Unit,     modifier: Modifier = Modifier, ) {     val app = state.app ?: return@@ -252,12 +257,43 @@ private fun TvStoreDetailIdentity(                 onClick = onDismissFailure,             )         }+        // Per-app "ignore updates" (§885): same exclusion as the phone — Update+        // All, the count and notifications skip it, but Update above still works.+        TvStoreDetailIgnoreRow(+            appName = app.name,+            ignored = state.updateIgnored,+            visible = state.isInstalled,+            onSetIgnored = onSetIgnored,+        )         // Stats row: Size / Rated / Version, like the phone's facts row.         TvStoreDetailStats(app = app)         TvStoreVerificationLine(state = state)     } } +/**+ * Per-app "ignore updates" toggle (§885). Its own function so the identity+ * pane stays under the complexity cap: excluded from Update All, the count+ * and notifications, but the Update button above still installs.+ */+@Composable+private fun TvStoreDetailIgnoreRow(+    appName: String,+    ignored: Boolean,+    visible: Boolean,+    onSetIgnored: (Boolean) -> Unit,+    modifier: Modifier = Modifier,+) {+    if (!visible) return+    TvSwitchRow(+        headline = stringResource(R.string.detail_ignore_updates, appName),+        checked = ignored,+        onCheckedChange = onSetIgnored,+        supporting = stringResource(R.string.detail_ignore_updates_summary),+        modifier = modifier,+    )+}+ /** 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/TvStoreOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreOps.ktindex 311428c1d4..b53cfdc9a8 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreOps.kt@@ -182,6 +182,8 @@ internal fun TvStoreViewModel.checkForUpdatesImpl() {  * Update everything, sequentially, and report the run once when it is over. Mirrors the  * phone's `updateAllImpl`: concurrent system dialogs would bury the user in prompts,  * and failures are collected and summarised instead of one snackbar per app.+ * Only the eligible batch runs — foreign installs stay listed for an explicit+ * tap, ignored packages are excluded everywhere (#885).  */ internal fun TvStoreViewModel.updateAllImpl() {     if (updateAllJob?.isActive == true) return
appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreUiState.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreUiState.kt b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreUiState.ktindex de1bcc1285..52e3280c2d 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreUiState.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreUiState.kt@@ -71,6 +71,8 @@ data class TvDetailUiState(     val verification: VerificationResult? = null,     /** True while richer Play/Accrescent details are being fetched over the network. */     val isLoadingDetails: Boolean = false,+    /** True when the user asked never to be offered updates for this package (#885). */+    val updateIgnored: Boolean = false, ) {     val isInstalled: Boolean get() = installedInfo != null @@ -99,6 +101,10 @@ data class TvSearchUiState( /** Everything the TV updates hub draws. Same shape as the phone's `UpdatesUiState`. */ data class TvUpdatesUiState(     val updates: List<UnifiedApp> = emptyList(),+    /** Newer versions of packages another store installed: listed, never bulk-run. */+    val foreignUpdates: List<UnifiedApp> = emptyList(),+    /** Updates the user asked never to be offered: listed under their own header. */+    val ignoredUpdates: List<UnifiedApp> = emptyList(),     val installedIcons: Map<String, Drawable> = emptyMap(),     /** Currently-installed info per package, so the row can show old → new versions. */     val installedInfos: Map<String, InstalledInfo> = emptyMap(),
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 e19c728331..7a7b076894 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreUpdates.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreUpdates.kt@@ -52,6 +52,7 @@ fun TvStoreUpdates(         onUpdateAll = viewModel::updateAll,         onInstall = viewModel::install,         onAppClick = onAppClick,+        onIgnore = viewModel::setUpdateIgnored,         modifier = modifier,     ) }@@ -64,9 +65,11 @@ internal fun TvStoreUpdatesScreen(     onUpdateAll: () -> Unit = {},     onInstall: (UnifiedApp) -> Unit = {},     onAppClick: (UnifiedApp) -> Unit = {},+    onIgnore: (String, Boolean) -> Unit = { _, _ -> }, ) {     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(@@ -81,7 +84,7 @@ internal fun TvStoreUpdatesScreen(     // 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)-    if (state.updates.isEmpty() && !state.isChecking) {+    if (total == 0 && state.ignoredUpdates.isEmpty() && !state.isChecking) {         TvEmptyState(             title = stringResource(R.string.all_apps_up_to_date),             body = stringResource(R.string.updates_empty_message),@@ -89,11 +92,18 @@ internal fun TvStoreUpdatesScreen(         )         return     }-    val countTitle = if (state.isChecking && state.updates.isEmpty()) {+    val countTitle = if (state.isChecking && total == 0) {         stringResource(R.string.updates_checking)     } else {-        pluralStringResource(R.plurals.updates_count, state.updates.size, state.updates.size)+        pluralStringResource(R.plurals.updates_count, total, total)     }+    // Resolved outside the grid scope: TvGrid's content lambda is a plain+    // LazyGridScope receiver, not a @Composable context, so stringResource calls+    // cannot live inside it.+    val foreignTitle = stringResource(R.string.updates_foreign_title)+    val foreignSubtitle = stringResource(R.string.updates_foreign_subtitle)+    val ignoredTitle = stringResource(R.string.updates_ignored_title)+    val ignoredSubtitle = stringResource(R.string.updates_ignored_subtitle)     TvGrid(columns = 3, modifier = modifier.fillMaxSize()) {         tvFullWidth(key = "header") {             TvScreenHeader(@@ -127,38 +137,96 @@ internal fun TvStoreUpdatesScreen(             first = true,         )         items(state.updates, key = { it.packageName }) { app ->-            val installed = state.installedInfos[app.packageName]-            val old = installed?.let { info ->-                info.versionName?.let { "$it (${info.versionCode})" }-                    ?: info.versionCode.toString()-            }-            val new = app.versionName?.let { "$it (${app.versionCode})" }-                ?: app.versionCode.toString()-            val versionLabel = old?.let { stringResource(R.string.version_update, it, new) }-            val stage = state.stages[app.packageName]-            val busy = stage != null && stage !is InstallStage.Failed-            // CENTER on the button updates that app; CENTER on the card opens its-            // page. Mirrors the phone's row + trailing Update button.-            TvStoreAppCard(+            TvUpdateCard(                 app = app,-                onClick = { onAppClick(app) },-                installedIcon = state.installedIcons[app.packageName],-                isInstalled = true,-                stage = stage,-                versionLabel = versionLabel,-                trailing = {-                    TvButton(-                        text = if (busy) {-                            stage.tvStageLabel()-                        } else {-                            stringResource(R.string.action_update)-                        },-                        onClick = { onInstall(app) },-                        primary = !busy,-                        enabled = !busy,-                    )-                },+                state = state,+                onAppClick = onAppClick,+                onInstall = { onInstall(app) },+                onIgnore = { onIgnore(app.packageName, true) },             )         }+        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) },+                    onIgnore = { onIgnore(app.packageName, true) },+                )+            }+        }+        if (state.ignoredUpdates.isNotEmpty()) {+            tvGridHeader(+                key = "ignored",+                title = ignoredTitle,+                subtitle = ignoredSubtitle,+            )+            items(state.ignoredUpdates, key = { "ignored-${it.packageName}" }) { app ->+                TvUpdateCard(+                    app = app,+                    state = state,+                    onAppClick = onAppClick,+                    onInstall = { onInstall(app) },+                    ignored = true,+                    onIgnore = { onIgnore(app.packageName, false) },+                )+            }+        }+    }+}++@Composable+private fun TvUpdateCard(+    app: UnifiedApp,+    state: TvUpdatesUiState,+    onAppClick: (UnifiedApp) -> Unit,+    onInstall: () -> Unit,+    ignored: Boolean = false,+    onIgnore: () -> Unit,+) {+    val installed = state.installedInfos[app.packageName]+    val old = installed?.let { info ->+        info.versionName?.let { "$it (${info.versionCode})" }+            ?: info.versionCode.toString()     }+    val new = app.versionName?.let { "$it (${app.versionCode})" }+        ?: app.versionCode.toString()+    val versionLabel = old?.let { stringResource(R.string.version_update, it, new) }+    val stage = state.stages[app.packageName]+    val busy = stage != null && stage !is InstallStage.Failed+    // CENTER on the button updates that app; CENTER on the card opens its+    // page. Mirrors the phone's row + trailing Update button.+    TvStoreAppCard(+        app = app,+        onClick = { onAppClick(app) },+        installedIcon = state.installedIcons[app.packageName],+        isInstalled = true,+        stage = stage,+        versionLabel = versionLabel,+        trailing = {+            if (ignored) {+                TvButton(+                    text = stringResource(R.string.action_show_updates),+                    onClick = onIgnore,+                )+            } else {+                TvButton(+                    text = if (busy) {+                        stage.tvStageLabel()+                    } else {+                        stringResource(R.string.action_update)+                    },+                    onClick = { onInstall() },+                    primary = !busy,+                    enabled = !busy,+                )+            }+        },+    ) }
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 e99be9ce54..4b7b47b98b 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreViewModel.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/tv/TvStoreViewModel.kt@@ -21,6 +21,7 @@ import com.vayunmathur.appstore.data.accrescent.AccrescentRepository import com.vayunmathur.appstore.data.installer.InstallCoordinator import com.vayunmathur.appstore.data.installer.InstallEvents import com.vayunmathur.appstore.data.installer.InstallStage+import com.vayunmathur.appstore.data.partitionUpdates import com.vayunmathur.appstore.data.play.PlayRepository import com.vayunmathur.appstore.data.priority import com.vayunmathur.appstore.data.security.ApkCertificates@@ -113,12 +114,17 @@ class TvStoreViewModel(     internal val playFullClustersFlow = MutableStateFlow<Map<String, List<UnifiedApp>>>(emptyMap())      val detail: StateFlow<TvDetailUiState> = combine(-        selectedAppFlow,-        isLoadingDetailsFlow,-        combine(installedRepo.apps, installedRepo.icons) { installed, icons -> installed to icons },+        combine(+            selectedAppFlow,+            isLoadingDetailsFlow,+            combine(installedRepo.apps, installedRepo.icons) { installed, icons -> installed to icons },+        ) { app, loading, installedPair -> Triple(app, loading, installedPair) },         installer.stages,         installer.verification,-    ) { app, loading, (installed, icons), stages, verification ->+        settings.ignoredUpdates,+    ) { appTriple, stages, verification, ignored ->+        val (app, loading, installedPair) = appTriple+        val (installed, icons) = installedPair         val pkg = app?.packageName         TvDetailUiState(             app = app,@@ -127,6 +133,7 @@ class TvStoreViewModel(             installedIcon = icons[pkg],             verification = verification[pkg],             isLoadingDetails = loading,+            updateIgnored = pkg != null && pkg in ignored,         )     }.stateIn(viewModelScope, SharingStarted.Eagerly, TvDetailUiState()) @@ -165,34 +172,39 @@ class TvStoreViewModel(      * Everything the TV updates hub draws.      *      * Same shape as the phone's `UpdatesUiState`: the merged update list plus the-     * installed versions behind it, so each row can show old → new.+     * installed versions behind it, so each row can show old → new. Ignored and+     * foreign partitions mirror the phone: Update All runs the eligible batch+     * only, and ignored rows surface under their own header with an unignore.      */     val updatesUi: StateFlow<TvUpdatesUiState> = combine(-        catalogUpdatesFlow,-        playUpdatesFlow,-        accrescentUpdatesFlow,+        combine(+            catalogUpdatesFlow,+            playUpdatesFlow,+            accrescentUpdatesFlow,+        ) { catalogUpdates, playUpdates, accrescentUpdates ->+            catalogUpdates + playUpdates + accrescentUpdates+        },         combine(installedRepo.apps, installedRepo.icons, installer.stages) { installed, icons, stages ->             Triple(installed, icons, stages)         },         combine(isCheckingUpdatesFlow, lastUpdateCheckFlow, statusMessageFlow) { checking, checkedAt, message ->             Triple(checking, checkedAt, message)         },-    ) { catalogUpdates, playUpdates, accrescentUpdates, (installed, icons, stages), (checking, checkedAt, message) ->-        // The surviving row's source decides which download-and-verify path the update-        // takes, so it has to be the same precedence search and the home rows use.-        // Re-check against what is on the device rather than trusting the lists: the-        // Play half is a snapshot from the last network check.-        val installedVersions = installed.associate { it.packageName to it.versionCode }-        val list = (catalogUpdates + playUpdates + accrescentUpdates)-            .sortedBy { it.source.priority }-            .distinctBy { it.packageName }-            .filter { app ->-                val installedVersion = installedVersions[app.packageName] ?: return@filter false-                app.versionCode > installedVersion-            }-            .sortedBy { it.name.lowercase() }+        settings.ignoredUpdates,+    ) { pending, installedTriple, statusTriple, ignored ->+        val (installed, icons, stages) = installedTriple+        val (checking, checkedAt, message) = statusTriple+        val partitioned = partitionUpdates(+            pending = pending,+            installed = installed.associateBy { it.packageName },+            enabled = enabledSourcesFlow.value,+            ignoredPackages = ignored,+            ownPackage = context.packageName,+        )         TvUpdatesUiState(-            updates = list,+            updates = partitioned.eligible,+            foreignUpdates = partitioned.foreign,+            ignoredUpdates = partitioned.ignored,             installedIcons = icons,             installedInfos = installed.associateBy { it.packageName },             stages = stages,@@ -634,6 +646,15 @@ class TvStoreViewModel(         viewModelScope.launch { settings.setAutoInstallUpdates(enabled) }     } +    /**+     * Stop offering updates for [packageName] (or offer them again). Mirrors+     * the phone: ignored packages leave Update All, the count and the screen's+     * main list, and appear under the ignored header instead (#885).+     */+    fun setUpdateIgnored(packageName: String, ignored: Boolean) {+        viewModelScope.launch { settings.setUpdateIgnored(packageName, ignored) }+    }+     /** Drop what a source had already contributed to the screens. Mirrors the phone. */     private fun forgetSource(source: AppSource) {         when (source) {
appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailSections.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailSections.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailSections.ktindex c7d235e4e5..598029f97d 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailSections.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/AppDetailSections.kt@@ -29,8 +29,10 @@ import com.vayunmathur.library.ui.HorizontalDivider import com.vayunmathur.library.ui.IconDelete import com.vayunmathur.library.ui.IconDownload import com.vayunmathur.library.ui.IconGlobe+import com.vayunmathur.library.ui.IconVisibilityOff import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.OutlinedButton+import com.vayunmathur.library.ui.SettingsSwitchRow import com.vayunmathur.library.ui.Text import com.vayunmathur.library.ui.TextButton @@ -101,6 +103,19 @@ internal fun AppInstallActions(             )         } +        // Per-app "ignore updates" (§885): excluded from Update All, the count/+        // badge and notifications, but the Update button above still installs —+        // so ignoring is never a dead end.+        if (state.isInstalled) {+            SettingsSwitchRow(+                title = stringResource(R.string.detail_ignore_updates, app.name),+                checked = state.updateIgnored,+                onCheckedChange = { actions.setUpdateIgnored(app.packageName, it) },+                supportingText = stringResource(R.string.detail_ignore_updates_summary),+                leadingContent = { IconVisibilityOff() },+            )+        }+         StageProgress(stage)         if (stage is InstallStage.Failed) {             TextButton(onClick = { actions.dismissInstallFailure(app.packageName) }) {
appstore/src/main/java/com/vayunmathur/appstore/ui/UpdatesPage.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/ui/UpdatesPage.kt b/appstore/src/main/java/com/vayunmathur/appstore/ui/UpdatesPage.ktindex 414415820c..8e9a226f4c 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/ui/UpdatesPage.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/ui/UpdatesPage.kt@@ -30,11 +30,14 @@ import com.vayunmathur.appstore.util.UpdatesUiState import com.vayunmathur.library.ui.AppPullToRefreshBox import com.vayunmathur.library.ui.Button import com.vayunmathur.library.ui.EmptyState+import com.vayunmathur.library.ui.IconButton import com.vayunmathur.library.ui.IconCheck import com.vayunmathur.library.ui.IconDownload+import com.vayunmathur.library.ui.IconVisibilityOff import com.vayunmathur.library.ui.MaterialTheme import com.vayunmathur.library.ui.Scaffold import com.vayunmathur.library.ui.Text+import com.vayunmathur.library.ui.TextButton  /** Binds [AppStoreViewModel] to the stateless [UpdatesScreen]. */ @Composable@@ -55,6 +58,7 @@ fun UpdatesScreen(     onAppClick: (UnifiedApp) -> Unit = {}, ) {     val anyInstalling = state.stages.values.any { it !is InstallStage.Failed }+    val total = state.updates.size + state.foreignUpdates.size      Scaffold { padding ->         AppPullToRefreshBox(@@ -103,7 +107,7 @@ fun UpdatesScreen(                     )                 } -                if (state.updates.isEmpty()) {+                if (total == 0 && state.ignoredUpdates.isEmpty()) {                     EmptyState(                         title = stringResource(R.string.all_apps_up_to_date),                         message = stringResource(R.string.updates_empty_message),@@ -114,47 +118,60 @@ fun UpdatesScreen(                         Modifier.fillMaxSize(),                         contentPadding = PaddingValues(bottom = 24.dp),                     ) {-                        item("count") {-                            Text(-                                pluralStringResource(-                                    R.plurals.updates_count,-                                    state.updates.size,-                                    state.updates.size,-                                ),-                                style = MaterialTheme.typography.titleSmall,-                                modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),-                            )+                        if (total > 0) {+                            item("count") {+                                Text(+                                    pluralStringResource(+                                        R.plurals.updates_count,+                                        total,+                                        total,+                                    ),+                                    style = MaterialTheme.typography.titleSmall,+                                    modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),+                                )+                            }+                            items(state.updates, key = { it.packageName }) { app ->+                                UpdateRow(+                                    app = app,+                                    state = state,+                                    onAppClick = onAppClick,+                                    onInstall = { actions.install(app) },+                                    onIgnore = { actions.setUpdateIgnored(app.packageName, true) },+                                )+                            }+                            if (state.foreignUpdates.isNotEmpty()) {+                                item("foreign-header") {+                                    SectionHeader(+                                        title = stringResource(R.string.updates_foreign_title),+                                        subtitle = stringResource(R.string.updates_foreign_subtitle),+                                    )+                                }+                                items(state.foreignUpdates, key = { "foreign-${it.packageName}" }) { app ->+                                    UpdateRow(+                                        app = app,+                                        state = state,+                                        onAppClick = onAppClick,+                                        onInstall = { actions.install(app) },+                                        onIgnore = { actions.setUpdateIgnored(app.packageName, true) },+                                    )+                                }+                            }                         }-                        items(state.updates, key = { it.packageName }) { app ->-                            val stage = state.stages[app.packageName]-                            val installed = state.installedInfos[app.packageName]-                            val versionLabel = installed?.let { info ->-                                val old = info.versionName?.let { "$it (${info.versionCode})" }-                                    ?: info.versionCode.toString()-                                val new = app.versionName?.let { "$it (${app.versionCode})" }-                                    ?: app.versionCode.toString()-                                stringResource(R.string.version_update, old, new)+                        if (state.ignoredUpdates.isNotEmpty()) {+                            item("ignored-header") {+                                SectionHeader(+                                    title = stringResource(R.string.updates_ignored_title),+                                    subtitle = stringResource(R.string.updates_ignored_subtitle),+                                )+                            }+                            items(state.ignoredUpdates, key = { "ignored-${it.packageName}" }) { app ->+                                IgnoredRow(+                                    app = app,+                                    state = state,+                                    onAppClick = onAppClick,+                                    onUnignore = { actions.setUpdateIgnored(app.packageName, false) },+                                )                             }-                            AppRow(-                                app = app,-                                isInstalled = true,-                                stage = stage,-                                installedIcon = state.installedIcons[app.packageName],-                                versionLabel = versionLabel,-                                onClick = { onAppClick(app) },-                                trailing = {-                                    Button(-                                        onClick = { actions.install(app) },-                                        enabled = stage == null || stage is InstallStage.Failed,-                                    ) {-                                        Text(stringResource(R.string.action_update))-                                    }-                                },-                                // Library keys the same app with the same key, but the tabs are a-                                // pager that only composes the settled page, so the two are never-                                // origins at the same time.-                                sharedKey = "appstore-app-${app.packageName}",-                            )                         }                     }                 }@@ -162,3 +179,82 @@ fun UpdatesScreen(         }     } }++@Composable+private fun SectionHeader(title: String, subtitle: String) {+    Column(Modifier.padding(horizontal = 16.dp, vertical = 8.dp)) {+        Text(title, style = MaterialTheme.typography.titleSmall)+        Text(+            subtitle,+            style = MaterialTheme.typography.labelSmall,+            color = MaterialTheme.colorScheme.onSurfaceVariant,+        )+    }+}++@Composable+private fun UpdateRow(+    app: UnifiedApp,+    state: UpdatesUiState,+    onAppClick: (UnifiedApp) -> Unit,+    onInstall: () -> Unit,+    onIgnore: () -> Unit,+) {+    val stage = state.stages[app.packageName]+    AppRow(+        app = app,+        isInstalled = true,+        stage = stage,+        installedIcon = state.installedIcons[app.packageName],+        versionLabel = versionLabel(app, state),+        onClick = { onAppClick(app) },+        trailing = {+            Row(verticalAlignment = Alignment.CenterVertically) {+                IconButton(onClick = onIgnore) { IconVisibilityOff() }+                Button(+                    onClick = onInstall,+                    enabled = stage == null || stage is InstallStage.Failed,+                ) {+                    Text(stringResource(R.string.action_update))+                }+            }+        },+        // Library keys the same app with the same key, but the tabs are a+        // pager that only composes the settled page, so the two are never+        // origins at the same time.+        sharedKey = "appstore-app-${app.packageName}",+    )+}++@Composable+private fun IgnoredRow(+    app: UnifiedApp,+    state: UpdatesUiState,+    onAppClick: (UnifiedApp) -> Unit,+    onUnignore: () -> Unit,+) {+    AppRow(+        app = app,+        isInstalled = true,+        stage = state.stages[app.packageName],+        installedIcon = state.installedIcons[app.packageName],+        versionLabel = versionLabel(app, state),+        onClick = { onAppClick(app) },+        trailing = {+            TextButton(onClick = onUnignore) {+                Text(stringResource(R.string.action_show_updates))+            }+        },+        sharedKey = null,+    )+}++@Composable+private fun versionLabel(app: UnifiedApp, state: UpdatesUiState): String? {+    val installed = state.installedInfos[app.packageName] ?: return null+    val old = installed.versionName?.let { "$it (${installed.versionCode})" }+        ?: installed.versionCode.toString()+    val new = app.versionName?.let { "$it (${app.versionCode})" }+        ?: app.versionCode.toString()+    return stringResource(R.string.version_update, old, new)+}
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 9d6772486c..062aac82d2 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUiContract.kt@@ -105,6 +105,8 @@ data class AppDetailUiState(     val installedIcon: Drawable? = null,     /** True while richer details are being fetched over the network. */     val isLoadingDetails: Boolean = false,+    /** True when the user asked never to be offered updates for this package (#885). */+    val updateIgnored: Boolean = false, ) {     val isInstalled: Boolean get() = installedInfo != null @@ -115,6 +117,18 @@ data class AppDetailUiState( /** Everything the updates screen draws. */ data class UpdatesUiState(     val updates: List<UnifiedApp> = emptyList(),+    /**+     * Newer versions of packages another store (or adb) installed. Listed under+     * their own header — each still updatable by an explicit tap — but never+     * part of an Update All run (#885).+     */+    val foreignUpdates: List<UnifiedApp> = emptyList(),+    /**+     * Updates the user asked never to be offered. Listed under a collapsed+     * header so they can be unignored; excluded from Update All, the count,+     * the badge and notifications (#885).+     */+    val ignoredUpdates: List<UnifiedApp> = emptyList(),     val installedIcons: Map<String, Drawable> = emptyMap(),     /** Currently-installed info per package, so the row can show old → new versions. */     val installedInfos: Map<String, InstalledInfo> = emptyMap(),@@ -175,6 +189,7 @@ interface AppDetailActions : AppActions {     fun openInBrowser(url: String) {}     fun shareApp(app: UnifiedApp) {}     fun dismissInstallFailure(packageName: String) {}+    fun setUpdateIgnored(packageName: String, ignored: Boolean) {}      companion object {         val Noop: AppDetailActions = object : AppDetailActions {}@@ -185,6 +200,7 @@ interface AppDetailActions : AppActions { interface UpdatesActions : AppActions {     fun checkForUpdates() {}     fun updateAll() {}+    fun setUpdateIgnored(packageName: String, ignored: Boolean) {}      companion object {         val Noop: UpdatesActions = object : UpdatesActions {}
appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.kt
diff --git a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.kt b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.ktindex d1351010eb..f08917ae5b 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreUpdateOps.kt@@ -8,6 +8,7 @@ import com.vayunmathur.appstore.R import com.vayunmathur.appstore.data.AppSource import com.vayunmathur.appstore.data.UnifiedApp import com.vayunmathur.appstore.data.installer.InstallFailureBatch+import com.vayunmathur.appstore.data.installer.SessionInstaller import com.vayunmathur.appstore.data.security.VerificationResult import com.vayunmathur.library.util.AppMessages import kotlinx.coroutines.delay@@ -89,8 +90,11 @@ internal fun AppStoreViewModel.checkForUpdatesImpl() { /**  * Update everything, and report the run once when it is over.  *- * Sequential on purpose: updates this store isn't the update owner of still get a- * system confirmation dialog, and firing them concurrently buries the user in prompts.+ * Only the eligible batch runs: packages this store has never installed would+ * each cost a system confirmation dialog (or a doomed failure) and slow the+ * whole run while the user waits for them to fail, so they stay listed for an+ * explicit tap instead (#885). Sequential on purpose for the same reason —+ * firing even the eligible ones concurrently buries the user in prompts.  *  * The reporting is the other half of issue #630. A run used to say nothing itself and  * let each app's failure raise its own snackbar, so a phone whose updates were all@@ -102,7 +106,9 @@ internal fun AppStoreViewModel.checkForUpdatesImpl() { internal fun AppStoreViewModel.updateAllImpl() {     if (updateAllJob?.isActive == true) return     updateAllJob = viewModelScope.launch {-        val batch = updates.value+        // Eligible only: foreign installs are individually updatable but never+        // bulk-attempted, and ignored packages are excluded everywhere (#885).+        val batch = partitionedUpdates.value.eligible         if (batch.isEmpty()) return@launch         val run = UpdateRun()         InstallFailureBatch.begin()@@ -155,7 +161,7 @@ private class UpdateRun {      * Records one install outcome. Returns true when the run should stop:      * the same reason has failed [REPEATED_FAILURE_LIMIT] times in a row.      */-    fun record(viewModel: AppStoreViewModel, outcome: com.vayunmathur.appstore.data.installer.SessionInstaller.Outcome): Boolean {+    fun record(viewModel: AppStoreViewModel, outcome: SessionInstaller.Outcome): Boolean {         if (outcome.started) {             started++             previousReason = null
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 528528e52e..941c55c7b4 100644--- a/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt+++ b/appstore/src/main/java/com/vayunmathur/appstore/util/AppStoreViewModel.kt@@ -15,10 +15,12 @@ import com.vayunmathur.appstore.data.DefaultRepos import com.vayunmathur.appstore.data.CatalogRepository import com.vayunmathur.appstore.data.InstalledAppsRepository import com.vayunmathur.appstore.data.InstalledInfo+import com.vayunmathur.appstore.data.PartitionedUpdates import com.vayunmathur.appstore.data.PlayStoreLinks import com.vayunmathur.appstore.data.SettingsRepository import com.vayunmathur.appstore.data.SyncStep import com.vayunmathur.appstore.data.UnifiedApp+import com.vayunmathur.appstore.data.partitionUpdates import com.vayunmathur.appstore.data.accrescent.AccrescentRepository import com.vayunmathur.appstore.data.installer.InstallCoordinator import com.vayunmathur.appstore.data.installer.InstallEvents@@ -181,28 +183,46 @@ class AppStoreViewModel(         },         installedRepo.apps,         enabledSources,-    ) { pending, installed, enabled ->-        val installedVersions = installed.associate { it.packageName to it.versionCode }-        pending-            // A disabled source contributes nothing, even if its in-memory snapshot has not-            // been cleared yet (issue #845): the toggle clears Play/Accrescent snapshots-            // via forgetSource, but a cold start can repopulate them before the persisted-            // choice arrives, so the merged list filters rather than trusting them.-            .filter { it.source in enabled }-            // The surviving row's source decides which download-and-verify path the update-            // takes, so it has to be the same precedence search and the library use.-            .sortedBy { it.source.priority }-            .distinctBy { it.packageName }-            // Re-check against what is on the device rather than trusting the lists.-            // playUpdatesFlow is a snapshot from the last network check, so without this a-            // Play app stays in the list after it has been updated, until the next check.-            .filter { app ->-                val installedVersion = installedVersions[app.packageName] ?: return@filter false-                app.versionCode > installedVersion-            }-            .sortedBy { it.name.lowercase() }+        settings.ignoredUpdates,+    ) { pending, installed, enabled, ignored ->+        // Ignored packages are excluded here — before the count, badge and+        // notifications — but explicit taps still install via installImpl (#885).+        partitionUpdates(+            pending = pending,+            installed = installed.associateBy { it.packageName },+            enabled = enabled,+            ignoredPackages = ignored,+            ownPackage = context.packageName,+        ).actionable     }.stateIn(viewModelScope, SharingStarted.Eagerly, emptyList()) +    /**+     * Everything an update check found, including [PartitionedUpdates.ignored]:+     * the updates screen lists ignored rows under their own collapsed header so+     * the user can unignore them. Update All and the badge read [updates], which+     * excludes them.+     */+    val partitionedUpdates: StateFlow<PartitionedUpdates> = combine(+        combine(+            catalogUpdatesFlow,+            playUpdatesFlow,+            accrescentUpdatesFlow,+        ) { catalogUpdates, playUpdates, accrescentUpdates ->+            catalogUpdates + playUpdates + accrescentUpdates+        },+        installedRepo.apps,+        enabledSources,+        settings.ignoredUpdates,+    ) { pending, installed, enabled, ignored ->+        partitionUpdates(+            pending = pending,+            installed = installed.associateBy { it.packageName },+            enabled = enabled,+            ignoredPackages = ignored,+            ownPackage = context.packageName,+        )+    }.stateIn(viewModelScope, SharingStarted.Eagerly, PartitionedUpdates())+     private val sections: StateFlow<List<AppSection>> = combine(         catalog.modernApps,         combine(@@ -303,7 +323,8 @@ class AppStoreViewModel(         isLoadingDetailsFlow,         chrome,         installer.verification,-    ) { app, loading, rows, verification ->+        settings.ignoredUpdates,+    ) { app, loading, rows, verification, ignored ->         val pkg = app?.packageName         AppDetailUiState(             app = app,@@ -312,18 +333,21 @@ class AppStoreViewModel(             stage = rows.stages[pkg],             installedIcon = rows.icons[pkg],             isLoadingDetails = loading,+            updateIgnored = pkg != null && pkg in ignored,         )     }.stateIn(viewModelScope, SharingStarted.Eagerly, AppDetailUiState())      val updatesUi: StateFlow<UpdatesUiState> = combine(-        updates,+        partitionedUpdates,         chrome,         isCheckingUpdatesFlow,         lastUpdateCheckFlow,         statusLine,-    ) { list, rows, checking, checkedAt, message ->+    ) { partitioned, rows, checking, checkedAt, message ->         UpdatesUiState(-            updates = list,+            updates = partitioned.eligible,+            foreignUpdates = partitioned.foreign,+            ignoredUpdates = partitioned.ignored,             installedIcons = rows.icons,             installedInfos = rows.installed.associateBy { it.packageName },             stages = rows.stages,@@ -589,6 +613,18 @@ class AppStoreViewModel(      */     override fun updateAll() = updateAllImpl() +    /**+     * Stop offering updates for [packageName] (or offer them again).+     *+     * Ignored packages leave Update All, the count/badge and notifications, and+     * appear under the updates screen's own ignored header — but an explicit+     * tap on the app's Update button still installs, so ignoring is never a+     * dead end (#885).+     */+    override fun setUpdateIgnored(packageName: String, ignored: Boolean) {+        viewModelScope.launch { settings.setUpdateIgnored(packageName, ignored) }+    }+     /** Turn fully unattended (no-tap) background update installation on or off. */     fun setAutoInstallUpdates(enabled: Boolean) {         viewModelScope.launch { settings.setAutoInstallUpdates(enabled) }
appstore/src/main/res/values/strings.xml
diff --git a/appstore/src/main/res/values/strings.xml b/appstore/src/main/res/values/strings.xmlindex 54923730f6..1f7d6b4b1a 100644--- a/appstore/src/main/res/values/strings.xml+++ b/appstore/src/main/res/values/strings.xml@@ -120,6 +120,18 @@     </plurals>     <!-- Message after Update all when some apps failed. %3$s is the reason the first one gave. -->     <string name="updates_batch_partial">Updated %1$d of %2$d. The rest failed: %3$s</string>+    <!-- Header over updates for apps installed by another store: listed for an explicit+        tap, never part of Update all. -->+    <string name="updates_foreign_title">Installed elsewhere</string>+    <string name="updates_foreign_subtitle">Update all skips these — tap Update on one to update it here.</string>+    <!-- Header over updates the user asked never to be offered, with a way back. -->+    <string name="updates_ignored_title">Ignored updates</string>+    <string name="updates_ignored_subtitle">These never count, notify or join Update all. Tap Show to offer one again.</string>+    <string name="action_ignore_updates">Ignore updates</string>+    <string name="action_show_updates">Show updates</string>+    <!-- Detail-page toggle. %1$s is the app name. -->+    <string name="detail_ignore_updates">Ignore updates for %1$s</string>+    <string name="detail_ignore_updates_summary">Skips Update all, the badge and notifications. You can still update from here.</string>      <!-- Install actions and progress. -->     <string name="action_install">Install</string>
appstore/src/test/java/com/vayunmathur/appstore/data/UpdateListsTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/data/UpdateListsTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/data/UpdateListsTest.ktnew file mode 100644index 0000000000..9e88cfbbd9--- /dev/null+++ b/appstore/src/test/java/com/vayunmathur/appstore/data/UpdateListsTest.kt@@ -0,0 +1,122 @@+package com.vayunmathur.appstore.data++import kotlin.test.Test+import kotlin.test.assertEquals+import kotlin.test.assertTrue++class UpdateListsTest {++    private val self = "com.vayunmathur.appstore"++    private fun app(+        pkg: String,+        source: AppSource = AppSource.MODERN_APPS,+        versionCode: Long = 2L,+    ) = UnifiedApp(packageName = pkg, source = source, name = pkg, versionCode = versionCode)++    private fun installed(+        pkg: String,+        versionCode: Long = 1L,+        installer: String? = self,+    ) = InstalledInfo(+        packageName = pkg,+        name = pkg,+        versionName = null,+        versionCode = versionCode,+        installerPackage = installer,+    )++    private val enabled = setOf(AppSource.MODERN_APPS, AppSource.PLAYSTORE)++    @Test+    fun `own installs are eligible`() {+        val result = partitionUpdates(+            pending = listOf(app("a")),+            installed = mapOf("a" to installed("a")),+            enabled = enabled,+            ignoredPackages = emptySet(),+            ownPackage = self,+        )+        assertEquals(listOf("a"), result.eligible.map { it.packageName })+        assertTrue(result.foreign.isEmpty())+        assertTrue(result.ignored.isEmpty())+    }++    @Test+    fun `play-installed apps are foreign not eligible`() {+        val result = partitionUpdates(+            pending = listOf(+                app("a", AppSource.PLAYSTORE),+                app("b", AppSource.PLAYSTORE),+            ),+            installed = mapOf(+                "a" to installed("a", installer = "com.android.vending"),+                "b" to installed("b", installer = self),+            ),+            enabled = enabled,+            ignoredPackages = emptySet(),+            ownPackage = self,+        )+        assertEquals(listOf("b"), result.eligible.map { it.packageName })+        assertEquals(listOf("a"), result.foreign.map { it.packageName })+    }++    @Test+    fun `ignored apps are excluded everywhere and surfaced separately`() {+        val result = partitionUpdates(+            pending = listOf(app("a"), app("b")),+            installed = mapOf("a" to installed("a"), "b" to installed("b")),+            enabled = enabled,+            ignoredPackages = setOf("a"),+            ownPackage = self,+        )+        assertEquals(listOf("b"), result.eligible.map { it.packageName })+        assertEquals(listOf("a"), result.ignored.map { it.packageName })+    }++    @Test+    fun `ignored foreign app is ignored not foreign`() {+        val result = partitionUpdates(+            pending = listOf(app("a", AppSource.PLAYSTORE)),+            installed = mapOf("a" to installed("a", installer = "com.android.vending")),+            enabled = enabled,+            ignoredPackages = setOf("a"),+            ownPackage = self,+        )+        assertTrue(result.eligible.isEmpty())+        assertTrue(result.foreign.isEmpty())+        assertEquals(listOf("a"), result.ignored.map { it.packageName })+    }++    @Test+    fun `stale and disabled-source rows are dropped before partitioning`() {+        val result = partitionUpdates(+            pending = listOf(+                app("stale", versionCode = 1L),+                app("disabled", source = AppSource.FDROID),+            ),+            installed = mapOf("stale" to installed("stale"), "disabled" to installed("disabled")),+            enabled = setOf(AppSource.MODERN_APPS),+            ignoredPackages = emptySet(),+            ownPackage = self,+        )+        assertTrue(result.eligible.isEmpty())+        assertTrue(result.foreign.isEmpty())+        assertTrue(result.ignored.isEmpty())+    }++    @Test+    fun `update owner counts when installer does not`() {+        val info = installed("a", installer = "com.android.vending").copy(+            updateOwnerPackage = self,+        )+        val result = partitionUpdates(+            pending = listOf(app("a")),+            installed = mapOf("a" to info),+            enabled = enabled,+            ignoredPackages = emptySet(),+            ownPackage = self,+        )+        assertEquals(listOf("a"), result.eligible.map { it.packageName })+    }+}
appstore/src/test/java/com/vayunmathur/appstore/domain/UpdateEligibilityTest.kt
diff --git a/appstore/src/test/java/com/vayunmathur/appstore/domain/UpdateEligibilityTest.kt b/appstore/src/test/java/com/vayunmathur/appstore/domain/UpdateEligibilityTest.ktnew file mode 100644index 0000000000..18b37759c7--- /dev/null+++ b/appstore/src/test/java/com/vayunmathur/appstore/domain/UpdateEligibilityTest.kt@@ -0,0 +1,41 @@+package com.vayunmathur.appstore.domain++import kotlin.test.Test+import kotlin.test.assertFalse+import kotlin.test.assertTrue++class UpdateEligibilityTest {++    private val self = "com.vayunmathur.appstore"++    @Test+    fun `installer of record being us counts as managed`() {+        assertTrue(UpdateEligibility.installedByStore(self, null, self))+    }++    @Test+    fun `update owner being us counts as managed`() {+        assertTrue(UpdateEligibility.installedByStore("com.android.vending", self, self))+    }++    @Test+    fun `play-installed app is not managed`() {+        assertFalse(UpdateEligibility.installedByStore("com.android.vending", null, self))+    }++    @Test+    fun `adb-sideloaded app with no installer record is not managed`() {+        assertFalse(UpdateEligibility.installedByStore(null, null, self))+    }++    @Test+    fun `another store being both installer and owner is not managed`() {+        assertFalse(+            UpdateEligibility.installedByStore(+                "org.fdroid.fdroid",+                "org.fdroid.fdroid",+                self,+            ),+        )+    }+}