Add Quest 3/3S compatibility to the standard APK (#642)

This commit is contained in:
Jagger15 authored and GitHub committed 2026-10-12 17:13:07 -04:00
1 parent 8f36eb7f54
commit 6c35297dba
25 files changed
+659 -12

No files matched your search

@@ -22,6 +22,7 @@ class App : Application() {
override fun onCreate() {
super.onCreate()
CrashHandler.install(this)
com.droiddeck.launcher.session.QuestExperimental.initialize(this)
com.droiddeck.launcher.session.SessionPrefs.settleGpuDriverMode(this)
com.droiddeck.launcher.update.AppUpdates.init(this)
GpuClockPin.clearLeftover(this)
@@ -50,7 +50,8 @@ public final class TurnipDriver {
/** Adreno 8xx (8 Elite, e.g. a Fold 8's A830). */
private static final String DRIVER_A8XX = "turnip-sdk36";
/** The two the apk carries; never removable, unpacked on demand. */
public static final List<String> BUNDLED = Collections.unmodifiableList(Arrays.asList(DRIVER_A7XX, DRIVER_A8XX));
public static final List<String> BUNDLED = Collections.unmodifiableList(Arrays.asList(
DRIVER_A7XX, DRIVER_A8XX, com.droiddeck.launcher.session.QuestExperimental.DRIVER));
/** Overrides the pick, for a device we cannot reach: a7xx, a8xx or system. */
private static final String OVERRIDE_FILE = "Download/droiddeck-driver";
/** Bundled drivers the user deleted: hidden from the list, their unpacked copy removed. */
@@ -33,7 +33,7 @@ import java.util.concurrent.atomic.AtomicInteger
*/
object BwrapSpawner {
private const val TAG = "BwrapSpawner"
const val SOCKET = "com.droiddeck.launcher.bwrap"
fun socket(context: Context): String = "${context.packageName}.bwrap"
private val seq = AtomicInteger()
@Volatile private var server: LocalServerSocket? = null
@@ -42,10 +42,11 @@ object BwrapSpawner {
fun start(context: Context) {
if (server != null) return
val app = context.applicationContext
val name = socket(app)
val socket = try {
LocalServerSocket(SOCKET)
LocalServerSocket(name)
} catch (e: IOException) {
Log.e(TAG, "cannot listen on $SOCKET", e)
Log.e(TAG, "cannot listen on $name", e)
return
}
server = socket
@@ -51,6 +51,7 @@ object GuestCommand {
"/usr/bin/env", "-i", "HOME=/root", "USER=root", "LANG=C.UTF-8",
"PATH=/usr/local/bin:/usr/bin:/bin", "XDG_RUNTIME_DIR=${LinuxRuntime.GUEST_RUNTIME_DIR}",
"XDG_DATA_HOME=/root/.local/share", "FLATPAK_BWRAP=${FlatpakManager.BWRAP}",
"DROIDDECK_BWRAP_SOCKET=${BwrapSpawner.socket(context)}",
"XDG_DATA_DIRS=/root/.local/share/flatpak/exports/share:/usr/local/share:/usr/share",
)
cmd += argv
@@ -24,6 +24,12 @@ object CrashHandler {
Thread.setDefaultUncaughtExceptionHandler { thread, error ->
try {
Log.e(TAG, "uncaught on ${thread.name}", error)
if (QuestExperimental.isSupported()) runCatching {
File(context.filesDir, "quest-last-crash.txt").writeText(
"${java.time.Instant.now()} thread=${thread.name}\n" +
StringWriter().also { error.printStackTrace(PrintWriter(it)) }.toString()
)
}
val dir = SessionPaths.current()
if (dir != null && dir.isDirectory) {
val trace = StringWriter().also { error.printStackTrace(PrintWriter(it)) }.toString()
@@ -0,0 +1,60 @@
package com.droiddeck.launcher.session
import android.content.Context
import android.os.Build
import android.util.Log
import com.droiddeck.launcher.BuildConfig
import java.io.File
/** Device-detected defaults and launch evidence for experimental Quest compatibility. */
object QuestExperimental {
private const val TAG = "QuestExperimental"
const val DRIVER = "turnip25.1.0-quest1"
// Quest 2 has an A6xx GPU and cannot use this bundled A7xx driver.
internal fun supported(model: String, device: String, manufacturer: String): Boolean =
model.equals("Quest 3", ignoreCase = true) || model.equals("Quest 3S", ignoreCase = true) ||
((manufacturer.equals("Oculus", ignoreCase = true) || manufacturer.equals("Meta", ignoreCase = true)) &&
(device == "eureka" || device == "panther"))
fun isSupported(): Boolean = supported(Build.MODEL, Build.DEVICE, Build.MANUFACTURER)
fun initialize(context: Context) {
if (!isSupported()) return
val prefs = context.getSharedPreferences("session", Context.MODE_PRIVATE)
if (!prefs.getBoolean("questDefaultsV1", false)) {
// Auto would download an unwrapped display driver and lose the compatibility path.
// Apply once so deliberate changes made during headset testing remain possible.
prefs.edit()
.putString("gpuDriverMode", SessionPrefs.GPU_DRIVERS_MANUAL)
.putString("androidDriver", DRIVER)
.putString("linuxDriver", "")
// The existing HDR option uses SurfaceControl presentation. This is a
// corruption workaround from upstream issue #245, not a claim of HDR accuracy.
.putBoolean("hdr.steam", true)
.putBoolean("questDefaultsV1", true)
.apply()
}
val report = buildString {
appendLine("DroidDeck Quest Experimental ${BuildConfig.VERSION_NAME}")
appendLine("package=${context.packageName}")
appendLine("manufacturer=${Build.MANUFACTURER} model=${Build.MODEL}")
appendLine("device=${Build.DEVICE} board=${Build.BOARD} hardware=${Build.HARDWARE}")
appendLine("android=${Build.VERSION.RELEASE} sdk=${Build.VERSION.SDK_INT}")
appendLine("abis=${Build.SUPPORTED_ABIS.joinToString()}")
for (name in listOf("gpu_model", "gpu_chipid")) {
val value = runCatching { File("/sys/class/kgsl/kgsl-3d0/$name").readText().trim() }
.getOrDefault("unavailable")
appendLine("$name=$value")
}
appendLine("driverMode=${SessionPrefs.gpuDriverMode(context)}")
appendLine("androidDriver=${SessionPrefs.androidDriver(context)}")
appendLine("steamSurfaceControlWorkaround=${SessionPrefs.hdr(context, "steam")}")
appendLine("GPUOBJ fallback installed in Android driver and ARM64 libblsession")
appendLine("Experimental Quest 3/3S compatibility; 2D panel application")
}
Log.i(TAG, report)
runCatching { File(context.filesDir, "quest-startup.txt").writeText(report) }
.onFailure { Log.w(TAG, "Could not write startup report", it) }
}
}
@@ -585,6 +585,8 @@ class SessionService : Service() {
private fun addClientEnvironment(guest: MutableList<String>, steamHere: Boolean) {
guest.add("/usr/bin/env")
guest.add("-i")
// PRoot executes guest[0] directly; assignments belong after env -i.
guest.add("DROIDDECK_BWRAP_SOCKET=" + com.droiddeck.launcher.runtime.BwrapSpawner.socket(this))
guest.add("HOME=/root")
guest.add("USER=root")
guest.add("PATH=/usr/local/bin:/usr/bin:/bin")