Mali bridge: Setup's "Safe mode" switch, on by default

A second row under the GPU check, shown only when the bridge is on: "Safe mode" keeps the
bridge's proven workarounds wherever its startup probe has not verified this GPU and driver;
off is performance mode, native paths wherever the probe passed. It reaches the server as
<cache dir>/mode ("safe" or "performance", written atomically before the server starts or is
reused, so the in-app server's JNI start stays as it is) and the guest as VKBRIDGE_MODE, which
/root/.vkbridge-env can still override. A server without modes ignores the file.
This commit is contained in:
Ahmad Sayed Alsayed Ebrahim authored and maxjivi05 committed 2026-10-26 13:55:31 -04:00
1 parent e04eb84090
commit 5b35ace098
7 files changed
+49 -3

No files matched your search

@@ -20,6 +20,7 @@ class VkBridgeComponent(private val socket: File, private val logFile: File) : S
}
socket.parentFile?.mkdirs()
val cacheDir = cacheDir(app())
writeMode(cacheDir, com.droiddeck.launcher.session.SessionPrefs.vkBridgeMode(app()))
if (VkBridgeNative.start(app(), socket, logFile, cacheDir)) {
Log.i(TAG, "server ready in the app's process at $socket")
return
@@ -56,6 +57,7 @@ class VkBridgeComponent(private val socket: File, private val logFile: File) : S
companion object {
private const val TAG = "VkBridge"
private const val CACHE_DIR = "vkbridge-pipelines"
private const val MODE_FILE = "mode"
fun cacheDir(context: Context): File {
val dir = File(context.filesDir, CACHE_DIR)
@@ -65,6 +67,17 @@ class VkBridgeComponent(private val socket: File, private val logFile: File) : S
return dir
}
fun writeMode(dir: File, mode: String) {
val file = File(dir, MODE_FILE)
if (runCatching { file.readText().trim() }.getOrNull() == mode) return
val tmp = File(dir, "$MODE_FILE.tmp")
runCatching {
tmp.writeText(mode + "\n")
if (!tmp.renameTo(file)) error("rename failed")
Log.i(TAG, "bridge mode: $mode")
}.onFailure { Log.w(TAG, "could not write $file: $it"); tmp.delete() }
}
private fun migrate(old: File, dir: File) {
val moved = if (!dir.exists()) old.renameTo(dir) else false
if (!moved) {