A rootless Android app that boots Alpine Linux: run containers (Podman/Docker/LXC) and GUI desktop apps.
fix: persistent notification, disabled theme/font while running, terminal navigation survival
ExTvdf81baf85d4b
diff --git a/app/src/main/java/com/excp/podroid/engine/PodroidQemu.kt b/app/src/main/java/com/excp/podroid/engine/PodroidQemu.ktindex ee7f776..d65c17f 100644--- a/app/src/main/java/com/excp/podroid/engine/PodroidQemu.kt+++ b/app/src/main/java/com/excp/podroid/engine/PodroidQemu.kt@@ -170,6 +170,15 @@ class PodroidQemu @Inject constructor(_state.value = VmState.Running}++ scope.launch {+ delay(60_000)+ if (_bootStage.value != "Ready") {+ Log.w(TAG, "Boot stage fallback: ${_bootStage.value} → Ready (timeout)")+ _bootStage.value = "Ready"+ }+ }+// Block until QEMU exits (keeps the calling service coroutine alive)val exitCode = proc.waitFor()Log.d(TAG, "QEMU exited: $exitCode")diff --git a/app/src/main/java/com/excp/podroid/service/PodroidService.kt b/app/src/main/java/com/excp/podroid/service/PodroidService.ktindex 60109b9..3f8adcb 100644--- a/app/src/main/java/com/excp/podroid/service/PodroidService.kt+++ b/app/src/main/java/com/excp/podroid/service/PodroidService.kt@@ -51,9 +51,8 @@ class PodroidService : Service() {override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {when (intent?.action) {ACTION_START -> {- startForeground(NOTIFICATION_ID, buildNotification("Starting Podman..."))+ startForeground(NOTIFICATION_ID, buildNotification("Starting VM..."))acquireWakeLock()- startNotificationUpdates()launchPodroid()}ACTION_STOP -> {@@ -106,22 +105,40 @@ class PodroidService : Service() {private fun startNotificationUpdates() {notificationJob?.cancel()notificationJob = serviceScope.launch {- podroidQemu.bootStage- .collect { stage ->+ launch {+ podroidQemu.bootStage.collect { stage ->val status = when {stage == "Ready" || podroidQemu.state.value is VmState.Running && stage.isEmpty() ->- "Podman is running"+ "VM is running"stage.isNotEmpty() -> stage- else -> "Starting Podman..."+ else -> "Starting VM..."}updateNotification(status)}+ }+ launch {+ podroidQemu.state.collect { state ->+ when (state) {+ is VmState.Stopped, is VmState.Idle -> {+ releaseWakeLock()+ if (android.os.Build.VERSION.SDK_INT >= 33) {+ stopForeground(STOP_FOREGROUND_REMOVE)+ } else {+ @Suppress("DEPRECATION") stopForeground(true)+ }+ stopSelf()+ }+ else -> {}+ }+ }+ }}}private fun launchPodroid() {launchJob?.cancel()launchJob = serviceScope.launch {+ startNotificationUpdates()withContext(Dispatchers.IO) {try {val rules = portForwardRepository.getRulesSnapshot().toMutableList()@@ -140,14 +157,6 @@ class PodroidService : Service() {Log.e(TAG, "QEMU failed to start", e)}}-- releaseWakeLock()- if (android.os.Build.VERSION.SDK_INT >= 33) {- stopForeground(STOP_FOREGROUND_REMOVE)- } else {- @Suppress("DEPRECATION") stopForeground(true)- }- stopSelf()}}diff --git a/app/src/main/java/com/excp/podroid/ui/screens/settings/SettingsScreen.kt b/app/src/main/java/com/excp/podroid/ui/screens/settings/SettingsScreen.ktindex 220f373..618ae94 100644--- a/app/src/main/java/com/excp/podroid/ui/screens/settings/SettingsScreen.kt+++ b/app/src/main/java/com/excp/podroid/ui/screens/settings/SettingsScreen.kt@@ -166,6 +166,7 @@ fun SettingsScreen() {FilledTonalButton(onClick = { showColorThemeDialog = true },+ enabled = vmNotRunning,modifier = Modifier.weight(1f),) {Icon(Icons.Default.Palette, contentDescription = null, modifier = Modifier.padding(end = 4.dp))@@ -176,6 +177,7 @@ fun SettingsScreen(}FilledTonalButton(onClick = { showFontDialog = true },+ enabled = vmNotRunning,modifier = Modifier.weight(1f),) {Icon(Icons.Default.TextFields, contentDescription = null, modifier = Modifier.padding(end = 4.dp))diff --git a/app/src/main/java/com/excp/podroid/ui/screens/terminal/TerminalViewModel.kt b/app/src/main/java/com/excp/podroid/ui/screens/terminal/TerminalViewModel.ktindex 8bbc259..d633f93 100644--- a/app/src/main/java/com/excp/podroid/ui/screens/terminal/TerminalViewModel.kt+++ b/app/src/main/java/com/excp/podroid/ui/screens/terminal/TerminalViewModel.kt@@ -205,28 +205,10 @@ class TerminalViewModel @Inject constructor(terminalView = view}- /**- * Creates the TerminalSession backed by podroid-bridge.- *- * Steps:- * 1. Release PodroidQemu's boot-monitoring socket so bridge can connect.- * 2. Start the bridge binary as the session subprocess.- * 3. Termux allocates a real PTY; bridge relays PTY ↔ serial.sock.- *- * Resize flow (fully automatic after this):- * TerminalView layout change → updateSize(cols, rows)- * → TerminalSession.updateSize → ioctl TIOCSWINSZ on PTY master- * → SIGWINCH to bridge → bridge writes RESIZE to ctrl.sock- * → VM daemon → stty on ttyAMA0 → SIGWINCH in VM- */fun createSession() {if (attached) returnattached = true- // Hand off the serial socket from boot monitoring to the bridge.- // shutdownInput() + close() tells the boot monitor to exit; the short- // sleep lets QEMU detect the disconnect and re-listen before the bridge- // tries to connect (QEMU serial only serves one client at a time).qemu.releaseSerial()Thread.sleep(500)@@ -308,7 +290,6 @@ class TerminalViewModel @Inject constructor(override fun onCleared() {super.onCleared()terminalView = null- session = nullattached = false}