Skip to content

Commit af71b30

Browse files
K2GO-395 feat(networkpolicy): bank-before-gate prompt at the Books commit point
Same shape as startZimDownload: startBooksDownload banks the wishlist first, then gates only the drain + navigation, so a declined/offline order is queued not lost. Its drain was already held by the ContentAdmission cost gate; this adds the interactive prompt. ADR-395 updated (Kolibri prompt remains -- async flow).
1 parent f288b75 commit af71b30

2 files changed

Lines changed: 30 additions & 24 deletions

File tree

‎controller/app/src/main/java/org/appdevforall/k2go/redesign/SetupLibraryActivity.java‎

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -524,20 +524,25 @@ public void startBooksDownload() {
524524
v != null && v.length > 2 ? v[2] : "");
525525
}
526526
selection().booksCart().clear();
527-
// ADFA-5074: through the wishlist, like ZIM and Courses. Books was the last door still
528-
// calling its service directly, and that had a real consequence beyond symmetry: the
529-
// service registers its session asynchronously in onStartCommand, so for a moment nothing
530-
// was pending and nothing was in session. The index reads exactly that pair to decide the
531-
// run is over — nothingToStart() plus an empty orchestrateStep — and could declare a
532-
// just-started download complete and count down to the Library. Writing the wishlist first
533-
// makes hasPending true synchronously, before the index is even launched, so that window
534-
// does not exist. It also makes Books queue behind a busy line instead of overwriting.
535-
BooksProvisioner.drain(this);
536-
// ADFA-4988: go to the progress screen instead of returning to Get More and downloading
537-
// invisibly. ADFA-5074: to the index, not the books detail. The hint that used to open the
538-
// detail "when books is the only stream" made the landing depend on state the user cannot
539-
// see, and the index is what ends the run.
540-
startActivity(new Intent(this, SetupProgressActivity.class));
527+
// K2GO-395 (ADR-395 sec.10): the order is banked above; gate only the drain + navigation, so
528+
// a declined or offline order stays queued (ContentAdmission also holds it on metered-without-
529+
// consent). Same shape as startZimDownload.
530+
org.appdevforall.k2go.networkpolicy.presentation.NetworkPolicyGate.guardHeavyStart(this, () -> {
531+
// ADFA-5074: through the wishlist, like ZIM and Courses. Books was the last door still
532+
// calling its service directly, and that had a real consequence beyond symmetry: the
533+
// service registers its session asynchronously in onStartCommand, so for a moment nothing
534+
// was pending and nothing was in session. The index reads exactly that pair to decide the
535+
// run is over — nothingToStart() plus an empty orchestrateStep — and could declare a
536+
// just-started download complete and count down to the Library. Writing the wishlist first
537+
// makes hasPending true synchronously, before the index is even launched, so that window
538+
// does not exist. It also makes Books queue behind a busy line instead of overwriting.
539+
BooksProvisioner.drain(this);
540+
// ADFA-4988: go to the progress screen instead of returning to Get More and downloading
541+
// invisibly. ADFA-5074: to the index, not the books detail. The hint that used to open the
542+
// detail "when books is the only stream" made the landing depend on state the user cannot
543+
// see, and the index is what ends the run.
544+
startActivity(new Intent(this, SetupProgressActivity.class));
545+
});
541546
}
542547

543548
/** ADFA-4850: Books landing -> the download manager screen (per-book checklist + retry). */

‎controller/docs/ADR-395-network-cost-consent.md‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,16 @@ Landed as a compiling, tested starting point for the implementer:
170170
- Enforcement (headless): `ContentAdmission.canStart` defers when
171171
`NetworkCostAdmission.allowsHeavyStartNow` is false, so the ZIM, Books and
172172
Kolibri drains all HOLD a banked order on metered-without-consent (sec.10).
173-
- Wiring: observer started in `IIABApplication`; the ZIM commit point
174-
(`SetupLibraryActivity.startZimDownload`) banks first, then gates the drain, so
175-
a declined/offline order is queued, not lost.
173+
- Wiring: observer started in `IIABApplication`; the ZIM and Books commit points
174+
(`SetupLibraryActivity.startZimDownload` / `startBooksDownload`) bank first, then
175+
gate the drain, so a declined/offline order is queued, not lost.
176176
- Strings translated to all 33 locales (machine-generated, pending human review)
177177
in `values*/strings_networkpolicy.xml`; `strings_untranslated.xml` is clear.
178178

179-
Remaining to finish the contract: the Books/Kolibri commit-point prompts (their
180-
drains are already held), the Maps seam (re-locate post K2GO-394), the
181-
DownloadManager seam, and the two-`hasInternet` fold. (l10n done pending review.)
179+
Remaining to finish the contract: the Kolibri commit-point prompt (its drain is
180+
already held; the ask needs care because the flow is async), the Maps seam
181+
(re-locate post K2GO-394), the DownloadManager seam, and the two-`hasInternet`
182+
fold. (l10n done pending review.)
182183

183184
## 6. Device evidence appendix (dark surfaces flattened)
184185

@@ -303,7 +304,7 @@ happens BEFORE the gate (`SetupLibraryActivity.startZimDownload` banks, then gat
303304
the drain), so a declined or offline order is queued, not lost. This removes the
304305
commit-point special case rather than adding one.
305306

306-
Still open as follow-ups: the Books/Kolibri commit-point prompts (their drains are
307-
already held by the ContentAdmission change; only the interactive ask is missing),
308-
the Maps seam (K2GO-394 reworked Maps; re-locate it), DownloadManager (OTA/portal),
309-
and the two-`hasInternet` fold.
307+
The ZIM and Books commit points now bank-then-prompt. Still open as follow-ups:
308+
the Kolibri commit-point prompt (its drain is already held; the ask needs care
309+
because the flow banks on a background thread), the Maps seam (K2GO-394 reworked
310+
Maps; re-locate it), DownloadManager (OTA/portal), and the two-`hasInternet` fold.

0 commit comments

Comments
 (0)