Repository navigation
ADFA-5074 fix(setup): forget the module install state when the system goes - #380
Merged
Merged
Conversation
… goes Reinstalling with Full, after Books reader had been installed by hand on the previous system, drew a "Books reader" row in the install index for a module this run never asked for. The module-install flow keeps two stores, and each was only cleared at the moment it happened to be finished with: `ModuleWishlist` when the batch is handed to the engine, `ModuleBatch` when the index reaches the library. Neither is cleared when the *system* goes away, so both outlived a wipe. They were not in the enumeration `PendingContent` owns, because a module install is not content. Worse than the stale row: `SetupProgressActivity.moduleInSession()` latches on `ModuleBatch`, and that decides whether the index becomes a gate, whether "Run in background" is offered, and whether the post-runrole server restart is awaited. A leftover batch changes how the screen behaves, not just how it looks. And a second store turned up while fixing the first, with a worse failure: a stale `ModuleWishlist` is a scheduled install that survived the box it was scheduled against — at best repeating work the new tier already ships, at worst running a runrole nobody asked for in this run. `ModuleInstallState.clearAll` forgets both, called from the two places that already drop the content orders — a fresh wizard run, and a completed system replacement — because it is the same event for the same reason. `ContentStateInvalidator` now clears nine stores rather than seven, so its name undersells it. Renaming would touch all five destructive routes for no behavioural gain, so the name stays and its javadoc carries the correction: what it forgets is state that described the system that went away, whether or not that state is content. **Verification.** Unit tests and lint on your run; nothing pure to add here, it is all SharedPreferences. On device: install Standard, install Books reader by hand from Module management, let it finish, then reinstall with Full choosing all four content categories — the Books reader row must not appear. And a plain Module management install must still show its row as before, which is what proves this did not clear too eagerly.
Review follow-ups. The wizard's clear-on-open and the replacement each listed the two facades in a pair, which is the same enumeration by hand one level up: six stores in five screens became two facades in three places. PendingWork.clearAll holds the list now, and both moments ask it — a seventh store is one line in one place. ModuleInstallState no longer asks before clearing. That cost two SharedPreferences reads purely to decide whether to log, and one caller is the wizard's onCreate; both clears are idempotent. Records why HiddenModules is not in there: it persists module keys too, but it is a preference about what the user sees on Home, not work arranged against a system, so it is meant to outlive a wipe. And the Courses hub card's note is no longer amber. The tint was a deliberate marker for "In-app: TBD"; with the card naming what it offers, amber had stopped meaning "unfinished" and started meaning "something is wrong with this one". Courses was the only card using the flag, so the flag goes too — a future not-ready card should reintroduce it on purpose.
The install index drew a green check over a maps install that had not started. mapsRow() decides "done" from ModuleQueueRepository's phase, and that repository is a process singleton: a module installed earlier by hand left it on DONE, so a new run read a verdict without asking whose it was. It corrected itself only once the real runrole published RUNNING. Same omission as the failure count, which was gated on queueVerdictIsOurs in an earlier commit while the row was left reading the phase directly. The state is now reset with the flow's other two stores — it is the same thing, held in memory rather than in preferences. Never over a live queue: a runrole in flight owns that state and posting idle under it would replace a true report with a false one. On a replacement the queue has already been stopped; on a fresh wizard run there is nothing to stop. Maps still runs on a Full reinstall, which is correct: the image ships the module, not the tiles, and the wizard banked a tile selection.
… shape The index showed "Run in background" while the header still said "Starting services…" and every row was Queued — including runs about to install a proot module, which is exactly what that button must not offer. prootActive() reads a latch that engages only once the proot work registers: launched, batched, or reported by the queue. On entry none of that has happened, so it answers false for a run that is about to be gated, and the screen offered an escape it would then withdraw. Gated on servicesReady rather than taught to predict the work. Until the engine answers there is no live work to leave running, so the button was offering nothing in that window; and inferring proot work from another source would add one more place that knows the same thing. The other window is left alone on purpose: once a module has finished and the server is back, the button returns, which is correct — only proot may trap the user, and it no longer is.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reinstalling with Full, after Books reader had been installed by hand on the previous system, drew a "Books reader" row in the install index for a module this run never asked for.
The module-install flow keeps two stores, and each was only cleared at the moment it happened to be finished with:
ModuleWishlistwhen the batch is handed to the engine,ModuleBatchwhen the index reaches the library. Neither is cleared when the system goes away, so both outlived a wipe. They were not in the enumerationPendingContentowns, because a module install is not content.Worse than the stale row:
SetupProgressActivity.moduleInSession()latches onModuleBatch, and that decides whether the index becomes a gate, whether "Run in background" is offered, and whether the post-runrole server restart is awaited. A leftover batch changes how the screen behaves, not just how it looks.And a second store turned up while fixing the first, with a worse failure: a stale
ModuleWishlistis a scheduled install that survived the box it was scheduled against — at best repeating work the new tier already ships, at worst running a runrole nobody asked for in this run.ModuleInstallState.clearAllforgets both, called from the two places that already drop the content orders — a fresh wizard run, and a completed system replacement — because it is the same event for the same reason.ContentStateInvalidatornow clears nine stores rather than seven, so its name undersells it. Renaming would touch all five destructive routes for no behavioural gain, so the name stays and its javadoc carries the correction: what it forgets is state that described the system that went away, whether or not that state is content.Verification. Unit tests and lint on your run; nothing pure to add here, it is all SharedPreferences. On device: install Standard, install Books reader by hand from Module management, let it finish, then reinstall with Full choosing all four content categories — the Books reader row must not appear. And a plain Module management install must still show its row as before, which is what proves this did not clear too eagerly.
A third store turned up while verifying this: ModuleQueueRepository holds the queue's verdict in memory for the life of the process, and the index reads that phase to decide whether a row is done. A module installed earlier by hand left it on DONE, so a Full reinstall drew a green check over a maps install that had not started, correcting itself only once the real runrole published RUNNING. It is reset with the other two, never over a live queue.
Two more found while verifying this branch, both the same shape — a screen
reading state that did not belong to this run.
ModuleQueueRepository holds the queue's verdict in memory for the life of the process, and the index reads that phase to decide whether a row is done. A module installed earlier by hand left it on DONE, so a Full reinstall drew a
green check over a maps install that had not started. Reset with the flow's other two stores, never over a live queue.
And the index offered "Run in background" while the header still said "Starting services…" and every row was Queued — including runs about to install a proot module, which must not offer it. prootActive() reads a latch that
engages only once the proot work registers, so on entry it answers false for a run that is about to be gated. Gated on servicesReady rather than taught to predict the work: until the engine answers there is nothing live to leave
running.
Verified on device: Analytics (Matomo) installs with no escape offered and the app can be left and returned to; a REST-only run offers it once services answer; a module install still shows its check when it really finishes; and entering a reinstall logs the state being discarded.