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 @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
18 changes: 18 additions & 0 deletions controller/app/src/main/java/org/iiab/controller/SystemState.java
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
* <p>Presentation maps {@code DashboardFragment.SystemState} to {@code rootfsPresent}
* <p>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.
*/
Expand Down
Loading