From ddf3985cb513e7041b45333024bb2e40ac056cc7 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Mon, 9 Nov 2026 13:36:38 -0500 Subject: [PATCH] feat(native): the terminal and bottom desktop run without proot --- .../launcher/session/BottomDesktop.kt | 16 +++++++++++++--- .../launcher/session/SessionService.kt | 18 ++++++++++-------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/session/BottomDesktop.kt b/app/src/main/java/com/droiddeck/launcher/session/BottomDesktop.kt index 36b9c3dfdc..10d031715b 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/BottomDesktop.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/BottomDesktop.kt @@ -39,6 +39,7 @@ object BottomDesktop { val sessionDir: File, val generation: Int, val installed: Boolean, + val nativeUserland: Boolean, ) @Volatile private var launch: Launch? = null @@ -89,10 +90,11 @@ object BottomDesktop { root: File, sessionDir: File, generation: Int, + nativeUserland: Boolean, stillCurrent: () -> Boolean, ) { val prepared = Launch(ArrayList(guest), ArrayList(binds), sessionRoot, hostEnvironment.copyOf(), root, sessionDir, generation, - DesktopCatalog.desktopInstalled(root)) + DesktopCatalog.desktopInstalled(root), nativeUserland) synchronized(launchLock) { if (stillCurrent()) launch = prepared } } @@ -320,9 +322,17 @@ object BottomDesktop { add("BL_IME_DIR=" + imeDir.path) add(SCRIPT) } - val command = LinuxRuntime.commandWithBinds(context, current.root, binds, guest) + val command = if (current.nativeUserland) { + com.droiddeck.launcher.runtime.NativeGuest.command(current.root, guest.first(), guest.drop(1)) + } else { + LinuxRuntime.commandWithBinds(context, current.root, binds, guest) + } + val environment = if (current.nativeUserland) { + com.droiddeck.launcher.runtime.NativeGuest.sessionEnvironment(current.root, binds, SessionPrefs.guestHostname(context)) + .map { (k, v) -> "$k=$v" }.toTypedArray() + } else current.hostEnvironment val line = command.joinToString(" ") { it.replace("\\", "\\\\").replace(" ", "\\ ") } - val pid = HostProcess.start(line, current.hostEnvironment, current.root, { status -> + val pid = HostProcess.start(line, environment, current.root, { status -> main.post { if (generation != guestGeneration) return@post Log.i(TAG, "the desktop ended ($status)") diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt index de8e5408c2..5cb407bf5d 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -689,8 +689,6 @@ class SessionService : Service() { LinuxRuntime.command(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds, guest) } - // The terminal and the bottom desktop still start through proot, so they get proot's - // environment even when the session itself runs without it val prootEnv = HostEnvironment() prootEnv["PROOT_LOADER"] = LinuxRuntime.prootLoader(this).path prootEnv["PROOT_TMP_DIR"] = LinuxRuntime.prootTempDir(this).path @@ -709,14 +707,18 @@ class SessionService : Service() { Log.i(TAG, "native userland: no proot (${sessionBindSpecs.size} mounts)") val drives = com.droiddeck.launcher.runtime.NativeGuest.relinkPrefixDrives(root, sessionBindSpecs) if (drives > 0) Log.i(TAG, "native userland: $drives Wine drive links made to point at their real places") - com.droiddeck.launcher.runtime.NativeGuest.sessionEnvironment(root, sessionBindSpecs).forEach { (k, v) -> env[k] = v } + com.droiddeck.launcher.runtime.NativeGuest.sessionEnvironment(root, sessionBindSpecs, SessionPrefs.guestHostname(this)) + .forEach { (k, v) -> env[k] = v } } else prootEnv - val terminalCommand = LinuxRuntime.command( - this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds, shellGuest, - ) + // The terminal and the bottom desktop run the way the session does: without proot when it does + val terminalCommand = if (nativeUserland) { + com.droiddeck.launcher.runtime.NativeGuest.command(root, shellGuest.first(), shellGuest.drop(1)) + } else { + LinuxRuntime.command(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds, shellGuest) + } val terminalHostEnvironment = LinkedHashMap(System.getenv()) - prootEnv.asArray().forEach { entry -> + hostEnv.asArray().forEach { entry -> val separator = entry.indexOf('=') if (separator > 0) terminalHostEnvironment[entry.substring(0, separator)] = entry.substring(separator + 1) } @@ -724,7 +726,7 @@ class SessionService : Service() { SessionTerminal.prepare(terminalCommand, terminalHostEnvironment.map { (key, value) -> "$key=$value" }.toTypedArray(), root, gen) val (fastPathName, _) = ProotFastPath.hostEnv("") BottomDesktop.prepare(desktopGuest, binds, sessionRoot, - prootEnv.asArray().filterNot { it.startsWith("$fastPathName=") }.toTypedArray(), root, sessionDir, gen, + prootEnv.asArray().filterNot { it.startsWith("$fastPathName=") }.toTypedArray(), root, sessionDir, gen, nativeUserland, ) { gen == sessionGen && SessionState.running } }