Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ public static java.io.File rootfsDir(Context ctx) {
private static volatile boolean archCalculated;

/** True when a system (rootfs) is actually installed on disk — the reliable signal for
* whether "Get more" should skip the destructive system step and go straight to content. */
* whether "Get more" should skip the destructive system step and go straight to content.
*
* <p><b>UI screens: prefer {@code SystemFactsReader.verdict(ctx)} (ADFA-5312).</b> This boolean
* folds "an install is in progress" into false (the marker is held), which is correct for boot /
* server-start / readiness gates but wrong for display: a screen that branches on it alone shows a
* false "no system / Recover" over a system that is present and mid-install. The shared verdict
* tells INSTALLING / NO_SYSTEM / DAMAGED / CLONE_* / READY apart so every screen agrees. */
public static boolean isSystemInstalled(Context ctx) {
// ADFA-4811: a running (or interrupted) install is not "installed" — the rootfs is
// half-baked, so callers must not treat it as ready or auto-start the server over it.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,16 @@ private void render() {
return;
}
receiveBox.setVisibility(View.GONE);
if (!systemPresent) { // ADFA-5150: empty state, like Connect — no system to send, offer Recover
renderNoSystemSend();
if (!systemPresent) { // ADFA-5150: empty state, like Connect — nothing to send
// ADFA-5312: a system op in progress (install/module holds the marker) is not "no system" —
// show busy, not Recover. systemPresent stays isSystemInstalled() on purpose: a clone-send
// holds no install marker, so it still renders the normal Send path above.
if (org.iiab.controller.system.data.SystemFactsReader.verdict(requireContext())
== org.iiab.controller.system.domain.SystemVerdict.State.INSTALLING) {
renderBusySend();
} else {
renderNoSystemSend();
}
return;
}
// ADFA-5154: Send is two pages. Common chrome, then the page.
Expand Down Expand Up @@ -675,6 +683,28 @@ private void renderNoSystemSend() {
footer.setVisibility(View.GONE);
}

/**
* ADFA-5312: a system op (install / module / deep-op) is in progress — the system is present but the
* server is down, so there is nothing to send yet and Recover would be wrong. Mirrors the no-system
* empty state but says "busy" and offers no action; render() reruns on resume when the op finishes.
*/
private void renderBusySend() {
netRow.setVisibility(View.GONE);
steps.setVisibility(View.GONE);
page1.setVisibility(View.GONE);
page2.setVisibility(View.VISIBLE);
if (stepTitle != null) stepTitle.setVisibility(View.GONE);
qr.setImageBitmap(null); qr.setVisibility(View.VISIBLE);
caption.setVisibility(View.VISIBLE);
caption.setText(getString(R.string.k2go_install_busy));
subCaption.setVisibility(View.GONE);
showcode.setVisibility(View.GONE); codeblock.setVisibility(View.GONE);
shareCard.setVisibility(View.GONE);
advance.setVisibility(View.GONE);
actionFooter.setVisibility(View.GONE); // no Recover during an install
footer.setVisibility(View.GONE);
}

/**
* ADFA-5154: Page 1 — Join ① and Get app ② stacked, both live at once. The other phone joins the
* network and installs the app from here; when it's installed, the "Installed? Copy the library"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ private enum Mode { HOTSPOT, WIFI }
private Mode mode = Mode.HOTSPOT;
// ADFA-5150: Connect shares this device's library — with no system there is nothing to serve, and
// the QR would point at a dead port. Read on onResume (a system is not gained while this is open).
private boolean systemPresent = true;

private final LocalHotspotManager hs = LocalHotspotManager.get();
private ActivityResultLauncher<String> locationPerm;
Expand Down Expand Up @@ -112,9 +111,6 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
// turns Wi-Fi on after landing on a blank QR); render() re-reads the IP via discover().
NetworkStateLiveData.get(requireContext()).observe(getViewLifecycleOwner(), net -> render());

// ADFA-5150: seed before the first render so a systemless open never flashes the QR flow;
// onResume re-reads it.
systemPresent = org.iiab.controller.SystemStateEvaluator.isSystemInstalled(requireContext());
setMode(Mode.HOTSPOT);
return v;
}
Expand All @@ -140,9 +136,8 @@ private void ensureHotspot() {
@Override
public void onResume() {
super.onResume();
// ADFA-5150: refresh the system fact on the way to the front and redraw — a system may have
// been recovered while the user was away in the Recover flow this screen sends them to.
systemPresent = org.iiab.controller.SystemStateEvaluator.isSystemInstalled(requireContext());
// ADFA-5150/5312: redraw on the way to the front — a system may have been recovered, or an
// install may have finished, while the user was away. render() re-reads the shared verdict.
render();
}

Expand All @@ -153,7 +148,17 @@ private void render() {
finish.setVisibility(View.GONE);
connFooter.setVisibility(View.VISIBLE); // default; the no-system state hides it
advance.setVisibility(View.GONE);
if (!systemPresent) { noSystemState(); return; }
// ADFA-5312: branch on the shared verdict. During an install the marker made isSystemInstalled()
// read false and this screen offered Recover over a system that is present and mid-setup.
switch (org.iiab.controller.system.data.SystemFactsReader.verdict(requireContext())) {
case NO_SYSTEM:
case DAMAGED:
noSystemState(); return;
case INSTALLING:
busyState(); return;
default:
break; // READY / CLONE_* -> the normal share render handles it
}
if (mode == Mode.HOTSPOT) renderHotspot(); else renderWifi();
}

Expand All @@ -175,6 +180,22 @@ private void noSystemState() {
connFooter.setVisibility(View.GONE); // no "available" note here
}

/**
* ADFA-5312: a system op (install / module / deep-op) is in progress — the system is present but the
* server is deliberately down, so there is nothing to share yet and Recover would be wrong. Say it is
* busy and offer no action; render() reruns on resume when the op finishes.
*/
private void busyState() {
showSingle();
secSingle.frame.setVisibility(View.GONE);
steps.setVisibility(View.GONE);
secSingle.caption.setText(R.string.k2go_install_busy);
secSingle.subCaption.setText("");
secSingle.setFallback(requireContext(), null);
advance.setVisibility(View.GONE);
connFooter.setVisibility(View.GONE);
}

private void renderHotspot() {
LocalHotspotManager.State st = hs.state().getValue();
LocalHotspotManager.Phase phase = (st != null) ? st.phase : LocalHotspotManager.Phase.OFF;
Expand Down
Loading
Loading