From f3da19b961adaf811e1c403a4549b16bb97350c6 Mon Sep 17 00:00:00 2001 From: "Luis Guzman (AppDevForAll)" Date: Mon, 10 Aug 2026 13:10:15 -0600 Subject: [PATCH 1/4] ADFA-5074 fix(setup): forget the module install state when the system goes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../redesign/ModuleInstallState.java | 69 +++++++++++++++++++ .../redesign/SetupLibraryActivity.java | 2 + .../system/data/ContentStateInvalidator.java | 17 ++++- 3 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallState.java diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallState.java b/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallState.java new file mode 100644 index 000000000..f80b460d9 --- /dev/null +++ b/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallState.java @@ -0,0 +1,69 @@ +/* + * ============================================================================ + * Name : ModuleInstallState.java + * Author : AppDevForAll + * Copyright : Copyright (c) 2026 AppDevForAll + * Description : The module-install flow's two stores, discarded together + * (ADFA-5074). + * ============================================================================ + */ +package org.iiab.controller.redesign; + +import android.content.Context; +import android.util.Log; + +/** + * Everything the module-install flow remembers between screens, in one place to forget. + * + *

Why this exists. The flow keeps two stores and each was only cleared at the + * moment it happened to be finished with: {@link ModuleWishlist} when the batch is handed + * to the engine, {@link ModuleBatch} when the install index reaches the library. Neither is + * cleared when the system goes away, so both outlived a wipe: + * + *

+ * + *

The content side already had this — four wishlists behind {@code PendingContent} — and + * these two were simply not in that enumeration, because a module install is not content. + * Rather than teach two more call sites to list them, they are cleared together here. + */ +public final class ModuleInstallState { + + private static final String TAG = "K2Go-ModuleState"; + + private ModuleInstallState() { + } + + /** Whether either store still holds something. */ + public static boolean any(Context ctx) { + return ctx != null && (ModuleWishlist.has(ctx) || ModuleBatch.has(ctx)); + } + + /** + * Forgets both: what was scheduled, and what a previous run was installing. + * + *

Called where the content wishlists are dropped — a fresh wizard run, and a completed + * system replacement — because it is the same event for the same reason: the work was + * arranged against a system that no longer exists. + */ + public static void clearAll(Context ctx) { + if (ctx == null) { + return; + } + Context app = ctx.getApplicationContext(); + boolean had = any(app); + ModuleWishlist.clear(app); + ModuleBatch.clear(app); + if (had) { + Log.i(TAG, "module install state discarded (scheduled list + batch)"); + } + } +} diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/SetupLibraryActivity.java b/controller/app/src/main/java/org/iiab/controller/redesign/SetupLibraryActivity.java index 1e7ea0506..1568109fd 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/SetupLibraryActivity.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/SetupLibraryActivity.java @@ -131,6 +131,7 @@ protected void onCreate(Bundle savedInstanceState) { } else if (reinstallMode) { // ADFA-5023: reinstall = the normal first-run wizard, but the final install wipes first. org.iiab.controller.system.data.PendingContent.clearAll(this); + ModuleInstallState.clearAll(this); // ADFA-5074: and the module flow's two first = new Step1SystemFragment(); } else { // ADFA-4874: a fresh wizard run — drop any wishlist left by an aborted first-run so @@ -141,6 +142,7 @@ protected void onCreate(Bundle savedInstanceState) { // The maps selector reached from Home takes the mapsSetup branch above and is // unaffected. org.iiab.controller.system.data.PendingContent.clearAll(this); + ModuleInstallState.clearAll(this); // ADFA-5074: and the module flow's two first = new Step1SystemFragment(); } getSupportFragmentManager().beginTransaction() diff --git a/controller/app/src/main/java/org/iiab/controller/system/data/ContentStateInvalidator.java b/controller/app/src/main/java/org/iiab/controller/system/data/ContentStateInvalidator.java index be4248d75..f412edcda 100644 --- a/controller/app/src/main/java/org/iiab/controller/system/data/ContentStateInvalidator.java +++ b/controller/app/src/main/java/org/iiab/controller/system/data/ContentStateInvalidator.java @@ -25,9 +25,16 @@ * The one place that forgets content state when the system is replaced. * *

{@link SystemReplacement} decides what; this carries it out against - * the seven stores that actually hold it — three in-memory download sessions (ZIM, - * Books, Kolibri) and four on-disk orders (those three plus Maps). Maps has no - * session of its own: it keeps no download progress in the app, only a wishlist. + * the nine stores that actually hold it — three in-memory download sessions (ZIM, + * Books, Kolibri), four on-disk orders (those three plus Maps), and the module-install + * flow's own two, behind {@code ModuleInstallState}. Maps has no session of its own: it + * keeps no download progress in the app, only a wishlist. + * + *

The name undersells it now (ADFA-5074). It began as content only, and the + * module stores were added when a stale batch was found drawing a row for a module from an + * unrelated install. Renaming it would touch every destructive route for no behavioural + * gain, so the name stays and this note carries the truth: what it forgets is state that + * described the system that went away, whether or not that state is content. * *

Two moments, because they have different costs. * @@ -118,6 +125,10 @@ public static void replacementSucceeded(Context ctx, SystemReplacement.Cause cau int discarded = PendingContent.read(app).bankedCount(); PendingContent.clearAll(app); + // ADFA-5074: the module-install flow keeps two stores of its own and neither was in + // this enumeration, because a module is not content. They describe work arranged + // against the system that just went away, which is exactly what this method is for. + org.iiab.controller.redesign.ModuleInstallState.clearAll(app); Log.i(TAG, "after " + cause + ": " + discarded + " pending order(s) discarded"); } From 026eb775a30ac7f8a37f14335276259529c738ed Mon Sep 17 00:00:00 2001 From: "Luis Guzman (AppDevForAll)" Date: Mon, 10 Aug 2026 14:28:44 -0600 Subject: [PATCH 2/4] ADFA-5074 refactor(setup): one door for forgetting pending work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../redesign/GetMoreHubFragment.java | 26 +++++---- .../redesign/ModuleInstallState.java | 17 ++++-- .../redesign/SetupLibraryActivity.java | 6 +- .../system/data/ContentStateInvalidator.java | 9 ++- .../controller/system/data/PendingWork.java | 58 +++++++++++++++++++ 5 files changed, 92 insertions(+), 24 deletions(-) create mode 100644 controller/app/src/main/java/org/iiab/controller/system/data/PendingWork.java diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/GetMoreHubFragment.java b/controller/app/src/main/java/org/iiab/controller/redesign/GetMoreHubFragment.java index 1a4713f41..90dbe5d0c 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/GetMoreHubFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/GetMoreHubFragment.java @@ -50,20 +50,26 @@ public class GetMoreHubFragment extends Fragment { /** One content type on the hub. {@code key} is what SetupLibraryActivity routes on; * {@code endpoint} is the server path probed to decide whether the module is installed - * (so the card shows); {@code note} is the second (bold) line, {@code amber} tints it. */ + * (so the card shows); {@code note} is the second (bold) line. + * + *

ADFA-5074: there was an {@code amber} flag here that tinted the note as a warning. + * Courses was the only card using it, to mark "In-app: TBD" as not ready. The card now + * names what it offers, so the tint had stopped meaning "unfinished" and started meaning + * "something is wrong with this one". A future not-ready card should reintroduce the flag + * deliberately rather than inherit a colour nobody chose. */ private static final class Item { final String key; final String endpoint; final int icon; - final int title; final int desc; final int note; final boolean amber; - Item(String k, String e, int i, int t, int d, int n, boolean a) { - key = k; endpoint = e; icon = i; title = t; desc = d; note = n; amber = a; + final int title; final int desc; final int note; + Item(String k, String e, int i, int t, int d, int n) { + key = k; endpoint = e; icon = i; title = t; desc = d; note = n; } } private static final Item[] ITEMS = { - new Item("wikipedia", "kiwix", R.drawable.ic_card_wikipedia, R.string.k2go_gm_wikipedia_title, R.string.k2go_gm_wikipedia_desc, R.string.k2go_gm_wikipedia_note, false), - new Item("books", "books", R.drawable.ic_card_book, R.string.k2go_gm_books_title, R.string.k2go_gm_books_desc, R.string.k2go_gm_books_note, false), - new Item("maps", "maps", R.drawable.ic_card_maps, R.string.k2go_gm_maps_title, R.string.k2go_gm_maps_desc, R.string.k2go_gm_maps_note, false), - new Item("courses", "kolibri", R.drawable.ic_card_courses, R.string.k2go_gm_courses_title, R.string.k2go_gm_courses_desc, R.string.k2go_gm_courses_note, true), + new Item("wikipedia", "kiwix", R.drawable.ic_card_wikipedia, R.string.k2go_gm_wikipedia_title, R.string.k2go_gm_wikipedia_desc, R.string.k2go_gm_wikipedia_note), + new Item("books", "books", R.drawable.ic_card_book, R.string.k2go_gm_books_title, R.string.k2go_gm_books_desc, R.string.k2go_gm_books_note), + new Item("maps", "maps", R.drawable.ic_card_maps, R.string.k2go_gm_maps_title, R.string.k2go_gm_maps_desc, R.string.k2go_gm_maps_note), + new Item("courses", "kolibri", R.drawable.ic_card_courses, R.string.k2go_gm_courses_title, R.string.k2go_gm_courses_desc, R.string.k2go_gm_courses_note), }; private final Handler main = new Handler(Looper.getMainLooper()); @@ -293,8 +299,8 @@ private void buildCards() { ((TextView) card.findViewById(R.id.k2go_gm_card_desc)).setText(it.desc); TextView note = card.findViewById(R.id.k2go_gm_card_note); note.setText(it.note); - note.setTextColor(androidx.core.content.ContextCompat.getColor(requireContext(), - it.amber ? R.color.k2go_amber_text : R.color.k2go_muted)); + note.setTextColor(androidx.core.content.ContextCompat.getColor( + requireContext(), R.color.k2go_muted)); card.setOnClickListener(v -> { if (!(getActivity() instanceof SetupLibraryActivity)) return; SetupLibraryActivity a = (SetupLibraryActivity) getActivity(); diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallState.java b/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallState.java index f80b460d9..e6d208758 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallState.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallState.java @@ -33,7 +33,14 @@ * *

The content side already had this — four wishlists behind {@code PendingContent} — and * these two were simply not in that enumeration, because a module install is not content. - * Rather than teach two more call sites to list them, they are cleared together here. + * Rather than teach two more call sites to list them, they are cleared together here, and + * both facades sit behind {@code PendingWork} so no caller enumerates anything. + * + *

Not {@code HiddenModules}, which also persists module keys. That one records which + * modules the user chose not to see on Home — a preference about the app, not work arranged + * against a system — so it is meant to outlive a wipe. Named here because it looks like a + * third store to anyone grepping for module keys, and the next person should not have to work + * out why it was left alone. */ public final class ModuleInstallState { @@ -59,11 +66,11 @@ public static void clearAll(Context ctx) { return; } Context app = ctx.getApplicationContext(); - boolean had = any(app); + // Unconditional: asking first cost two SharedPreferences reads purely to decide + // whether to log, and one caller is the wizard's onCreate — main-thread disk for a + // message. Both clears are idempotent, so there is nothing to guard. ModuleWishlist.clear(app); ModuleBatch.clear(app); - if (had) { - Log.i(TAG, "module install state discarded (scheduled list + batch)"); - } + Log.i(TAG, "module install state discarded (scheduled list + batch)"); } } diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/SetupLibraryActivity.java b/controller/app/src/main/java/org/iiab/controller/redesign/SetupLibraryActivity.java index 1568109fd..39e8d7faa 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/SetupLibraryActivity.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/SetupLibraryActivity.java @@ -130,8 +130,7 @@ protected void onCreate(Bundle savedInstanceState) { first = new GetMoreHubFragment(); // ADFA-4848: Get More opens the content hub } else if (reinstallMode) { // ADFA-5023: reinstall = the normal first-run wizard, but the final install wipes first. - org.iiab.controller.system.data.PendingContent.clearAll(this); - ModuleInstallState.clearAll(this); // ADFA-5074: and the module flow's two + org.iiab.controller.system.data.PendingWork.clearAll(this); first = new Step1SystemFragment(); } else { // ADFA-4874: a fresh wizard run — drop any wishlist left by an aborted first-run so @@ -141,8 +140,7 @@ protected void onCreate(Bundle savedInstanceState) { // others were, so an abandoned run's map selection survived into the next one. // The maps selector reached from Home takes the mapsSetup branch above and is // unaffected. - org.iiab.controller.system.data.PendingContent.clearAll(this); - ModuleInstallState.clearAll(this); // ADFA-5074: and the module flow's two + org.iiab.controller.system.data.PendingWork.clearAll(this); first = new Step1SystemFragment(); } getSupportFragmentManager().beginTransaction() diff --git a/controller/app/src/main/java/org/iiab/controller/system/data/ContentStateInvalidator.java b/controller/app/src/main/java/org/iiab/controller/system/data/ContentStateInvalidator.java index f412edcda..01476b783 100644 --- a/controller/app/src/main/java/org/iiab/controller/system/data/ContentStateInvalidator.java +++ b/controller/app/src/main/java/org/iiab/controller/system/data/ContentStateInvalidator.java @@ -124,11 +124,10 @@ public static void replacementSucceeded(Context ctx, SystemReplacement.Cause cau Context app = ctx.getApplicationContext(); int discarded = PendingContent.read(app).bankedCount(); - PendingContent.clearAll(app); - // ADFA-5074: the module-install flow keeps two stores of its own and neither was in - // this enumeration, because a module is not content. They describe work arranged - // against the system that just went away, which is exactly what this method is for. - org.iiab.controller.redesign.ModuleInstallState.clearAll(app); + // ADFA-5074: through PendingWork, so this and the wizard's own clear-on-open ask the + // same question. Listing the facades here as well would put the enumeration back in + // two places, which is how the module stores came to be missing from it. + PendingWork.clearAll(app); Log.i(TAG, "after " + cause + ": " + discarded + " pending order(s) discarded"); } diff --git a/controller/app/src/main/java/org/iiab/controller/system/data/PendingWork.java b/controller/app/src/main/java/org/iiab/controller/system/data/PendingWork.java new file mode 100644 index 000000000..3eb2d4804 --- /dev/null +++ b/controller/app/src/main/java/org/iiab/controller/system/data/PendingWork.java @@ -0,0 +1,58 @@ +/* + * ============================================================================ + * Name : PendingWork.java + * Author : AppDevForAll + * Copyright : Copyright (c) 2026 AppDevForAll + * Description : One door for forgetting everything arranged against a system + * that is gone (ADFA-5074). + * ============================================================================ + */ +package org.iiab.controller.system.data; + +import android.content.Context; + +/** + * Discards every order the user placed against a system that no longer exists. + * + *

Why one more class rather than two calls. There are two families of pending + * work — content orders behind {@link PendingContent}, and the module-install flow's own two + * stores behind {@code ModuleInstallState} — and for a while both call sites listed them in + * a pair: + * + *

+ *     PendingContent.clearAll(ctx);
+ *     ModuleInstallState.clearAll(ctx);
+ * 
+ * + *

That is the same mistake as before, one level up. It began as six stores enumerated by + * hand in five screens; consolidating them into two facades left three places enumerating + * the two facades. A seventh store tomorrow would need adding in all of them, and the one + * that got missed would be the one nobody tested — which is precisely how a stale module + * batch ended up drawing a row for an install that never happened. + * + *

So the list lives here, and both moments ask the same question. + * + *

Two moments, one reason. A fresh wizard run drops whatever an abandoned earlier + * run left behind, and a completed system replacement drops the orders placed against the box + * that was wiped. They arrive by different routes but they are the same event: the work was + * arranged against a system that is no longer there. + * + *

Touches SharedPreferences, so prefer calling it off the main thread. The wizard path + * calls it during {@code onCreate} because that is where the decision is made; the writes are + * {@code apply()} and asynchronous. + */ +public final class PendingWork { + + private PendingWork() { + } + + /** Everything: content orders, and the module flow's scheduled list and batch. */ + public static void clearAll(Context ctx) { + if (ctx == null) { + return; + } + Context app = ctx.getApplicationContext(); + PendingContent.clearAll(app); + org.iiab.controller.redesign.ModuleInstallState.clearAll(app); + } +} From 4fd2a6d0dee2b45cd4179032f63a4d552a09cab2 Mon Sep 17 00:00:00 2001 From: "Luis Guzman (AppDevForAll)" Date: Mon, 10 Aug 2026 14:38:19 -0600 Subject: [PATCH 3/4] ADFA-5074 fix(setup): the queue's verdict belongs to one run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../redesign/ModuleInstallState.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallState.java b/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallState.java index e6d208758..690a6c080 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallState.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/ModuleInstallState.java @@ -12,6 +12,8 @@ import android.content.Context; import android.util.Log; +import org.iiab.controller.install.presentation.ModuleQueueRepository; + /** * Everything the module-install flow remembers between screens, in one place to forget. * @@ -49,7 +51,7 @@ public final class ModuleInstallState { private ModuleInstallState() { } - /** Whether either store still holds something. */ + /** Whether either persisted store still holds something. */ public static boolean any(Context ctx) { return ctx != null && (ModuleWishlist.has(ctx) || ModuleBatch.has(ctx)); } @@ -71,6 +73,20 @@ public static void clearAll(Context ctx) { // message. Both clears are idempotent, so there is nothing to guard. ModuleWishlist.clear(app); ModuleBatch.clear(app); - Log.i(TAG, "module install state discarded (scheduled list + batch)"); + + // ADFA-5074: and the queue's own verdict, which is held in memory for the life of the + // process. A finished install leaves it on DONE, and the install index reads that phase + // to decide whether a row is complete — so a new run drew a green check over a maps + // install that had not started, and only corrected itself when the real runrole + // published RUNNING. The row was trusting a verdict without asking whose it was. + // + // Never over a live one: a runrole in flight owns this 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. + ModuleQueueRepository queue = ModuleQueueRepository.get(); + if (!queue.isRunning()) { + queue.postIdle(); + } + Log.i(TAG, "module install state discarded (scheduled list, batch, queue verdict)"); } } From 8b846640ec2de4239c7b37f5e499aa52e98f7224 Mon Sep 17 00:00:00 2001 From: "Luis Guzman (AppDevForAll)" Date: Mon, 10 Aug 2026 19:05:43 -0600 Subject: [PATCH 4/4] ADFA-5074 fix(setup): do not offer an escape before knowing the run's shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../redesign/SetupProgressActivity.java | 9 +++++- .../ADR-5061-rest-vs-proot-operation-model.md | 14 +++++++++ controller/docs/content-execution-order.svg | 31 ++++++++++--------- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/SetupProgressActivity.java b/controller/app/src/main/java/org/iiab/controller/redesign/SetupProgressActivity.java index 5e09c3315..3c042acd4 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/SetupProgressActivity.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/SetupProgressActivity.java @@ -659,7 +659,14 @@ private void render() { show(redirect, false); show(cancel, false); } else { // starting or running cancelRedirect(); - show(runBgBtn, !prootActive); // ADFA-4919: no "Run in background" while a proot module runs — the index is the gate + // ADFA-4919: no "Run in background" while a proot module runs — the index is the gate. + // ADFA-5074: and not before the run's shape is known either. prootActive() reads a latch + // that only engages once the proot work registers — launched, batched, or reported by the + // queue — so on entry it is false even for a run that is about to install a module, and + // the screen offered an escape it was going to withdraw. Waiting for servicesReady costs + // nothing: until the engine answers there is no live work to leave running anyway, and + // the header already says "Starting services…". + show(runBgBtn, servicesReady && !prootActive); show(finishBtn, false); show(finishNote, false); show(redirect, false); show(cancel, false); } } diff --git a/controller/docs/ADR-5061-rest-vs-proot-operation-model.md b/controller/docs/ADR-5061-rest-vs-proot-operation-model.md index 21e38f77e..4fec80ca4 100644 --- a/controller/docs/ADR-5061-rest-vs-proot-operation-model.md +++ b/controller/docs/ADR-5061-rest-vs-proot-operation-model.md @@ -353,6 +353,20 @@ most expensive by the third platform. A is B done safely over time. The point of the indirection is that changing it later is one line, and that a module which turns out to need its own can have it without anyone touching a layout. + **Serialising is not the net it looks like** (noted, not blocking). The three live + streams are meant to run one at a time, which was the poor man's stand-in for a disk + budget: if only one runs, each selector's free-space reading is roughly valid. + `ZimProvisioner.drain` starts asynchronously, though — it fetches the Kiwix catalogue + first and only starts the service from the callback — so within one + `orchestrateStep` pass Books and Courses look at a ZIM that has no session yet and + start too. Three at once, observed on device. + + Not urgent and deliberately not part of ADFA-5074: the fix would have the guard count + an order already handed to a drain, not just a session in flight, and that changes + serialisation semantics with a real risk of two flows waiting on each other. And it + would still only be a stand-in — the honest answer is the run-level budget above. + Recorded so it is not rediscovered as a surprise. + Also decide **which lifetime each piece of state gets**. Three mechanisms are in use and nothing says which is for what: a `ViewModel` (survives a configuration change only), a `SavedStateHandle` (also survives a process death, riding the task's instance state), and diff --git a/controller/docs/content-execution-order.svg b/controller/docs/content-execution-order.svg index 6ef5c2704..bc81261e0 100644 --- a/controller/docs/content-execution-order.svg +++ b/controller/docs/content-execution-order.svg @@ -1,4 +1,4 @@ - + Content installation — mechanism and order How the four content types install: which mechanism each uses, why they are serialised, where the server is stopped, and what is still unsolved. Companion to operation-model-roadmap.svg, which tracks ticket state rather than behaviour. Update when the behaviour changes, not when a ticket moves. @@ -30,7 +30,7 @@ - + Content installation — mechanism and order Four content types, two mechanisms. What runs when, what waits for what, and why. @@ -91,26 +91,29 @@ InstallService.runModuleQueue():704 - + OPEN No run-level disk budget Each selector does block: it compares its own total against StatFs at the moment it is opened. But a banked order is not on disk yet, so two selections can each fit and jointly overflow — and the one that drains second dies mid-download with tens of GB already written. The wizard DOES show the running total ("Your picks 9.4 GB"); what none of them does is subtract it before deciding. The sum informs, it does not guard. -ZimConfirmFragment:94 · MapsChooseFragment:270 · KolibriConfirmFragment:211 — three readings, three moments, no total +And serialising is not the safety net it looks like: ZimProvisioner.drain starts asynchronously (catalogue fetch first), so in the +same orchestrateStep pass Books and Courses see no session yet and start too. Observed on device: three streams at once. +ZimConfirmFragment:94 · MapsChooseFragment:270 · KolibriConfirmFragment:211 — three readings, three moments, no total +Noted, not blocking: nice-to-have, and the real answer is the budget rather than tighter serialising. Do not let it displace the ticket. - - -OPEN -Five landings for one kind of work — owned by ADFA-5074 -Wizard, all four types: the order is banked and the user returns to the hub. No progress surface at all until after the install. -Get More: ZIM → ZimPreparingFragment inside SetupLibraryActivity · Books → the index, with a hint that jumps straight to the detail · -Maps → the index list · Courses → KolibriSeedingFragment inside SetupLibraryActivity. -The screens are NOT duplicated: SetupProgressActivity.openDetail() hosts those same fragments, with a fromIndex flag for the chrome. -What differs is the host, so Back still walks out of a live download and a notification returns you to a different screen than you left. -Closed already: the Home header opens the index (PR 1) · a finished session no longer gates anything (PR 2). Hosting is what remains. + + +OPEN +Five landings for one kind of work — owned by ADFA-5074 +Wizard, all four types: the order is banked and the user returns to the hub. No progress surface at all until after the install. +Get More: ZIM → ZimPreparingFragment inside SetupLibraryActivity · Books → the index, with a hint that jumps straight to the detail · +Maps → the index list · Courses → KolibriSeedingFragment inside SetupLibraryActivity. +The screens are NOT duplicated: SetupProgressActivity.openDetail() hosts those same fragments, with a fromIndex flag for the chrome. +What differs is the host, so Back still walks out of a live download and a notification returns you to a different screen than you left. +Closed already: the Home header opens the index (PR 1) · a finished session no longer gates anything (PR 2). Hosting is what remains.