mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 12:56:06 +00:00
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:
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) {
|
||||
|
||||
Reference in new issue
Block a user