feat: experimental native userland that runs the Linux side without proot

This commit is contained in:
Kurt Himebauch committed 2026-11-08 14:53:52 -05:00
1 parent 3bb279f635
commit 70c33fc039
45 files changed
+10132 -8

No files matched your search

@@ -185,6 +185,7 @@ class FrontEndActivity : ComponentActivity() {
private var gpuClockPin by mutableStateOf(false)
private var prootNoSeccomp by mutableStateOf(false)
private var prootFastPath by mutableStateOf(true)
private var nativeUserland by mutableStateOf(false)
private var cursorComposite by mutableStateOf(false)
private var guestHostname by mutableStateOf(SessionPrefs.DEFAULT_GUEST_HOSTNAME)
private var phantomWarning by mutableStateOf<String?>(null)
@@ -2557,7 +2558,7 @@ class FrontEndActivity : ComponentActivity() {
deviceRamMb = (android.app.ActivityManager.MemoryInfo()
.also((getSystemService(ACTIVITY_SERVICE) as android.app.ActivityManager)::getMemoryInfo).totalMem / (1024 * 1024)).toInt(),
ramCapAvailable = com.droiddeck.launcher.core.ZramSupport.supported(),
prootNoSeccomp = prootNoSeccomp, prootFastPath = prootFastPath, cursorComposite = cursorComposite,
prootNoSeccomp = prootNoSeccomp, prootFastPath = prootFastPath, nativeUserland = nativeUserland, cursorComposite = cursorComposite,
guestHostname = guestHostname, phantomWarning = phantomWarning,
onClientOverride = { on -> SessionPrefs.setClientCpusOverride(this, on); clientOverride = on },
onTuSysmem = { on -> SessionPrefs.setTuSysmem(this, on); tuSysmem = on },
@@ -2575,6 +2576,7 @@ class FrontEndActivity : ComponentActivity() {
onVramCapMb = { mb -> SessionPrefs.setVramCapMb(this, mb); vramCapMb = mb },
onProotNoSeccomp = { on -> SessionPrefs.setProotNoSeccomp(this, on); prootNoSeccomp = on },
onProotFastPath = { on -> SessionPrefs.setProotFastPath(this, on); prootFastPath = on },
onNativeUserland = { on -> SessionPrefs.setNativeUserland(this, on); nativeUserland = on },
onCursorComposite = { on -> SessionPrefs.setCursorComposite(this, on); cursorComposite = on },
onGuestHostname = { name -> SessionPrefs.setGuestHostname(this, name) },
onClientCore = { core, on ->
@@ -2797,6 +2799,7 @@ class FrontEndActivity : ComponentActivity() {
gpuClockPin = SessionPrefs.gpuClockPin(this)
prootNoSeccomp = SessionPrefs.prootNoSeccomp(this)
prootFastPath = SessionPrefs.prootFastPath(this)
nativeUserland = SessionPrefs.nativeUserland(this)
cursorComposite = SessionPrefs.cursorComposite(this)
guestHostname = SessionPrefs.guestHostname(this)
refreshPhantomStatus()
@@ -40,6 +40,7 @@ class AgentBridgeProvider : ContentProvider() {
recoveryComplete.countDown()
}
}, "agent-recover-artifacts").start()
AgentCallReceiver.register(appContext)
return true
}
@@ -85,6 +86,10 @@ class AgentBridgeProvider : ContentProvider() {
AgentAccess.requireCommands(context)
guest(context, JSONObject(request.toString()).put("kind", "exec"), timeoutMs(request, 30.0, 10_000))
}
"native" -> {
AgentAccess.requireCommands(context)
AgentNative.run(context, request, timeoutMs(request, 30.0, 0))
}
"cdp" -> {
AgentAccess.requireCommands(context)
guest(context, JSONObject(request.toString()).put("kind", "cdp"), timeoutMs(request, 15.0, 5_000))
@@ -0,0 +1,46 @@
package com.droiddeck.launcher.agent
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.os.Bundle
import java.io.File
/**
* The agent bridge for devices whose shell has no `content` command: the same calls as
* [AgentBridgeProvider], answered in a file under the app's external files folder.
*/
class AgentCallReceiver : BroadcastReceiver() {
companion object {
fun action(context: Context) = "${context.packageName}.AGENT_CALL"
fun register(context: Context) {
context.registerReceiver(AgentCallReceiver(), android.content.IntentFilter(action(context)),
android.Manifest.permission.DUMP, null)
}
}
override fun onReceive(context: Context, intent: Intent) {
val method = intent.getStringExtra("method") ?: return
val id = intent.getStringExtra("id")?.takeIf { it.matches(Regex("[A-Za-z0-9_-]{1,64}")) } ?: return
val request = intent.getStringExtra(AgentBridgeProvider.EXTRA_REQUEST)
val pending = goAsync()
Thread({
val json = try {
val extras = Bundle().apply { putString(AgentBridgeProvider.EXTRA_REQUEST, request) }
context.contentResolver.call("${context.packageName}.agent", method, null, extras)
?.getString(AgentBridgeProvider.RESULT_JSON) ?: """{"ok":false,"error":{"code":"NO_RESPONSE","message":"no response"}}"""
} catch (e: Exception) {
org.json.JSONObject().put("ok", false)
.put("error", org.json.JSONObject().put("code", "COMMAND_FAILED").put("message", e.message ?: e.javaClass.simpleName)).toString()
}
try {
val dir = File(context.getExternalFilesDir(null), "agent-calls").apply { mkdirs() }
File(dir, "$id.json.part").writeText(json)
File(dir, "$id.json.part").renameTo(File(dir, "$id.json"))
} finally {
pending.finish()
}
}, "agent-call-$id").start()
}
}
@@ -0,0 +1,56 @@
package com.droiddeck.launcher.agent
import android.content.Context
import com.droiddeck.launcher.runtime.LinuxRuntime
import com.droiddeck.launcher.runtime.NativeGuest
import org.json.JSONArray
import org.json.JSONObject
import java.util.concurrent.TimeUnit
/** Runs a guest program without proot (`droiddeckctl native`), for testing the native userland. */
object AgentNative {
private const val OUTPUT_CAP = 256 * 1024
fun run(context: Context, request: JSONObject, timeoutMs: Long): JSONObject {
val root = LinuxRuntime.rootDir(context)
com.droiddeck.launcher.session.SessionFiles.stage(context, root)
if (!NativeGuest.available(root)) throw AgentException("NATIVE_UNAVAILABLE", "The rootfs has no native hook or glibc loader yet; start a session once")
val argvJson = request.optJSONArray("argv") ?: throw AgentException("INVALID_REQUEST", "argv is required")
val argv = (0 until argvJson.length()).map { argvJson.getString(it) }
if (argv.isEmpty()) throw AgentException("INVALID_REQUEST", "argv is empty")
val env = linkedMapOf<String, String>()
request.optJSONObject("env")?.let { obj -> obj.keys().forEach { env[it] = obj.getString(it) } }
val preload = request.optJSONArray("preload")?.let { a -> (0 until a.length()).map { a.getString(it) } } ?: emptyList()
val builder = NativeGuest.builder(root, request.optString("cwd", "/root"), argv, env, preload)
val started = System.nanoTime()
val process = builder.start()
val out = StringBuilder()
val err = StringBuilder()
val readers = listOf(
Thread { drain(process.inputStream, out) },
Thread { drain(process.errorStream, err) },
).onEach { it.isDaemon = true; it.start() }
process.outputStream.use { stdin -> request.optString("stdin").takeIf { it.isNotEmpty() }?.let { stdin.write(it.toByteArray()) } }
val finished = process.waitFor(timeoutMs, TimeUnit.MILLISECONDS)
if (!finished) process.destroyForcibly().waitFor()
readers.forEach { it.join(2000) }
val code = if (finished) process.exitValue() else -1
return JSONObject().put("ok", true).put("command", "native")
.put("exitCode", code).put("timedOut", !finished)
.put("ms", (System.nanoTime() - started) / 1_000_000)
.put("stdout", JSONObject().put("text", out.toString()))
.put("stderr", JSONObject().put("text", err.toString()))
.put("argv", JSONArray(argv))
}
private fun drain(input: java.io.InputStream, into: StringBuilder) {
val buffer = ByteArray(8192)
val text = java.io.ByteArrayOutputStream()
while (true) {
val n = try { input.read(buffer) } catch (e: java.io.IOException) { -1 }
if (n < 0) break
if (text.size() < OUTPUT_CAP) text.write(buffer, 0, minOf(n, OUTPUT_CAP - text.size()))
}
into.append(text.toString(Charsets.UTF_8.name()))
}
}
@@ -278,6 +278,7 @@ object DeviceReport {
k("RAM cap", SessionPrefs.ramCapMb(context).let { if (it > 0) "$it MB" else "off" })
k("VRAM cap", SessionPrefs.vramCapMb(context).let { if (it > 0) "$it MB" else "driver default" })
k("proot without seccomp", SessionPrefs.prootNoSeccomp(context))
k("native userland (no proot)", SessionPrefs.nativeUserland(context))
k("proot fast path", SessionPrefs.prootFastPath(context))
k("proot binary", LinuxRuntime.prootSource(context) + " " + LinuxRuntime.prootBinary(context).path)
k("proot fast path (eligible)", com.droiddeck.launcher.runtime.ProotFastPath.enabled(context))
@@ -0,0 +1,72 @@
package com.droiddeck.launcher.runtime
import java.io.File
import java.io.RandomAccessFile
import java.nio.ByteBuffer
import java.nio.ByteOrder
/** The absolute DT_RUNPATH and DT_RPATH directories of a 64-bit little-endian ELF object. */
object ElfRunpath {
private const val PT_LOAD = 1
private const val PT_DYNAMIC = 2
private const val DT_STRTAB = 5
private const val DT_RPATH = 15
private const val DT_RUNPATH = 29
fun read(file: File): List<String> {
if (file.length() < 64) return emptyList()
RandomAccessFile(file, "r").use { raf ->
val channel = raf.channel
val header = ByteBuffer.allocate(64).order(ByteOrder.LITTLE_ENDIAN)
channel.read(header, 0)
if (header.getInt(0) != 0x464c457f || header.get(4).toInt() != 2 || header.get(5).toInt() != 1) return emptyList()
val phoff = header.getLong(32)
val phentsize = header.getShort(54).toInt() and 0xffff
val phnum = header.getShort(56).toInt() and 0xffff
if (phnum == 0 || phnum > 128 || phentsize < 56) return emptyList()
val table = ByteBuffer.allocate(phentsize * phnum).order(ByteOrder.LITTLE_ENDIAN)
channel.read(table, phoff)
class Load(val vaddr: Long, val offset: Long, val size: Long)
val loads = ArrayList<Load>()
var dynOffset = -1L
var dynSize = 0L
for (i in 0 until phnum) {
val at = i * phentsize
val type = table.getInt(at)
val offset = table.getLong(at + 8)
val vaddr = table.getLong(at + 16)
val filesz = table.getLong(at + 32)
if (type == PT_LOAD) loads.add(Load(vaddr, offset, filesz))
if (type == PT_DYNAMIC) { dynOffset = offset; dynSize = filesz }
}
if (dynOffset < 0 || dynSize <= 0 || dynSize > 1 shl 20) return emptyList()
val dynamic = ByteBuffer.allocate(dynSize.toInt()).order(ByteOrder.LITTLE_ENDIAN)
channel.read(dynamic, dynOffset)
var strtab = -1L
val names = ArrayList<Long>()
var at = 0
while (at + 16 <= dynamic.capacity()) {
val tag = dynamic.getLong(at)
val value = dynamic.getLong(at + 8)
if (tag == 0L) break
if (tag == DT_STRTAB.toLong()) strtab = value
if (tag == DT_RPATH.toLong() || tag == DT_RUNPATH.toLong()) names.add(value)
at += 16
}
if (strtab < 0 || names.isEmpty()) return emptyList()
val strtabOffset = loads.firstOrNull { strtab >= it.vaddr && strtab < it.vaddr + it.size }
?.let { strtab - it.vaddr + it.offset } ?: return emptyList()
val result = ArrayList<String>()
for (name in names) {
val buffer = ByteBuffer.allocate(4096)
val n = channel.read(buffer, strtabOffset + name)
if (n <= 0) continue
val bytes = buffer.array()
var end = 0
while (end < n && bytes[end].toInt() != 0) end++
String(bytes, 0, end, Charsets.UTF_8).split(':').filter { it.startsWith("/") }.forEach { result.add(it.trimEnd('/')) }
}
return result
}
}
}
@@ -0,0 +1,144 @@
package com.droiddeck.launcher.runtime
import android.content.Context
import com.droiddeck.launcher.session.SessionPrefs
import java.io.File
import java.nio.file.Files
/**
* Starts guest programs directly on the Android kernel, with no proot: the glibc loader of the
* rootfs runs the program and [HOOK] translates the guest's absolute paths, execs and the system
* calls Android's seccomp policy blocks, from inside the process.
*/
object NativeGuest {
const val HOOK = "usr/lib/libddnatv-hook.so"
private val LIB_DIRS = listOf("usr/lib", "usr/lib/aarch64-linux-gnu", "usr/local/lib", "usr/lib/systemd")
/** Libraries every native program loads before the hook, as /etc/ld.so.preload does for proot. */
fun preloadList(root: File): List<String> {
val listed = File(root, "etc/droiddeck/native-preload").takeIf { it.isFile }?.readLines().orEmpty()
return listed.map { it.trim() }.filter { it.startsWith("/") && File(root, it.removePrefix("/")).isFile }
}
fun enabled(context: Context): Boolean =
SessionPrefs.nativeUserland(context) && available(LinuxRuntime.rootDir(context))
fun hook(root: File): File = File(root, HOOK)
fun loader(root: File): File? =
listOf("usr/lib/ld-linux-aarch64.so.1", "lib/ld-linux-aarch64.so.1").map { File(root, it) }.firstOrNull { it.exists() }
fun available(root: File): Boolean = hook(root).isFile && loader(root) != null
fun libraryPath(root: File): String = LIB_DIRS.joinToString(":") { File(root, it).path }
/** Environment every native process starts with; a guest `env -i` is re-seeded by the hook. */
fun environment(root: File, preload: List<String> = emptyList()): Map<String, String> = linkedMapOf(
"DDNATV_ROOT" to root.path,
"LD_LIBRARY_PATH" to libraryPath(root),
"LD_PRELOAD" to (preload.map { File(root, it.removePrefix("/")).path } + hook(root).path).joinToString(":"),
)
/**
* The host command line for the guest program at [program] (an absolute guest path to a real
* file, not a symlink).
*/
fun command(root: File, program: String, args: List<String>): List<String> {
val loader = checkNotNull(loader(root)) { "no glibc loader in ${root.path}" }
val host = File(root, program.removePrefix("/"))
return listOf(loader.path, "--argv0", host.name, host.path) + args
}
/** The environment of the session process: the hook's root, the mounts proot used to make, the preload list. */
fun sessionEnvironment(root: File, binds: List<String>): Map<String, String> {
val preload = preloadList(root)
return linkedMapOf(
"DDNATV_ROOT" to root.path,
"DDNATV_BINDS" to binds.joinToString("|") { if (it.contains(':')) it else "$it:$it" },
"DDNATV_PRELOAD" to preload.joinToString(":"),
"LD_LIBRARY_PATH" to libraryPath(root),
"LD_PRELOAD" to (preload.map { File(root, it.removePrefix("/")).path } + hook(root).path).joinToString(":"),
).filterValues { it.isNotEmpty() }
}
private const val RUNPATH_CONF = "etc/ld.so.conf.d/zz-droiddeck-native.conf"
private val SCAN_DIRS = listOf("usr/lib", "usr/local/lib", "opt")
/**
* ld.so opens the absolute RUNPATH directories of a library itself, with system calls the hook
* cannot translate, so every one of them is also listed in ld.so.conf (which the hook maps).
* Rescanned when dpkg's state or a library directory changes.
*/
fun syncLibraryDirs(root: File) {
val conf = File(root, RUNPATH_CONF)
val signature = (listOf("var/lib/dpkg/status", "usr/lib", "usr/local/lib", "usr/lib/aarch64-linux-gnu")
.joinToString(",") { File(root, it).lastModified().toString() }) + "," + conf.parentFile.list()?.size
val stamp = File(root, "etc/droiddeck/native-runpath-signature")
if (conf.isFile && stamp.isFile && stamp.readText() == signature) return
val dirs = sortedSetOf<String>()
for (name in SCAN_DIRS) File(root, name).walkTopDown().maxDepth(6)
.onEnter { !Files.isSymbolicLink(it.toPath()) }
.filter { it.isFile && !Files.isSymbolicLink(it.toPath()) && ".so" in it.name }
.forEach { file -> runCatching { ElfRunpath.read(file) }.getOrNull()?.let { dirs.addAll(it) } }
val kept = dirs.filter { it.startsWith("/usr") || it.startsWith("/lib") || it.startsWith("/opt") }
conf.parentFile?.mkdirs()
conf.writeText(kept.joinToString("\n", postfix = "\n"))
stamp.parentFile?.mkdirs()
stamp.writeText(signature)
}
private val HOST_LINK_TARGETS = listOf("/proc", "/dev", "/sys", "/sdcard", "/storage", "/data", "/system", "/vendor", "/apex",
"/system_ext", "/product", "/odm", "/linkerconfig", "/mnt")
/**
* Symbolic links the kernel follows by itself (ld.so, Steam, anything that skips the hook) read
* their absolute target on Android's own filesystem. The image's links were made for proot,
* which reads the target inside the rootfs, so each is rewritten as a relative link, which
* resolves the same way under proot and without it. Rerun when the runtime changes.
*/
fun relinkAbsoluteSymlinks(context: Context, root: File): Int {
val stamp = File(root, "etc/droiddeck/native-symlinks")
val version = com.droiddeck.launcher.runtime.LinuxRuntimeInstaller.installedVersion(context).orEmpty() + "/2"
if (stamp.isFile && stamp.readText() == version) return 0
val rootPath = root.toPath()
var rewritten = 0
Files.walkFileTree(rootPath, object : java.nio.file.SimpleFileVisitor<java.nio.file.Path>() {
override fun visitFile(file: java.nio.file.Path, attrs: java.nio.file.attribute.BasicFileAttributes): java.nio.file.FileVisitResult {
if (attrs.isSymbolicLink) {
try {
val target = Files.readSymbolicLink(file).toString()
if (target.startsWith("/") && HOST_LINK_TARGETS.none { target == it || target.startsWith("$it/") }
&& !target.startsWith(root.path)) {
val relative = file.parent.relativize(rootPath.resolve(target.removePrefix("/")))
val temp = file.resolveSibling(".relink-" + file.fileName)
Files.deleteIfExists(temp)
Files.createSymbolicLink(temp, relative)
Files.move(temp, file, java.nio.file.StandardCopyOption.REPLACE_EXISTING)
rewritten++
}
} catch (_: java.io.IOException) {
}
}
return java.nio.file.FileVisitResult.CONTINUE
}
override fun visitFileFailed(file: java.nio.file.Path, exc: java.io.IOException) = java.nio.file.FileVisitResult.CONTINUE
})
stamp.parentFile?.mkdirs()
stamp.writeText(version)
return rewritten
}
fun builder(root: File, cwd: String, argv: List<String>, env: Map<String, String>, preload: List<String> = emptyList()): ProcessBuilder {
val program = argv.first()
val cmd = command(root, program, argv.drop(1))
val builder = ProcessBuilder(cmd).redirectErrorStream(false)
builder.directory(File(root, cwd.removePrefix("/")).takeIf { it.isDirectory } ?: root)
builder.environment().apply {
clear()
putAll(environment(root, preload))
putAll(env)
}
return builder
}
}
@@ -50,6 +50,7 @@ object SessionFiles {
"libblsession.so" to "usr/local/lib/libblsession.so",
"libfakeinput.so" to "usr/local/lib/libfakeinput.so",
"libblfastpath.so" to "usr/local/lib/libblfastpath.so",
"libddnatv-hook.so" to "usr/lib/libddnatv-hook.so",
"libblaudit.so" to "usr/local/lib/libblaudit.so",
"libssbs.so" to "usr/local/lib/libssbs.so",
"usr/local/bin/droiddeck-session" to "usr/local/bin/droiddeck-session",
@@ -255,12 +256,20 @@ object SessionFiles {
if (!File(Environment.getExternalStorageDirectory(), NO_PAD_SWITCH).exists()) {
preload.append("/usr/local/lib/libfakeinput.so\n")
}
if (ProotFastPath.enabled(context)) {
val nativeUserland = SessionPrefs.nativeUserland(context)
if (nativeUserland) {
val relinked = com.droiddeck.launcher.runtime.NativeGuest.relinkAbsoluteSymlinks(context, root)
if (relinked > 0) Log.i(TAG, "native userland: $relinked absolute symlinks made relative")
com.droiddeck.launcher.runtime.NativeGuest.syncLibraryDirs(root)
}
if (ProotFastPath.enabled(context) && !nativeUserland) {
val library = com.droiddeck.launcher.agent.AgentEnv.fastPathLibrary(context)
preload.append(library + "\n")
if (startsSession && library != ProotFastPath.LIBRARY) Log.i(TAG, "fast path preload: $library (debugging override)")
}
val etc = File(root, "etc").apply { mkdirs() }
File(etc, "droiddeck").mkdirs()
FileUtils.writeString(File(etc, "droiddeck/native-preload"), preload.toString())
val staged = File(etc, "ld.so.preload.staged")
if (!FileUtils.writeString(staged, preload.toString())
|| !staged.renameTo(File(etc, "ld.so.preload"))) {
@@ -752,6 +752,12 @@ object SessionPrefs {
prefs(context).edit().putBoolean("prootNoSeccomp", on).apply()
}
fun nativeUserland(context: Context): Boolean = prefs(context).getBoolean("nativeUserland", false)
fun setNativeUserland(context: Context, on: Boolean) {
prefs(context).edit().putBoolean("nativeUserland", on).apply()
}
fun prootFastPath(context: Context): Boolean = prefs(context).getBoolean("prootFastPath", true)
fun setProotFastPath(context: Context, on: Boolean) {
@@ -665,7 +665,8 @@ class SessionService : Service() {
FileUtils.clear(File(LinuxRuntime.liveDir(this), "shm"))
val binds = sessionBinds(controllersOn, fakeInputDir, sessionDir, guest, sessionRoot, runtimeDir)
val fastPathKey = if (ProotFastPath.enabled(this)) {
val nativeUserland = com.droiddeck.launcher.runtime.NativeGuest.enabled(this)
val fastPathKey = if (ProotFastPath.enabled(this) && !nativeUserland) {
val prootBinds = LinuxRuntime.binds(
this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds,
)
@@ -681,11 +682,18 @@ class SessionService : Service() {
}
} else null
val command = LinuxRuntime.command(
this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds, guest,
)
val sessionBindSpecs = LinuxRuntime.binds(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds)
val command = if (nativeUserland) {
com.droiddeck.launcher.runtime.NativeGuest.command(root, guest.first(), guest.drop(1))
} else {
LinuxRuntime.command(this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds, guest)
}
val hostEnv = HostEnvironment()
if (nativeUserland) {
Log.i(TAG, "native userland: no proot (${sessionBindSpecs.size} mounts)")
com.droiddeck.launcher.runtime.NativeGuest.sessionEnvironment(root, sessionBindSpecs).forEach { (k, v) -> hostEnv[k] = v }
} else {
hostEnv["PROOT_LOADER"] = LinuxRuntime.prootLoader(this).path
hostEnv["PROOT_TMP_DIR"] = LinuxRuntime.prootTempDir(this).path
if (SessionPrefs.prootNoSeccomp(this)) {
@@ -698,6 +706,7 @@ class SessionService : Service() {
}
val prootLibs = LinuxRuntime.prootLibraryPath(this)
if (prootLibs.isNotEmpty()) hostEnv["LD_LIBRARY_PATH"] = prootLibs
}
val terminalCommand = LinuxRuntime.command(
this, sessionRoot, runtimeDir, Environment.getExternalStorageDirectory(), binds, shellGuest,
@@ -22,7 +22,7 @@ object SettingsReset {
"gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop",
"tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "ramCapMb", "vramCapMb", "zramClient",
"directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus",
"noXalia", "fastSync", "fsyncFirst", "syncFallback", "prootNoSeccomp", "prootFastPath", "cursorComposite",
"noXalia", "fastSync", "fsyncFirst", "syncFallback", "prootNoSeccomp", "prootFastPath", "nativeUserland", "cursorComposite",
"guestHostname", "fexPreset", "forceSsbs", "logs", "gameDebugLogsEnabled", "enhancedDiagnosticsNext", "storageDiagnostics",
"upscaler", "upscaleSharpness", "screenEffects", "textureAnisotropy", "textureLodBias",
"steamDownloadsInBackground", "steam_offline", "bootMovie", "bootMovieSound", "bootMovieVolume", "bootMovieSeconds",
@@ -53,6 +53,7 @@ fun PerformancePage(
ramCapAvailable: Boolean,
prootNoSeccomp: Boolean,
prootFastPath: Boolean,
nativeUserland: Boolean,
cursorComposite: Boolean,
guestHostname: String,
phantomWarning: String?,
@@ -72,6 +73,7 @@ fun PerformancePage(
onVramCapMb: (Int) -> Unit,
onProotNoSeccomp: (Boolean) -> Unit,
onProotFastPath: (Boolean) -> Unit,
onNativeUserland: (Boolean) -> Unit,
onCursorComposite: (Boolean) -> Unit,
onGuestHostname: (String) -> Unit,
onClientCore: (Int, Boolean) -> Unit,
@@ -191,6 +193,11 @@ fun PerformancePage(
else stringResource(R.string.perf_fastpath_hint),
prootFastPath && !prootNoSeccomp, enabled = !prootNoSeccomp, onChange = onProotFastPath,
)
ToggleRow(
host, "nativeuserland", stringResource(R.string.perf_native_userland),
stringResource(R.string.perf_native_userland_hint),
nativeUserland, onChange = onNativeUserland,
)
ToggleRow(
host, "cursorcomposite", stringResource(R.string.perf_cursor_composite),
stringResource(R.string.perf_cursor_composite_hint),
+2
View File
@@ -648,6 +648,8 @@
<string name="perf_xalia_hint">Disables Proton\'s gamepad navigation helper, which costs CPU in every game.</string>
<string name="perf_seccomp">Run proot without seccomp</string>
<string name="perf_seccomp_hint">May fix missing-syscall errors on some kernels. Can reduce performance.</string>
<string name="perf_native_userland">Run without proot (experimental)</string>
<string name="perf_native_userland_hint">Starts the Linux side directly on Android. Applies to the next session. Turn off if something fails to start.</string>
<string name="perf_fastpath">proot fast path</string>
<string name="perf_fastpath_needs_seccomp">Needs proot\'s seccomp filter.</string>
<string name="perf_fastpath_hint">Faster file lookups and less stutter. Turn off if a program can\'t find its files.</string>
@@ -0,0 +1,31 @@
package com.droiddeck.launcher.runtime
import java.io.File
import java.nio.file.Files
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
class NativeGuestTest {
private fun rootWithLoader(): File = Files.createTempDirectory("native-root").toFile().also {
File(it, "usr/lib").mkdirs()
File(it, "usr/lib/ld-linux-aarch64.so.1").writeText("")
}
@Test
fun commandRunsTheProgramThroughTheRootfsLoader() {
val root = rootWithLoader()
val command = NativeGuest.command(root, "/usr/bin/env", listOf("-i", "A=1"))
assertEquals(File(root, "usr/lib/ld-linux-aarch64.so.1").path, command[0])
assertEquals(listOf("--argv0", "env", File(root, "usr/bin/env").path, "-i", "A=1"), command.drop(1))
}
@Test
fun mountsWithoutADestinationMapToThemselves() {
val root = rootWithLoader()
val env = NativeGuest.sessionEnvironment(root, listOf("/dev", "/a:/b"))
assertEquals("/dev:/dev|/a:/b", env["DDNATV_BINDS"])
assertEquals(root.path, env["DDNATV_ROOT"])
assertTrue(env.getValue("LD_PRELOAD").replace(File.separatorChar, '/').endsWith("usr/lib/libddnatv-hook.so"))
}
}