From 87bfa41488dcab9b98bf4994a899cf595f3046d6 Mon Sep 17 00:00:00 2001 From: Luis Guzman Date: Fri, 30 Oct 2026 07:15:31 -0600 Subject: [PATCH] K2GO-515 fix(library): consume cancelled-install state so Copy from a phone opens Clone The terminal CANCELLED install state (an in-memory singleton, set on cancel) was never cleared, so LibraryActivity's observer bounced ANY open to the download chooser, including "Copy from a phone". Now it consumes the one-shot (postIdle) and routes back only when this instance was the install monitor (the installing field), matching the FAILED branch's own-install guard. --- .../appdevforall/k2go/redesign/LibraryActivity.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/controller/app/src/main/java/org/appdevforall/k2go/redesign/LibraryActivity.java b/controller/app/src/main/java/org/appdevforall/k2go/redesign/LibraryActivity.java index c307e4e3e..00cbce6c0 100644 --- a/controller/app/src/main/java/org/appdevforall/k2go/redesign/LibraryActivity.java +++ b/controller/app/src/main/java/org/appdevforall/k2go/redesign/LibraryActivity.java @@ -302,6 +302,9 @@ public android.graphics.Typeface fetchFont(String fontFamily) { showInstallProgress(st); } else if (st.isTerminal()) { hideInstallProgress(); + // K2GO-515: was THIS instance the install monitor? (EXTRA_INSTALLING / a live install at + // open / it saw the install run.) Captured before the reset below; see the CANCELLED branch. + boolean wasMonitoringInstall = installing; installing = false; // install finished; let the server-alive observer lift the gate // ADFA-5119: the user gave up on this install. The service has already removed the // partial download, the half-written rootfs and the wishlists, and cleared @@ -310,7 +313,12 @@ public android.graphics.Typeface fetchFont(String fontFamily) { // this ticket exists to close. Go back to the decision instead: the tier and the // content, chosen again from the start. if (st.phase == InstallState.Phase.CANCELLED) { - if (!isFinishing()) { + // K2GO-515: CANCELLED is a one-shot "route back to the choice". Consume it (postIdle) + // so a stale CANCELLED cannot hijack a later unrelated open (e.g. "Copy from a phone" + // opening the Clone tab). Only the install-monitor instance routes back; others just + // clear the stale signal. (FAILED already gates on "our install" via InstallGuard.isLive.) + InstallProgressRepository.get().postIdle(); + if (wasMonitoringInstall && !isFinishing()) { startActivity(new android.content.Intent(this, SetupLibraryActivity.class)); finish(); }