diff --git a/controller/app/src/main/java/org/iiab/controller/DashboardFragment.java b/controller/app/src/main/java/org/iiab/controller/DashboardFragment.java index 9cb1663ca..29c30724c 100644 --- a/controller/app/src/main/java/org/iiab/controller/DashboardFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/DashboardFragment.java @@ -96,10 +96,8 @@ private static class IiabModule { new IiabModule("dashboard", R.string.dash_system, false) ); - public enum SystemState { - ONLINE, OFFLINE, DEBIAN_ONLY, INSTALLER, TERMUX_ONLY, NONE - } - + // ADFA-5192: SystemState is now a top-level enum (org.iiab.controller.SystemState), + // extracted so it survives the retirement of this legacy fragment. private SystemState currentSystemState = SystemState.NONE; @Nullable diff --git a/controller/app/src/main/java/org/iiab/controller/ServerController.java b/controller/app/src/main/java/org/iiab/controller/ServerController.java index c5b3cc025..c74c6ca9d 100644 --- a/controller/app/src/main/java/org/iiab/controller/ServerController.java +++ b/controller/app/src/main/java/org/iiab/controller/ServerController.java @@ -155,7 +155,7 @@ private void checkServerStatus() { // ADFA-4578: evaluate + publish the SystemState at app level (every poll), // so every tab reflects the server live instead of only after visiting the Dashboard. - final DashboardFragment.SystemState sysState = SystemStateEvaluator.evaluate(activity, localAlive); + final SystemState sysState = SystemStateEvaluator.evaluate(activity, localAlive); ServerStateRepository.get().post(ServerState.of(localAlive, sysState)); // STATE MACHINE: Has the target state been reached? diff --git a/controller/app/src/main/java/org/iiab/controller/ServerState.java b/controller/app/src/main/java/org/iiab/controller/ServerState.java index eeb7d3eb9..7282f3bc5 100644 --- a/controller/app/src/main/java/org/iiab/controller/ServerState.java +++ b/controller/app/src/main/java/org/iiab/controller/ServerState.java @@ -14,18 +14,18 @@ public final class ServerState { public final boolean alive; - public final DashboardFragment.SystemState systemState; + public final SystemState systemState; - private ServerState(boolean alive, DashboardFragment.SystemState systemState) { + private ServerState(boolean alive, SystemState systemState) { this.alive = alive; this.systemState = systemState; } - public static ServerState of(boolean alive, DashboardFragment.SystemState systemState) { + public static ServerState of(boolean alive, SystemState systemState) { return new ServerState(alive, systemState); } public static ServerState unknown() { - return new ServerState(false, DashboardFragment.SystemState.NONE); + return new ServerState(false, SystemState.NONE); } } diff --git a/controller/app/src/main/java/org/iiab/controller/SystemState.java b/controller/app/src/main/java/org/iiab/controller/SystemState.java new file mode 100644 index 000000000..594212c33 --- /dev/null +++ b/controller/app/src/main/java/org/iiab/controller/SystemState.java @@ -0,0 +1,18 @@ +/* + * ============================================================================ + * Name : SystemState.java + * Author : AppDevForAll + * Copyright : Copyright (c) 2026 AppDevForAll + * Description : ADFA-5192. The derived state of the on-device system, evaluated from + * the rootfs/Debian/server facts (see SystemStateEvaluator) and published + * on ServerState so any surface can observe it live. Extracted from the + * legacy DashboardFragment (where it began as a nested enum) so it survives + * the retirement of the legacy tabbed UI; the redesign reads it through + * ServerState / ServerStateRepository. + * ============================================================================ + */ +package org.iiab.controller; + +public enum SystemState { + ONLINE, OFFLINE, DEBIAN_ONLY, INSTALLER, TERMUX_ONLY, NONE +} 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 7377edb55..4589b08fa 100644 --- a/controller/app/src/main/java/org/iiab/controller/SystemStateEvaluator.java +++ b/controller/app/src/main/java/org/iiab/controller/SystemStateEvaluator.java @@ -65,21 +65,21 @@ public static boolean rootfsPresent(Context ctx) { } /** Server responding → ONLINE; else derive from the rootfs on disk. */ - public static DashboardFragment.SystemState evaluate(Context ctx, boolean serverAlive) { + public static SystemState evaluate(Context ctx, boolean serverAlive) { File rootfsDir = rootfsDir(ctx); File debianBash = new File(rootfsDir, "bin/bash"); File flagIiabReady = new File(rootfsDir, "usr/local/pdsm/flag_install_ready"); if (serverAlive) { - return DashboardFragment.SystemState.ONLINE; + return SystemState.ONLINE; } if (flagIiabReady.exists()) { - return DashboardFragment.SystemState.OFFLINE; + return SystemState.OFFLINE; } if (debianBash.exists()) { - return DashboardFragment.SystemState.DEBIAN_ONLY; + return SystemState.DEBIAN_ONLY; } - return DashboardFragment.SystemState.NONE; + return SystemState.NONE; } public static String termuxArch(Context ctx) { diff --git a/controller/app/src/main/java/org/iiab/controller/UsageFragment.java b/controller/app/src/main/java/org/iiab/controller/UsageFragment.java index b6c18cafc..0bf9fb87f 100644 --- a/controller/app/src/main/java/org/iiab/controller/UsageFragment.java +++ b/controller/app/src/main/java/org/iiab/controller/UsageFragment.java @@ -184,8 +184,8 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat btnServerControl.setOnClickListener(v -> { // --- Intercept based on State Machine --- - DashboardFragment.SystemState state = ServerStateRepository.get().current().systemState; - boolean isFullyInstalled = (state == DashboardFragment.SystemState.ONLINE || state == DashboardFragment.SystemState.OFFLINE); + SystemState state = ServerStateRepository.get().current().systemState; + boolean isFullyInstalled = (state == SystemState.ONLINE || state == SystemState.OFFLINE); if (!isFullyInstalled) { Snackbar.make(v, R.string.server_not_installed_warning, 6000).show(); @@ -259,8 +259,8 @@ public void updateUIColorsAndVisibility() { } // Server Control Logic - DashboardFragment.SystemState state = ServerStateRepository.get().current().systemState; - boolean isFullyInstalled = (state == DashboardFragment.SystemState.ONLINE || state == DashboardFragment.SystemState.OFFLINE); + SystemState state = ServerStateRepository.get().current().systemState; + boolean isFullyInstalled = (state == SystemState.ONLINE || state == SystemState.OFFLINE); if (!isFullyInstalled) { // SYSTEM NOT READY: Gray out the button diff --git a/controller/app/src/main/java/org/iiab/controller/help/domain/Tier3LinkResolver.java b/controller/app/src/main/java/org/iiab/controller/help/domain/Tier3LinkResolver.java index 27fdfe13d..55d19b8dd 100644 --- a/controller/app/src/main/java/org/iiab/controller/help/domain/Tier3LinkResolver.java +++ b/controller/app/src/main/java/org/iiab/controller/help/domain/Tier3LinkResolver.java @@ -12,7 +12,7 @@ * Resolves a tier-3 help link's {@link Tier3LinkState} from the two facts that matter: * whether a usable IIAB rootfs is present, and whether the local web server is alive. * - *
Presentation maps {@code DashboardFragment.SystemState} to {@code rootfsPresent} + *
Presentation maps {@code SystemState} to {@code rootfsPresent} * (ONLINE/OFFLINE = true; NONE/DEBIAN_ONLY/TERMUX_ONLY/INSTALLER = false) and reads * {@code alive} from {@code ServerState}. Kept UI-agnostic so it is JVM-unit-testable. */