diff --git a/controller/app/src/main/java/org/iiab/controller/SystemStateEvaluator.java b/controller/app/src/main/java/org/iiab/controller/SystemStateEvaluator.java index 4589b08fa..3bc2aac99 100644 --- a/controller/app/src/main/java/org/iiab/controller/SystemStateEvaluator.java +++ b/controller/app/src/main/java/org/iiab/controller/SystemStateEvaluator.java @@ -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. + * + *

UI screens: prefer {@code SystemFactsReader.verdict(ctx)} (ADFA-5312). 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. diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/CloneFragment.java b/controller/app/src/main/java/org/iiab/controller/redesign/CloneFragment.java index 4ac8132f1..872ffd331 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/CloneFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/CloneFragment.java @@ -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. @@ -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" diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/ConnectFragment.java b/controller/app/src/main/java/org/iiab/controller/redesign/ConnectFragment.java index 49190875b..8ba2bdec8 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/ConnectFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/ConnectFragment.java @@ -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 locationPerm; @@ -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; } @@ -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(); } @@ -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(); } @@ -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; diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/LibraryHomeFragment.java b/controller/app/src/main/java/org/iiab/controller/redesign/LibraryHomeFragment.java index 6d942658a..6825184cb 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/LibraryHomeFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/LibraryHomeFragment.java @@ -53,7 +53,12 @@ public class LibraryHomeFragment extends Fragment { H_CLONE_RECEIVING = 6, H_CLONE_SHARING = 7, // ADFA-5147: a system is on disk but was left unbootable (a killed install or clone). Split // out of H_NO_LIBRARY, which offered to install over it — this offers to repair it instead. - H_DAMAGED = 8; + H_DAMAGED = 8, + // ADFA-5312: a system op is in progress with the server deliberately DOWN (a proot module, + // a rootfs install, or a deep op). That is "wait", so it is rendered amber like the clone + // states — NOT the green "Adding content" of H_INSTALLING, which is a content download over + // a live, navigable box. Same "See progress" action, different colour + label. + H_INSTALLING_SYSTEM = 9; // ADFA-4837: how long a card stays amber (patient) once the box is up before it's called stuck. private static final long CARD_RED_GRACE_MS = 60000L; @@ -106,7 +111,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c homeStatusAction.setOnClickListener(v -> { // ADFA-5074: the way back into a running install. Opens the index without // starting anything — every other route to it begins new work. - if (headerState == H_INSTALLING) { + if (headerState == H_INSTALLING || headerState == H_INSTALLING_SYSTEM) { startActivity(new android.content.Intent( requireContext(), SetupProgressActivity.class)); return; @@ -293,10 +298,22 @@ private void openGetMore() { } return; } - // If a system is already installed, skip the destructive system step and go straight - // to content (Step 2). Otherwise run the full setup from Step 1. + // ADFA-5312: the content-only vs full-setup decision (and the busy guard) come from the shared + // verdict. A running proot module holds the install marker but NOT the env-lock owner, so the + // ownerHeld guard above misses it — without this, "Get more" during a module install would + // launch the destructive full setup over a system that is present and mid-install. + org.iiab.controller.system.domain.SystemVerdict.State verdict = + org.iiab.controller.system.data.SystemFactsReader.verdict(requireContext()); + if (verdict == org.iiab.controller.system.domain.SystemVerdict.State.INSTALLING) { + if (getView() != null) { + org.iiab.controller.util.Snackbars.make(getView(), R.string.k2go_install_busy).show(); + } + return; + } + // A ready system skips the destructive system step and goes straight to content (Step 2); + // otherwise (no system / damaged) run the full setup from Step 1. Intent i = new Intent(requireContext(), SetupLibraryActivity.class); - if (org.iiab.controller.SystemStateEvaluator.isSystemInstalled(requireContext())) { + if (verdict == org.iiab.controller.system.domain.SystemVerdict.State.READY) { i.putExtra(SetupLibraryActivity.EXTRA_CONTENT_ONLY, true); } startActivity(i); @@ -365,13 +382,20 @@ private static String authServiceFor(String endpoint) { private void openSheet(Card c) { ModuleActionSheet.State s; final PlatformPresence.Evidence ev = PlatformEvidence.last(c.endpoint); + // ADFA-5312: the "no usable system" decision comes from the shared verdict, so a card's sheet + // can't collapse to Recover during an install (marker held) the way bare !systemInstalled did. + org.iiab.controller.system.domain.SystemVerdict.State verdict = + org.iiab.controller.system.data.SystemFactsReader.verdict(requireContext()); if (c.state == GREEN || contentInFlight(c)) s = ModuleActionSheet.State.READY; else if (isScheduled(c)) s = ModuleActionSheet.State.SCHEDULED; - else if (!systemInstalled) { + else if (verdict == org.iiab.controller.system.domain.SystemVerdict.State.NO_SYSTEM + || verdict == org.iiab.controller.system.domain.SystemVerdict.State.DAMAGED) { // ADFA-5150: no system to install a module into. This used to be NOT_INSTALLED — About / // Install now / Schedule — which banked an install order with nothing to drain it. The // sheet now collapses to Recover. (A first-run phone never reaches this surface; the wizard // runs before the tabs, so a systemless card here always means a system was lost.) + // ADFA-5312: gated on the verdict (NO_SYSTEM/DAMAGED), not bare !systemInstalled, so a + // mid-install marker no longer routes a card to Recover. s = ModuleActionSheet.State.NO_SYSTEM; } else if (ev != null && !PlatformPresence.resolve(ev)) { // Known absent, and still known absent with the box off — that is the state where @@ -433,11 +457,21 @@ private boolean unsupported(Card c) { */ private boolean systemInstalled = true; + /** + * ADFA-5312: the shared system verdict, read once per pass alongside {@link #passContent} and + * {@link #systemInstalled} — so the cards and the header decide from ONE reading rather than two + * taken moments apart (the same "once per decision" reason SystemFactsReader states). Seeded READY + * so paths before the first pass behave as they did. + */ + private org.iiab.controller.system.domain.SystemVerdict.State passVerdict = + org.iiab.controller.system.domain.SystemVerdict.State.READY; + private void refreshStatuses() { boolean installed = org.iiab.controller.SystemStateEvaluator.isSystemInstalled(requireContext()); systemInstalled = installed; boolean alive = ServerStateRepository.get().current().alive; passContent = org.iiab.controller.system.data.PendingContent.read(requireContext()); + passVerdict = org.iiab.controller.system.data.SystemFactsReader.verdict(requireContext()); // ADFA-4837: track when the server first came up; the card red-grace is measured from here. if (alive) { if (serverAliveSinceMs == 0L) serverAliveSinceMs = android.os.SystemClock.elapsedRealtime(); } @@ -446,7 +480,12 @@ private void refreshStatuses() { // ADFA-4828: nothing installed (or an install is running — the boot gate normally covers // that). The home isn't starting anything, so don't imply it: the cards read "Not installed" // and the header points to Get more (set in updateHeaderFromCards). - if (!installed) { + // ADFA-5312: only paint every card "Not installed" when there is genuinely no usable system — + // nothing on disk (NO_SYSTEM) or a killed install left it damaged (DAMAGED). During an install, + // clone or deep op the system is present/arriving, so fall through and keep last-known state. + // Uses the once-per-pass passVerdict so the cards and the header cannot disagree. + if (passVerdict == org.iiab.controller.system.domain.SystemVerdict.State.NO_SYSTEM + || passVerdict == org.iiab.controller.system.domain.SystemVerdict.State.DAMAGED) { for (final Card c : cards) { // ADFA-5061: this used to record ABSENT for all five, and the write was right at // the instant it happened and wrong forever after. "No system is installed" is a @@ -563,42 +602,21 @@ private void refreshStatuses() { */ private void updateHeaderFromCards() { if (homeStatus == null || !isAdded()) return; - boolean installed = systemInstalled; boolean alive = ServerStateRepository.get().current().alive; - // ADFA-5143: a clone in flight outranks everything below, and has to be asked FIRST. During a - // receive the install marker makes isSystemInstalled() false, so without this the very next - // line says "no library" while a whole system is arriving — and the branch after it would call - // a deliberately stopped server a failure. Neither is true and both were on screen. - if (org.iiab.controller.sync.presentation.SyncProgressRepository.get().isActive()) { - setHeader(H_CLONE_RECEIVING); - return; - } - if (CloneSendSession.isActive()) { - setHeader(H_CLONE_SHARING); - return; - } - if (!installed) { - // ADFA-5147: "not installed" is two states, and this line used to collapse them. A truly - // empty phone has no install marker; a killed install or clone leaves the marker set and - // the system unbootable. isSystemInstalled() folds both into false, so a damaged system - // read as "no library" and the header offered to install over it — the misdiagnosis that - // sent a whole night at rsync while the cloned system was intact. - // - // Ask the one owner of that distinction — the same verdict the launch recovery dialog uses - // (InterruptedInstallDetector) — so Home and the dialog cannot disagree about what a marker - // means. The full form is required here: a live install, module queue or deep op holds the - // marker legitimately and must NOT read as damage (ADFA-4971). This is the destination made - // honest, so the diagnosis no longer depends on which launch branch was taken to reach it. - boolean marker = org.iiab.controller.InstallGuard.inProgress(requireContext()); - boolean instRunning = org.iiab.controller.install.presentation.InstallProgressRepository.get().current().isRunning(); - boolean modRunning = org.iiab.controller.install.presentation.ModuleQueueRepository.get().isRunning(); - boolean deepOp = org.iiab.controller.env.EnvironmentLock.ownerHeld(requireContext()); - org.iiab.controller.install.domain.InterruptedInstallDetector.Verdict v = - org.iiab.controller.install.domain.InterruptedInstallDetector.evaluate( - marker, instRunning, modRunning, deepOp, alive); - setHeader(v == org.iiab.controller.install.domain.InterruptedInstallDetector.Verdict.DAMAGED_REINSTALL - ? H_DAMAGED : H_NO_LIBRARY); - return; + // ADFA-5312: the system-state axis comes from the ONE shared verdict (SystemFactsReader), so + // Home cannot disagree with Modules/Connect/Clone about whether an install-in-progress is + // "installing" vs "no system / damaged". Clone, any system op (install/module/deep-op) and + // damaged all outrank the content + server sub-states below, which only apply once the system + // itself is READY. (This centralizes what used to be re-derived here from isSystemInstalled() + // plus a grab-bag of running flags — the ADFA-5312 bug class.) Reads the once-per-pass + // passVerdict so the header and the cards cannot answer from two readings taken moments apart. + switch (passVerdict) { + case CLONE_RECEIVING: setHeader(H_CLONE_RECEIVING); return; + case CLONE_SHARING: setHeader(H_CLONE_SHARING); return; + case INSTALLING: setHeader(H_INSTALLING_SYSTEM); return; + case NO_SYSTEM: setHeader(H_NO_LIBRARY); return; + case DAMAGED: setHeader(H_DAMAGED); return; + case READY: break; // fall through to the content + server sub-state below } // ADFA-5074: content being added outranks everything below. It is the only state // the user can act on from here, and reporting "ready" over a running install is @@ -607,11 +625,13 @@ private void updateHeaderFromCards() { // claiming work that is not happening. // ADFA-5061: from the pass snapshot, so the header and the cards cannot answer this // from two different readings taken moments apart. + // ADFA-5074: content being added (REST download) still shows "installing" — but that is the + // content axis on a READY system, not a system state, so it lives here in the READY branch + // (the system op case is already handled by the verdict above). boolean contentRunning = passContent != null ? passContent.anyRunning() : org.iiab.controller.system.data.PendingContent.anyRunning(requireContext()); - if (contentRunning - || org.iiab.controller.install.presentation.ModuleQueueRepository.get().isRunning()) { + if (contentRunning) { setHeader(H_INSTALLING); return; } @@ -650,6 +670,8 @@ private void setHeader(int h) { // content arriving blocks nothing: the library works, and it is getting bigger. // The label carries the news, and the row stays tappable as the way into progress. case H_INSTALLING: text = getString(R.string.k2go_home_installing); dotColor = R.color.k2go_leaf; break; + // ADFA-5312: a system op with the server stopped — amber "wait", not the green content look. + case H_INSTALLING_SYSTEM: text = getString(R.string.k2go_home_installing_system); dotColor = R.color.k2go_amber; break; // ADFA-5143: amber, not green and not red. The server is deliberately down and the box is // busy with something the user started — that is "wait", which is what amber says here. case H_CLONE_RECEIVING: text = getString(R.string.k2go_home_clone_receiving); dotColor = R.color.k2go_amber; break; @@ -678,7 +700,7 @@ private void setHeader(int h) { // common: a state with no exit is a bug whoever reaches it, including by a route that does not // exist yet. One line in a switch that already hands out two other buttons. int action = h == H_FAILED ? R.string.k2go_home_retry - : h == H_INSTALLING ? R.string.k2go_home_see_progress + : (h == H_INSTALLING || h == H_INSTALLING_SYSTEM) ? R.string.k2go_home_see_progress : h == H_NO_LIBRARY ? R.string.k2go_home_install_system // ADFA-5143: a transfer is not offered a restart — restarting the server is not a // meaningful thing to do to a transfer. Each side is offered the place that matters: diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/ModuleDetailFragment.java b/controller/app/src/main/java/org/iiab/controller/redesign/ModuleDetailFragment.java index df2db21ad..e59e1c7f7 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/ModuleDetailFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/ModuleDetailFragment.java @@ -112,22 +112,33 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c // Null is "could not read", not "nothing installed" — same distinction the hub keeps. final boolean isInstalled = onDisk != null && onDisk.contains(c.key()); final boolean unknown = onDisk == null; - // ADFA-5150: read the system fact off the same IO thread (it hits the disk). A damaged - // rootfs with still-readable flags used to show Install now, guarded only by the lock — - // installing a module into a system that is not there. No system → the button is Recover. - final boolean noSystem = !org.iiab.controller.SystemStateEvaluator.isSystemInstalled(appCtx); + // ADFA-5150/5312: read the system verdict off the same IO thread (it hits the disk). A + // damaged rootfs with still-readable flags used to show Install now; and during an install + // the marker made it read "no system" and offer Recover into a system that is actually there + // and mid-setup. Branch on the one shared verdict instead of bare isSystemInstalled(). + final org.iiab.controller.system.domain.SystemVerdict.State verdict = + org.iiab.controller.system.data.SystemFactsReader.verdict(appCtx); // root, not requireView(): inside onCreateView the fragment's view is not set yet, // so requireView() would throw. root is already inflated and its handler is the // main looper's. root.post(() -> { if (!isAdded()) return; - if (noSystem) { + if (verdict == org.iiab.controller.system.domain.SystemVerdict.State.NO_SYSTEM + || verdict == org.iiab.controller.system.domain.SystemVerdict.State.DAMAGED) { chipRow.addView(chip(getString(R.string.k2go_state_no_system), R.color.k2go_amber_text)); installNowBtn.setText(R.string.k2go_home_recover); installNowBtn.setOnClickListener(v -> SetupLibraryActivity.recover(requireContext())); installNowBtn.setVisibility(View.VISIBLE); return; // no Install/Schedule into a system that is not there } + if (verdict == org.iiab.controller.system.domain.SystemVerdict.State.INSTALLING + || verdict == org.iiab.controller.system.domain.SystemVerdict.State.CLONE_RECEIVING + || verdict == org.iiab.controller.system.domain.SystemVerdict.State.CLONE_SHARING) { + // ADFA-5312: a system op is in progress — the system is present but mid-setup and the + // server is down. Don't offer Install or Recover into it; just say it's busy. + chipRow.addView(chip(getString(R.string.k2go_home_installing), R.color.k2go_amber_text)); + return; + } if (isInstalled) { chipRow.addView(chip(getString(R.string.k2go_mod_phase_done), R.color.k2go_leaf)); return; // nothing to offer: a module cannot be uninstalled or reinstalled here diff --git a/controller/app/src/main/java/org/iiab/controller/redesign/ModuleHubFragment.java b/controller/app/src/main/java/org/iiab/controller/redesign/ModuleHubFragment.java index 4bfb52f76..20a0231e6 100644 --- a/controller/app/src/main/java/org/iiab/controller/redesign/ModuleHubFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/redesign/ModuleHubFragment.java @@ -94,6 +94,7 @@ public class ModuleHubFragment extends Fragment { private boolean stateUnknown = false; private int probesPending = 0; private int probeGen = 0; // ADFA-4842: supersedes an in-flight probe batch (e.g. onResume re-probe) + private boolean lastQueueRunning = false; // ADFA-5312: react only to running-transitions of the module queue private LinearLayout host; private Button proceed; @@ -140,6 +141,16 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c }); buildCards(); // shows "checking…" until probes resolve + + // ADFA-5312: re-probe when the module queue starts/stops so the "installing" state appears and + // clears live (the screen otherwise only re-probes on resume). React to running-transitions + // only, not the per-second percent ticks — a fresh probe is needed on finish to re-read the + // now-cleared install marker (systemPresent flips back to true). + org.iiab.controller.install.presentation.ModuleQueueRepository.get().state() + .observe(getViewLifecycleOwner(), st -> { + boolean running = st != null && st.isRunning(); + if (running != lastQueueRunning) { lastQueueRunning = running; probeAll(); } + }); return root; } @@ -231,28 +242,51 @@ private void confirmByProbe(final int gen) { private void buildCards() { if (host == null) return; host.removeAllViews(); - // ADFA-5104: with no system there is nothing to install into, so nothing is offered and - // the screen says why. Listing modules here would be an invitation the box cannot honour. - if (!systemPresent) { - TextView msg = new TextView(requireContext()); - msg.setGravity(Gravity.CENTER); - msg.setPadding(px(8), px(24), px(8), px(24)); - msg.setTextAppearance(com.google.android.material.R.style.TextAppearance_Material3_BodyMedium); - msg.setTextColor(ContextCompat.getColor(requireContext(), R.color.k2go_muted)); - msg.setText(R.string.k2go_mod_needs_system); - host.addView(msg); - // ADFA-5150: was a dead end — the sentence, and no way forward but Back. Give it the one - // action that helps: Recover (restore / internet / clone all live there). - com.google.android.material.button.MaterialButton recover = - new com.google.android.material.button.MaterialButton(requireContext()); - recover.setText(R.string.k2go_home_recover); - recover.setOnClickListener(v -> SetupLibraryActivity.recover(requireContext())); - LinearLayout.LayoutParams rlp = new LinearLayout.LayoutParams( - LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); - rlp.gravity = Gravity.CENTER; - host.addView(recover, rlp); - addHiddenSection(); - return; + // ADFA-5312: branch on the ONE shared system verdict instead of bare systemPresent, so this + // screen can't offer Recover / Install-a-system over a system that is present and mid-install + // (the runrole stops the server, so systemPresent reads false during a legitimate install). + switch (org.iiab.controller.system.data.SystemFactsReader.verdict(requireContext())) { + case INSTALLING: + case CLONE_RECEIVING: + case CLONE_SHARING: { + // A system op is in progress — show it and do NOT offer Recover. + TextView installing = new TextView(requireContext()); + installing.setGravity(Gravity.CENTER); + installing.setPadding(px(8), px(24), px(8), px(24)); + installing.setTextAppearance(com.google.android.material.R.style.TextAppearance_Material3_BodyMedium); + installing.setTextColor(ContextCompat.getColor(requireContext(), R.color.k2go_muted)); + String mod = org.iiab.controller.install.presentation.ModuleQueueRepository.get().currentModule(); + installing.setText(mod != null && !mod.isEmpty() + ? getString(R.string.install_status_installing_module, mod) + : getString(R.string.k2go_home_installing)); + host.addView(installing); + return; + } + case NO_SYSTEM: + case DAMAGED: { + // ADFA-5104: with no usable system there is nothing to install into, so nothing is + // offered and the screen says why. ADFA-5150: give the one action that helps — Recover + // (restore / internet / clone all live there). + TextView msg = new TextView(requireContext()); + msg.setGravity(Gravity.CENTER); + msg.setPadding(px(8), px(24), px(8), px(24)); + msg.setTextAppearance(com.google.android.material.R.style.TextAppearance_Material3_BodyMedium); + msg.setTextColor(ContextCompat.getColor(requireContext(), R.color.k2go_muted)); + msg.setText(R.string.k2go_mod_needs_system); + host.addView(msg); + com.google.android.material.button.MaterialButton recover = + new com.google.android.material.button.MaterialButton(requireContext()); + recover.setText(R.string.k2go_home_recover); + recover.setOnClickListener(v -> SetupLibraryActivity.recover(requireContext())); + LinearLayout.LayoutParams rlp = new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); + rlp.gravity = Gravity.CENTER; + host.addView(recover, rlp); + addHiddenSection(); + return; + } + case READY: + break; // build the module grid below } TextView helper = new TextView(requireContext()); // ADFA-4958 diff --git a/controller/app/src/main/java/org/iiab/controller/system/data/SystemFactsReader.java b/controller/app/src/main/java/org/iiab/controller/system/data/SystemFactsReader.java index d4d50e6f4..52d4aea5b 100644 --- a/controller/app/src/main/java/org/iiab/controller/system/data/SystemFactsReader.java +++ b/controller/app/src/main/java/org/iiab/controller/system/data/SystemFactsReader.java @@ -88,6 +88,30 @@ public static SystemFacts read(Context ctx) { : SystemFacts.serverUnknown(installed, healthy); } + /** + * ADFA-5312: the single DISPLAY verdict for "what state is the system in", for UI screens to + * switch on instead of each re-deriving it from {@code isSystemInstalled()} plus its own set of + * running flags. Gathers the raw signals here (this is the one reader) and delegates the rule to + * the pure {@link org.iiab.controller.system.domain.SystemVerdict}. Does NOT feed the boot gate, + * the server-start gate or the recovery dialog — those keep their strict checks. + */ + public static org.iiab.controller.system.domain.SystemVerdict.State verdict(Context ctx) { + if (ctx == null) { + return org.iiab.controller.system.domain.SystemVerdict.State.NO_SYSTEM; + } + ServerStateRepository server = ServerStateRepository.get(); + return org.iiab.controller.system.domain.SystemVerdict.evaluate( + SystemStateEvaluator.rootfsPresent(ctx), + InstallGuard.inProgress(ctx), + InstallProgressRepository.get().isRunning(), + ModuleQueueRepository.get().isRunning(), + EnvironmentLock.ownerHeld(ctx), + org.iiab.controller.sync.presentation.SyncProgressRepository.get().isActive(), + org.iiab.controller.redesign.CloneSendSession.isActive(), + server.current().alive, + server.hasObservation()); + } + /** * ADFA-5137: does this device have a system, or is one on its way? * diff --git a/controller/app/src/main/java/org/iiab/controller/system/domain/SystemVerdict.java b/controller/app/src/main/java/org/iiab/controller/system/domain/SystemVerdict.java new file mode 100644 index 000000000..ed71312ca --- /dev/null +++ b/controller/app/src/main/java/org/iiab/controller/system/domain/SystemVerdict.java @@ -0,0 +1,70 @@ +/* + * ============================================================================ + * Name : SystemVerdict.java + * Author : AppDevForAll + * Copyright : Copyright (c) 2026 AppDevForAll + * Description : ADFA-5312. One pure verdict for "what state is the system in", so UI screens switch + * on it instead of each re-deriving it from SystemStateEvaluator.isSystemInstalled() + * plus an ad-hoc grab-bag of running flags. That ad-hoc pattern is the bug this closes: + * a running proot module (or any system op) holds the install marker, so + * isSystemInstalled() reads false, and a screen that branches on it alone shows a false + * "no system / Recover" over a system that is actually there and busy installing. + * + * Booleans in, enum out, unit-tested. This is the DISPLAY verdict only — the boot gate, + * the server-start gate and the recovery/reinstall dialog keep their own strict checks + * (SystemStateEvaluator / InterruptedInstallDetector directly); this does not feed them. + * ============================================================================ + */ +package org.iiab.controller.system.domain; + +import org.iiab.controller.install.domain.InterruptedInstallDetector; + +public final class SystemVerdict { + + /** The states a UI screen needs to tell apart. Server sub-states (starting/failed/empty) and the + * content-download axis stay local to the screens that care (Home); they are not system states. */ + public enum State { READY, INSTALLING, NO_SYSTEM, DAMAGED, CLONE_RECEIVING, CLONE_SHARING } + + private SystemVerdict() {} + + /** + * @param rootfsPresent a rootfs exists on disk (SystemStateEvaluator.rootfsPresent) + * @param markerPresent InstallGuard's install-in-progress marker is set + * @param installerRunning a rootfs install pipeline is alive in this process + * @param moduleQueueRunning a proot module queue is alive in this process + * @param deepOpHoldsLock a backup/restore/clone holds the environment lock + * @param cloneReceiving a clone receive is active + * @param cloneSharing a clone send is active + * @param serverUp the server answered + * @param serverStateKnown the server has been observed at least once (else "unknown", not "down") + */ + public static State evaluate(boolean rootfsPresent, + boolean markerPresent, + boolean installerRunning, + boolean moduleQueueRunning, + boolean deepOpHoldsLock, + boolean cloneReceiving, + boolean cloneSharing, + boolean serverUp, + boolean serverStateKnown) { + // A clone in flight outranks everything: a whole system is arriving or leaving. + if (cloneReceiving) return State.CLONE_RECEIVING; + if (cloneSharing) return State.CLONE_SHARING; + // Any system-level operation legitimately holds the marker/lock — a rootfs install, a proot + // module runrole, or a backup/restore. Work in progress is not an absent or damaged system, + // and must never be offered Recover/Install-a-system (ADFA-5312). + if (installerRunning || moduleQueueRunning || deepOpHoldsLock) return State.INSTALLING; + // Nothing running and nothing on disk: the first-run install is the only path. + if (!rootfsPresent) return State.NO_SYSTEM; + // A rootfs exists and nothing is running. If a marker is still set and the server won't come + // up, a prior install was killed and left it damaged — deferred to the existing DAMAGED oracle. + // Before the first server observation the answer is "unknown", not "down", so hold READY until + // the poll reports rather than flashing a false DAMAGED. + if (serverStateKnown + && InterruptedInstallDetector.evaluate(markerPresent, false, false, false, serverUp) + == InterruptedInstallDetector.Verdict.DAMAGED_REINSTALL) { + return State.DAMAGED; + } + return State.READY; + } +} diff --git a/controller/app/src/main/res/values-ar/strings_k2go.xml b/controller/app/src/main/res/values-ar/strings_k2go.xml index 1207bfdee..6de5a5ba5 100644 --- a/controller/app/src/main/res/values-ar/strings_k2go.xml +++ b/controller/app/src/main/res/values-ar/strings_k2go.xml @@ -49,6 +49,7 @@ جارٍ إضافة المحتوى + جارٍ التثبيت — يُرجى الانتظار الوصول إلى التخزين التخزين افتراضي النظام diff --git a/controller/app/src/main/res/values-az/strings_k2go.xml b/controller/app/src/main/res/values-az/strings_k2go.xml index b20a58c3a..487306cb2 100644 --- a/controller/app/src/main/res/values-az/strings_k2go.xml +++ b/controller/app/src/main/res/values-az/strings_k2go.xml @@ -49,6 +49,7 @@ Məzmun əlavə edilir + Quraşdırılır — gözləyin Yaddaşa giriş Yaddaş Sistem defoltu diff --git a/controller/app/src/main/res/values-bg/strings_k2go.xml b/controller/app/src/main/res/values-bg/strings_k2go.xml index 75e6249f0..065c72c0b 100644 --- a/controller/app/src/main/res/values-bg/strings_k2go.xml +++ b/controller/app/src/main/res/values-bg/strings_k2go.xml @@ -49,6 +49,7 @@ Добавяне на съдържание + Инсталиране — изчакайте Достъп до хранилището Хранилище По подразбиране от системата diff --git a/controller/app/src/main/res/values-bn/strings_k2go.xml b/controller/app/src/main/res/values-bn/strings_k2go.xml index 3e427de9a..056dc5386 100644 --- a/controller/app/src/main/res/values-bn/strings_k2go.xml +++ b/controller/app/src/main/res/values-bn/strings_k2go.xml @@ -49,6 +49,7 @@ কনটেন্ট যোগ করা হচ্ছে + ইনস্টল হচ্ছে — অপেক্ষা করুন স্টোরেজ অ্যাক্সেস স্টোরেজ সিস্টেম ডিফল্ট diff --git a/controller/app/src/main/res/values-cs/strings_k2go.xml b/controller/app/src/main/res/values-cs/strings_k2go.xml index 8be808d2f..41610f1c9 100644 --- a/controller/app/src/main/res/values-cs/strings_k2go.xml +++ b/controller/app/src/main/res/values-cs/strings_k2go.xml @@ -49,6 +49,7 @@ Přidává se obsah + Instaluje se — čekejte prosím Přístup k úložišti Úložiště Výchozí nastavení systému diff --git a/controller/app/src/main/res/values-de/strings_k2go.xml b/controller/app/src/main/res/values-de/strings_k2go.xml index 02c21d23d..d0dbea7c0 100644 --- a/controller/app/src/main/res/values-de/strings_k2go.xml +++ b/controller/app/src/main/res/values-de/strings_k2go.xml @@ -50,6 +50,7 @@ Inhalte werden hinzugefügt + Wird installiert — bitte warten Speicherzugriff Speicher Systemstandard diff --git a/controller/app/src/main/res/values-el/strings_k2go.xml b/controller/app/src/main/res/values-el/strings_k2go.xml index 1a6088193..211988ebe 100644 --- a/controller/app/src/main/res/values-el/strings_k2go.xml +++ b/controller/app/src/main/res/values-el/strings_k2go.xml @@ -50,6 +50,7 @@ Προσθήκη περιεχομένου + Εγκατάσταση — περιμένετε Πρόσβαση στον χώρο αποθήκευσης Αποθηκευτικός χώρος Προεπιλογή συστήματος diff --git a/controller/app/src/main/res/values-es/strings_k2go.xml b/controller/app/src/main/res/values-es/strings_k2go.xml index 0aad7b219..f24995dc1 100644 --- a/controller/app/src/main/res/values-es/strings_k2go.xml +++ b/controller/app/src/main/res/values-es/strings_k2go.xml @@ -49,6 +49,7 @@ Añadiendo contenido + Instalando — espera un momento Acceso al almacenamiento Almacenamiento Predeterminado del sistema diff --git a/controller/app/src/main/res/values-fa/strings_k2go.xml b/controller/app/src/main/res/values-fa/strings_k2go.xml index 1b8c7a829..65ffe9abe 100644 --- a/controller/app/src/main/res/values-fa/strings_k2go.xml +++ b/controller/app/src/main/res/values-fa/strings_k2go.xml @@ -49,6 +49,7 @@ در حال افزودن محتوا + در حال نصب — لطفاً صبر کنید دسترسی به حافظه حافظه پیش‌فرض سیستم diff --git a/controller/app/src/main/res/values-fr/strings_k2go.xml b/controller/app/src/main/res/values-fr/strings_k2go.xml index 390e6ada0..2e605be21 100644 --- a/controller/app/src/main/res/values-fr/strings_k2go.xml +++ b/controller/app/src/main/res/values-fr/strings_k2go.xml @@ -49,6 +49,7 @@ Ajout de contenu + Installation en cours — veuillez patienter Accès au stockage Stockage Par défaut du système diff --git a/controller/app/src/main/res/values-gu/strings_k2go.xml b/controller/app/src/main/res/values-gu/strings_k2go.xml index 5bb19cd24..9a1e2f261 100644 --- a/controller/app/src/main/res/values-gu/strings_k2go.xml +++ b/controller/app/src/main/res/values-gu/strings_k2go.xml @@ -49,6 +49,7 @@ સામગ્રી ઉમેરાઈ રહી છે + ઇન્સ્ટોલ થઈ રહ્યું છે — કૃપા કરીને રાહ જુઓ સ્ટોરેજ ઍક્સેસ સ્ટોરેજ સિસ્ટમ ડિફૉલ્ટ diff --git a/controller/app/src/main/res/values-hi/strings_k2go.xml b/controller/app/src/main/res/values-hi/strings_k2go.xml index 7aa5ebb3a..3f2154f0d 100644 --- a/controller/app/src/main/res/values-hi/strings_k2go.xml +++ b/controller/app/src/main/res/values-hi/strings_k2go.xml @@ -49,6 +49,7 @@ सामग्री जोड़ी जा रही है + इंस्टॉल हो रहा है — कृपया प्रतीक्षा करें स्टोरेज एक्सेस स्टोरेज सिस्टम डिफ़ॉल्ट diff --git a/controller/app/src/main/res/values-hu/strings_k2go.xml b/controller/app/src/main/res/values-hu/strings_k2go.xml index 40f65886b..51926e75a 100644 --- a/controller/app/src/main/res/values-hu/strings_k2go.xml +++ b/controller/app/src/main/res/values-hu/strings_k2go.xml @@ -49,6 +49,7 @@ Tartalom hozzáadása + Telepítés — kérjük, várjon Tárhely-hozzáférés Tárhely Rendszer alapértelmezett diff --git a/controller/app/src/main/res/values-in/strings_k2go.xml b/controller/app/src/main/res/values-in/strings_k2go.xml index 97ba14839..b1a285c4e 100644 --- a/controller/app/src/main/res/values-in/strings_k2go.xml +++ b/controller/app/src/main/res/values-in/strings_k2go.xml @@ -49,6 +49,7 @@ Menambahkan konten + Memasang — harap tunggu Akses penyimpanan Penyimpanan Default sistem diff --git a/controller/app/src/main/res/values-it/strings_k2go.xml b/controller/app/src/main/res/values-it/strings_k2go.xml index 99b71bb4e..80b594ac8 100644 --- a/controller/app/src/main/res/values-it/strings_k2go.xml +++ b/controller/app/src/main/res/values-it/strings_k2go.xml @@ -49,6 +49,7 @@ Aggiunta di contenuti + Installazione in corso — attendere Accesso all\'archiviazione Archiviazione Predefinita del sistema diff --git a/controller/app/src/main/res/values-ja/strings_k2go.xml b/controller/app/src/main/res/values-ja/strings_k2go.xml index 97c616e59..8168316dd 100644 --- a/controller/app/src/main/res/values-ja/strings_k2go.xml +++ b/controller/app/src/main/res/values-ja/strings_k2go.xml @@ -49,6 +49,7 @@ コンテンツを追加中 + インストール中 — お待ちください ストレージへのアクセス ストレージ システムの既定 diff --git a/controller/app/src/main/res/values-ko/strings_k2go.xml b/controller/app/src/main/res/values-ko/strings_k2go.xml index fd6a8c583..d50d4b90a 100644 --- a/controller/app/src/main/res/values-ko/strings_k2go.xml +++ b/controller/app/src/main/res/values-ko/strings_k2go.xml @@ -49,6 +49,7 @@ 콘텐츠 추가 중 + 설치 중 — 잠시 기다려 주세요 저장소 접근 저장소 시스템 기본값 diff --git a/controller/app/src/main/res/values-lt/strings_k2go.xml b/controller/app/src/main/res/values-lt/strings_k2go.xml index d76bd5687..5ce46e6ef 100644 --- a/controller/app/src/main/res/values-lt/strings_k2go.xml +++ b/controller/app/src/main/res/values-lt/strings_k2go.xml @@ -49,6 +49,7 @@ Pridedamas turinys + Įdiegiama — palaukite Prieiga prie saugyklos Saugykla Sistemos numatytoji diff --git a/controller/app/src/main/res/values-nl/strings_k2go.xml b/controller/app/src/main/res/values-nl/strings_k2go.xml index 00d34aaed..be7333d4c 100644 --- a/controller/app/src/main/res/values-nl/strings_k2go.xml +++ b/controller/app/src/main/res/values-nl/strings_k2go.xml @@ -49,6 +49,7 @@ Inhoud toevoegen + Bezig met installeren — even geduld Opslagtoegang Opslag Systeemstandaard diff --git a/controller/app/src/main/res/values-no/strings_k2go.xml b/controller/app/src/main/res/values-no/strings_k2go.xml index fd2764b2e..b5c43af30 100644 --- a/controller/app/src/main/res/values-no/strings_k2go.xml +++ b/controller/app/src/main/res/values-no/strings_k2go.xml @@ -49,6 +49,7 @@ Legger til innhold + Installerer — vent litt Lagringstilgang Lagring Systemstandard diff --git a/controller/app/src/main/res/values-pl/strings_k2go.xml b/controller/app/src/main/res/values-pl/strings_k2go.xml index 041c01b79..96aef8003 100644 --- a/controller/app/src/main/res/values-pl/strings_k2go.xml +++ b/controller/app/src/main/res/values-pl/strings_k2go.xml @@ -49,6 +49,7 @@ Dodawanie treści + Instalowanie — proszę czekać Dostęp do pamięci Pamięć Domyślny systemu diff --git a/controller/app/src/main/res/values-pt/strings_k2go.xml b/controller/app/src/main/res/values-pt/strings_k2go.xml index ab9a34dd7..89d20abdb 100644 --- a/controller/app/src/main/res/values-pt/strings_k2go.xml +++ b/controller/app/src/main/res/values-pt/strings_k2go.xml @@ -49,6 +49,7 @@ Adicionando conteúdo + Instalando — aguarde Acesso ao armazenamento Armazenamento Predefinição do sistema diff --git a/controller/app/src/main/res/values-ro/strings_k2go.xml b/controller/app/src/main/res/values-ro/strings_k2go.xml index af618443d..0b501ae4e 100644 --- a/controller/app/src/main/res/values-ro/strings_k2go.xml +++ b/controller/app/src/main/res/values-ro/strings_k2go.xml @@ -49,6 +49,7 @@ Se adaugă conținut + Se instalează — așteptați Acces la stocare Stocare Implicit sistem diff --git a/controller/app/src/main/res/values-ru-rRU/strings_k2go.xml b/controller/app/src/main/res/values-ru-rRU/strings_k2go.xml index 3ac12a195..2744e837f 100644 --- a/controller/app/src/main/res/values-ru-rRU/strings_k2go.xml +++ b/controller/app/src/main/res/values-ru-rRU/strings_k2go.xml @@ -49,6 +49,7 @@ Добавление контента + Установка — подождите Доступ к хранилищу Хранилище Системный по умолчанию diff --git a/controller/app/src/main/res/values-sk/strings_k2go.xml b/controller/app/src/main/res/values-sk/strings_k2go.xml index 96849c6be..6a7027e65 100644 --- a/controller/app/src/main/res/values-sk/strings_k2go.xml +++ b/controller/app/src/main/res/values-sk/strings_k2go.xml @@ -49,6 +49,7 @@ Pridáva sa obsah + Inštaluje sa — počkajte, prosím Prístup k úložisku Úložisko Predvolené systémom diff --git a/controller/app/src/main/res/values-sr/strings_k2go.xml b/controller/app/src/main/res/values-sr/strings_k2go.xml index 9f2b9a712..e7eadf134 100644 --- a/controller/app/src/main/res/values-sr/strings_k2go.xml +++ b/controller/app/src/main/res/values-sr/strings_k2go.xml @@ -49,6 +49,7 @@ Додавање садржаја + Инсталирање — сачекајте Приступ складишту Складиште Подразумевано системски diff --git a/controller/app/src/main/res/values-sw/strings_k2go.xml b/controller/app/src/main/res/values-sw/strings_k2go.xml index 96769519b..f6997638e 100644 --- a/controller/app/src/main/res/values-sw/strings_k2go.xml +++ b/controller/app/src/main/res/values-sw/strings_k2go.xml @@ -49,6 +49,7 @@ Inaongeza maudhui + Inasakinishwa — tafadhali subiri Ufikiaji wa hifadhi Hifadhi Chaguo-msingi la mfumo diff --git a/controller/app/src/main/res/values-ta/strings_k2go.xml b/controller/app/src/main/res/values-ta/strings_k2go.xml index 93e39ae59..cca6c5f65 100644 --- a/controller/app/src/main/res/values-ta/strings_k2go.xml +++ b/controller/app/src/main/res/values-ta/strings_k2go.xml @@ -49,6 +49,7 @@ உள்ளடக்கம் சேர்க்கப்படுகிறது + நிறுவப்படுகிறது — காத்திருக்கவும் சேமிப்பக அணுகல் சேமிப்பகம் கணினி இயல்பு diff --git a/controller/app/src/main/res/values-tr/strings_k2go.xml b/controller/app/src/main/res/values-tr/strings_k2go.xml index fea693790..71cdf37e3 100644 --- a/controller/app/src/main/res/values-tr/strings_k2go.xml +++ b/controller/app/src/main/res/values-tr/strings_k2go.xml @@ -49,6 +49,7 @@ İçerik ekleniyor + Kuruluyor — lütfen bekleyin Depolama erişimi Depolama Sistem varsayılanı diff --git a/controller/app/src/main/res/values-uk/strings_k2go.xml b/controller/app/src/main/res/values-uk/strings_k2go.xml index 3ede32c87..efc165d3a 100644 --- a/controller/app/src/main/res/values-uk/strings_k2go.xml +++ b/controller/app/src/main/res/values-uk/strings_k2go.xml @@ -49,6 +49,7 @@ Додавання вмісту + Встановлення — зачекайте, будь ласка Доступ до сховища Сховище Системна за замовчуванням diff --git a/controller/app/src/main/res/values-vi/strings_k2go.xml b/controller/app/src/main/res/values-vi/strings_k2go.xml index 90a197a84..f2c03fbd3 100644 --- a/controller/app/src/main/res/values-vi/strings_k2go.xml +++ b/controller/app/src/main/res/values-vi/strings_k2go.xml @@ -49,6 +49,7 @@ Đang thêm nội dung + Đang cài đặt — vui lòng đợi Truy cập bộ nhớ Bộ nhớ Mặc định hệ thống diff --git a/controller/app/src/main/res/values-yo/strings_k2go.xml b/controller/app/src/main/res/values-yo/strings_k2go.xml index 6f3dbe889..72a3f0066 100644 --- a/controller/app/src/main/res/values-yo/strings_k2go.xml +++ b/controller/app/src/main/res/values-yo/strings_k2go.xml @@ -49,6 +49,7 @@ Ń fi àkóónú kún un + Ó ń fi sórí ẹ̀rọ — jọ̀wọ́ dúró Ìwọlé sí ibi ìtọ́jú Ibi ìtọ́jú Àbùdá ẹ̀rọ diff --git a/controller/app/src/main/res/values-zh-rCN/strings_k2go.xml b/controller/app/src/main/res/values-zh-rCN/strings_k2go.xml index d342e455b..2104c858e 100644 --- a/controller/app/src/main/res/values-zh-rCN/strings_k2go.xml +++ b/controller/app/src/main/res/values-zh-rCN/strings_k2go.xml @@ -49,6 +49,7 @@ 正在添加内容 + 正在安装 — 请稍候 存储访问 存储 系统默认 diff --git a/controller/app/src/main/res/values/strings_k2go.xml b/controller/app/src/main/res/values/strings_k2go.xml index f90f534f6..a01e9206e 100644 --- a/controller/app/src/main/res/values/strings_k2go.xml +++ b/controller/app/src/main/res/values/strings_k2go.xml @@ -52,6 +52,10 @@ Adding content + + Installing — please wait Storage access Storage System default diff --git a/controller/app/src/test/java/org/iiab/controller/system/domain/SystemVerdictTest.java b/controller/app/src/test/java/org/iiab/controller/system/domain/SystemVerdictTest.java new file mode 100644 index 000000000..84d4880f0 --- /dev/null +++ b/controller/app/src/test/java/org/iiab/controller/system/domain/SystemVerdictTest.java @@ -0,0 +1,73 @@ +package org.iiab.controller.system.domain; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import org.iiab.controller.system.domain.SystemVerdict.State; + +/** + * ADFA-5312: the truth table for the shared display verdict. Pure, so the rule the five UI screens + * now switch on is locked here — including the case the bug was about (a running proot module reads + * INSTALLING, never NO_SYSTEM). Args order mirrors + * {@link SystemVerdict#evaluate}: rootfs, marker, installer, moduleQueue, deepOp, cloneRx, cloneTx, + * serverUp, serverKnown. + */ +public class SystemVerdictTest { + + private static State v(boolean rootfs, boolean marker, boolean inst, boolean mod, boolean deep, + boolean cloneRx, boolean cloneTx, boolean serverUp, boolean known) { + return SystemVerdict.evaluate(rootfs, marker, inst, mod, deep, cloneRx, cloneTx, serverUp, known); + } + + @Test public void readySystem() { + assertEquals(State.READY, v(true, false, false, false, false, false, false, true, true)); + } + + @Test public void staleMarkerButServerUp_isReady() { + // A rootfs that boots (server up) with a leftover marker is ready, not damaged. + assertEquals(State.READY, v(true, true, false, false, false, false, false, true, true)); + } + + @Test public void moduleRunning_isInstalling_notNoSystem() { + // ADFA-5312 core: a proot module holds the marker and stops the server -> INSTALLING, never the + // false "no system / Recover" that shipped before. + assertEquals(State.INSTALLING, v(true, true, false, true, false, false, false, false, true)); + } + + @Test public void rootfsInstallRunning_isInstalling() { + assertEquals(State.INSTALLING, v(false, true, true, false, false, false, false, false, true)); + } + + @Test public void deepOp_isInstalling() { + // A backup/restore legitimately holds the lock -> busy, not absent or damaged. + assertEquals(State.INSTALLING, v(true, true, false, false, true, false, false, false, true)); + } + + @Test public void noRootfsAndIdle_isNoSystem() { + assertEquals(State.NO_SYSTEM, v(false, false, false, false, false, false, false, false, true)); + } + + @Test public void killedInstall_serverKnownDown_isDamaged() { + // Marker set, nothing running, server observed down -> a killed install that won't boot. + assertEquals(State.DAMAGED, v(true, true, false, false, false, false, false, false, true)); + } + + @Test public void killedInstall_serverUnknown_holdsReady_notDamaged() { + // Before the first server observation the answer is "unknown", not "down" — don't flash DAMAGED. + assertEquals(State.READY, v(true, true, false, false, false, false, false, false, false)); + } + + @Test public void cloneReceiving_outranksEverything() { + assertEquals(State.CLONE_RECEIVING, v(true, true, true, true, true, true, false, false, true)); + } + + @Test public void cloneSharing_outranksInstallAndDamaged() { + assertEquals(State.CLONE_SHARING, v(true, true, false, false, false, false, true, false, true)); + } + + @Test public void installing_outranksNoSystemAndDamaged() { + // A running op wins even with no rootfs yet and the server down (a fresh install in flight). + assertEquals(State.INSTALLING, v(false, true, true, false, false, false, false, false, true)); + } +}