Compare commits

...
11 changed files with 104 additions and 17 deletions

No files matched your search

@@ -6349,10 +6349,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
if (!intent.hasExtra(EXTRA_LINK_TASK)) intent.putExtra(EXTRA_LINK_TASK, this.intent.getIntExtra(EXTRA_LINK_TASK, -1)) if (!intent.hasExtra(EXTRA_LINK_TASK)) intent.putExtra(EXTRA_LINK_TASK, this.intent.getIntExtra(EXTRA_LINK_TASK, -1))
setIntent(intent) setIntent(intent)
if (::pip.isInitialized) pip.refresh(true) if (::pip.isInitialized) pip.refresh(true)
if (intent.getBooleanExtra(EXTRA_STEAMVR, false) && SessionState.mode == SessionService.MODE_STEAM) { if (intent.getBooleanExtra(EXTRA_STEAMVR, false) && SessionState.mode == SessionService.MODE_STEAM) requestSteamVr()
SessionState.steamVr = true
steamVrAutoTried = false
}
if (intent.action == SessionService.ACTION_HOME_GUIDE) { if (intent.action == SessionService.ACTION_HOME_GUIDE) {
handleHomeGuideIntent(intent) handleHomeGuideIntent(intent)
} else if (intent.action == SessionService.ACTION_RESUME) { } else if (intent.action == SessionService.ACTION_RESUME) {
@@ -6441,7 +6438,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private val questSteamVrRequest = object : Runnable { private val questSteamVrRequest = object : Runnable {
override fun run() { override fun run() {
if (com.droiddeck.launcher.session.QuestSteamVrLaunch.takeRequest(this@SessionActivity) && if (com.droiddeck.launcher.session.QuestSteamVrLaunch.takeRequest(this@SessionActivity) &&
SessionState.running && SessionState.mode == SessionService.MODE_STEAM) steamVrAction("start") SessionState.running && SessionState.mode == SessionService.MODE_STEAM) {
if (com.droiddeck.launcher.session.QuestSteamVrLaunch.opensDirectly(steamVrStatus)) steamVrAction("start")
else requestSteamVr()
}
uiHandler.postDelayed(this, 1000) uiHandler.postDelayed(this, 1000)
} }
} }
@@ -6500,6 +6500,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
updateHeadTracker() updateHeadTracker()
} }
private fun requestSteamVr() {
SessionState.steamVr = true
steamVrAutoTried = false
steamVrInstallTried = false
}
private fun steamVrAction(action: String) { private fun steamVrAction(action: String) {
if (action == "start" && com.droiddeck.launcher.session.QuestExperimental.isSupported()) { if (action == "start" && com.droiddeck.launcher.session.QuestExperimental.isSupported()) {
startActivity(android.content.Intent(this, QuestXrActivity::class.java)) startActivity(android.content.Intent(this, QuestXrActivity::class.java))
@@ -6977,6 +6983,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
SessionState.mode == SessionService.MODE_STEAM, steamVrAutoTried, steamVrInstallTried) ?: return SessionState.mode == SessionService.MODE_STEAM, steamVrAutoTried, steamVrInstallTried) ?: return
if (action == "start") steamVrAutoTried = true else steamVrInstallTried = true if (action == "start") steamVrAutoTried = true else steamVrInstallTried = true
Log.i(TAG, "requested SteamVR $action (glasses=${glasses.model}, output=$glassesOutputActive, control=${glasses.canControl})") Log.i(TAG, "requested SteamVR $action (glasses=${glasses.model}, output=$glassesOutputActive, control=${glasses.canControl})")
if (action == "install") Toast.makeText(this, R.string.cardboard_steamvr_installing, Toast.LENGTH_LONG).show()
steamVrAction(action) steamVrAction(action)
} }
@@ -951,6 +951,7 @@ internal object EnhancedSessionLogShare {
"battlenet.log", "spawned.log", "flatpak-install.log", "cef_log.txt", "cef_log.previous.txt", "droiddeck-bionic.log", "battlenet.log", "spawned.log", "flatpak-install.log", "cef_log.txt", "cef_log.previous.txt", "droiddeck-bionic.log",
"console_log.txt", "webhelper_js.txt", "controller_support.txt", "systemperfmanager.txt", "console_log.txt", "webhelper_js.txt", "controller_support.txt", "systemperfmanager.txt",
"rpcs3", "RPCS3.log", "rpcs3", "RPCS3.log",
"droiddeck-steamvr-launch.log", "droiddeck-vrstartup.log",
) )
private val KNOWN_COMPONENT_PATTERNS = listOf( private val KNOWN_COMPONENT_PATTERNS = listOf(
Regex("[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2,}-[a-z0-9-]{1,24}"), Regex("[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2,}-[a-z0-9-]{1,24}"),
@@ -1,6 +1,7 @@
package com.droiddeck.launcher.session package com.droiddeck.launcher.session
import android.content.Context import android.content.Context
import com.droiddeck.launcher.gpu.SteamVr
import java.io.File import java.io.File
/** /**
@@ -32,4 +33,7 @@ object QuestSteamVrLaunch {
fun takeRequest(context: Context): Boolean = fun takeRequest(context: Context): Boolean =
QuestExperimental.isSupported() && File(context.filesDir, "$DIR/$REQUEST").delete() QuestExperimental.isSupported() && File(context.filesDir, "$DIR/$REQUEST").delete()
fun opensDirectly(status: SteamVr.Status?): Boolean =
status == SteamVr.Status.READY || status == SteamVr.Status.RUNNING
} }
@@ -114,6 +114,23 @@ class EnhancedSessionLogShareTest {
SessionLogShare.clear(app) SessionLogShare.clear(app)
} }
@Test fun steamVrLaunchLogsAreSharedUnderTheirNames() {
val session = tmp.newFolder("2026-11-29-05-steam")
session.resolve("session.log").writeText("startup ok\n")
val steam = session.resolve("steam").apply { mkdirs() }
steam.resolve("droiddeck-steamvr-launch.log").writeText("downloading SteamVR (571 MB)\n")
steam.resolve("droiddeck-vrstartup.log").writeText("vrstartup ok\n")
steam.resolve("unknown-tool.log").writeText("other\n")
val zips = EnhancedSessionLogShare.create(app, session)
val names = zips.flatMap { zip -> ZipFile(zip).use { archive -> archive.entries().toList().map { it.name } } }
assertTrue(names.contains("${session.name}/steam/droiddeck-steamvr-launch.log"))
assertTrue(names.contains("${session.name}/steam/droiddeck-vrstartup.log"))
assertTrue(names.none { it.endsWith("/unknown-tool.log") })
SessionLogShare.clear(app)
}
@Test fun oversizedFilesKeepBoundedBeginningAndTailAndDeclareTruncation() { @Test fun oversizedFilesKeepBoundedBeginningAndTailAndDeclareTruncation() {
val session = tmp.newFolder("2026-11-04-02-game") val session = tmp.newFolder("2026-11-04-02-game")
session.resolve("steam-7.log").writeText("begin\n" + "middle\n".repeat(100) + "tail\n") session.resolve("steam-7.log").writeText("begin\n" + "middle\n".repeat(100) + "tail\n")
@@ -0,0 +1,24 @@
package com.droiddeck.launcher.session
import com.droiddeck.launcher.gpu.SteamVr
import org.junit.Assert.assertEquals
import org.junit.Test
class QuestSteamVrLaunchTest {
@Test fun aLibraryRequestOpensTheImmersiveViewOnlyWhenSteamVrIsInstalled() {
assertEquals(
setOf(SteamVr.Status.READY, SteamVr.Status.RUNNING),
SteamVr.Status.values().filter { QuestSteamVrLaunch.opensDirectly(it) }.toSet(),
)
assertEquals(false, QuestSteamVrLaunch.opensDirectly(null))
}
@Test fun aRequestThatHasToInstallSteamVrGoesThroughTheAutomaticInstallThenStart() {
assertEquals("install", SteamVr.autoAction(SteamVr.Status.NOT_INSTALLED, requested = true, loading = false,
steamSession = true, startTried = false, installTried = false))
assertEquals(null, SteamVr.autoAction(SteamVr.Status.INSTALLING, requested = true, loading = false,
steamSession = true, startTried = false, installTried = true))
assertEquals("start", SteamVr.autoAction(SteamVr.Status.READY, requested = true, loading = false,
steamSession = true, startTried = false, installTried = true))
}
}
+4 -2
View File
@@ -145,8 +145,10 @@ verification against the actual phone's Steam version after installation.
The helper serializes installation/startup and avoids restarting an active The helper serializes installation/startup and avoids restarting an active
DroidDeck SteamVR session. Library launch diagnostics are in DroidDeck SteamVR session. Library launch diagnostics are in
`${XDG_RUNTIME_DIR:-/tmp}/droiddeck-steamvr/library-launch.log`; normal runtime `droiddeck-steamvr-launch.log` in Steam's logs directory, next to
logs remain in `vrstartup.log` and Steam's logs directory. It does not intercept `droiddeck-vrstartup.log`, and Share logs includes both. On a Quest the helper
only asks the app for SteamVR: the app installs it if needed, showing that it is
downloading, then opens the immersive view. It does not intercept
arbitrary external `steam://` URLs or change VR game launch arguments. arbitrary external `steam://` URLs or change VR game launch arguments.
Only VR-only games (`vr_only`) wait for SteamVR and start it. Games where VR is Only VR-only games (`vr_only`) wait for SteamVR and start it. Games where VR is
+4
View File
@@ -83,6 +83,10 @@ and display timing, and returns owned stereo images tagged with the latest eye p
SteamVR haptics return through the tracking bridge. No root or separate XR APK SteamVR haptics return through the tracking bridge. No root or separate XR APK
is required. Other devices retain their existing SteamVR start behavior. is required. Other devices retain their existing SteamVR start behavior.
Play on SteamVR in Steam's library does the same: if SteamVR is not installed yet,
DroidDeck shows that it is downloading SteamVR, installs it, then opens the
immersive view.
The left Touch menu button is SteamVR's system button and toggles its dashboard. The left Touch menu button is SteamVR's system button and toggles its dashboard.
The right Meta button remains reserved by the headset OS. The right Meta button remains reserved by the headset OS.
@@ -546,10 +546,10 @@ VR_JS = r"""
def launch_steamvr(): def launch_steamvr():
say("SteamVR library launch: using the DroidDeck ARM64 helper") say("SteamVR library launch: using the DroidDeck ARM64 helper")
state = os.path.join(os.environ.get("XDG_RUNTIME_DIR", "/tmp"), "droiddeck-steamvr") logs = os.path.join(os.path.expanduser("~"), ".local/share/Steam/logs")
try: try:
os.makedirs(state, exist_ok=True) os.makedirs(logs, exist_ok=True)
with open(os.path.join(state, "library-launch.log"), "a") as log: with open(os.path.join(logs, "droiddeck-steamvr-launch.log"), "a") as log:
return subprocess.Popen([VR_HELPER, "launch"], stdin=subprocess.DEVNULL, return subprocess.Popen([VR_HELPER, "launch"], stdin=subprocess.DEVNULL,
stdout=log, stderr=subprocess.STDOUT, start_new_session=True) stdout=log, stderr=subprocess.STDOUT, start_new_session=True)
except OSError as e: except OSError as e:
@@ -103,15 +103,15 @@ case "${1:-status}" in
launch) launch)
exec 8>"$state/launch.lock" exec 8>"$state/launch.lock"
flock -n 8 || exit 0 flock -n 8 || exit 0
if [ -f "$state/quest-immersive" ]; then
: > "$state/xr-request"
echo "asked DroidDeck to install SteamVR if needed and open the Quest's immersive view"
exit 0
fi
if ! installed; then if ! installed; then
"$0" install || exit $? "$0" install || exit $?
while [ -f "$state/installing" ]; do sleep 1; done while [ -f "$state/installing" ]; do sleep 1; done
fi fi
if [ -f "$state/quest-immersive" ]; then
: > "$state/xr-request"
echo "asked DroidDeck to open the Quest's immersive view, which starts SteamVR"
exit 0
fi
"$0" start "$0" start
;; ;;
status) status)
+4 -2
View File
@@ -1003,13 +1003,15 @@ class SwitchToDesktopTest(unittest.TestCase):
self.assertEqual(patched["launch_steamvr"].call_count, 2) self.assertEqual(patched["launch_steamvr"].call_count, 2)
def test_vr_launch_runs_helper_without_shell_in_background(self): def test_vr_launch_runs_helper_without_shell_in_background(self):
with tempfile.TemporaryDirectory() as tmp, mock.patch.dict(os.environ, {"XDG_RUNTIME_DIR": tmp}): with tempfile.TemporaryDirectory() as tmp, mock.patch.dict(os.environ, {"HOME": tmp}):
with mock.patch.object(self.globals["subprocess"], "Popen") as popen: with mock.patch.object(self.globals["subprocess"], "Popen") as popen:
LIVE["launch_steamvr"]() LIVE["launch_steamvr"]()
self.assertEqual(popen.call_args.args, ([LIVE["VR_HELPER"], "launch"],)) self.assertEqual(popen.call_args.args, ([LIVE["VR_HELPER"], "launch"],))
self.assertTrue(popen.call_args.kwargs["start_new_session"]) self.assertTrue(popen.call_args.kwargs["start_new_session"])
self.assertNotIn("shell", popen.call_args.kwargs) self.assertNotIn("shell", popen.call_args.kwargs)
self.assertTrue((Path(tmp) / "droiddeck-steamvr/library-launch.log").exists()) self.assertEqual(popen.call_args.kwargs["stdout"].name,
str(Path(tmp) / ".local/share/Steam/logs/droiddeck-steamvr-launch.log"))
self.assertTrue((Path(tmp) / ".local/share/Steam/logs/droiddeck-steamvr-launch.log").exists())
def test_the_request_goes_to_steamos_session_select(self): def test_the_request_goes_to_steamos_session_select(self):
helper = LIVE["Helper"]("/steam", 1) helper = LIVE["Helper"]("/steam", 1)
+26
View File
@@ -274,6 +274,32 @@ class SteamVrHelperTest(unittest.TestCase):
self.assertTrue(vrpath.is_file()) self.assertTrue(vrpath.is_file())
self.assertTrue(xr.is_symlink()) self.assertTrue(xr.is_symlink())
def launch(self):
self.executable(self.commands / 'curl', 'echo curl >> "$CURL_CALLS"; exit 22')
self.environment['CURL_CALLS'] = str(self.root / 'curl-calls')
self.helper.chmod(0o755)
return subprocess.run(['sh', str(self.helper), 'launch'], env=self.environment,
capture_output=True, text=True, timeout=5)
def test_quest_launch_hands_a_missing_steamvr_to_the_app_without_downloading_it(self):
(self.steamvr / 'bin/linuxarm64/vrstartup').unlink()
state = self.runtime / 'droiddeck-steamvr'
state.mkdir(parents=True)
(state / 'quest-immersive').touch()
result = self.launch()
self.assertEqual(result.returncode, 0, result.stderr)
self.assertTrue((state / 'xr-request').is_file())
self.assertFalse((self.root / 'curl-calls').exists())
self.assertFalse((state / 'installing').exists())
def test_launch_elsewhere_still_installs_a_missing_steamvr_itself(self):
(self.steamvr / 'bin/linuxarm64/vrstartup').unlink()
result = self.launch()
self.assertEqual(result.returncode, 1)
self.assertIn('download failed', result.stdout)
self.assertTrue((self.root / 'curl-calls').is_file())
self.assertFalse((self.runtime / 'droiddeck-steamvr/xr-request').exists())
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()