From 342d2e7f208f131f6405aa482216a50ffafa78d7 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Sun, 11 Oct 2026 14:45:57 -0400 Subject: [PATCH 01/50] fix: the Steam client download resumes, retries and shows megabytes A first run downloads the native client, about 360 MB in 17 parts, before anything is on screen. The script ran plain `curl -fsSL` per part: no timeout, no retry, no progress. A stalled connection could wait for ever on "downloading Steam: bins_linuxarm64_linuxarm64 (2/17)" (a 110 MB part), a failed one ended the session and threw away everything fetched, and the loading screen said "~1-2 min" while counting parts, not bytes. Parts now go to package/droiddeck-download and stay there until the client is installed. Each one resumes from the bytes on disk (curl -C -), a transfer under 4 KB/s for a minute is dropped and resumed, attempts without progress back off 5-30 s before giving up, and a finished part is marked unpacked so a later session skips it. Bytes that fail their checksum are fetched whole again; a server that will not resume starts the part over; parts left for another client version are dropped. A repair redoes every part once and keeps what an interrupted repair redid. Every 5 s the step line carries megabytes overall ("(2/17), 45 of 360 MB"), which the loading screen shows as "45 / 360 MB" with the bar following the bytes. The session's step no longer promises 1-2 minutes. --- .../launcher/session/LoadingState.kt | 23 ++- .../launcher/session/LoadingStateTest.kt | 37 ++++ .../overlay/usr/local/bin/droiddeck-session | 4 +- .../usr/local/bin/droiddeck-steam-install | 108 ++++++++++-- tools/tests/test_steam_install.py | 159 +++++++++++++++++- 5 files changed, 311 insertions(+), 20 deletions(-) create mode 100644 app/src/test/java/com/droiddeck/launcher/session/LoadingStateTest.kt diff --git a/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt b/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt index 26799d0036..a190cbaef8 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt @@ -102,11 +102,10 @@ class LoadingState(context: Context, private val steam: Boolean = true) { if (line.startsWith("== STEP ")) { stepAt = at stepText = line.substringAfter("== STEP ").substringAfter(' ') - val m = INSTALL_COUNT.find(line) - if (m != null) { + clientDownload(line)?.let { (what, percent) -> clientDownloadAt = at - clientDownload = m.groupValues[1] - clientPercent = m.groupValues[2].toInt() * 100 / maxOf(1, m.groupValues[3].toInt()) + clientDownload = what + clientPercent = percent } } else { val m = UPDATE_PROGRESS.find(line) @@ -152,6 +151,21 @@ class LoadingState(context: Context, private val steam: Boolean = true) { } } + /** + * What a Steam client download line says to show and how far it is: megabytes when the + * runtime counts them (" (2/17), 45 of 360 MB"), else the part and its number. + */ + internal fun clientDownload(line: String): Pair? { + val count = INSTALL_COUNT.find(line) ?: return null + val mb = INSTALL_MEGABYTES.find(line.substring(count.range.last + 1)) + val done = mb?.groupValues?.get(1)?.toLongOrNull() + val total = mb?.groupValues?.get(2)?.toLongOrNull() + if (done != null && total != null && total > 0) { + return "$done / $total MB" to (done * 100 / total).toInt().coerceIn(0, 100) + } + return count.groupValues[1] to count.groupValues[2].toInt() * 100 / maxOf(1, count.groupValues[3].toInt()) + } + /** The script's install lines are worth reading as they are; its other notes are not. */ internal fun readableScriptStep(scriptStep: String): Boolean { val t = scriptStep.lowercase() @@ -161,5 +175,6 @@ class LoadingState(context: Context, private val steam: Boolean = true) { private const val TAIL_BYTES = 48L * 1024 private val UPDATE_PROGRESS = Regex("""Downloading update \((\d+) of (\d+) KB\)""") private val INSTALL_COUNT = Regex("""downloading Steam: (\S+) \((\d+)/(\d+)\)""") + private val INSTALL_MEGABYTES = Regex("""^, (\d+) of (\d+) MB""") } } diff --git a/app/src/test/java/com/droiddeck/launcher/session/LoadingStateTest.kt b/app/src/test/java/com/droiddeck/launcher/session/LoadingStateTest.kt new file mode 100644 index 0000000000..dd545f1f51 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/session/LoadingStateTest.kt @@ -0,0 +1,37 @@ +package com.droiddeck.launcher.session + +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Test + +class LoadingStateTest { + @Test fun clientDownloadCountsMegabytesWhenTheRuntimeSaysThem() { + assertEquals( + "45 / 360 MB" to 12, + LoadingState.clientDownload("== STEP 17:38:20 downloading Steam: bins_linuxarm64_linuxarm64 (2/17), 45 of 360 MB"), + ) + } + + @Test fun aStalledDownloadStillShowsWhereItIs() { + assertEquals( + "45 / 360 MB" to 12, + LoadingState.clientDownload( + "== STEP 17:39:20 downloading Steam: bins_linuxarm64_linuxarm64 (2/17), 45 of 360 MB" + + " - interrupted (curl exit 28), trying again in 5 s", + ), + ) + } + + @Test fun anOlderRuntimeShowsThePartAndItsNumber() { + assertEquals( + "bins_linuxarm64_linuxarm64" to 11, + LoadingState.clientDownload("== STEP 17:38:17 downloading Steam: bins_linuxarm64_linuxarm64 (2/17)"), + ) + // Under a megabyte in all: nothing to count yet. + assertEquals("a_all" to 50, LoadingState.clientDownload("== STEP 00:00:00 downloading Steam: a_all (1/2), 0 of 0 MB")) + } + + @Test fun otherStepsAreNotClientDownloads() { + assertNull(LoadingState.clientDownload("== STEP 17:38:14 checking the Steam client (a first run downloads it)")) + } +} diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session index 94d9a69370..5822ef0beb 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session @@ -368,7 +368,9 @@ case $mode in esac ;; steam) - step "checking the Steam client (first run downloads it, ~1-2 min with nothing on screen)" + # A first run downloads the client (about 360 MB in 2026): minutes on a slow connection, with + # the progress in megabytes on the loading screen. + step "checking the Steam client (a first run downloads it)" droiddeck-steam-install || exit $? step "Steam client ready" steam_root=$XDG_DATA_HOME/Steam diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install index 0eae6d0d27..85404bd620 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install @@ -12,6 +12,9 @@ stamp=$steam_root/package/droiddeck-installed legacy_stamp=$steam_root/package/bannerlator-installed unconfirmed=$steam_root/package/droiddeck-unconfirmed repair_request=$HOME/.bl-steam-repair +# The parts of an unfinished download: a session that ends, or loses its connection, part way +# through picks up where it stopped instead of fetching the whole client again. +parts=$steam_root/package/droiddeck-download if [ -f "$legacy_stamp" ] && [ ! -f "$stamp" ]; then mv -f "$legacy_stamp" "$stamp" || true fi @@ -24,6 +27,11 @@ elif [ -f "$unconfirmed" ] && ! grep -qx repaired "$unconfirmed" \ fi if [ -n "$repair" ]; then echo "== STEP $(date -u +%H:%M:%S) repairing the Steam client ($repair)" + # A repair unpacks every part again - once: an interrupted one keeps what it has redone. + if [ ! -f "$parts/.repair" ]; then + rm -rf "$parts" + mkdir -p "$parts" && : > "$parts/.repair" + fi rm -f "$stamp" "$legacy_stamp" "$steam_root/.crash" "$steam_root/steam.pid" \ "$steam_root"/package/steam_client_*.manifest "$steam_root"/package/steam_client_*.installed for part in "$steam_root"/package/*.zip.*; do @@ -41,26 +49,105 @@ fi work=$(mktemp -d) trap 'rm -rf "$work"' EXIT -curl -fsSL "$cdn/$manifest" -o "$work/manifest" + +# A sleep that starts no process (droiddeck-session's nap): read -t on a pipe nothing writes to. +nap() { + [ -n "${nap_fd:-}" ] || exec {nap_fd}<> <(:) + read -r -t "$1" -u "$nap_fd" _ 2>/dev/null || : +} +size_of() { + local n=0 + [ -f "$1" ] && n=$(wc -c < "$1") + echo $((n)) +} +# A connection can stall without closing (Wi-Fi power save, a phone changing networks), and +# curl's default then is to wait for ever with nothing on screen. A transfer under 4 KB/s for a +# minute is dropped and resumed from the bytes already on disk. +limits=(--connect-timeout 30 --speed-limit 4096 --speed-time 60) +# Seconds between attempts that made no progress; the download fails after the last one. +read -r -a delays <<< "${BL_STEAM_RETRY_DELAYS:-5 10 20 30 30}" + +step() { echo "== STEP $(date -u +%H:%M:%S) $*"; } +# The line the app's loading screen reads: the part, its number, and megabytes overall. A third +# argument is said after it (a stall), and is always said; otherwise only a change is. +progress() { + local mb=$(( (done_bytes + $(size_of "$1")) / 1000000 )) + [ -z "${3:-}" ] && [ "$mb" = "${shown_mb:-}" ] && [ "$2" = "${shown_part:-}" ] && return 0 + shown_mb=$mb shown_part=$2 + step "downloading Steam: $2 ($i/$total), $mb of $((total_bytes / 1000000)) MB${3:+ - $3}" +} + +# fetch URL FILE SIZE SHA256 PART: FILE complete and checked, resuming whatever is already there. +fetch() { + local url=$1 dest=$2 size=$3 sum=$4 part=$5 failures=0 bad=0 finished=0 before rc fd wait + while :; do + # Whole once it is as long as the manifest says, or (no size given) once curl finished it. + if [ -f "$dest" ] && { [ "$finished" = 1 ] || { [ "$size" -gt 0 ] && [ "$(size_of "$dest")" -ge "$size" ]; }; }; then + echo "$sum $dest" | sha256sum -c --quiet 2>/dev/null && return 0 + # Bytes that do not check out are fetched whole again, a few times at most. + rm -f "$dest" + finished=0 bad=$((bad + 1)) + [ "$bad" -lt 3 ] || { echo "droiddeck-steam-install: $part does not match its checksum" >&2; return 1; } + fi + before=$(size_of "$dest") + # curl's status comes back through the pipe (|| keeps set -e from ending the subshell before it + # is said); until then a progress line every 5 s. + exec {fd}< <(curl -fsSL "${limits[@]}" -C - -o "$dest" "$url" && echo 0 || echo $?) + until read -r -t 5 -u "$fd" rc; do + if [ $? -le 128 ]; then rc=1; break; fi + progress "$dest" "$part" + done + exec {fd}<&- + if [ "$rc" = 0 ]; then finished=1; continue; fi + # 33: the server would not resume. Start the part over. + [ "$rc" = 33 ] && rm -f "$dest" + if [ "$(size_of "$dest")" -gt "$before" ]; then failures=0; else failures=$((failures + 1)); fi + if [ "$failures" -gt "${#delays[@]}" ]; then + echo "droiddeck-steam-install: could not download $part (curl exit $rc); what arrived is kept for the next try" >&2 + return 1 + fi + wait=${delays[$((failures > 0 ? failures - 1 : 0))]} + progress "$dest" "$part" "interrupted (curl exit $rc), trying again in ${wait} s" + nap "$wait" + done +} + +curl -fsSL "${limits[@]}" --retry 5 --retry-connrefused --retry-delay 5 "$cdn/$manifest" -o "$work/manifest" version=$(awk -F'"' '$2 == "version" { print $4; exit }' "$work/manifest") -# Every component block: its name, then the plain zip's file name and sha256. +# Every component block: its name, then the plain zip's file name, sha256 and size. awk -F'"' ' /^\t"/ && NF >= 3 && $4 == "" { block = $2 } $2 == "file" { file[block] = $4 } $2 == "sha2" { sha[block] = $4 } - END { for (b in file) if (b ~ /_all$/ || b ~ /_linuxarm64_linuxarm64$/) print b, file[b], sha[b] } + $2 == "size" { size[block] = $4 } + END { for (b in file) if (b ~ /_all$/ || b ~ /_linuxarm64_linuxarm64$/) print b, file[b], sha[b], size[b] + 0 } ' "$work/manifest" | sort > "$work/parts" [ -s "$work/parts" ] || { echo "droiddeck-steam-install: no client components in $manifest" >&2; exit 1; } total=$(grep -c . "$work/parts" 2>/dev/null || echo 0) +total_bytes=$(awk '{ n += $4 } END { print n + 0 }' "$work/parts") -mkdir -p "$steam_root/package" -while read -r block file sum; do +mkdir -p "$parts" +# What an earlier attempt left for another client version is no use to this one. A part's file +# name carries its own hash, so a name still listed is the same part. +for left in "$parts"/*; do + [ -e "$left" ] || continue + name=${left##*/} + name=${name%.unpacked} + grep -qF " $name " "$work/parts" || rm -rf "$left" +done +done_bytes=0 +while read -r block file sum size; do i=$((${i:-0} + 1)) - echo "== STEP $(date -u +%H:%M:%S) downloading Steam: $block ($i/$total)" - curl -fsSL "$cdn/$file" -o "$work/$file" - echo "$sum $work/$file" | sha256sum -c --quiet - unzip -qo "$work/$file" -d "$steam_root" - rm -f "$work/$file" + if [ -f "$parts/$file.unpacked" ]; then + done_bytes=$((done_bytes + size)) + continue + fi + progress "$parts/$file" "$block" + fetch "$cdn/$file" "$parts/$file" "$size" "$sum" "$block" || exit 1 + unzip -qo "$parts/$file" -d "$steam_root" + : > "$parts/$file.unpacked" + rm -f "$parts/$file" + done_bytes=$((done_bytes + size)) done < "$work/parts" # Some entries are zipped with Windows separators; unzip keeps the backslash in the file name. find "$steam_root" -depth -name '*\\*' | while read -r odd; do @@ -90,6 +177,7 @@ ln -sfn "$steam_root/linuxarm64" "$HOME/.steam/sdkarm64" ln -sfn "$steam_root/steamrtarm64" "$HOME/.steam/binarm64" ln -sfn "$steam_root/linux32" "$HOME/.steam/sdk32" echo "$version" > "$stamp" +rm -rf "$parts" if [ -n "$repair" ]; then echo repaired > "$unconfirmed" rm -f "$repair_request" diff --git a/tools/tests/test_steam_install.py b/tools/tests/test_steam_install.py index f3e29bbe26..d71dd7b4db 100644 --- a/tools/tests/test_steam_install.py +++ b/tools/tests/test_steam_install.py @@ -26,13 +26,43 @@ class SteamInstallTest(unittest.TestCase): self.bin = self.root / 'bin' self.bin.mkdir() # Only the network is faked: exercise real manifest parsing, checksums and zip extraction. + # TEST_PLAN lines " " are used up in order by requests for that file: + # "cut " delivers up to that offset then drops the connection, "fail " + # delivers nothing, "norange" refuses to resume. curl = self.bin / 'curl' - curl.write_text('''#!/bin/bash -set -eu -printf '%s\\n' "$2" >> "$TEST_REQUESTS" -cp "$TEST_CDN/${2##*/}" "$4" + curl.write_text('''#!/usr/bin/env python3 +import os, sys +args = sys.argv[1:] +url = next(a for a in args if a.startswith('https://')) +out = args[args.index('-o') + 1] +name = url.rsplit('/', 1)[1] +offset = os.path.getsize(out) if '-C' in args and os.path.exists(out) else 0 +with open(os.environ['TEST_REQUESTS'], 'a') as log: + log.write(url + '\\n') +with open(os.environ['TEST_REQUESTS'] + '.offsets', 'a') as log: + log.write(f'{name} {offset}\\n') +action = [] +plan = os.environ.get('TEST_PLAN') +if plan and os.path.exists(plan): + lines = open(plan).read().splitlines() + for n, line in enumerate(lines): + if line.split()[0] == name: + action = line.split()[1:] + del lines[n] + open(plan, 'w').write(''.join(l + '\\n' for l in lines)) + break +if action[:1] == ['fail']: + sys.exit(int(action[1])) +if action[:1] == ['norange'] and offset: + sys.exit(33) +data = open(os.path.join(os.environ['TEST_CDN'], name), 'rb').read() +end = int(action[1]) if action[:1] == ['cut'] else len(data) +with open(out, 'ab' if offset else 'wb') as target: + target.write(data[offset:end]) +sys.exit(28 if end < len(data) else 0) ''') curl.chmod(0o755) + self.plan = self.root / 'plan' # macOS has shasum; the guest and Linux CI have sha256sum. if shutil.which('sha256sum') is None: sha = self.bin / 'sha256sum' @@ -44,7 +74,8 @@ cp "$TEST_CDN/${2##*/}" "$4" sha1.chmod(0o755) self.env = dict(os.environ, HOME=str(self.home), XDG_DATA_HOME=str(self.data), PATH=str(self.bin) + os.pathsep + os.environ['PATH'], - TEST_CDN=str(self.cdn), TEST_REQUESTS=str(self.requests)) + TEST_CDN=str(self.cdn), TEST_REQUESTS=str(self.requests), + TEST_PLAN=str(self.plan), BL_STEAM_RETRY_DELAYS='0 0 0') for channel in ('steamdeck_publicbeta',): archive = self.cdn / (channel + '.zip') with zipfile.ZipFile(archive, 'w') as package: @@ -157,5 +188,123 @@ cp "$TEST_CDN/${2##*/}" "$4" self.assertFalse(self.requests.exists()) + def publish(self, **parts): + """The CDN's client as these parts (block name -> byte count of incompressible content), + listed with sizes as Valve's manifest lists them.""" + files = {} + blocks = '' + for block, length in parts.items(): + archive = self.cdn / f'{block}.zip.{hashlib.sha1(block.encode()).hexdigest()}' + with zipfile.ZipFile(archive, 'w', zipfile.ZIP_STORED) as package: + package.writestr(f'parts/{block}', os.urandom(length)) + if block.endswith('_linuxarm64_linuxarm64'): + package.writestr('steamrtarm64/steam', 'steamdeck_publicbeta') + data = archive.read_bytes() + files[block] = archive.name + blocks += (f'\t"{block}"\n\t{{\n\t\t"file"\t\t"{archive.name}"\n\t\t"size"\t\t"{len(data)}"\n' + f'\t\t"sha2"\t\t"{hashlib.sha256(data).hexdigest()}"\n\t}}\n') + (self.cdn / 'steam_client_steamdeck_publicbeta_linuxarm64').write_text( + '"linuxarm64"\n{\n\t"version"\t\t"123456"\n' + blocks + '}\n') + return files + + def two_parts(self): + return self.publish(a_all=1_200_000, client_linuxarm64_linuxarm64=1_300_000) + + def plan_for(self, name, *actions): + with self.plan.open('a') as plan: + plan.writelines(f'{name} {action}\n' for action in actions) + + def offsets(self, name): + log = Path(str(self.requests) + '.offsets') + return [int(line.split()[1]) for line in log.read_text().splitlines() if line.split()[0] == name] + + def requested(self): + return [line.rsplit('/', 1)[1] for line in self.requests.read_text().splitlines()] + + @property + def download(self): + return self.steam / 'package/droiddeck-download' + + def test_progress_is_counted_in_megabytes_across_parts(self): + self.two_parts() + result = self.install() + self.assertEqual(0, result.returncode, result.stderr) + self.assertIn('downloading Steam: a_all (1/2), 0 of 2 MB\n', result.stdout) + self.assertIn('downloading Steam: client_linuxarm64_linuxarm64 (2/2), 1 of 2 MB\n', result.stdout) + self.assertTrue((self.steam / 'parts/a_all').is_file()) + self.assertFalse(self.download.exists()) + + def test_a_dropped_connection_resumes_from_what_arrived(self): + files = self.two_parts() + client = files['client_linuxarm64_linuxarm64'] + self.plan_for(client, 'cut 500000') + result = self.install() + self.assertEqual(0, result.returncode, result.stderr) + self.assertEqual([0, 500000], self.offsets(client)) + self.assertIn('interrupted (curl exit 28), trying again in 0 s', result.stdout) + self.assertEqual('123456\n', (self.steam / 'package/droiddeck-installed').read_text()) + + def test_a_failed_session_keeps_what_it_finished_and_fetched(self): + files = self.two_parts() + client = files['client_linuxarm64_linuxarm64'] + self.plan_for(client, 'cut 400000', *['fail 6'] * 4) + result = self.install() + self.assertNotEqual(0, result.returncode) + self.assertIn('could not download client_linuxarm64_linuxarm64 (curl exit 6)', result.stderr) + self.assertFalse((self.steam / 'package/droiddeck-installed').exists()) + self.assertTrue((self.download / (files['a_all'] + '.unpacked')).is_file()) + self.assertFalse((self.download / files['a_all']).exists()) + self.assertEqual(400000, (self.download / client).stat().st_size) + self.requests.unlink() + Path(str(self.requests) + '.offsets').unlink() + self.assertEqual(0, self.install().returncode) + # The next session asks only for the rest of the part it did not finish. + self.assertEqual(['steam_client_steamdeck_publicbeta_linuxarm64', client], self.requested()) + self.assertEqual([400000], self.offsets(client)) + self.assertFalse(self.download.exists()) + + def test_a_server_that_will_not_resume_starts_the_part_over(self): + files = self.two_parts() + client = files['client_linuxarm64_linuxarm64'] + self.plan_for(client, 'cut 400000', 'norange') + result = self.install() + self.assertEqual(0, result.returncode, result.stderr) + self.assertEqual([0, 400000, 0], self.offsets(client)) + + def test_bytes_that_do_not_check_out_are_fetched_again(self): + files = self.two_parts() + client = files['client_linuxarm64_linuxarm64'] + self.download.mkdir(parents=True) + (self.download / client).write_bytes(b'x' * (self.cdn / client).stat().st_size) + result = self.install() + self.assertEqual(0, result.returncode, result.stderr) + self.assertEqual([0], self.offsets(client)) + + def test_parts_left_for_another_client_version_are_dropped(self): + files = self.two_parts() + self.download.mkdir(parents=True) + (self.download / 'a_all.zip.0123').write_bytes(b'older') + (self.download / 'b_all.zip.4567.unpacked').write_bytes(b'') + self.plan_for(files['client_linuxarm64_linuxarm64'], *['fail 7'] * 4) + self.assertNotEqual(0, self.install().returncode) + self.assertEqual([files['a_all'] + '.unpacked'], sorted(p.name for p in self.download.iterdir())) + + def test_a_repair_unpacks_every_part_again_once(self): + files = self.two_parts() + self.assertEqual(0, self.install().returncode) + (self.home / '.bl-steam-repair').write_text('1\n') + self.requests.unlink() + self.plan_for(files['client_linuxarm64_linuxarm64'], *['fail 7'] * 4) + self.assertNotEqual(0, self.install().returncode) + self.assertIn(files['a_all'], self.requested()) + self.requests.unlink() + # Still a repair, but what the interrupted one redid is not done a third time. + self.assertEqual(0, self.install().returncode) + self.assertEqual(['steam_client_steamdeck_publicbeta_linuxarm64', files['client_linuxarm64_linuxarm64']], + self.requested()) + self.assertFalse((self.home / '.bl-steam-repair').exists()) + self.assertFalse(self.download.exists()) + + if __name__ == '__main__': unittest.main() From 0cd7f077257c8c86b7cd6ec5dfc0fa085ff0e1e3 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Sun, 11 Oct 2026 14:45:57 -0400 Subject: [PATCH 02/50] fix: a first run's Steam client download is not paused out of sight With the default background behavior (Manual), a session pauses as soon as DroidDeck is hidden or the screen turns off - one second after start in the report this came from, before the download had begun. "Keep downloads running" did not help: it is off by default, and it only recognizes the client's own game downloads, not the runtime fetching the client itself. Until the session shows its first frame, the download watch now also asks whether the client is still to be fetched (no install stamp or no client binary, or a repair asked for). While it is, the session is kept awake with its wake and Wi-Fi locks whatever the downloads setting says, the notification reads "Steam download active" with Suspend now, and a steam.client_download event marks start and end. The watch is set up before the first suspend decision, so a session started with the screen off is not paused first. Once the client is there, the chosen behavior applies again. --- .../launcher/session/SessionService.kt | 55 ++++++++++++++----- .../launcher/session/SteamDownloadMonitor.kt | 27 ++++++--- .../session/SteamDownloadMonitorTest.kt | 33 +++++++++++ 3 files changed, 93 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt index 4910015614..77031187a8 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -83,6 +83,12 @@ class SessionService : Service() { private val steamDownloadMonitor = SteamDownloadMonitor() private var downloadMonitorTask: Runnable? = null private var downloadActive = false + /** + * The runtime is fetching the Steam client itself (a first run, a repair), before anything is on + * screen. That download keeps the session awake whatever the downloads setting says: paused, a + * first run never gets as far as showing Steam. + */ + private var clientInstallActive = false private var suspendDownloadNow = false private var suspendPolicy = SessionPrefs.SUSPEND_MANUAL private var steamDownloadsInBackground = false @@ -229,6 +235,7 @@ class SessionService : Service() { suspendDownloadNow = false steamDownloadMonitor.reset() downloadActive = false + clientInstallActive = false steamSleepToken = null completeNativeSleep() suspendOperationPending = false @@ -550,8 +557,9 @@ class SessionService : Service() { if (!pulse.setSinkSuspended(false)) Log.w(TAG, "could not resume audio sink") }, ) - mainHandler.post { updateSuspendPolicy() } + // Watching first: a first run's client download must be known before anything is paused. updateDownloadMonitoring() + mainHandler.post { updateSuspendPolicy() } } } @@ -1331,8 +1339,7 @@ class SessionService : Service() { } val controller = suspendController ?: return val hidden = !activityVisible || !screenOn - val downloadsBlockingSuspend = steamDownloadsInBackground && SessionState.mode == MODE_STEAM && - suspendPolicy != SessionPrefs.SUSPEND_NEVER && hidden && downloadActive && !suspendDownloadNow + val downloadsBlockingSuspend = downloadsKeepAwake() && hidden && !suspendDownloadNow if (downloadsBlockingSuspend) acquireLocks() if (suspendPolicy != SessionPrefs.SUSPEND_NATIVE || !hidden || downloadsBlockingSuspend) { completeNativeSleep() @@ -1709,8 +1716,7 @@ class SessionService : Service() { .setContentText(getString( when { SessionState.suspended -> R.string.session_notification_paused - downloadActive && steamDownloadsInBackground && - suspendPolicy != SessionPrefs.SUSPEND_NEVER -> R.string.session_notification_downloads + downloadsKeepAwake() -> R.string.session_notification_downloads else -> R.string.session_notification } )) @@ -1718,8 +1724,7 @@ class SessionService : Service() { .apply { if (SessionState.suspended) { addAction(Notification.Action.Builder(null, getString(R.string.resume_session), resume).build()) - } else if (downloadActive && steamDownloadsInBackground && - suspendPolicy != SessionPrefs.SUSPEND_NEVER) { + } else if (downloadsKeepAwake()) { val suspend = PendingIntent.getService( this@SessionService, 3, Intent(this@SessionService, SessionService::class.java).setAction(ACTION_SUSPEND_NOW), @@ -1739,31 +1744,51 @@ class SessionService : Service() { getSystemService(NotificationManager::class.java)?.notify(NOTIFICATION_ID, buildNotification()) } + /** A download is under way that holds the session awake while it is out of sight. */ + private fun downloadsKeepAwake(): Boolean = + downloadActive && (steamDownloadsInBackground || clientInstallActive) && + SessionState.mode == MODE_STEAM && suspendPolicy != SessionPrefs.SUSPEND_NEVER + + /** + * Steam's own downloads with the downloads setting on, and the Steam client's download until the + * session shows its first frame whatever the setting: once Steam is on screen it was fetched. + */ + private fun downloadWatchWanted(): Boolean = + SessionState.running && SessionState.mode == MODE_STEAM && suspendPolicy != SessionPrefs.SUSPEND_NEVER && + (steamDownloadsInBackground || !SessionState.firstFrameSeen) + private fun updateDownloadMonitoring() { - val enabled = SessionState.running && SessionState.mode == MODE_STEAM && - steamDownloadsInBackground && suspendPolicy != SessionPrefs.SUSPEND_NEVER - if (!enabled) { + if (!downloadWatchWanted()) { val wasActive = downloadActive downloadMonitorTask?.let(mainHandler::removeCallbacks) downloadMonitorTask = null steamDownloadMonitor.reset() downloadActive = false + clientInstallActive = false if (wasActive) refreshNotification() return } if (downloadMonitorTask != null) return val poll = object : Runnable { override fun run() { - if (downloadMonitorTask !== this || !SessionState.running || - SessionState.mode != MODE_STEAM || !steamDownloadsInBackground || - suspendPolicy == SessionPrefs.SUSPEND_NEVER) { + if (downloadMonitorTask !== this) return + if (!downloadWatchWanted()) { + downloadMonitorTask = null + updateDownloadMonitoring() + updateSuspendPolicy() return } + val root = LinuxRuntime.rootDir(this@SessionService) val wasActive = downloadActive - downloadActive = steamDownloadMonitor.poll( - LinuxRuntime.rootDir(this@SessionService), + val wasInstalling = clientInstallActive + clientInstallActive = !SessionState.firstFrameSeen && SteamDownloadMonitor.clientInstallPending(root) + downloadActive = clientInstallActive || steamDownloadsInBackground && steamDownloadMonitor.poll( + root, receivedBytes = TrafficStats.getUidRxBytes(android.os.Process.myUid()), ) + if (wasInstalling != clientInstallActive) { + SessionEvents.record("steam.client_download", mapOf("active" to clientInstallActive)) + } if (wasActive != downloadActive) refreshNotification() updateSuspendPolicy() mainHandler.postDelayed(this, DOWNLOAD_POLL_MS) diff --git a/app/src/main/java/com/droiddeck/launcher/session/SteamDownloadMonitor.kt b/app/src/main/java/com/droiddeck/launcher/session/SteamDownloadMonitor.kt index af8515fbb6..d43aa3ab27 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SteamDownloadMonitor.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SteamDownloadMonitor.kt @@ -126,13 +126,26 @@ internal class SteamDownloadMonitor { private fun value(text: String, key: String): String? = Regex("\"$key\"\\s+\"([^\"]*)\"").find(text)?.groupValues?.get(1) - private companion object { - const val MANIFEST_PROGRESS_GRACE_MS = 8_000L + companion object { + /** + * The runtime has yet to fetch the Steam client: a first run, or a repair asked for or begun + * (droiddeck-steam-install drops its stamp as it starts one). That download runs before + * anything is on screen, and a paused session pauses it with the rest. + */ + fun clientInstallPending(runtimeRoot: File): Boolean { + val home = File(runtimeRoot, "root") + val steam = File(home, ".local/share/Steam") + val stamped = File(steam, "package/droiddeck-installed").isFile || + File(steam, "package/bannerlator-installed").isFile + return !(stamped && File(steam, "steamrtarm64/steam").isFile) || File(home, ".bl-steam-repair").exists() + } + + private const val MANIFEST_PROGRESS_GRACE_MS = 8_000L // Longer than Steam's ~60 s between rate lines, for when no traffic counter is available. - const val CONTENT_ACTIVITY_GRACE_MS = 90_000L - const val MIN_RECEIVE_BYTES_PER_SEC = 64L * 1024L - val PATH = Regex("\"path\"\\s+\"([^\"]+)\"") - val CONTENT_UPDATE = Regex("""AppID (\d+) (App|Workshop|Shader) update changed : (.*)""") - val CURRENT_RATE = Regex("""Current download rate: ([\d.]+) Mbps""") + private const val CONTENT_ACTIVITY_GRACE_MS = 90_000L + private const val MIN_RECEIVE_BYTES_PER_SEC = 64L * 1024L + private val PATH = Regex("\"path\"\\s+\"([^\"]+)\"") + private val CONTENT_UPDATE = Regex("""AppID (\d+) (App|Workshop|Shader) update changed : (.*)""") + private val CURRENT_RATE = Regex("""Current download rate: ([\d.]+) Mbps""") } } diff --git a/app/src/test/java/com/droiddeck/launcher/session/SteamDownloadMonitorTest.kt b/app/src/test/java/com/droiddeck/launcher/session/SteamDownloadMonitorTest.kt index 86cf320093..7ac818cfba 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/SteamDownloadMonitorTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/SteamDownloadMonitorTest.kt @@ -126,6 +126,39 @@ class SteamDownloadMonitorTest { } } + @Test fun theClientIsPendingUntilItIsInstalledAndStamped() { + val root = Files.createTempDirectory("droiddeck-steam-client-").toFile() + try { + val steam = File(root, "root/.local/share/Steam") + assertTrue(SteamDownloadMonitor.clientInstallPending(root)) + File(steam, "steamrtarm64").mkdirs() + File(steam, "steamrtarm64/steam").writeText("client") + // Unpacked but not finished: droiddeck-steam-install stamps the client last. + assertTrue(SteamDownloadMonitor.clientInstallPending(root)) + File(steam, "package").mkdirs() + File(steam, "package/droiddeck-installed").writeText("1791686101\n") + assertFalse(SteamDownloadMonitor.clientInstallPending(root)) + } finally { + root.deleteRecursively() + } + } + + @Test fun anOlderStampCountsAndARepairRequestIsPending() { + val root = Files.createTempDirectory("droiddeck-steam-client-").toFile() + try { + val steam = File(root, "root/.local/share/Steam") + File(steam, "steamrtarm64").mkdirs() + File(steam, "steamrtarm64/steam").writeText("client") + File(steam, "package").mkdirs() + File(steam, "package/bannerlator-installed").writeText("1\n") + assertFalse(SteamDownloadMonitor.clientInstallPending(root)) + File(root, "root/.bl-steam-repair").writeText("1\n") + assertTrue(SteamDownloadMonitor.clientInstallPending(root)) + } finally { + root.deleteRecursively() + } + } + private fun manifest(root: File, appId: String, downloaded: Long, total: Long, flags: Int): File { val file = File(root, "steamapps/appmanifest_$appId.acf") check(file.parentFile?.mkdirs() != false) From 430e77178e95146452816cf287b4d7c9345fe5f1 Mon Sep 17 00:00:00 2001 From: ovurrsl Date: Sat, 17 Oct 2026 06:35:50 +0300 Subject: [PATCH 03/50] fix: one refused thermal or power query no longer drops the others from the session report Thermal status, thermal headroom and power saver are now read one by one, so a vendor that throws on one of them still gets the other two lines, and the refused one shows as unknown. --- .../com/droiddeck/launcher/core/DeviceReport.kt | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt index 903851a5a9..f10eeb1c12 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt @@ -152,13 +152,17 @@ object DeviceReport { k("RAM total", FileUtils.sizeToString(mi.totalMem)) k("RAM available", FileUtils.sizeToString(mi.availMem)) } - runCatching { - val pm = context.getSystemService(Context.POWER_SERVICE) as PowerManager - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) k("Thermal status", thermalStatusName(pm.currentThermalStatus)) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - k("Thermal headroom (10 s)", pm.getThermalHeadroom(10).let { if (it.isNaN()) "not reported" else String.format(Locale.US, "%.2f", it) }) + val pm = runCatching { context.getSystemService(Context.POWER_SERVICE) as? PowerManager }.getOrNull() + if (pm != null) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + k("Thermal status", runCatching { thermalStatusName(pm.currentThermalStatus) }.getOrNull()) } - k("Power saver", pm.isPowerSaveMode) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + k("Thermal headroom (10 s)", runCatching { + pm.getThermalHeadroom(10).let { if (it.isNaN()) "not reported" else String.format(Locale.US, "%.2f", it) } + }.getOrNull()) + } + k("Power saver", runCatching { pm.isPowerSaveMode }.getOrNull()) } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { val rate = runCatching { context.getSystemService(PerformanceHintManager::class.java)?.preferredUpdateRateNanos }.getOrNull() From 663da2948c66b9de6ffa53c06e9fb719c593c787 Mon Sep 17 00:00:00 2001 From: The412Banner Date: Thu, 22 Oct 2026 22:12:20 +0000 Subject: [PATCH 04/50] fix(steam): the last change to a game's compatibility tool wins A game's tool can be chosen in DroidDeck (per-game Proton) and in Steam's game properties. When they disagreed, DroidDeck always put its own choice back: the live helper within a second of the change, and again at every session start. Resetting the game's DroidDeck profile made it worse - it saved "use the default" (null), which was then forced onto the game. A DroidDeck choice is now applied once, and the client's later pick stands: a pick of one of DroidDeck's Protons becomes the DroidDeck choice too, any other pick (FEX, a Steam Linux Runtime, clearing the forced tool) ends it. "Use the default" and a profile reset are applied once and then dropped, so the game follows the default like one DroidDeck never touched. What was applied is kept in state.json (games_applied); choices an earlier build already applied count as applied. games.json is rewritten only if the app did not replace it meanwhile. An x86-only Proton picked in Steam is still replaced, since it cannot start on the phone. --- .../usr/local/bin/droiddeck-steam-compat | 13 ++- .../overlay/usr/local/bin/steam-compatibility | 102 +++++++++++++++++- tools/tests/test_steam_compat_live.py | 82 ++++++++++++++ 3 files changed, 187 insertions(+), 10 deletions(-) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat index 3972faa9b3..e751d1f95d 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat @@ -583,9 +583,8 @@ class Helper: picked = COMPAT["picked_apps"](state) runnable = {t["name"].lower() for t in live} apps = sorted(set(installed) | set(picks) | set(prior_auto) | native_choices, key=COMPAT["app_order"]) - overrides = COMPAT["requested_games"]( - COMPAT["game_requests"](), catalog, [t["name"] for t in live]) - apps = sorted(set(apps) | set(overrides), key=COMPAT["app_order"]) + asked = [app for app, request in COMPAT["game_requests"]().items() if COMPAT["valid_game_request"](app, request)] + apps = sorted(set(apps) | set(asked), key=COMPAT["app_order"]) current = dict(page.compat("many(%s)" % json.dumps(apps)) or {}) refused = set(apps) - set(current) refused_native = native_choices & refused @@ -597,7 +596,6 @@ class Helper: if isinstance(state.get("auto"), dict): state["auto"] = prior_auto native_choices -= refused - overrides = {app: tool for app, tool in overrides.items() if app not in refused} current["0"] = top["selected"] native = COMPAT["native_targets"](self.steam_root, apps) raw_mapping = COMPAT["read_config_mapping"]( @@ -619,6 +617,10 @@ class Helper: current[app] = "" elif not current.get(app): current.pop(app, None) + # The client's pick of a tool the app chose for a game wins once the app's choice was applied. + requests = COMPAT["settled_game_requests"](state, current, catalog) + overrides = COMPAT["requested_games"](requests, catalog, [t["name"] for t in live]) + overrides = {app: tool for app, tool in overrides.items() if app not in refused} changes, auto = COMPAT["plan_mapping"]( current, installed, [t["name"] for t in live], default, COMPAT["followers"](state, current), native, picks, overrides, @@ -630,7 +632,8 @@ class Helper: state.update( auto={app: tool for app, tool in auto.items() if tool is not COMPAT["NATIVE_CHOICE"]}, native_choices=sorted(refused_native | {app for app, tool in auto.items() if tool is COMPAT["NATIVE_CHOICE"]}), - picked=COMPAT["picked_after"](current, changes), tools=catalog, live=True) + picked=COMPAT["picked_after"](current, changes), tools=catalog, live=True, + games_applied=COMPAT["applied_game_requests"](requests, overrides, state)) state.pop("native", None) if waiting: state["pending"] = wanted diff --git a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility index 41a37a9aa5..055f33ede5 100755 --- a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility +++ b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility @@ -1113,10 +1113,99 @@ def requested_tool(request, catalog): def game_requests(directory=None): - value = read_json(state_path("games.json", directory)) - if value.get("version") != 1 or not isinstance(value.get("games"), dict): - return {} - return value["games"] + return read_game_requests(directory)[0] + + +def read_game_requests(directory=None): + """The app's per-game Proton choices, and the file's text so a rewrite can tell the app wrote it since.""" + try: + with open(state_path("games.json", directory), encoding="utf-8") as f: + text = f.read() + value = json.loads(text) + except (OSError, ValueError): + return {}, None + if not isinstance(value, dict) or value.get("version") != 1 or not isinstance(value.get("games"), dict): + return {}, text + return value["games"], text + + +def write_game_requests(requests, original, directory=None): + """Rewrites games.json unless the app replaced it after it was read; that newer choice wins.""" + path = state_path("games.json", directory) + try: + with open(path, encoding="utf-8") as f: + if f.read() != original: + return False + except OSError: + if original is not None: + return False + return write_json(path, {"version": 1, "games": requests}) + + +def valid_game_request(app, request): + return (isinstance(app, str) and re.fullmatch(r"[1-9][0-9]*", app) is not None and int(app) <= 0xFFFFFFFF and + (request is None or isinstance(request, dict) and isinstance(request.get("dir"), str) and + request["dir"] != "" and isinstance(request.get("valve"), bool))) + + +def settle_game_requests(requests, state, current, catalog, missing_is_cleared=False): + """Whichever side changed a game's tool last wins. A choice the app makes is applied once; after + that the client's own pick stands: a pick of one of our Protons becomes the app's choice too, any + other pick (FEX, a Steam Linux Runtime, clearing the forced tool) ends the app's choice. "Use the + default" (null, also what a profile reset writes) is applied once and then dropped, so the game + follows the default like one the app never touched. Returns the new requests and whether they changed.""" + recorded = state.get("games_applied") + if isinstance(recorded, dict): + applied = dict(recorded) + else: + # Builds before this one kept no record but had already applied every choice they found; a + # first start has applied nothing yet. + applied = dict(requests) if "tools" in state else {} + by_name = {t["name"]: t for t in catalog} + out = dict(requests) + for app, request in requests.items(): + if not valid_game_request(app, request) or app not in applied or applied[app] != request: + continue + if request is None: + del out[app] + continue + wanted = requested_tool(request, catalog) + if wanted is None: + continue + if app in current: + picked = current[app] + elif missing_is_cleared: + picked = "" + else: + continue + if picked == wanted: + continue + tool = by_name.get(picked) + if tool and tool["dir"]: + out[app] = {"valve": tool["valve"], "dir": tool["dir"]} + else: + del out[app] + return out, out != requests + + +def settled_game_requests(state, current, catalog, missing_is_cleared=False, directory=None): + """Reads the app's choices, settles them against the client's picks and stores the result. When the + app rewrote the file meanwhile, its newer choices are settled again; they are never overwritten.""" + for _ in range(2): + requests, text = read_game_requests(directory) + settled, moved = settle_game_requests(requests, state, current, catalog, missing_is_cleared) + if not moved or write_game_requests(settled, text, directory): + return settled + return settled + + +def applied_game_requests(requests, overrides, state): + """What the app asked for that is now in the mapping; a tool not installed yet stays unapplied.""" + recorded = state.get("games_applied") + before = recorded if isinstance(recorded, dict) else {} + return {app: request if overrides.get(app) is not DEFERRED_GAME_TOOL else before.get(app) + for app, request in requests.items() if app in overrides and + (overrides.get(app) is not DEFERRED_GAME_TOOL or app in before)} def requested_games(requests, catalog, runnable=None): @@ -1306,7 +1395,9 @@ def register_default(config_path, apps=(), protect=(), default=None, catalog=Non else: default = state.get("default") if state.get("default") in names else TOOL steam_root = os.path.dirname(os.path.dirname(os.path.abspath(config_path))) - overrides = requested_games(game_requests(directory), catalog) + # With the client stopped, config.vdf is what it last kept: an app missing from it has no forced tool. + requests = settled_game_requests(state, current, catalog, not steam_running(), directory) + overrides = requested_games(requests, catalog) managed = state.get("auto", {}).keys() if isinstance(state.get("auto"), dict) else () native_choices = state.get("native_choices", ()) native = native_targets(steam_root, set(apps) | set(picks) | set(managed) | set(native_choices)) @@ -1325,6 +1416,7 @@ def register_default(config_path, apps=(), protect=(), default=None, catalog=Non state["auto"] = {app: tool for app, tool in auto.items() if tool is not NATIVE_CHOICE} state["native_choices"] = sorted(app for app, tool in auto.items() if tool is NATIVE_CHOICE) state["picked"] = picked_after(current, changes) + state["games_applied"] = applied_game_requests(requests, overrides, state) state.pop("native", None) state["tools"] = catalog state.setdefault("default", default) diff --git a/tools/tests/test_steam_compat_live.py b/tools/tests/test_steam_compat_live.py index a86aab8644..5b793c313c 100644 --- a/tools/tests/test_steam_compat_live.py +++ b/tools/tests/test_steam_compat_live.py @@ -641,6 +641,88 @@ class ReconcileTest(unittest.TestCase): self.assertEqual(page.mapping["10"], "GE-Proton9-1") self.assertEqual(state["auto"], {"11": TOOL}) + def games(self): + return json.loads((self.state / "games.json").read_text())["games"] + + def write_games(self, games): + (self.state / "games.json").write_text(json.dumps({"version": 1, "games": games})) + + def test_a_steam_pick_after_the_app_choice_is_kept_live(self): + page = FakePage({"0": TOOL, "10": TOOL, "11": TOOL}, [TOOL, TOOL_11, COMPAT["FEX_TOOL"]]) + self.write_games({"10": {"valve": True, "dir": "Proton 11.0 (ARM64)"}}) + state = self.reconcile(page) + self.assertEqual(page.sets, [("10", TOOL_11)]) + self.assertEqual(state["games_applied"], {"10": {"valve": True, "dir": "Proton 11.0 (ARM64)"}}) + + page.sets.clear() + page.mapping["10"] = COMPAT["FEX_TOOL"] + state = self.reconcile(page) + self.assertEqual(page.sets, []) + self.assertEqual(page.mapping["10"], COMPAT["FEX_TOOL"]) + self.assertEqual(self.games(), {}) + self.assertEqual(state["games_applied"], {}) + + self.write_games({"10": {"valve": True, "dir": "Proton 11.0 (ARM64)"}}) + self.reconcile(page) + self.assertEqual(page.sets, [("10", TOOL_11)]) + + def test_a_steam_pick_of_our_proton_becomes_the_app_choice_live(self): + page = FakePage({"0": TOOL, "10": TOOL, "11": TOOL}, [TOOL, TOOL_11]) + self.write_games({"10": {"valve": True, "dir": "Proton 11.0 (ARM64)"}}) + self.reconcile(page) + page.sets.clear() + page.mapping["10"] = TOOL + state = self.reconcile(page) + self.assertEqual(page.sets, []) + self.assertEqual(self.games(), {"10": {"valve": True, "dir": "Proton Experimental (ARM64)"}}) + self.assertEqual(state["games_applied"], self.games()) + + def test_use_the_default_applies_once_then_steam_picks_stand_live(self): + page = FakePage({"0": TOOL, "10": TOOL_11, "11": TOOL}, [TOOL, TOOL_11, COMPAT["FEX_TOOL"]]) + self.write_games({"10": None}) + self.reconcile(page) + self.assertEqual(page.sets, [("10", TOOL)]) + + page.sets.clear() + self.reconcile(page) + self.assertEqual(self.games(), {}) + page.mapping["10"] = COMPAT["FEX_TOOL"] + self.reconcile(page) + self.assertEqual(page.sets, []) + self.assertEqual(page.mapping["10"], COMPAT["FEX_TOOL"]) + + def test_choices_an_earlier_build_applied_give_way_to_steam_picks_live(self): + (self.state / "state.json").write_text(json.dumps({"default": TOOL, "auto": {"11": TOOL}, "tools": []})) + self.write_games({"10": None, "11": {"valve": True, "dir": "Proton 11.0 (ARM64)"}}) + page = FakePage({"0": TOOL, "10": COMPAT["FEX_TOOL"], "11": "steamlinuxruntime_sniper"}, + [TOOL, TOOL_11, COMPAT["FEX_TOOL"]]) + self.reconcile(page) + self.assertEqual(page.sets, []) + self.assertEqual(self.games(), {}) + + def test_an_app_choice_written_during_a_sync_is_not_overwritten(self): + self.write_games({"10": {"valve": True, "dir": "Proton 11.0 (ARM64)"}}) + requests, text = COMPAT["read_game_requests"]() + self.write_games({"10": {"valve": True, "dir": "Proton Experimental (ARM64)"}}) + self.assertFalse(COMPAT["write_game_requests"]({}, text)) + self.assertEqual(self.games(), {"10": {"valve": True, "dir": "Proton Experimental (ARM64)"}}) + + def test_a_steam_pick_is_kept_at_the_next_start(self): + config = self.steam / "config/config.vdf" + config.parent.mkdir(parents=True) + vdf = '"InstallConfigStore" { "Software" { "Valve" { "Steam" { "CompatToolMapping" { %s } } } } }' + entry = '"%s" { "name" "%s" "config" "" "priority" "250" }' + catalog = COMPAT["tool_catalog"](str(self.steam)) + self.write_games({"10": {"valve": True, "dir": "Proton 11.0 (ARM64)"}}) + config.write_text(vdf % (entry % ("0", TOOL) + entry % ("10", TOOL))) + with mock.patch.dict(COMPAT["register_default"].__globals__, steam_running=lambda: False): + COMPAT["register_default"](str(config), ["10"], catalog=catalog, directory=str(self.state), settle=True) + self.assertIn(entry % ("10", TOOL_11), " ".join(config.read_text().split())) + config.write_text(vdf % (entry % ("0", TOOL) + entry % ("10", COMPAT["FEX_TOOL"]))) + COMPAT["register_default"](str(config), ["10"], catalog=catalog, directory=str(self.state), settle=True) + self.assertIn(entry % ("10", COMPAT["FEX_TOOL"]), " ".join(config.read_text().split())) + self.assertEqual(self.games(), {}) + def test_file_mode_defers_to_the_live_helper(self): (self.state / "live.pid").write_text("%d\n" % os.getpid()) self.assertTrue(COMPAT["live_helper_running"]()) From 449dc301bd1d9320824662568397cea6c0c9afca Mon Sep 17 00:00:00 2001 From: The412Banner Date: Thu, 22 Oct 2026 22:29:03 +0000 Subject: [PATCH 05/50] fix(steam): keep the applied record for a game the client did not report, and apply nothing after a lost write Review: a game the client briefly refused lost its games_applied record, so its unchanged request later looked new and overwrote the Steam pick; it now keeps what was applied before. When the app rewrote games.json during both tries, the stale second read was applied; that pass now applies no per-game choice and keeps the record. --- .../usr/local/bin/droiddeck-steam-compat | 2 +- .../overlay/usr/local/bin/steam-compatibility | 18 ++++++++----- tools/tests/test_steam_compat_live.py | 26 +++++++++++++++++++ 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat index e751d1f95d..2793365bc8 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat @@ -619,7 +619,7 @@ class Helper: current.pop(app, None) # The client's pick of a tool the app chose for a game wins once the app's choice was applied. requests = COMPAT["settled_game_requests"](state, current, catalog) - overrides = COMPAT["requested_games"](requests, catalog, [t["name"] for t in live]) + overrides = COMPAT["requested_games"](requests or {}, catalog, [t["name"] for t in live]) overrides = {app: tool for app, tool in overrides.items() if app not in refused} changes, auto = COMPAT["plan_mapping"]( current, installed, [t["name"] for t in live], default, diff --git a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility index 055f33ede5..69030a6b09 100755 --- a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility +++ b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility @@ -1190,22 +1190,26 @@ def settle_game_requests(requests, state, current, catalog, missing_is_cleared=F def settled_game_requests(state, current, catalog, missing_is_cleared=False, directory=None): """Reads the app's choices, settles them against the client's picks and stores the result. When the - app rewrote the file meanwhile, its newer choices are settled again; they are never overwritten.""" + app rewrote the file meanwhile, its newer choices are settled again; they are never overwritten. + None when the app kept rewriting it: this pass then applies no per-game choice and records nothing.""" for _ in range(2): requests, text = read_game_requests(directory) settled, moved = settle_game_requests(requests, state, current, catalog, missing_is_cleared) if not moved or write_game_requests(settled, text, directory): return settled - return settled + return None def applied_game_requests(requests, overrides, state): - """What the app asked for that is now in the mapping; a tool not installed yet stays unapplied.""" + """What the app asked for that is now in the mapping. A tool not installed yet stays unapplied, and a + game this pass did not handle (the client refused to report it) keeps what was applied before.""" recorded = state.get("games_applied") before = recorded if isinstance(recorded, dict) else {} - return {app: request if overrides.get(app) is not DEFERRED_GAME_TOOL else before.get(app) - for app, request in requests.items() if app in overrides and - (overrides.get(app) is not DEFERRED_GAME_TOOL or app in before)} + if requests is None: + return dict(before) + return {app: request if app in overrides and overrides[app] is not DEFERRED_GAME_TOOL else before[app] + for app, request in requests.items() + if app in overrides and overrides[app] is not DEFERRED_GAME_TOOL or app in before} def requested_games(requests, catalog, runnable=None): @@ -1397,7 +1401,7 @@ def register_default(config_path, apps=(), protect=(), default=None, catalog=Non steam_root = os.path.dirname(os.path.dirname(os.path.abspath(config_path))) # With the client stopped, config.vdf is what it last kept: an app missing from it has no forced tool. requests = settled_game_requests(state, current, catalog, not steam_running(), directory) - overrides = requested_games(requests, catalog) + overrides = requested_games(requests or {}, catalog) managed = state.get("auto", {}).keys() if isinstance(state.get("auto"), dict) else () native_choices = state.get("native_choices", ()) native = native_targets(steam_root, set(apps) | set(picks) | set(managed) | set(native_choices)) diff --git a/tools/tests/test_steam_compat_live.py b/tools/tests/test_steam_compat_live.py index 5b793c313c..af2d8cfb62 100644 --- a/tools/tests/test_steam_compat_live.py +++ b/tools/tests/test_steam_compat_live.py @@ -707,6 +707,32 @@ class ReconcileTest(unittest.TestCase): self.assertFalse(COMPAT["write_game_requests"]({}, text)) self.assertEqual(self.games(), {"10": {"valve": True, "dir": "Proton Experimental (ARM64)"}}) + def test_an_app_the_client_briefly_refuses_keeps_its_applied_choice_live(self): + page = FakePage({"0": TOOL, "10": TOOL, "11": TOOL}, [TOOL, TOOL_11, COMPAT["FEX_TOOL"]]) + self.write_games({"10": {"valve": True, "dir": "Proton 11.0 (ARM64)"}}) + self.reconcile(page) + page.refused = {"10"} + state = self.reconcile(page) + self.assertEqual(state["games_applied"], {"10": {"valve": True, "dir": "Proton 11.0 (ARM64)"}}) + page.refused = set() + page.sets.clear() + page.mapping["10"] = COMPAT["FEX_TOOL"] + self.reconcile(page) + self.assertEqual(page.sets, []) + self.assertEqual(page.mapping["10"], COMPAT["FEX_TOOL"]) + + def test_an_app_rewriting_its_choices_during_both_tries_applies_none_of_them_live(self): + page = FakePage({"0": TOOL, "10": TOOL, "11": TOOL}, [TOOL, TOOL_11, COMPAT["FEX_TOOL"]]) + self.write_games({"10": {"valve": True, "dir": "Proton 11.0 (ARM64)"}}) + self.reconcile(page) + page.sets.clear() + page.mapping["10"] = COMPAT["FEX_TOOL"] + self.write_games({"10": {"valve": True, "dir": "Proton 11.0 (ARM64)"}, "11": None}) + with mock.patch.dict(COMPAT["settled_game_requests"].__globals__, write_game_requests=lambda *_: False): + state = self.reconcile(page) + self.assertEqual(page.sets, []) + self.assertEqual(state["games_applied"], {"10": {"valve": True, "dir": "Proton 11.0 (ARM64)"}}) + def test_a_steam_pick_is_kept_at_the_next_start(self): config = self.steam / "config/config.vdf" config.parent.mkdir(parents=True) From 53c63b6dc2dc0662a4f8da6ec7a817c19184a771 Mon Sep 17 00:00:00 2001 From: 0x1Nawaf Date: Fri, 23 Oct 2026 15:43:52 +0000 Subject: [PATCH 06/50] fix: keep a slightly early vsync tick for frame pacing --- app/src/main/cpp/waylandcomp/src/compositor.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/waylandcomp/src/compositor.c b/app/src/main/cpp/waylandcomp/src/compositor.c index 95a8bf83a6..fb15d50c32 100644 --- a/app/src/main/cpp/waylandcomp/src/compositor.c +++ b/app/src/main/cpp/waylandcomp/src/compositor.c @@ -807,11 +807,21 @@ static uint32_t nominal_refresh_ns(void) { return (uint32_t)(1000000000000LL / (int64_t)mhz); } +/* Gamescope paces from this timestamp (#717). The Choreographer tick is often still + * slightly ahead of this thread, because the UI thread queues the callback, and that + * used to throw the tick away (render_ns < tick) and report the draw time instead. + * Keep a tick within one refresh of the draw, ahead or behind. A missing tick, or one + * more than a refresh away, falls back to the draw time. Never report the next refresh: + * gamescope would wake a frame late. */ static int64_t presented_ns(int64_t render_ns) { - if (!g_tick_vsync_ns || render_ns - g_last_vsync_ns > (int64_t)nominal_refresh_ns() || - render_ns < g_tick_vsync_ns) + int64_t tick = g_tick_vsync_ns; + int64_t refresh = (int64_t)nominal_refresh_ns(); + if (!tick || render_ns - g_last_vsync_ns > refresh) return render_ns; - return g_tick_vsync_ns; + int64_t delta = render_ns - tick; + if (delta > refresh || -delta > refresh) + return render_ns; + return tick; } static void feedback_present_all(struct wl_list *list, int64_t t) { From 5d1e70cd203046d90cb2ef4c953386551a31206a Mon Sep 17 00:00:00 2001 From: coffeemeist3r Date: Wed, 21 Oct 2026 23:57:09 -0500 Subject: [PATCH 07/50] Keep FEX's TSO on for Unity games A FEX preset that turns TSO off (Performance, Extreme, Extreme-gn, Denuvo) breaks Unity players under FEX: - Megabonk (Unity 2023.2, IL2CPP, native Linux build, "Linux x86 (FEX)") froze on about half of its launches, every thread parked on a futex. With TSO on: 5 of 5 starts, and a played run stayed responsive. - Crab Game (Windows IL2CPP build under Proton arm64) crashed on 1 of 5 starts with an access violation in UnityPlayer.dll on a garbage pointer. With TSO on: 5 of 5 starts. A Unity player (UnityPlayer.dll, UnityPlayer.so or GameAssembly.so beside the executable) now keeps FEX_TSOENABLED=1 over the shared preset, the way .NET games already keep full TSO. The FEX tool applies the environment half of the game-file fixes too, so native Linux builds get it as well. A FEX preset chosen for the game itself still wins. Related: #1386 (its Mono crash happens with TSO already on) --- docs/development/game-environment.md | 6 +++++ .../overlay/usr/local/bin/droiddeck-fex | 20 +++++++++++--- .../overlay/usr/local/bin/droiddeck-game-env | 9 +++++++ tools/tests/test_droiddeck_fex.py | 26 +++++++++++++++++++ tools/tests/test_game_environment.py | 21 +++++++++++++++ 5 files changed, 78 insertions(+), 4 deletions(-) diff --git a/docs/development/game-environment.md b/docs/development/game-environment.md index a6e02b8e27..62530ca48d 100644 --- a/docs/development/game-environment.md +++ b/docs/development/game-environment.md @@ -52,6 +52,12 @@ environment entries and is intentionally narrower than **Reset game profile**. Values are literal strings, with no shell expansion; quotes are only needed when the consuming program expects them. +A Unity game under FEX (`UnityPlayer.dll` for Windows builds under Proton, +`UnityPlayer.so` or `GameAssembly.so` for native Linux builds started by +**Linux x86 (FEX)**) keeps FEX's TSO on when the Default profile's FEX preset +turns it off: without TSO such games can deadlock or crash (seen with Megabonk +and Crab Game). A FEX preset chosen for the game itself still applies. + ## Defaults and available suggestions The initial configuration enables Mesa shader caching with diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex b/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex index 331dcfecc2..0c05d4089b 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex @@ -671,15 +671,27 @@ def launch(command, env, mode, decide=None): return os.execve(fex["bin"], [fex["bin"], program] + command[1:], guest) -def game_environment(env): +def game_environment(env, command): try: game_env = runpy.run_path(os.path.join(BIN_DIR, "droiddeck-game-env")) env = game_env["game_gpu"](env) app = game_env["game_id"](env) or env.get("SteamAppId") or env.get("SteamGameId") if not app: return env - with open(GAME_ENVIRONMENT, encoding="utf-8") as source: - return game_env["apply_config"](env, json.load(source), str(app)) + fixes = {} + game = game_env["Game"](resolve(command[0], env), command[1:]) + for check in game_env["FIXES"]: + found = check(game) + # Environment fixes only: the launch arguments some fixes add were chosen for Windows builds. + if found and found[0]: + fixes.update(found[0]) + say(found[2]) + try: + with open(GAME_ENVIRONMENT, encoding="utf-8") as source: + config = json.load(source) + except FileNotFoundError: + config = {"version": 1} + return game_env["apply_config"](env, config, str(app), fixes) except FileNotFoundError: return env except Exception as error: @@ -810,7 +822,7 @@ def main(argv): return 0 if not command: return 2 - return launch(command, game_environment(dict(os.environ)), os.environ.get("DROIDDECK_FEX", "auto")) + return launch(command, game_environment(dict(os.environ), command), os.environ.get("DROIDDECK_FEX", "auto")) if action == "run": try: mode, decide, command = parse_run(args) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env index a38d77d8c5..22b5248f36 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env @@ -87,6 +87,15 @@ def dotnet_memory_ordering(game): return DOTNET_FEX, [], ".NET runtime: FEX with full TSO and without multiblock" +@fix +def unity_memory_ordering(game): + """A Unity player under FEX without TSO deadlocks or crashes: Megabonk (Linux, IL2CPP) froze with every + thread parked on a futex on about half of all launches, Crab Game (Windows under Proton, IL2CPP) died with + an access violation in UnityPlayer.dll. Presets that turn TSO off keep it on for Unity games.""" + if {"unityplayer.so", "gameassembly.so", "unityplayer.dll"} & game.files: + return {"FEX_TSOENABLED": "1"}, [], "Unity: FEX with TSO" + + @fix def godot_vulkan(game): if is_godot(game) and not game.has_arg("--rendering-driver"): diff --git a/tools/tests/test_droiddeck_fex.py b/tools/tests/test_droiddeck_fex.py index fed546dddc..fb8f9ad732 100644 --- a/tools/tests/test_droiddeck_fex.py +++ b/tools/tests/test_droiddeck_fex.py @@ -690,6 +690,32 @@ class LaunchTest(FexTestCase): command, env, mode = G["launch"].call_args[0] self.assertEqual((command, mode), (["/game/run.sh", "-a"], "auto")) + def test_steam_games_get_their_settings_and_linux_unity_keeps_tso(self): + config = self.home / ".config/droiddeck/game-environment.json" + unity = self.write(self.tmp / "Megabonk/Megabonk.x86_64", elf(62), 0o755) + self.write(self.tmp / "Megabonk/UnityPlayer.so", elf(62)) + self.write(self.tmp / "Megabonk/GameAssembly.so", elf(62)) + other = self.write(self.tmp / "Other/game.x86_64", elf(62), 0o755) + self.write(config, json.dumps({"version": 1, "shared": {"FEX_TSOENABLED": "0", "FEX_MULTIBLOCK": "1"}, + "games": {"20": {"FEX_TSOENABLED": "0"}}})) + + def started(program, app): + with mock.patch.dict(G, {"launch": mock.Mock(return_value=0), "GAME_ENVIRONMENT": str(config)}), \ + mock.patch.dict(os.environ, {"SteamAppId": app}, clear=True): + _, said = self.quiet(FEX["main"], ["steam", "waitforexitandrun", str(program), "-arg"]) + command, env, _ = G["launch"].call_args[0] + self.assertEqual(command, [str(program), "-arg"]) + return env.get("FEX_TSOENABLED"), env.get("FEX_MULTIBLOCK"), said + + tso, multiblock, said = started(unity, "10") + self.assertEqual((tso, multiblock), ("1", "1")) + self.assertIn("Unity: FEX with TSO", said) + self.assertEqual(started(other, "10")[:2], ("0", "1")) + self.assertEqual(started(unity, "20")[:2], ("0", "1")) + config.unlink() + self.assertEqual(started(unity, "10")[:2], ("1", None)) + self.assertEqual(started(other, "10")[:2], (None, None)) + class AppInfoTest(unittest.TestCase): COMPAT = runpy.run_path(str(BIN / "steam-compatibility")) diff --git a/tools/tests/test_game_environment.py b/tools/tests/test_game_environment.py index c5c308c8cc..bbae1b3a7d 100644 --- a/tools/tests/test_game_environment.py +++ b/tools/tests/test_game_environment.py @@ -357,6 +357,27 @@ class GameEnvironmentTest(unittest.TestCase): (asylum / name).touch() self.assertEqual(MODULE["engine_fixes"](str(asylum / "BmLauncher.exe"), []), ({}, [], [])) + def test_unity_players_keep_tso_over_the_preset(self): + with tempfile.TemporaryDirectory() as tmp: + def game(*names): + for name in names: + (Path(tmp) / name).parent.mkdir(parents=True, exist_ok=True) + (Path(tmp) / name).touch() + return str(Path(tmp) / names[0]) + + il2cpp = game("Megabonk/Megabonk.x86_64", "Megabonk/UnityPlayer.so", "Megabonk/GameAssembly.so") + mono = game("Mono/Game.x86_64", "Mono/UnityPlayer.so") + windows = game("Crab Game/Crab Game.exe", "Crab Game/UnityPlayer.dll", "Crab Game/GameAssembly.dll") + windows_mono = game("RoR2/Risk of Rain 2.exe", "RoR2/UnityPlayer.dll", "RoR2/MonoBleedingEdge/mono-2.0-bdwgc.dll") + for exe in (il2cpp, mono, windows, windows_mono): + env, extra, notes = MODULE["engine_fixes"](exe, []) + self.assertEqual((env, extra, notes), ({"FEX_TSOENABLED": "1"}, [], ["Unity: FEX with TSO"])) + performance = {"version": 1, "shared": {"FEX_TSOENABLED": "0", "FEX_VECTORTSOENABLED": "0"}} + result = MODULE["apply_config"]({}, performance, "3405340", env) + self.assertEqual((result["FEX_TSOENABLED"], result["FEX_VECTORTSOENABLED"]), ("1", "0")) + performance["games"] = {"3405340": {"FEX_TSOENABLED": "0"}} + self.assertEqual(MODULE["apply_config"]({}, performance, "3405340", env)["FEX_TSOENABLED"], "0") + def test_a_new_fix_only_needs_registering(self): with tempfile.TemporaryDirectory() as tmp: (Path(tmp) / "Game.exe").touch() From 4d868399100fd0a69718257e27c3eb91afeae3bb Mon Sep 17 00:00:00 2001 From: XxJSONDeruloxX Date: Fri, 23 Oct 2026 15:00:11 -0400 Subject: [PATCH 08/50] fix: preserve GPU stats while pinning clocks --- app/src/main/cpp/waylandcomp/CMakeLists.txt | 1 + .../main/cpp/waylandcomp/src/gpu_clock_pin.c | 160 ++++++++++++++++ .../main/cpp/waylandcomp/src/gpu_clock_pin.h | 5 + .../cpp/waylandcomp/src/waylandcomp_jni.c | 11 +- .../droiddeck/launcher/session/GpuClockPin.kt | 1 + tools/tests/test_gpu_clock_pin.c | 172 ++++++++++++++++++ tools/tests/test_gpu_clock_pin.py | 30 +++ 7 files changed, 378 insertions(+), 2 deletions(-) create mode 100644 app/src/main/cpp/waylandcomp/src/gpu_clock_pin.c create mode 100644 app/src/main/cpp/waylandcomp/src/gpu_clock_pin.h create mode 100644 tools/tests/test_gpu_clock_pin.c create mode 100644 tools/tests/test_gpu_clock_pin.py diff --git a/app/src/main/cpp/waylandcomp/CMakeLists.txt b/app/src/main/cpp/waylandcomp/CMakeLists.txt index 33585818ba..f8eb312910 100644 --- a/app/src/main/cpp/waylandcomp/CMakeLists.txt +++ b/app/src/main/cpp/waylandcomp/CMakeLists.txt @@ -8,6 +8,7 @@ add_library(droiddeckwayland SHARED src/sc_layer.c src/ahb_swapchain.c src/waylandcomp_jni.c + src/gpu_clock_pin.c src/droiddeck_ext.c src/wl_dmabuf.c src/wl_clipboard.c diff --git a/app/src/main/cpp/waylandcomp/src/gpu_clock_pin.c b/app/src/main/cpp/waylandcomp/src/gpu_clock_pin.c new file mode 100644 index 0000000000..5b079da973 --- /dev/null +++ b/app/src/main/cpp/waylandcomp/src/gpu_clock_pin.c @@ -0,0 +1,160 @@ +#include "gpu_clock_pin.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../adrenotools/src/hook/kgsl.h" + +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; +static pthread_t worker; +static bool joinable; +static atomic_bool running; + +struct pin { + int fd; + unsigned int context; + unsigned int memory; + unsigned int timestamp; + unsigned long gpuaddr; + void *commands; + size_t size; +}; + +static struct pin pin = { .fd = -1 }; + +static void release_pin(void) { + if (pin.context) { + struct kgsl_drawctxt_destroy destroy = { .drawctxt_id = pin.context }; + ioctl(pin.fd, IOCTL_KGSL_DRAWCTXT_DESTROY, &destroy); + } + if (pin.commands) munmap(pin.commands, pin.size); + if (pin.memory) { + struct kgsl_gpumem_free_id free_memory = { .id = pin.memory }; + ioctl(pin.fd, IOCTL_KGSL_GPUMEM_FREE_ID, &free_memory); + } + if (pin.fd >= 0) close(pin.fd); + pin = (struct pin) { .fd = -1 }; +} + +static bool submit_pin(void) { + struct kgsl_command_object object = { + .gpuaddr = pin.gpuaddr, + .size = 2 * sizeof(uint32_t), + .flags = KGSL_CMDLIST_IB, + .id = pin.memory, + }; + struct kgsl_gpu_command command = { + .flags = KGSL_CMDBATCH_PWR_CONSTRAINT, + .cmdlist = (uintptr_t)&object, + .cmdsize = sizeof(object), + .numcmds = 1, + .context_id = pin.context, + }; + if (ioctl(pin.fd, IOCTL_KGSL_GPU_COMMAND, &command) < 0) return false; + pin.timestamp = command.timestamp; + return true; +} + +static bool prepare_pin(void) { + pin.fd = open("/dev/kgsl-3d0", O_RDWR | O_CLOEXEC); + if (pin.fd < 0) return false; + struct kgsl_drawctxt_create context = { + .flags = KGSL_CONTEXT_NO_GMEM_ALLOC | KGSL_CONTEXT_PREAMBLE | KGSL_CONTEXT_PWR_CONSTRAINT, + }; + if (ioctl(pin.fd, IOCTL_KGSL_DRAWCTXT_CREATE, &context) < 0) return false; + pin.context = context.drawctxt_id; + struct kgsl_device_constraint_pwrlevel level = { .level = KGSL_CONSTRAINT_PWR_MAX }; + struct kgsl_device_constraint constraint = { + .type = KGSL_CONSTRAINT_PWRLEVEL, + .context_id = pin.context, + .data = &level, + .size = sizeof(level), + }; + struct kgsl_device_getproperty property = { + .type = KGSL_PROP_PWR_CONSTRAINT, + .value = &constraint, + .sizebytes = sizeof(constraint), + }; + if (ioctl(pin.fd, IOCTL_KGSL_SETPROPERTY, &property) < 0) return false; + struct kgsl_gpumem_alloc_id memory = { .size = 4096 }; + if (ioctl(pin.fd, IOCTL_KGSL_GPUMEM_ALLOC_ID, &memory) < 0) return false; + pin.memory = memory.id; + pin.gpuaddr = memory.gpuaddr; + pin.size = memory.mmapsize; + void *commands = mmap(NULL, pin.size, PROT_READ | PROT_WRITE, MAP_SHARED, pin.fd, + (off_t)pin.memory << 12); + if (commands == MAP_FAILED) return false; + pin.commands = commands; + // Type-7 CP_NOP, one payload dword; both odd-parity bits are zero. + uint32_t *words = commands; + words[0] = 0x70100001; + words[1] = 0; + struct kgsl_gpumem_sync_cache sync = { .id = pin.memory, .op = KGSL_GPUMEM_CACHE_CLEAN }; + if (ioctl(pin.fd, IOCTL_KGSL_GPUMEM_SYNC_CACHE, &sync) < 0) return false; + return submit_pin(); +} + +static void *hold_pin(void *unused) { + (void)unused; + while (atomic_load(&running)) { + struct kgsl_device_waittimestamp_ctxtid wait = { + .context_id = pin.context, + .timestamp = pin.timestamp, + .timeout = 100, + }; + if (ioctl(pin.fd, IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID, &wait) < 0) { + if (errno == EINTR || errno == ETIMEDOUT) continue; + break; + } + // Constraints expire after idle_timer (normally 80 ms); renew with a NOP, keeping devfreq alive. + usleep(25000); + if (atomic_load(&running) && !submit_pin()) break; + } + if (atomic_exchange(&running, false)) + __android_log_print(ANDROID_LOG_WARN, "GpuClockPin", "constraint stopped: %s", strerror(errno)); + release_pin(); + return NULL; +} + +bool gpu_clock_pin_set(bool on) { + pthread_mutex_lock(&lock); + if (joinable) { + if (on && atomic_load(&running)) { + pthread_mutex_unlock(&lock); + return true; + } + atomic_store(&running, false); + pthread_join(worker, NULL); + joinable = false; + } + bool ok = true; + if (on) { + ok = prepare_pin(); + if (ok) { + atomic_store(&running, true); + int error = pthread_create(&worker, NULL, hold_pin, NULL); + if (error) { + atomic_store(&running, false); + errno = error; + ok = false; + } else { + joinable = true; + } + } + if (!ok) { + int error = errno; + release_pin(); + errno = error; + } + } + pthread_mutex_unlock(&lock); + return ok; +} diff --git a/app/src/main/cpp/waylandcomp/src/gpu_clock_pin.h b/app/src/main/cpp/waylandcomp/src/gpu_clock_pin.h new file mode 100644 index 0000000000..5fe17d102e --- /dev/null +++ b/app/src/main/cpp/waylandcomp/src/gpu_clock_pin.h @@ -0,0 +1,5 @@ +#pragma once + +#include + +bool gpu_clock_pin_set(bool on); diff --git a/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c b/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c index 6a407088bb..bc349cdf6c 100644 --- a/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c +++ b/app/src/main/cpp/waylandcomp/src/waylandcomp_jni.c @@ -16,6 +16,7 @@ #include "effects_chain.h" #include "cardboard.h" #include "droiddeck_color.h" +#include "gpu_clock_pin.h" extern int droiddeck_wayland_run(void); extern void droiddeck_wayland_set_scale_mode(int mode, int alignment); @@ -634,8 +635,14 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeTextInputDelete(JNIE extern void adrenotools_set_turbo(bool turbo); JNIEXPORT void JNICALL Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetGpuTurbo(JNIEnv *env, jclass clazz, jboolean on) { - (void)env; (void)clazz; - adrenotools_set_turbo(on == JNI_TRUE); + (void)clazz; + if (!gpu_clock_pin_set(on == JNI_TRUE)) { + int saved_errno = errno; + jclass error = (*env)->FindClass(env, "java/lang/IllegalStateException"); + if (error) (*env)->ThrowNew(env, error, strerror(saved_errno)); + } + // Clear a legacy global pin when recovering its marker after an app upgrade or crash. + if (on != JNI_TRUE) adrenotools_set_turbo(false); } JNIEXPORT jint JNICALL diff --git a/app/src/main/java/com/droiddeck/launcher/session/GpuClockPin.kt b/app/src/main/java/com/droiddeck/launcher/session/GpuClockPin.kt index 7855c49590..40135f08de 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/GpuClockPin.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/GpuClockPin.kt @@ -26,6 +26,7 @@ object GpuClockPin { pinned = true "gpu clock: held at its top" } catch (t: Throwable) { + File(context.filesDir, MARKER).delete() Log.w(TAG, "pin", t) "gpu clock: pin failed" } diff --git a/tools/tests/test_gpu_clock_pin.c b/tools/tests/test_gpu_clock_pin.c new file mode 100644 index 0000000000..8e3f0b6a4c --- /dev/null +++ b/tools/tests/test_gpu_clock_pin.c @@ -0,0 +1,172 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../../app/src/main/cpp/adrenotools/src/hook/kgsl.h" +#include "../../app/src/main/cpp/waylandcomp/src/gpu_clock_pin.h" + +enum { NONE, OPEN, CONTEXT, CONSTRAINT, MEMORY, MAP, SYNC, SUBMIT, THREAD, WAIT }; +static atomic_int failure, descriptors, contexts, memories, mappings, submissions; +static atomic_bool timeout_wait; +static uint32_t commands[1024]; + +int __android_log_print(int priority, const char *tag, const char *format, ...) { + (void)priority; (void)tag; (void)format; + return 0; +} + +int __wrap_open(const char *path, int flags, ...) { + (void)flags; + assert(!strcmp(path, "/dev/kgsl-3d0")); + if (atomic_load(&failure) == OPEN) { errno = EACCES; return -1; } + assert(atomic_fetch_add(&descriptors, 1) == 0); + return 91; +} + +int __wrap_close(int fd) { + assert(fd == 91); + assert(atomic_fetch_sub(&descriptors, 1) == 1); + errno = EBADF; + return 0; +} + +void *__wrap_mmap(void *address, size_t size, int protection, int flags, int fd, off_t offset) { + (void)address; (void)protection; (void)flags; + assert(fd == 91 && size == sizeof(commands) && offset == (23 << 12)); + if (atomic_load(&failure) == MAP) { errno = EACCES; return MAP_FAILED; } + assert(atomic_fetch_add(&mappings, 1) == 0); + return commands; +} + +int __wrap_munmap(void *address, size_t size) { + assert(address == commands && size == sizeof(commands)); + assert(atomic_fetch_sub(&mappings, 1) == 1); + return 0; +} + +#ifdef __ANDROID__ +int __wrap_ioctl(int fd, int request, ...) { +#else +int __wrap_ioctl(int fd, unsigned long request, ...) { +#endif + assert(fd == 91); + va_list args; + va_start(args, request); + void *arg = va_arg(args, void *); + va_end(args); + int step = NONE; + switch ((unsigned int)request) { + case IOCTL_KGSL_DRAWCTXT_CREATE: step = CONTEXT; break; + case IOCTL_KGSL_SETPROPERTY: step = CONSTRAINT; break; + case IOCTL_KGSL_GPUMEM_ALLOC_ID: step = MEMORY; break; + case IOCTL_KGSL_GPUMEM_SYNC_CACHE: step = SYNC; break; + case IOCTL_KGSL_GPU_COMMAND: step = SUBMIT; break; + case IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID: step = WAIT; break; + } + if (step && atomic_load(&failure) == step) { errno = EACCES; return -1; } + switch ((unsigned int)request) { + case IOCTL_KGSL_DRAWCTXT_CREATE: { + struct kgsl_drawctxt_create *context = arg; + assert(context->flags & KGSL_CONTEXT_PWR_CONSTRAINT); + context->drawctxt_id = 17; + atomic_fetch_add(&contexts, 1); + break; + } + case IOCTL_KGSL_SETPROPERTY: { + struct kgsl_device_getproperty *property = arg; + assert(property->type == KGSL_PROP_PWR_CONSTRAINT); + struct kgsl_device_constraint *constraint = property->value; + assert(constraint->context_id == 17 && constraint->type == KGSL_CONSTRAINT_PWRLEVEL); + assert(((struct kgsl_device_constraint_pwrlevel *)constraint->data)->level == KGSL_CONSTRAINT_PWR_MAX); + break; + } + case IOCTL_KGSL_GPUMEM_ALLOC_ID: { + struct kgsl_gpumem_alloc_id *memory = arg; + memory->id = 23; memory->gpuaddr = 0x100000; memory->mmapsize = sizeof(commands); + atomic_fetch_add(&memories, 1); + break; + } + case IOCTL_KGSL_GPUMEM_SYNC_CACHE: + assert(((struct kgsl_gpumem_sync_cache *)arg)->op == KGSL_GPUMEM_CACHE_CLEAN); + break; + case IOCTL_KGSL_GPU_COMMAND: { + struct kgsl_gpu_command *command = arg; + struct kgsl_command_object *object = (void *)(uintptr_t)command->cmdlist; + assert(command->context_id == 17 && command->numcmds == 1); + assert(command->flags & KGSL_CMDBATCH_PWR_CONSTRAINT); + assert(object->id == 23 && object->gpuaddr == 0x100000 && object->size == 8); + assert(commands[0] == 0x70100001 && commands[1] == 0); + command->timestamp = atomic_fetch_add(&submissions, 1) + 1; + break; + } + case IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID: + if (atomic_load(&timeout_wait)) { errno = ETIMEDOUT; return -1; } + break; + case IOCTL_KGSL_DRAWCTXT_DESTROY: + assert(atomic_fetch_sub(&contexts, 1) == 1); + break; + case IOCTL_KGSL_GPUMEM_FREE_ID: + assert(atomic_fetch_sub(&memories, 1) == 1); + break; + default: assert(!"unexpected ioctl"); + } + return 0; +} + +int __real_pthread_create(pthread_t *, const pthread_attr_t *, void *(*)(void *), void *); +int __wrap_pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start)(void *), void *arg) { + if (atomic_load(&failure) == THREAD) return EAGAIN; + return __real_pthread_create(thread, attr, start, arg); +} + +static void assert_released(void) { + assert(!atomic_load(&descriptors) && !atomic_load(&contexts)); + assert(!atomic_load(&memories) && !atomic_load(&mappings)); +} + +int main(void) { + assert(gpu_clock_pin_set(false)); + assert_released(); + for (int step = OPEN; step <= THREAD; ++step) { + atomic_store(&failure, step); + assert(!gpu_clock_pin_set(true)); + assert(errno == (step == THREAD ? EAGAIN : EACCES)); + assert_released(); + } + atomic_store(&failure, NONE); + atomic_store(&submissions, 0); + assert(gpu_clock_pin_set(true)); + assert(gpu_clock_pin_set(true)); + usleep(80000); + assert(atomic_load(&submissions) > 1); + assert(gpu_clock_pin_set(false)); + assert(gpu_clock_pin_set(false)); + assert_released(); + + atomic_store(&timeout_wait, true); + atomic_store(&submissions, 0); + assert(gpu_clock_pin_set(true)); + usleep(80000); + assert(atomic_load(&submissions) == 1); + assert(gpu_clock_pin_set(false)); + assert_released(); + atomic_store(&timeout_wait, false); + + atomic_store(&failure, WAIT); + assert(gpu_clock_pin_set(true)); + for (int i = 0; i < 100 && atomic_load(&descriptors); ++i) usleep(10000); + assert_released(); + atomic_store(&failure, NONE); + assert(gpu_clock_pin_set(true)); + assert(gpu_clock_pin_set(false)); + assert_released(); + puts("gpu clock pin: failure cleanup, renewal, bounded queue and restart passed"); + return 0; +} diff --git a/tools/tests/test_gpu_clock_pin.py b/tools/tests/test_gpu_clock_pin.py new file mode 100644 index 0000000000..f6f4668719 --- /dev/null +++ b/tools/tests/test_gpu_clock_pin.py @@ -0,0 +1,30 @@ +import pathlib +import shutil +import subprocess +import sys +import tempfile +import unittest + + +ROOT = pathlib.Path(__file__).resolve().parents[2] + + +class GpuClockPinTest(unittest.TestCase): + @unittest.skipUnless(sys.platform.startswith('linux') and shutil.which('cc'), 'requires a Linux C compiler') + def test_constraint_lifecycle(self): + with tempfile.TemporaryDirectory() as tmp: + directory = pathlib.Path(tmp) + (directory / 'android').mkdir() + (directory / 'android/log.h').write_text( + '#define ANDROID_LOG_WARN 5\n' + 'int __android_log_print(int, const char *, const char *, ...);\n') + binary = directory / 'gpu-clock-pin-test' + subprocess.run([ + 'cc', '-std=c11', '-D_DEFAULT_SOURCE', '-D__user=', '-Wall', '-Wextra', '-Werror', + '-I', str(directory), '-pthread', + str(ROOT / 'tools/tests/test_gpu_clock_pin.c'), + str(ROOT / 'app/src/main/cpp/waylandcomp/src/gpu_clock_pin.c'), + '-Wl,--wrap=open,--wrap=close,--wrap=mmap,--wrap=munmap,--wrap=ioctl,--wrap=pthread_create', + '-o', str(binary), + ], check=True) + subprocess.run([str(binary)], check=True, timeout=10) From 556bd96d5a77ecea65d7e6f13298c0b8c2d548f0 Mon Sep 17 00:00:00 2001 From: XxJSONDeruloxX Date: Fri, 23 Oct 2026 15:01:04 -0400 Subject: [PATCH 09/50] ci: reuse build metadata and verified pack downloads --- .github/workflows/build.yml | 9 +++ app/build.gradle | 4 ++ tools/packs/build.sh | 9 +-- tools/packs/fetch-verified.sh | 29 ++++++++ tools/release/report-build.sh | 2 +- tools/release/runtime_inputs.py | 2 +- tools/tests/test_ci_checks.py | 25 +++++++ tools/tests/test_pack_downloads.py | 106 +++++++++++++++++++++++++++++ 8 files changed, 176 insertions(+), 10 deletions(-) create mode 100644 tools/packs/fetch-verified.sh create mode 100644 tools/tests/test_pack_downloads.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 265b1faee6..b1a585e3e6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -484,6 +484,12 @@ jobs: name: xbox-arm64 path: app/src/main/assets/linuxfs/usr/local/lib/droiddeck-xbox + - name: Cache checksum-pinned pack inputs + uses: actions/cache@v4 + with: + path: ~/.cache/droiddeck-pack-inputs + key: pack-inputs-v1-${{ hashFiles('tools/packs/build.sh', 'tools/packs/fetch-verified.sh', 'tools/packs/tracking/release.env') }} + restore-keys: pack-inputs-v1- - name: Build the add-on packs run: bash tools/packs/build.sh app/build/packs @@ -526,6 +532,9 @@ jobs: - name: Unit tests id: unit-tests + env: + DROIDDECK_BUILD_LABEL: ${{ steps.build-label.outputs.label }} + SGDB_API_KEY: ${{ secrets.SGDB_API_KEY }} run: | set -o pipefail mkdir -p app/build diff --git a/app/build.gradle b/app/build.gradle index e81b92711c..bdc9ed4d36 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -220,6 +220,10 @@ android { unitTests.returnDefaultValues = true unitTests.includeAndroidResources = true unitTests.all { + if (ciBuild) { + outputs.upToDateWhen { false } + outputs.doNotCacheIf('CI executes the test suite on every run') { true } + } // Robolectric keeps a sandbox per SDK level the tests ask for; seven no longer fit in Gradle's default 512 MB. maxHeapSize = '2g' def logTarget = providers.systemProperty('robolectric.logging').orNull diff --git a/tools/packs/build.sh b/tools/packs/build.sh index d06a4c8fb4..27611ab0b4 100755 --- a/tools/packs/build.sh +++ b/tools/packs/build.sh @@ -25,14 +25,7 @@ trap 'rm -rf "$work"' EXIT sha256() { if command -v sha256sum >/dev/null; then sha256sum "$1" | cut -d' ' -f1; else shasum -a 256 "$1" | cut -d' ' -f1; fi; } fetch() { - local url=$1 expected=$2 dest=$3 - curl -fsSL --retry 4 -o "$dest" "$url" - local actual - actual=$(sha256 "$dest") - if [ "$actual" != "$expected" ]; then - echo "checksum mismatch for $url: $actual" >&2 - exit 1 - fi + bash "$here/fetch-verified.sh" "$@" } pack() { diff --git a/tools/packs/fetch-verified.sh b/tools/packs/fetch-verified.sh new file mode 100644 index 0000000000..0b8c03977a --- /dev/null +++ b/tools/packs/fetch-verified.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +set -euo pipefail +url=${1:?URL required} +expected=${2:?SHA-256 required} +destination=${3:?destination required} +[[ "$expected" =~ ^[a-f0-9]{64}$ ]] || { echo 'Invalid download SHA-256' >&2; exit 1; } +cache=${DROIDDECK_PACK_CACHE:-"$HOME/.cache/droiddeck-pack-inputs"} +mkdir -p "$cache" "$(dirname "$destination")" +kept="$cache/$expected" +verify() { + if command -v sha256sum >/dev/null; then + echo "$expected $1" | sha256sum -c - >/dev/null 2>&1 + else + echo "$expected $1" | shasum -a 256 -c - >/dev/null 2>&1 + fi +} +if [ -f "$kept" ] && verify "$kept"; then + echo "Verified pack input cache hit: $expected" +else + part=$(mktemp "$cache/$expected.part.XXXXXX") + trap 'rm -f "$part"' EXIT + curl -fsSL --retry 4 --retry-all-errors --connect-timeout 15 --max-time 180 --retry-max-time 240 \ + -o "$part" "$url" + verify "$part" || { echo "Checksum mismatch for $url" >&2; exit 1; } + mv -f "$part" "$kept" + echo "Downloaded and verified pack input: $expected" +fi +cp "$kept" "$destination" +verify "$destination" || { echo 'Copied pack input checksum mismatch' >&2; exit 1; } diff --git a/tools/release/report-build.sh b/tools/release/report-build.sh index fc031c634f..75b16f666f 100644 --- a/tools/release/report-build.sh +++ b/tools/release/report-build.sh @@ -69,7 +69,7 @@ MARK="" echo } > /tmp/pr-report.md cat /tmp/pr-report.md >> "$GITHUB_STEP_SUMMARY" -ID=$(gh api "repos/${GITHUB_REPOSITORY}/issues/${PR}/comments" --paginate --jq ".[] | select(.body | startswith(\"$MARK\")) | .id" | head -1 || true) +ID=$(gh api "repos/${GITHUB_REPOSITORY}/issues/${PR}/comments" --paginate --jq ".[] | select(.user.login == \"github-actions[bot]\" and (.body | startswith(\"$MARK\"))) | .id" | head -1 || true) if [ -n "$ID" ]; then gh api -X PATCH "repos/${GITHUB_REPOSITORY}/issues/comments/${ID}" -F body=@/tmp/pr-report.md >/dev/null else diff --git a/tools/release/runtime_inputs.py b/tools/release/runtime_inputs.py index 83f87be033..ccce1f0f0d 100644 --- a/tools/release/runtime_inputs.py +++ b/tools/release/runtime_inputs.py @@ -21,7 +21,7 @@ PACKED_FILES = {'lib/arm64-v8a/libproot.so': ('proot', 'libproot.so'), PACKED_LIBRARIES = ['lib/arm64-v8a/libopencv_java4.so', 'lib/arm64-v8a/libmediapipe_tasks_jni.so'] PACK_NAMES = ['proot', 'directaudio', 'tracking', 'xbox', 'comet'] SOURCE_PATHS = ['app/build.gradle', 'app/src/main/cpp/fakeinput_steam.cpp', 'app/src/main/assets/pulseaudio.tzst', - 'tools/linuxfs', 'tools/proot', 'tools/aaudio-sink', 'tools/directaudio', + 'tools/linuxfs', 'tools/proot', 'tools/aaudio-sink', 'tools/directaudio', 'tools/packs', 'tools/gamescope/release.env', 'tools/droiddeck-esync/release.env', 'tools/mangoapp', 'tools/msitools', 'tools/pipewire', 'tools/comet', 'tools/xbox', 'tools/components', 'tools/ci', 'tools/build_local.sh', 'tools/release/runtime_inputs.py', 'app/src/main/assets/desktop-removal', diff --git a/tools/tests/test_ci_checks.py b/tools/tests/test_ci_checks.py index 3a0216d778..503b9fb5ba 100644 --- a/tools/tests/test_ci_checks.py +++ b/tools/tests/test_ci_checks.py @@ -1,6 +1,9 @@ import itertools +import json import os from pathlib import Path +import shlex +import shutil import subprocess import tempfile import unittest @@ -12,6 +15,28 @@ ROOT = Path(__file__).resolve().parents[2] class CiChecksTest(unittest.TestCase): + def test_report_comment_lookup_ignores_human_marker(self): + if not shutil.which('jq'): + self.skipTest('jq required to execute comment selection') + script = (ROOT / 'tools/release/report-build.sh').read_text() + line = next(line for line in script.splitlines() if line.startswith('ID=')) + arguments = shlex.split(line[len('ID=$('):].split(' | head', 1)[0]) + query = arguments[arguments.index('--jq') + 1].replace('$MARK', '') + comments = [dict(id=1, user=dict(login='someone'), body=' forged'), + dict(id=2, user=dict(login='github-actions[bot]'), body=' result')] + result = subprocess.check_output(['jq', '-r', query], input=json.dumps(comments), text=True) + self.assertEqual(result.strip(), '2') + + def test_build_and_tests_use_identical_generated_metadata(self): + jobs = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs'] + steps = {step.get('id'): step for step in jobs['build']['steps']} + self.assertEqual(steps['build']['env'], steps['unit-tests']['env']) + self.assertIn('DROIDDECK_BUILD_LABEL', steps['unit-tests']['env']) + self.assertIn('SGDB_API_KEY', steps['unit-tests']['env']) + gradle = (ROOT / 'app/build.gradle').read_text() + self.assertIn("outputs.doNotCacheIf('CI executes the test suite on every run') { true }", gradle) + self.assertIn('outputs.upToDateWhen { false }', gradle) + def test_independent_jobs_wait_only_for_the_pinned_source(self): jobs = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs'] for name in ('xbox', 'components', 'python-tests'): diff --git a/tools/tests/test_pack_downloads.py b/tools/tests/test_pack_downloads.py new file mode 100644 index 0000000000..20547c03bb --- /dev/null +++ b/tools/tests/test_pack_downloads.py @@ -0,0 +1,106 @@ +import hashlib +import http.server +import json +import os +from pathlib import Path +import shutil +import socket +import subprocess +import tempfile +import threading +import unittest + + +ROOT = Path(__file__).resolve().parents[2] +FETCH = ROOT / 'tools/packs/fetch-verified.sh' + + +class PackDownloadsTest(unittest.TestCase): + def setUp(self): + directory = tempfile.TemporaryDirectory() + self.addCleanup(directory.cleanup) + self.root = Path(directory.name) + self.cache = self.root / 'cache' + self.cache.mkdir() + self.destination = self.root / 'download' + self.remote = self.root / 'remote' + self.remote.write_bytes(b'verified input') + self.checksum = hashlib.sha256(self.remote.read_bytes()).hexdigest() + self.log = self.root / 'curl.log' + tool = self.root / 'bin/curl' + tool.parent.mkdir() + tool.write_text('#!/usr/bin/env python3\nimport json,os,shutil,sys\n' + 'args=sys.argv[1:]\n' + 'with open(os.environ["CURL_LOG"],"a") as f: f.write(json.dumps(args)+"\\n")\n' + 'shutil.copyfile(os.environ["REMOTE"],args[args.index("-o")+1])\n') + tool.chmod(0o755) + self.env = dict(os.environ, DROIDDECK_PACK_CACHE=str(self.cache), CURL_LOG=str(self.log), + REMOTE=str(self.remote), PATH=str(tool.parent) + os.pathsep + os.environ['PATH']) + + def fetch(self, checksum=None, url='https://example.test/pinned', env=None): + return subprocess.run(['bash', str(FETCH), url, checksum or self.checksum, str(self.destination)], + env=env or self.env, capture_output=True, text=True) + + def test_cold_download_then_warm_reuse_and_corruption_repair(self): + self.assertEqual(self.fetch().returncode, 0) + self.assertEqual(self.fetch().returncode, 0) + self.assertEqual(len(self.log.read_text().splitlines()), 1) + self.assertEqual(self.destination.read_bytes(), b'verified input') + (self.cache / self.checksum).write_bytes(b'corrupt') + self.assertEqual(self.fetch().returncode, 0) + self.assertEqual(len(self.log.read_text().splitlines()), 2) + self.assertEqual((self.cache / self.checksum).read_bytes(), b'verified input') + + def test_changed_pin_cannot_reuse_old_bytes(self): + self.assertEqual(self.fetch().returncode, 0) + self.remote.write_bytes(b'new approved input') + updated = hashlib.sha256(self.remote.read_bytes()).hexdigest() + self.assertEqual(self.fetch(updated).returncode, 0) + self.assertEqual(len(self.log.read_text().splitlines()), 2) + self.assertEqual(self.destination.read_bytes(), b'new approved input') + + def test_bad_download_is_not_cached_or_written(self): + self.remote.write_bytes(b'tampered download') + self.assertNotEqual(self.fetch().returncode, 0) + self.assertFalse((self.cache / self.checksum).exists()) + self.assertFalse(self.destination.exists()) + self.assertEqual(list(self.cache.iterdir()), []) + arguments = json.loads(self.log.read_text()) + self.assertIn('--retry-all-errors', arguments) + self.assertIn('--max-time', arguments) + self.assertIn('--retry-max-time', arguments) + + def test_connection_reset_retries_then_verifies_real_download(self): + if not shutil.which('curl'): + self.skipTest('curl required for transport test') + content = self.remote.read_bytes() + attempts = [] + + class Handler(http.server.BaseHTTPRequestHandler): + def do_GET(self): + attempts.append(True) + if len(attempts) == 1: + self.connection.shutdown(socket.SHUT_RDWR) + self.connection.close() + return + self.send_response(200) + self.send_header('Content-Length', str(len(content))) + self.end_headers() + self.wfile.write(content) + + def log_message(self, *args): + pass + + server = http.server.ThreadingHTTPServer(('127.0.0.1', 0), Handler) + thread = threading.Thread(target=server.serve_forever, daemon=True) + thread.start() + try: + env = dict(self.env, PATH=os.environ['PATH']) + result = self.fetch(url=f'http://127.0.0.1:{server.server_port}/input', env=env) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertGreaterEqual(len(attempts), 2) + self.assertEqual(self.destination.read_bytes(), content) + finally: + server.shutdown() + server.server_close() + thread.join() From 9c66a1ac0a3f95eef6da438bf62271ee4ec7fc8a Mon Sep 17 00:00:00 2001 From: XxJSONDeruloxX Date: Fri, 23 Oct 2026 15:04:50 -0400 Subject: [PATCH 10/50] fix: select NOP packets for older Adreno cores --- .../main/cpp/waylandcomp/src/gpu_clock_pin.c | 14 ++++++++++++-- tools/tests/test_gpu_clock_pin.c | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/src/main/cpp/waylandcomp/src/gpu_clock_pin.c b/app/src/main/cpp/waylandcomp/src/gpu_clock_pin.c index 5b079da973..0f8e1f61bf 100644 --- a/app/src/main/cpp/waylandcomp/src/gpu_clock_pin.c +++ b/app/src/main/cpp/waylandcomp/src/gpu_clock_pin.c @@ -24,6 +24,7 @@ struct pin { unsigned int memory; unsigned int timestamp; unsigned long gpuaddr; + uint32_t nop; void *commands; size_t size; }; @@ -66,6 +67,15 @@ static bool submit_pin(void) { static bool prepare_pin(void) { pin.fd = open("/dev/kgsl-3d0", O_RDWR | O_CLOEXEC); if (pin.fd < 0) return false; + struct kgsl_devinfo info = {0}; + struct kgsl_device_getproperty device_info = { + .type = KGSL_PROP_DEVICE_INFO, .value = &info, .sizebytes = sizeof(info), + }; + if (ioctl(pin.fd, IOCTL_KGSL_DEVICE_GETPROPERTY, &device_info) < 0) return false; + unsigned int core = info.chip_id >> 24; + if (!core) core = info.gpu_id / 100; + if (core < 3) { errno = ENODEV; return false; } + pin.nop = core >= 5 ? 0x70100001 : 0xc0001000; struct kgsl_drawctxt_create context = { .flags = KGSL_CONTEXT_NO_GMEM_ALLOC | KGSL_CONTEXT_PREAMBLE | KGSL_CONTEXT_PWR_CONSTRAINT, }; @@ -93,9 +103,9 @@ static bool prepare_pin(void) { (off_t)pin.memory << 12); if (commands == MAP_FAILED) return false; pin.commands = commands; - // Type-7 CP_NOP, one payload dword; both odd-parity bits are zero. + // A3xx/A4xx use type-3 CP_NOP; newer cores use type-7 with zero odd-parity bits. uint32_t *words = commands; - words[0] = 0x70100001; + words[0] = pin.nop; words[1] = 0; struct kgsl_gpumem_sync_cache sync = { .id = pin.memory, .op = KGSL_GPUMEM_CACHE_CLEAN }; if (ioctl(pin.fd, IOCTL_KGSL_GPUMEM_SYNC_CACHE, &sync) < 0) return false; diff --git a/tools/tests/test_gpu_clock_pin.c b/tools/tests/test_gpu_clock_pin.c index 8e3f0b6a4c..b20a6e6fc9 100644 --- a/tools/tests/test_gpu_clock_pin.c +++ b/tools/tests/test_gpu_clock_pin.c @@ -12,9 +12,10 @@ #include "../../app/src/main/cpp/adrenotools/src/hook/kgsl.h" #include "../../app/src/main/cpp/waylandcomp/src/gpu_clock_pin.h" -enum { NONE, OPEN, CONTEXT, CONSTRAINT, MEMORY, MAP, SYNC, SUBMIT, THREAD, WAIT }; +enum { NONE, OPEN, DEVICE, CONTEXT, CONSTRAINT, MEMORY, MAP, SYNC, SUBMIT, THREAD, WAIT }; static atomic_int failure, descriptors, contexts, memories, mappings, submissions; static atomic_bool timeout_wait; +static bool legacy_core; static uint32_t commands[1024]; int __android_log_print(int priority, const char *tag, const char *format, ...) { @@ -63,6 +64,7 @@ int __wrap_ioctl(int fd, unsigned long request, ...) { va_end(args); int step = NONE; switch ((unsigned int)request) { + case IOCTL_KGSL_DEVICE_GETPROPERTY: step = DEVICE; break; case IOCTL_KGSL_DRAWCTXT_CREATE: step = CONTEXT; break; case IOCTL_KGSL_SETPROPERTY: step = CONSTRAINT; break; case IOCTL_KGSL_GPUMEM_ALLOC_ID: step = MEMORY; break; @@ -72,6 +74,12 @@ int __wrap_ioctl(int fd, unsigned long request, ...) { } if (step && atomic_load(&failure) == step) { errno = EACCES; return -1; } switch ((unsigned int)request) { + case IOCTL_KGSL_DEVICE_GETPROPERTY: { + struct kgsl_device_getproperty *property = arg; + assert(property->type == KGSL_PROP_DEVICE_INFO); + ((struct kgsl_devinfo *)property->value)->chip_id = legacy_core ? 0x04030000 : 0x07030000; + break; + } case IOCTL_KGSL_DRAWCTXT_CREATE: { struct kgsl_drawctxt_create *context = arg; assert(context->flags & KGSL_CONTEXT_PWR_CONSTRAINT); @@ -102,7 +110,7 @@ int __wrap_ioctl(int fd, unsigned long request, ...) { assert(command->context_id == 17 && command->numcmds == 1); assert(command->flags & KGSL_CMDBATCH_PWR_CONSTRAINT); assert(object->id == 23 && object->gpuaddr == 0x100000 && object->size == 8); - assert(commands[0] == 0x70100001 && commands[1] == 0); + assert(commands[0] == (legacy_core ? 0xc0001000 : 0x70100001) && commands[1] == 0); command->timestamp = atomic_fetch_add(&submissions, 1) + 1; break; } @@ -134,6 +142,11 @@ static void assert_released(void) { int main(void) { assert(gpu_clock_pin_set(false)); assert_released(); + legacy_core = true; + assert(gpu_clock_pin_set(true)); + assert(gpu_clock_pin_set(false)); + assert_released(); + legacy_core = false; for (int step = OPEN; step <= THREAD; ++step) { atomic_store(&failure, step); assert(!gpu_clock_pin_set(true)); From 6cc289f7d3f74eaa3c187e2ea0edaed6b7e2da3d Mon Sep 17 00:00:00 2001 From: XxJSONDeruloxX Date: Fri, 23 Oct 2026 15:06:27 -0400 Subject: [PATCH 11/50] test: avoid GPU pin scheduling races --- tools/tests/test_gpu_clock_pin.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/tests/test_gpu_clock_pin.c b/tools/tests/test_gpu_clock_pin.c index b20a6e6fc9..5fdbe60330 100644 --- a/tools/tests/test_gpu_clock_pin.c +++ b/tools/tests/test_gpu_clock_pin.c @@ -13,7 +13,7 @@ #include "../../app/src/main/cpp/waylandcomp/src/gpu_clock_pin.h" enum { NONE, OPEN, DEVICE, CONTEXT, CONSTRAINT, MEMORY, MAP, SYNC, SUBMIT, THREAD, WAIT }; -static atomic_int failure, descriptors, contexts, memories, mappings, submissions; +static atomic_int failure, descriptors, contexts, memories, mappings, submissions, waits; static atomic_bool timeout_wait; static bool legacy_core; static uint32_t commands[1024]; @@ -115,6 +115,7 @@ int __wrap_ioctl(int fd, unsigned long request, ...) { break; } case IOCTL_KGSL_DEVICE_WAITTIMESTAMP_CTXTID: + atomic_fetch_add(&waits, 1); if (atomic_load(&timeout_wait)) { errno = ETIMEDOUT; return -1; } break; case IOCTL_KGSL_DRAWCTXT_DESTROY: @@ -157,7 +158,7 @@ int main(void) { atomic_store(&submissions, 0); assert(gpu_clock_pin_set(true)); assert(gpu_clock_pin_set(true)); - usleep(80000); + for (int i = 0; i < 100 && atomic_load(&submissions) < 2; ++i) usleep(10000); assert(atomic_load(&submissions) > 1); assert(gpu_clock_pin_set(false)); assert(gpu_clock_pin_set(false)); @@ -165,8 +166,10 @@ int main(void) { atomic_store(&timeout_wait, true); atomic_store(&submissions, 0); + atomic_store(&waits, 0); assert(gpu_clock_pin_set(true)); - usleep(80000); + for (int i = 0; i < 100 && atomic_load(&waits) < 2; ++i) usleep(10000); + assert(atomic_load(&waits) >= 2); assert(atomic_load(&submissions) == 1); assert(gpu_clock_pin_set(false)); assert_released(); From 5a806b35f15f0d36a44680dc8ad7a29f7426b3f4 Mon Sep 17 00:00:00 2001 From: XxJSONDeruloxX Date: Fri, 23 Oct 2026 15:22:01 -0400 Subject: [PATCH 12/50] test: support configured artwork key --- .../droiddeck/launcher/frontend/AddedGameArtLookupTest.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/test/java/com/droiddeck/launcher/frontend/AddedGameArtLookupTest.kt b/app/src/test/java/com/droiddeck/launcher/frontend/AddedGameArtLookupTest.kt index 1f1e30c816..f481462014 100644 --- a/app/src/test/java/com/droiddeck/launcher/frontend/AddedGameArtLookupTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/frontend/AddedGameArtLookupTest.kt @@ -1,5 +1,6 @@ package com.droiddeck.launcher.frontend +import com.droiddeck.launcher.BuildConfig import com.droiddeck.launcher.stores.CredentialCipher import org.json.JSONArray import org.json.JSONObject @@ -92,8 +93,9 @@ class AddedGameArtLookupTest { assertEquals("build", SteamGridDb.pick("", "build")) assertEquals("build", SteamGridDb.pick(" ", "build")) assertEquals("", SteamGridDb.pick("", "")) - assertEquals("", SteamGridDb.builtInKey()) - assertEquals("", SteamGridDb.key(app)) + val builtIn = SteamGridDb.builtInKey() + assertTrue(builtIn == BuildConfig.SGDB_API_KEY.trim()) + assertTrue(SteamGridDb.key(app) == builtIn) } @Test fun theUsersKeyIsSealedOnDiskAndClears() { @@ -106,7 +108,7 @@ class AddedGameArtLookupTest { assertEquals("abcdef0123456789secretkey", SteamGridDb.key(app)) SteamGridDb.setUserKey(app, "") assertFalse(file.exists()) - assertEquals("", SteamGridDb.key(app)) + assertTrue(SteamGridDb.key(app) == SteamGridDb.builtInKey()) } @Test fun aFailedLookupIsNotRememberedAsNoMatch() { From a7d6279ee3ce0b857b1a0b9b688f4a1f77830781 Mon Sep 17 00:00:00 2001 From: XxJSONDeruloxX Date: Fri, 23 Oct 2026 15:22:12 -0400 Subject: [PATCH 13/50] test: check artwork key normalization --- .../droiddeck/launcher/frontend/AddedGameArtLookupTest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/test/java/com/droiddeck/launcher/frontend/AddedGameArtLookupTest.kt b/app/src/test/java/com/droiddeck/launcher/frontend/AddedGameArtLookupTest.kt index f481462014..095cf9a5c5 100644 --- a/app/src/test/java/com/droiddeck/launcher/frontend/AddedGameArtLookupTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/frontend/AddedGameArtLookupTest.kt @@ -94,8 +94,8 @@ class AddedGameArtLookupTest { assertEquals("build", SteamGridDb.pick(" ", "build")) assertEquals("", SteamGridDb.pick("", "")) val builtIn = SteamGridDb.builtInKey() - assertTrue(builtIn == BuildConfig.SGDB_API_KEY.trim()) - assertTrue(SteamGridDb.key(app) == builtIn) + assertTrue(builtIn == BuildConfig.SGDB_API_KEY) + assertTrue(SteamGridDb.key(app) == builtIn.trim()) } @Test fun theUsersKeyIsSealedOnDiskAndClears() { @@ -108,7 +108,7 @@ class AddedGameArtLookupTest { assertEquals("abcdef0123456789secretkey", SteamGridDb.key(app)) SteamGridDb.setUserKey(app, "") assertFalse(file.exists()) - assertTrue(SteamGridDb.key(app) == SteamGridDb.builtInKey()) + assertTrue(SteamGridDb.key(app) == SteamGridDb.builtInKey().trim()) } @Test fun aFailedLookupIsNotRememberedAsNoMatch() { From 9835c4e3e16b7a9695c13362bfa370f665645508 Mon Sep 17 00:00:00 2001 From: XxJSONDeruloxX Date: Fri, 23 Oct 2026 15:39:22 -0400 Subject: [PATCH 14/50] ci: persist PR caches and stabilize build time --- .github/workflows/build.yml | 1 + app/build.gradle | 2 +- tools/tests/test_ci_checks.py | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b1a585e3e6..146e7fe3bf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -403,6 +403,7 @@ jobs: - uses: gradle/actions/setup-gradle@v4 with: + cache-read-only: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }} cache-cleanup: on-success - name: Resolve the pinned Android NDK diff --git a/app/build.gradle b/app/build.gradle index bdc9ed4d36..1b1eb5ae7c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -80,7 +80,7 @@ def sourceCommit = providers.environmentVariable('DROIDDECK_SOURCE_COMMIT').getO def prNumber = (providers.environmentVariable('DROIDDECK_PR_NUMBER').getOrNull() ?: '0').with { it.isInteger() ? it : '0' } def ciBuild = providers.environmentVariable('GITHUB_ACTIONS').getOrNull() == 'true' def releaseSigner = rootProject.file('keystore/release-signer.sha256').text.trim() -def commitTime = (gitValue(['show', '-s', '--format=%ct', 'HEAD']) ?: '0').with { it.isLong() ? it : '0' } +def commitTime = (gitValue(['show', '-s', '--format=%ct', '--end-of-options', sourceCommit]) ?: '0').with { it.isLong() ? it : '0' } def desktopKde = rootProject.file('tools/desktop-kde/release.env').readLines() .findAll { it.contains('=') && !it.startsWith('#') } .collectEntries { def kv = it.split('=', 2); [(kv[0].trim()): kv[1].trim()] } diff --git a/tools/tests/test_ci_checks.py b/tools/tests/test_ci_checks.py index 503b9fb5ba..b7c29fceba 100644 --- a/tools/tests/test_ci_checks.py +++ b/tools/tests/test_ci_checks.py @@ -15,6 +15,15 @@ ROOT = Path(__file__).resolve().parents[2] class CiChecksTest(unittest.TestCase): + def test_pr_cache_writes_and_source_timestamp_policy(self): + jobs = yaml.safe_load((ROOT / '.github/workflows/build.yml').read_text())['jobs'] + cache = next(step for step in jobs['build']['steps'] + if step.get('uses') == 'gradle/actions/setup-gradle@v4')['with'] + self.assertEqual(cache['cache-read-only'], + "${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}") + gradle = (ROOT / 'app/build.gradle').read_text() + self.assertIn("gitValue(['show', '-s', '--format=%ct', '--end-of-options', sourceCommit])", gradle) + def test_report_comment_lookup_ignores_human_marker(self): if not shutil.which('jq'): self.skipTest('jq required to execute comment selection') From f909c7a69cc351de7063c048819191bf5b654359 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 15:44:35 -0400 Subject: [PATCH 15/50] fix: x86 Linux games under FEX keep LD_PRELOAD libraries given by name droiddeck-fex dropped every LD_PRELOAD entry that was not an existing path, so a bare soname the loader finds through LD_LIBRARY_PATH (MelonLoader's bootstrap in Drova, for one) never reached the game. Names without a slash are now kept; missing paths and arm64 libraries are still dropped. --- tools/linuxfs/overlay/usr/local/bin/droiddeck-fex | 3 ++- tools/tests/test_droiddeck_fex.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex b/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex index 331dcfecc2..545ea0d1a3 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex @@ -589,7 +589,8 @@ def guest_environment(fex, env): result["FEX_THUNKHOSTLIBS"] = fex["host_thunks"] result["FEX_THUNKGUESTLIBS"] = fex["guest_thunks"] result["FEX_THUNKCONFIG"] = os.path.join(CONFIG_DIR, "ThunksConfig.json") - preload = [part for part in split_paths(result.get("LD_PRELOAD")) if os.path.exists(part) and not is_arm(part)] + preload = [part for part in split_paths(result.get("LD_PRELOAD")) + if "/" not in part or (os.path.exists(part) and not is_arm(part))] library_path = [part for part in (result.get("LD_LIBRARY_PATH") or "").split(":") if part and "arm64" not in part and "aarch64" not in part] for name, parts in (("LD_PRELOAD", preload), ("LD_LIBRARY_PATH", library_path)): diff --git a/tools/tests/test_droiddeck_fex.py b/tools/tests/test_droiddeck_fex.py index fed546dddc..1ba2982dab 100644 --- a/tools/tests/test_droiddeck_fex.py +++ b/tools/tests/test_droiddeck_fex.py @@ -549,11 +549,12 @@ class LaunchTest(FexTestCase): def test_the_guest_environment(self): arm = self.write(self.tmp / "arm.so", elf(183)) x86 = self.write(self.tmp / "x86.so", elf(62)) - env = {"LD_PRELOAD": "%s:%s %s" % (arm, x86, self.tmp / "gone.so"), + env = {"LD_PRELOAD": "%s:%s %s libMelonLoader.Bootstrap.so" % (arm, x86, self.tmp / "gone.so"), "LD_LIBRARY_PATH": "/steam/steamrtarm64:/usr/lib/aarch64-linux-gnu:/game/lib:/steam/linuxarm64", "FEX_ROOTFS": "/usr/share/guestos/fex-mesa", "FEX_TSOENABLED": "1"} guest = FEX["guest_environment"]({"portable": True}, env) - self.assertEqual((guest["LD_PRELOAD"], guest["LD_LIBRARY_PATH"], guest["FEX_PORTABLE"]), (str(x86), "/game/lib", "1")) + self.assertEqual((guest["LD_PRELOAD"], guest["LD_LIBRARY_PATH"], guest["FEX_PORTABLE"]), + ("%s:libMelonLoader.Bootstrap.so" % x86, "/game/lib", "1")) self.assertNotIn("FEX_ROOTFS", guest) self.assertEqual(guest["FEX_TSOENABLED"], "1") self.assertTrue(guest["FEX_APP_CONFIG_LOCATION"].endswith("/config/")) From 6378c3f3d2e9e3450563853364146249ff0fdc3b Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 15:48:03 -0400 Subject: [PATCH 16/50] fix: the app follows automatic landscape rotation again unless an orientation was picked --- app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt | 2 +- .../main/java/com/droiddeck/launcher/session/SessionPrefs.kt | 4 ++-- app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt | 2 +- .../java/com/droiddeck/launcher/session/OrientationTest.kt | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt index 52aed25cbc..d648f44e74 100644 --- a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt @@ -163,7 +163,7 @@ class FrontEndActivity : ComponentActivity() { private var directAudio by mutableStateOf(false) private var picturePosition by mutableStateOf("center") private var stretch16x9 by mutableStateOf(false) - private var orientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) + private var orientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) private var launcherFullscreen by mutableStateOf(true) private var downloadSource by mutableStateOf(DownloadSource.MODE_AUTO) private var downloadMirror by mutableStateOf("") diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt index 93df369004..aaf084c323 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt @@ -50,9 +50,9 @@ object SessionPrefs { ) fun orientation(context: Context): Int = - prefs(context).getInt("orientation", ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) + prefs(context).getInt("orientation", ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) .takeIf { value -> orientationOptions.any { it.first == value } } - ?: ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE + ?: ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE fun setOrientation(context: Context, orientation: Int) { require(orientationOptions.any { it.first == orientation }) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt index 1840d0f077..6e44aca350 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt @@ -132,7 +132,7 @@ class FrontEndState( val controller: com.droiddeck.launcher.input.ControllerPrefs.Settings? = null, val phantomProcessStatus: PhantomProcessStatus = PhantomProcessStatus.NOT_APPLICABLE, val showPhantomGate: Boolean = false, - val orientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, + val orientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, val launcherFullscreen: Boolean = true, val downloadSource: String = DownloadSource.MODE_AUTO, val downloadMirror: String = "", diff --git a/app/src/test/java/com/droiddeck/launcher/session/OrientationTest.kt b/app/src/test/java/com/droiddeck/launcher/session/OrientationTest.kt index 5ce8030d5a..5d67d041a2 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/OrientationTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/OrientationTest.kt @@ -20,7 +20,7 @@ class OrientationTest { } @Test fun landscapeChoicesPersistGloballyAndCanRestoreAutomaticRotation() { - assertEquals(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, SessionPrefs.orientation(context)) + assertEquals(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, SessionPrefs.orientation(context)) for (value in listOf( ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE, @@ -34,7 +34,7 @@ class OrientationTest { @Test fun invalidStoredOrientationFallsBackAndInvalidChoicePreservesTheSavedValue() { val prefs = context.getSharedPreferences("session", Context.MODE_PRIVATE) prefs.edit().putInt("orientation", ActivityInfo.SCREEN_ORIENTATION_PORTRAIT).commit() - assertEquals(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, SessionPrefs.orientation(context)) + assertEquals(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, SessionPrefs.orientation(context)) SessionPrefs.setOrientation(context, ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) assertThrows(IllegalArgumentException::class.java) { SessionPrefs.setOrientation(context, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) From b6ca673d6edf5528c788e1cebda766d3ec2dc8ab Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 15:50:16 -0400 Subject: [PATCH 17/50] fix: Steam starts on ROMs that refuse the Android ID read --- .../runtime/LinuxNetworkLinkComponent.kt | 17 ++++++++------- .../launcher/runtime/SeededMacTest.kt | 21 +++++++++++++++++++ 2 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 app/src/test/java/com/droiddeck/launcher/runtime/SeededMacTest.kt diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponent.kt b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponent.kt index ac87bd0aa5..45f07471bc 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponent.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxNetworkLinkComponent.kt @@ -301,15 +301,18 @@ class LinuxNetworkLinkComponent( } } - private fun seededMac(): String { - val id = Settings.Secure.getString(appContext.contentResolver, Settings.Secure.ANDROID_ID) ?: "bannerlator" - val bytes = java.security.MessageDigest.getInstance("SHA-1").digest(id.toByteArray()) - val b0 = (bytes[0].toInt() and 0xfc) or 0x02 - return listOf(b0, bytes[1].toInt(), bytes[2].toInt(), bytes[3].toInt(), bytes[4].toInt(), bytes[5].toInt()) - .joinToString(":") { "%02x".format(it and 0xff) } - } + private fun seededMac(): String = + seededMac { Settings.Secure.getString(appContext.contentResolver, Settings.Secure.ANDROID_ID) } companion object { + internal fun seededMac(readId: () -> String?): String { + val id = runCatching(readId).getOrNull() ?: "bannerlator" + val bytes = java.security.MessageDigest.getInstance("SHA-1").digest(id.toByteArray()) + val b0 = (bytes[0].toInt() and 0xfc) or 0x02 + return listOf(b0, bytes[1].toInt(), bytes[2].toInt(), bytes[3].toInt(), bytes[4].toInt(), bytes[5].toInt()) + .joinToString(":") { "%02x".format(it and 0xff) } + } + private const val TAG = "LinuxNetworkLink" private const val LINK_FILE = "etc/droiddeck-net" private const val LINK_INDEX = 2 diff --git a/app/src/test/java/com/droiddeck/launcher/runtime/SeededMacTest.kt b/app/src/test/java/com/droiddeck/launcher/runtime/SeededMacTest.kt new file mode 100644 index 0000000000..e7a5212633 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/runtime/SeededMacTest.kt @@ -0,0 +1,21 @@ +package com.droiddeck.launcher.runtime + +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNotEquals +import org.junit.Test + +class SeededMacTest { + @Test + fun theAndroidIdSeedsAStableLocalMac() { + val mac = LinuxNetworkLinkComponent.seededMac { "0123456789abcdef" } + assertEquals(mac, LinuxNetworkLinkComponent.seededMac { "0123456789abcdef" }) + assertNotEquals(mac, LinuxNetworkLinkComponent.seededMac { null }) + assertEquals(0x02, mac.substringBefore(':').toInt(16) and 0x03) + } + + @Test + fun aRomThatThrowsOnTheAndroidIdReadFallsBackToTheDefaultSeed() { + val mac = LinuxNetworkLinkComponent.seededMac { throw IllegalArgumentException("Illegal char: - at offset 8") } + assertEquals(LinuxNetworkLinkComponent.seededMac { null }, mac) + } +} From 3e85e4a61410044b35c113339023ad81c8867774 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 15:51:06 -0400 Subject: [PATCH 18/50] chore: drop comments --- .../overlay/usr/local/bin/droiddeck-steam-compat | 1 - .../overlay/usr/local/bin/steam-compatibility | 15 --------------- 2 files changed, 16 deletions(-) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat index 2793365bc8..1de4bcf1c9 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat @@ -617,7 +617,6 @@ class Helper: current[app] = "" elif not current.get(app): current.pop(app, None) - # The client's pick of a tool the app chose for a game wins once the app's choice was applied. requests = COMPAT["settled_game_requests"](state, current, catalog) overrides = COMPAT["requested_games"](requests or {}, catalog, [t["name"] for t in live]) overrides = {app: tool for app, tool in overrides.items() if app not in refused} diff --git a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility index 69030a6b09..29fe4f8e43 100755 --- a/tools/linuxfs/overlay/usr/local/bin/steam-compatibility +++ b/tools/linuxfs/overlay/usr/local/bin/steam-compatibility @@ -1117,7 +1117,6 @@ def game_requests(directory=None): def read_game_requests(directory=None): - """The app's per-game Proton choices, and the file's text so a rewrite can tell the app wrote it since.""" try: with open(state_path("games.json", directory), encoding="utf-8") as f: text = f.read() @@ -1130,7 +1129,6 @@ def read_game_requests(directory=None): def write_game_requests(requests, original, directory=None): - """Rewrites games.json unless the app replaced it after it was read; that newer choice wins.""" path = state_path("games.json", directory) try: with open(path, encoding="utf-8") as f: @@ -1149,17 +1147,10 @@ def valid_game_request(app, request): def settle_game_requests(requests, state, current, catalog, missing_is_cleared=False): - """Whichever side changed a game's tool last wins. A choice the app makes is applied once; after - that the client's own pick stands: a pick of one of our Protons becomes the app's choice too, any - other pick (FEX, a Steam Linux Runtime, clearing the forced tool) ends the app's choice. "Use the - default" (null, also what a profile reset writes) is applied once and then dropped, so the game - follows the default like one the app never touched. Returns the new requests and whether they changed.""" recorded = state.get("games_applied") if isinstance(recorded, dict): applied = dict(recorded) else: - # Builds before this one kept no record but had already applied every choice they found; a - # first start has applied nothing yet. applied = dict(requests) if "tools" in state else {} by_name = {t["name"]: t for t in catalog} out = dict(requests) @@ -1189,9 +1180,6 @@ def settle_game_requests(requests, state, current, catalog, missing_is_cleared=F def settled_game_requests(state, current, catalog, missing_is_cleared=False, directory=None): - """Reads the app's choices, settles them against the client's picks and stores the result. When the - app rewrote the file meanwhile, its newer choices are settled again; they are never overwritten. - None when the app kept rewriting it: this pass then applies no per-game choice and records nothing.""" for _ in range(2): requests, text = read_game_requests(directory) settled, moved = settle_game_requests(requests, state, current, catalog, missing_is_cleared) @@ -1201,8 +1189,6 @@ def settled_game_requests(state, current, catalog, missing_is_cleared=False, dir def applied_game_requests(requests, overrides, state): - """What the app asked for that is now in the mapping. A tool not installed yet stays unapplied, and a - game this pass did not handle (the client refused to report it) keeps what was applied before.""" recorded = state.get("games_applied") before = recorded if isinstance(recorded, dict) else {} if requests is None: @@ -1399,7 +1385,6 @@ def register_default(config_path, apps=(), protect=(), default=None, catalog=Non else: default = state.get("default") if state.get("default") in names else TOOL steam_root = os.path.dirname(os.path.dirname(os.path.abspath(config_path))) - # With the client stopped, config.vdf is what it last kept: an app missing from it has no forced tool. requests = settled_game_requests(state, current, catalog, not steam_running(), directory) overrides = requested_games(requests or {}, catalog) managed = state.get("auto", {}).keys() if isinstance(state.get("auto"), dict) else () From 06946fe8ae7fddff9e68ece65e23458f4595f6f8 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 16:01:41 -0400 Subject: [PATCH 19/50] chore: drop comments --- app/src/main/cpp/waylandcomp/src/compositor.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/src/main/cpp/waylandcomp/src/compositor.c b/app/src/main/cpp/waylandcomp/src/compositor.c index fb15d50c32..1be637a7bb 100644 --- a/app/src/main/cpp/waylandcomp/src/compositor.c +++ b/app/src/main/cpp/waylandcomp/src/compositor.c @@ -807,12 +807,6 @@ static uint32_t nominal_refresh_ns(void) { return (uint32_t)(1000000000000LL / (int64_t)mhz); } -/* Gamescope paces from this timestamp (#717). The Choreographer tick is often still - * slightly ahead of this thread, because the UI thread queues the callback, and that - * used to throw the tick away (render_ns < tick) and report the draw time instead. - * Keep a tick within one refresh of the draw, ahead or behind. A missing tick, or one - * more than a refresh away, falls back to the draw time. Never report the next refresh: - * gamescope would wake a frame late. */ static int64_t presented_ns(int64_t render_ns) { int64_t tick = g_tick_vsync_ns; int64_t refresh = (int64_t)nominal_refresh_ns(); From 7eb4717d4c8919688d74b294d0db538a247e5b5d Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 16:16:10 -0400 Subject: [PATCH 20/50] chore: drop the comments added with the Unity TSO fix --- tools/linuxfs/overlay/usr/local/bin/droiddeck-fex | 1 - tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env | 3 --- 2 files changed, 4 deletions(-) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex b/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex index aaa4830cec..6ca792143d 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-fex @@ -683,7 +683,6 @@ def game_environment(env, command): game = game_env["Game"](resolve(command[0], env), command[1:]) for check in game_env["FIXES"]: found = check(game) - # Environment fixes only: the launch arguments some fixes add were chosen for Windows builds. if found and found[0]: fixes.update(found[0]) say(found[2]) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env index 22b5248f36..75154ab6df 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env @@ -89,9 +89,6 @@ def dotnet_memory_ordering(game): @fix def unity_memory_ordering(game): - """A Unity player under FEX without TSO deadlocks or crashes: Megabonk (Linux, IL2CPP) froze with every - thread parked on a futex on about half of all launches, Crab Game (Windows under Proton, IL2CPP) died with - an access violation in UnityPlayer.dll. Presets that turn TSO off keep it on for Unity games.""" if {"unityplayer.so", "gameassembly.so", "unityplayer.dll"} & game.files: return {"FEX_TSOENABLED": "1"}, [], "Unity: FEX with TSO" From c95e114766adb7b2ef585302e9474c5cb2ed53bf Mon Sep 17 00:00:00 2001 From: XxJSONDeruloxX Date: Fri, 23 Oct 2026 16:20:42 -0400 Subject: [PATCH 21/50] fix(ci): recover directory cache entries --- tools/packs/fetch-verified.sh | 3 +++ tools/tests/test_pack_downloads.py | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/tools/packs/fetch-verified.sh b/tools/packs/fetch-verified.sh index 0b8c03977a..41bba28190 100644 --- a/tools/packs/fetch-verified.sh +++ b/tools/packs/fetch-verified.sh @@ -22,6 +22,9 @@ else curl -fsSL --retry 4 --retry-all-errors --connect-timeout 15 --max-time 180 --retry-max-time 240 \ -o "$part" "$url" verify "$part" || { echo "Checksum mismatch for $url" >&2; exit 1; } + if [ -d "$kept" ]; then + rm -rf -- "$kept" + fi mv -f "$part" "$kept" echo "Downloaded and verified pack input: $expected" fi diff --git a/tools/tests/test_pack_downloads.py b/tools/tests/test_pack_downloads.py index 20547c03bb..0b5eb60602 100644 --- a/tools/tests/test_pack_downloads.py +++ b/tools/tests/test_pack_downloads.py @@ -51,6 +51,25 @@ class PackDownloadsTest(unittest.TestCase): self.assertEqual(len(self.log.read_text().splitlines()), 2) self.assertEqual((self.cache / self.checksum).read_bytes(), b'verified input') + def test_directory_cache_entry_is_replaced_only_after_verification(self): + entry = self.cache / self.checksum + entry.mkdir() + sentinel = entry / 'old-entry' + sentinel.write_bytes(b'preserve until verified') + self.remote.write_bytes(b'tampered download') + self.assertNotEqual(self.fetch().returncode, 0) + self.assertEqual(sentinel.read_bytes(), b'preserve until verified') + self.assertFalse(self.destination.exists()) + self.remote.write_bytes(b'verified input') + result = self.fetch() + self.assertEqual(result.returncode, 0, result.stderr) + self.assertTrue(entry.is_file()) + self.assertEqual(entry.read_bytes(), b'verified input') + self.assertEqual(self.destination.read_bytes(), b'verified input') + self.assertEqual(list(self.cache.iterdir()), [entry]) + self.assertEqual(self.fetch().returncode, 0) + self.assertEqual(len(self.log.read_text().splitlines()), 2) + def test_changed_pin_cannot_reuse_old_bytes(self): self.assertEqual(self.fetch().returncode, 0) self.remote.write_bytes(b'new approved input') From 992912fdf87c970a4c2a6135fe98bb4727f15a83 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 17:43:44 -0400 Subject: [PATCH 22/50] fix: other apps can record game audio --- app/src/main/AndroidManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index fcd9b2e11b..286a9ee8ad 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -34,6 +34,7 @@ android:localeConfig="@xml/locales_config" android:networkSecurityConfig="@xml/network_security_config" android:allowBackup="false" + android:allowAudioPlaybackCapture="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" From 94b530ecb2a32efe6b92a67a97ea6cf6bc38e72a Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 18:28:35 -0400 Subject: [PATCH 23/50] fix: stored components can be deleted after a Proton update --- .../launcher/session/ComponentsManager.kt | 52 +++++++++++++------ .../session/ComponentsSelectionTest.kt | 32 ++++++++++++ 2 files changed, 67 insertions(+), 17 deletions(-) create mode 100644 app/src/test/java/com/droiddeck/launcher/session/ComponentsSelectionTest.kt diff --git a/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt b/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt index d1aae9d720..d05ba28366 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt @@ -721,13 +721,19 @@ object ComponentsManager { class StoredOriginal(val protonId: String, val protonName: String?, val comp: String, val protonVersion: String, val size: Long, val kept: Boolean) class Stored(val packages: List, val originals: List) - private fun packagesInUse(state: JSONObject): Set { + internal fun liveSelection(key: String, entry: JSONObject, proton: Proton?): Boolean = + proton != null && (key == "queued" || entry.optString("protonVersion") == proton.version) + + private fun packagesInUse(state: JSONObject, installed: Map): Set { val names = HashSet() for (key in listOf("active", "queued")) { val byProton = state.optJSONObject(key) ?: continue for (pid in byProton.keys()) { val comps = byProton.optJSONObject(pid) ?: continue - for (comp in comps.keys()) comps.optJSONObject(comp)?.optString("file")?.takeIf { it.isNotEmpty() }?.let(names::add) + for (comp in comps.keys()) { + val entry = comps.optJSONObject(comp) ?: continue + if (liveSelection(key, entry, installed[pid])) entry.optString("file").takeIf { it.isNotEmpty() }?.let(names::add) + } } } val profiles = state.optJSONObject("profiles") @@ -747,8 +753,8 @@ object ComponentsManager { fun stored(context: Context): Stored = synchronized(lock) { val state = loadState(context) - val used = packagesInUse(state) val installed = protons(context).associateBy { it.id } + val used = packagesInUse(state, installed) val originals = originalsDir(context).listFiles()?.filter { it.isDirectory }?.flatMap { proton -> proton.listFiles()?.filter { it.isDirectory }?.flatMap { version -> COMPONENTS.mapNotNull { comp -> @@ -777,23 +783,35 @@ object ComponentsManager { fun deletePackage(context: Context, file: String): String = synchronized(lock) { val name = safeName(file) val state = loadState(context) - val queued = state.sub("queued") - for (pid in queued.keys()) { - val comps = queued.optJSONObject(pid) ?: continue - for (comp in comps.keys()) check(comps.optJSONObject(comp)?.optString("file") != name) { context.getString(R.string.cmgr_package_in_use, name, pid) } - } - val active = state.sub("active") - for (pid in active.keys()) { - val comps = active.optJSONObject(pid) ?: continue - for (comp in comps.keys()) check(comps.optJSONObject(comp)?.optString("file") != name) { context.getString(R.string.cmgr_package_in_use, name, pid) } - } - val profiles = state.sub("profiles") - for (scope in profiles.keys()) { - val profile = profiles.optJSONObject(scope) ?: continue - check(COMPONENTS.none { profile.optString(it) == name }) { context.getString(R.string.cmgr_package_in_use, name, scope) } + val installed = protons(context).associateBy { it.id } + var changed = false + for (key in listOf("queued", "active")) { + val byProton = state.sub(key) + for (pid in byProton.keys().asSequence().toList()) { + val comps = byProton.optJSONObject(pid) ?: continue + for (comp in comps.keys().asSequence().toList()) { + val entry = comps.optJSONObject(comp) ?: continue + if (entry.optString("file") != name) continue + check(!liveSelection(key, entry, installed[pid])) { context.getString(R.string.cmgr_package_in_use, name, installed[pid]?.name ?: pid) } + comps.remove(comp) + changed = true + } + if (comps.length() == 0) byProton.remove(pid) + } } val f = File(packagesDir(context), name) check(f.isFile) { context.getString(R.string.cmgr_package_not_stored, name) } + val profiles = state.sub("profiles") + for (scope in profiles.keys().asSequence().toList()) { + val profile = profiles.optJSONObject(scope) ?: continue + for (comp in COMPONENTS.filter { profile.optString(it) == name }) { + rememberProfiledComponent(state, comp) + profile.remove(comp) + changed = true + } + if (profile.length() == 0) profiles.remove(scope) + } + if (changed) saveState(context, state) f.delete() context.getString(R.string.cmgr_deleted, name) } diff --git a/app/src/test/java/com/droiddeck/launcher/session/ComponentsSelectionTest.kt b/app/src/test/java/com/droiddeck/launcher/session/ComponentsSelectionTest.kt new file mode 100644 index 0000000000..517d6ad2b3 --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/session/ComponentsSelectionTest.kt @@ -0,0 +1,32 @@ +package com.droiddeck.launcher.session + +import org.json.JSONObject +import org.junit.Assert.assertFalse +import org.junit.Assert.assertTrue +import org.junit.Test +import org.junit.runner.RunWith +import org.robolectric.RobolectricTestRunner +import java.io.File + +@RunWith(RobolectricTestRunner::class) +class ComponentsSelectionTest { + private val proton = ComponentsManager.Proton("DroidDeck-Proton_11-11.1", "DroidDeck-Proton 11-11.1", File("/p"), "/p", "DroidDeck-Proton-11-11.1", false) + private val entry = JSONObject().put("file", "dxvk-low-latency-arm64ec-3.1.1-2-linux.wcp").put("protonVersion", "DroidDeck-Proton-11-11.1") + + @Test + fun `a package swapped into an installed Proton is in use`() { + assertTrue(ComponentsManager.liveSelection("active", entry, proton)) + assertTrue(ComponentsManager.liveSelection("queued", JSONObject().put("file", "x.wcp"), proton)) + } + + @Test + fun `a package left on a removed Proton is not in use`() { + assertFalse(ComponentsManager.liveSelection("active", entry, null)) + assertFalse(ComponentsManager.liveSelection("queued", entry, null)) + } + + @Test + fun `a package from before a Proton update is not in use`() { + assertFalse(ComponentsManager.liveSelection("active", JSONObject(entry.toString()).put("protonVersion", "DroidDeck-Proton-11-9.1"), proton)) + } +} From 70b8ec5de4abc2d8bceebc6d5beae87de0c80349 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 18:36:24 -0400 Subject: [PATCH 24/50] docs: add the Trendshift #1 daily and weekly badges to the README --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 7fd8cfbdbd..7d90815935 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,16 @@ DroidDeck brings the SteamOS experience to Android: Valve's Steam client in Big

Join the DroidDeck Discord

+

+ Droid-Deck%2FDroidDeck | Trendshift + Droid-Deck%2FDroidDeck | Trendshift +

+ +

+ Droid-Deck%2FDroidDeck | Trendshift + Droid-Deck%2FDroidDeck | Trendshift +

+

Tapping DroidDeck on the Android home screen and landing in Steam Big Picture

> Note: DroidDeck does not have a stand-alone website. Do not click on any download links from websites claiming to be the DroidDeck team. From db9aae7b876a297eeed2c0ab5b6defb3a946b451 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 18:56:24 -0400 Subject: [PATCH 25/50] fix: delete the package before saving, and match Protons the same way --- .../com/droiddeck/launcher/session/ComponentsManager.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt b/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt index d05ba28366..776a9f7a0f 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/ComponentsManager.kt @@ -753,7 +753,7 @@ object ComponentsManager { fun stored(context: Context): Stored = synchronized(lock) { val state = loadState(context) - val installed = protons(context).associateBy { it.id } + val installed = protons(context).distinctBy { it.id }.associateBy { it.id } val used = packagesInUse(state, installed) val originals = originalsDir(context).listFiles()?.filter { it.isDirectory }?.flatMap { proton -> proton.listFiles()?.filter { it.isDirectory }?.flatMap { version -> @@ -783,7 +783,7 @@ object ComponentsManager { fun deletePackage(context: Context, file: String): String = synchronized(lock) { val name = safeName(file) val state = loadState(context) - val installed = protons(context).associateBy { it.id } + val installed = protons(context).distinctBy { it.id }.associateBy { it.id } var changed = false for (key in listOf("queued", "active")) { val byProton = state.sub(key) @@ -811,8 +811,8 @@ object ComponentsManager { } if (profile.length() == 0) profiles.remove(scope) } + check(f.delete()) { name } if (changed) saveState(context, state) - f.delete() context.getString(R.string.cmgr_deleted, name) } From 7261b262649ef02dac8b9f54e8da8ec8dadbb3ab Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 18:56:44 -0400 Subject: [PATCH 26/50] fix: a game started from another launcher returns to that launcher --- .../com/droiddeck/launcher/SessionActivity.kt | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index 4f159908bf..114ea81cdb 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -3549,17 +3549,27 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { } return } - super.finish() if (!closeAtOnce && intent.getBooleanExtra(EXTRA_RETURN_HOME, false)) { com.droiddeck.launcher.ui.QuitFlood.take() com.droiddeck.launcher.ui.LaunchOrigin.flooding = null - startActivity(Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_HOME) - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)) - } + closeLinkTasks() + super.finishAndRemoveTask() + } else super.finish() if (quitFlooded) overridePendingTransition(0, 0) else overridePendingTransition(R.anim.session_hold, R.anim.session_sink) } + private fun closeLinkTasks() { + val tasks = runCatching { getSystemService(android.app.ActivityManager::class.java)?.appTasks }.getOrNull().orEmpty() + for (task in tasks) { + runCatching { + val base = task.taskInfo.baseIntent + if (base.component?.className == FrontEndActivity::class.java.name && + com.droiddeck.launcher.frontend.GameLaunchIntent.accepts(base.action)) task.finishAndRemoveTask() + } + } + } + private fun completeLeave() { if (isFinishing) return val signal = com.droiddeck.launcher.ui.Themes.current(this).signal From 69b2b8fcdfabc365a476846425fabc9284e52943 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 19:17:08 -0400 Subject: [PATCH 27/50] fix: only close the game-link task that started the session --- .../java/com/droiddeck/launcher/FrontEndActivity.kt | 12 ++++++++---- .../java/com/droiddeck/launcher/SessionActivity.kt | 12 ++++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt index d648f44e74..2852a4c52d 100644 --- a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt @@ -544,12 +544,12 @@ class FrontEndActivity : ComponentActivity() { } startActivity(Intent(this, SessionActivity::class.java).setAction(SessionService.ACTION_RESUME) .putExtra(SessionActivity.EXTRA_STEAMVR, steamVr) - .putExtra(SessionActivity.EXTRA_RETURN_HOME, returnHome) + .returnTo(returnHome) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)) return true } return startSession(Intent(this, SessionActivity::class.java) - .putExtra(SessionActivity.EXTRA_RETURN_HOME, returnHome) + .returnTo(returnHome) .apply { if (game.gameIdString == com.droiddeck.launcher.gpu.SteamVr.APP_ID) { putExtra(SessionActivity.EXTRA_STEAMVR, true) @@ -560,6 +560,10 @@ class FrontEndActivity : ComponentActivity() { }, steamSession = true) } + private fun Intent.returnTo(returnHome: Boolean): Intent = + putExtra(SessionActivity.EXTRA_RETURN_HOME, returnHome) + .putExtra(SessionActivity.EXTRA_LINK_TASK, if (returnHome) taskId else -1) + private fun launchWithoutSteam(game: Library.SteamGame, returnHome: Boolean): Boolean { val app = applicationContext Thread({ @@ -573,7 +577,7 @@ class FrontEndActivity : ComponentActivity() { } com.droiddeck.launcher.session.NoSteamLaunch.remember(command) val next = Intent(this, SessionActivity::class.java) - .putExtra(SessionActivity.EXTRA_RETURN_HOME, returnHome) + .returnTo(returnHome) .putExtra(SessionService.EXTRA_MODE, SessionService.MODE_RUN) .putExtra(SessionService.EXTRA_PROGRAM, command.program) .putExtra(SessionService.EXTRA_PROGRAM_ARGS, command.args.toTypedArray()) @@ -582,7 +586,7 @@ class FrontEndActivity : ComponentActivity() { SessionState.stopRequested -> android.widget.Toast.makeText(this, R.string.game_link_session_busy, android.widget.Toast.LENGTH_LONG).show() SessionState.mode == SessionService.MODE_RUN && SessionState.program == command.program && SessionState.programArgs == command.args -> startActivity(Intent(this, SessionActivity::class.java).setAction(SessionService.ACTION_RESUME) - .putExtra(SessionActivity.EXTRA_RETURN_HOME, returnHome) + .returnTo(returnHome) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP)) else -> pendingSwitch = next } diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index 114ea81cdb..7c4a19b9a0 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -1926,6 +1926,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { SessionState.relaunch?.let { next -> SessionState.relaunch = null next.putExtra(EXTRA_RETURN_HOME, intent.getBooleanExtra(EXTRA_RETURN_HOME, false)) + next.putExtra(EXTRA_LINK_TASK, intent.getIntExtra(EXTRA_LINK_TASK, -1)) setIntent(next) recreate() return@runOnUiThread @@ -3027,6 +3028,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { return } if (this.intent.getBooleanExtra(EXTRA_RETURN_HOME, false)) intent.putExtra(EXTRA_RETURN_HOME, true) + if (!intent.hasExtra(EXTRA_LINK_TASK)) intent.putExtra(EXTRA_LINK_TASK, this.intent.getIntExtra(EXTRA_LINK_TASK, -1)) setIntent(intent) if (intent.getBooleanExtra(EXTRA_STEAMVR, false) && SessionState.mode == SessionService.MODE_STEAM) { SessionState.steamVr = true @@ -3560,11 +3562,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { } private fun closeLinkTasks() { + val linkTask = intent.getIntExtra(EXTRA_LINK_TASK, -1) + if (linkTask == -1) return val tasks = runCatching { getSystemService(android.app.ActivityManager::class.java)?.appTasks }.getOrNull().orEmpty() for (task in tasks) { runCatching { - val base = task.taskInfo.baseIntent - if (base.component?.className == FrontEndActivity::class.java.name && + val info = task.taskInfo + @Suppress("DEPRECATION") + val id = if (android.os.Build.VERSION.SDK_INT >= 29) info.taskId else info.persistentId + val base = info.baseIntent + if (id == linkTask && base.component?.className == FrontEndActivity::class.java.name && com.droiddeck.launcher.frontend.GameLaunchIntent.accepts(base.action)) task.finishAndRemoveTask() } } @@ -3581,6 +3588,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { companion object { const val EXTRA_RETURN_HOME = "returnHome" + const val EXTRA_LINK_TASK = "linkTask" const val EXTRA_STEAMVR = "steamVr" const val EXTRA_REPAIR_RUNTIME = "repairRuntime" private const val LEAVE_TIMEOUT_MS = 1_500L From 8123d5b3612f6e9132e8817448f104332643ebcb Mon Sep 17 00:00:00 2001 From: superboo07 Date: Fri, 23 Oct 2026 23:39:27 +0000 Subject: [PATCH 28/50] xbox backend x86 to arm cross compilation --- tools/xbox/build-local.sh | 29 +++++++++++++++++++++-------- tools/xbox/build.sh | 2 +- tools/xbox/cross.Dockerfile | 28 ++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 tools/xbox/cross.Dockerfile diff --git a/tools/xbox/build-local.sh b/tools/xbox/build-local.sh index 6a3eb90ce5..979c95b12b 100755 --- a/tools/xbox/build-local.sh +++ b/tools/xbox/build-local.sh @@ -1,14 +1,7 @@ #!/usr/bin/env bash set -euo pipefail repo=$(cd "$(dirname "$0")/../.." && pwd) -cache=${DROIDDECK_XBOX_CACHE:-"${HOME}/.cache/droiddeck-xbox-build"} -mkdir -p "$cache" -docker run --rm --platform linux/arm64 -v "$repo:/src" -v "$cache:/work" -w /src \ - -e CARGO_HOME=/work/cargo -e RUSTUP_HOME=/work/rustup -e XBOX_BUILD_DIR=/work/build ubuntu:24.04 bash -lc ' - set -euo pipefail - apt-get update -qq - DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \ - build-essential pkg-config libssl-dev protobuf-compiler cmake curl git ca-certificates xz-utils python3 >/dev/null +build=' export PATH=/work/cargo/bin:$PATH if ! command -v rustup >/dev/null; then version=$(python3 -c '\''import json;print(json.load(open("tools/xbox/backend.lock.json"))["rust"])'\'') @@ -16,3 +9,23 @@ docker run --rm --platform linux/arm64 -v "$repo:/src" -v "$cache:/work" -w /src fi bash tools/xbox/build.sh ' +if [[ $(uname -m) = x86_64 ]]; then + cache=${DROIDDECK_XBOX_CACHE:-"${HOME}/.cache/droiddeck-xbox-cross"} + platform=linux/amd64 + image=droiddeck-xbox-cross:$(shasum -a 256 "$repo/tools/xbox/cross.Dockerfile" | cut -c1-12) + docker image inspect "$image" >/dev/null 2>&1 \ + || docker build --platform "$platform" -t "$image" -f "$repo/tools/xbox/cross.Dockerfile" "$repo/tools/xbox" +else + cache=${DROIDDECK_XBOX_CACHE:-"${HOME}/.cache/droiddeck-xbox-build"} + platform=linux/arm64 + image=ubuntu:24.04 + build=' + apt-get update -qq + DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \ + build-essential pkg-config libssl-dev protobuf-compiler cmake curl git ca-certificates xz-utils python3 >/dev/null +'"$build" +fi +mkdir -p "$cache" +docker run --rm --platform "$platform" -v "$repo:/src" -v "$cache:/work" -w /src \ + -e CARGO_HOME=/work/cargo -e RUSTUP_HOME=/work/rustup -e XBOX_BUILD_DIR=/work/build "$image" \ + bash -lc "set -euo pipefail$build" diff --git a/tools/xbox/build.sh b/tools/xbox/build.sh index f5598aee19..99bee8c76b 100755 --- a/tools/xbox/build.sh +++ b/tools/xbox/build.sh @@ -13,7 +13,7 @@ export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=${CARGO_TARGET_AARCH64_UNKN if [[ $(uname -m) = aarch64 ]]; then export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=cc; fi cd "$source_dir" cargo build --locked --release --no-default-features --target aarch64-unknown-linux-gnu -p xodus-cli -p xodus-service -if [[ $(uname -m) = aarch64 ]]; then +if [[ $(uname -m) = aarch64 || -n ${CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER:-} ]]; then cargo test --locked --release --no-default-features --target aarch64-unknown-linux-gnu -p xodus-cli cargo test --locked --release --no-default-features --target aarch64-unknown-linux-gnu -p xodus credential_ cargo test --locked --release --no-default-features --target aarch64-unknown-linux-gnu -p msixvc streaming_ diff --git a/tools/xbox/cross.Dockerfile b/tools/xbox/cross.Dockerfile new file mode 100644 index 0000000000..665dd17d71 --- /dev/null +++ b/tools/xbox/cross.Dockerfile @@ -0,0 +1,28 @@ +FROM ubuntu:24.04 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN dpkg --add-architecture arm64 \ + && sed -i '/^Types:/a Architectures: amd64' /etc/apt/sources.list.d/ubuntu.sources \ + && printf '%s\n' \ + 'Types: deb' \ + 'URIs: http://ports.ubuntu.com/ubuntu-ports/' \ + 'Suites: noble noble-updates noble-security' \ + 'Components: main universe restricted multiverse' \ + 'Architectures: arm64' \ + 'Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg' \ + > /etc/apt/sources.list.d/ubuntu-ports.sources \ + && apt-get update -qq \ + && apt-get install -y -qq --no-install-recommends \ + build-essential pkg-config protobuf-compiler cmake curl git ca-certificates xz-utils python3 \ + gcc-aarch64-linux-gnu g++-aarch64-linux-gnu qemu-user \ + libssl-dev:arm64 libstdc++6:arm64 \ + && rm -rf /var/lib/apt/lists/* + +ENV CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \ + CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ \ + AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar \ + PKG_CONFIG_ALLOW_CROSS=1 \ + PKG_CONFIG_LIBDIR_aarch64_unknown_linux_gnu=/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/share/pkgconfig \ + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER=qemu-aarch64 From caaf6b3a011c7d27db573f0d1d0ccb2cefa3b6ca Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 19:47:32 -0400 Subject: [PATCH 29/50] fix: keep the link task id when an in-app resume reaches the session --- .../main/java/com/droiddeck/launcher/FrontEndActivity.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt index 2852a4c52d..943b07be83 100644 --- a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt @@ -560,9 +560,11 @@ class FrontEndActivity : ComponentActivity() { }, steamSession = true) } - private fun Intent.returnTo(returnHome: Boolean): Intent = - putExtra(SessionActivity.EXTRA_RETURN_HOME, returnHome) - .putExtra(SessionActivity.EXTRA_LINK_TASK, if (returnHome) taskId else -1) + private fun Intent.returnTo(returnHome: Boolean): Intent { + val task = taskId + return putExtra(SessionActivity.EXTRA_RETURN_HOME, returnHome) + .apply { if (returnHome) putExtra(SessionActivity.EXTRA_LINK_TASK, task) } + } private fun launchWithoutSteam(game: Library.SteamGame, returnHome: Boolean): Boolean { val app = applicationContext From c7bcd8278216ed5632cb852b31b0b4ec468220cf Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 19:47:41 -0400 Subject: [PATCH 30/50] fix: Snapdragon 8 Gen 2 no longer pins Steam to one core by default --- .../launcher/core/CpuAllocationDefaults.kt | 27 ------------ .../launcher/session/SessionPrefs.kt | 18 ++------ .../core/CpuAllocationDefaultsTest.kt | 42 ------------------- .../session/CoreAllocationPrefsTest.kt | 37 +++++----------- 4 files changed, 14 insertions(+), 110 deletions(-) delete mode 100644 app/src/main/java/com/droiddeck/launcher/core/CpuAllocationDefaults.kt delete mode 100644 app/src/test/java/com/droiddeck/launcher/core/CpuAllocationDefaultsTest.kt diff --git a/app/src/main/java/com/droiddeck/launcher/core/CpuAllocationDefaults.kt b/app/src/main/java/com/droiddeck/launcher/core/CpuAllocationDefaults.kt deleted file mode 100644 index adaa106a02..0000000000 --- a/app/src/main/java/com/droiddeck/launcher/core/CpuAllocationDefaults.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.droiddeck.launcher.core - -import com.droiddeck.launcher.gpu.GpuInfo -import com.droiddeck.launcher.gpu.SocNames - -object CpuAllocationDefaults { - data class Allocation(val client: String, val game: String) - - val device: Allocation? by lazy { - forDevice(SocNames.model(), GpuInfo.systemProperty("ro.board.platform"), - CpuCores.all.associateWith(CpuCores::maxGhz)) - } - - fun forDevice(model: String, platform: String, frequencies: Map): Allocation? { - val chip = model.trim().uppercase().substringBefore('-') - val gen2 = chip in setOf("SM8550", "QCS8550") || - (chip.isEmpty() && platform.trim().equals("kalama", ignoreCase = true)) - if (!gen2 || frequencies.size != 8 || frequencies.keys.any { it < 0 } || - frequencies.values.any { it == null || !it.isFinite() || it <= 0.0 }) return null - val clusters = frequencies.entries.groupBy { it.value }.toSortedMap(compareBy { it ?: 0.0 }).values.toList() - if (clusters.map { it.size } != listOf(3, 4, 1)) return null - return Allocation( - client = CpuCores.format(clusters[2].map { it.key }.toSet()), - game = CpuCores.format(clusters[1].map { it.key }.toSet()), - ) - } -} diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt index aaf084c323..e8041fe0b8 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt @@ -4,7 +4,6 @@ import android.content.Context import android.content.pm.ActivityInfo import androidx.annotation.StringRes import com.droiddeck.launcher.R -import com.droiddeck.launcher.core.CpuAllocationDefaults import com.droiddeck.launcher.core.GameEnvironment import com.droiddeck.launcher.core.TextureFiltering import com.droiddeck.launcher.gpu.Cardboard @@ -382,30 +381,19 @@ object SessionPrefs { prefs(context).edit().putBoolean("wifiDiscoveryAsked", true).apply() } - internal data class CoreAllocation(val clientOverride: Boolean, val clientCpus: String, val gameCpus: String) - - internal fun coreAllocation(context: Context, defaults: CpuAllocationDefaults.Allocation? = CpuAllocationDefaults.device): CoreAllocation { - val saved = prefs(context) - return CoreAllocation( - saved.getBoolean("clientCpusOverride", defaults != null && !saved.contains("clientCpus")), - saved.getString("clientCpus", defaults?.client.orEmpty()).orEmpty(), - saved.getString("gameCpus", defaults?.game.orEmpty()).orEmpty(), - ) - } - - fun clientCpusOverride(context: Context): Boolean = coreAllocation(context).clientOverride + fun clientCpusOverride(context: Context): Boolean = prefs(context).getBoolean("clientCpusOverride", false) fun setClientCpusOverride(context: Context, on: Boolean) { prefs(context).edit().putBoolean("clientCpusOverride", on).apply() } - fun clientCpus(context: Context): String = coreAllocation(context).clientCpus + fun clientCpus(context: Context): String = prefs(context).getString("clientCpus", "").orEmpty() fun setClientCpus(context: Context, list: String) { prefs(context).edit().putString("clientCpus", list).apply() } - fun gameCpus(context: Context): String = coreAllocation(context).gameCpus + fun gameCpus(context: Context): String = prefs(context).getString("gameCpus", "").orEmpty() fun setGameCpus(context: Context, list: String) { prefs(context).edit().putString("gameCpus", list).apply() diff --git a/app/src/test/java/com/droiddeck/launcher/core/CpuAllocationDefaultsTest.kt b/app/src/test/java/com/droiddeck/launcher/core/CpuAllocationDefaultsTest.kt deleted file mode 100644 index ba6e31a10f..0000000000 --- a/app/src/test/java/com/droiddeck/launcher/core/CpuAllocationDefaultsTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -package com.droiddeck.launcher.core - -import org.junit.Assert.* -import org.junit.Test - -class CpuAllocationDefaultsTest { - private val thor = (0..7).associateWith { when (it) { in 0..2 -> 2.016; in 3..6 -> 2.8032; else -> 3.1872 } } - - @Test fun gen2UsesTheFourMiddleCoresAndOnePrime() { - for (model in listOf("SM8550", "QCS8550", "sm8550-ac")) { - assertEquals(CpuAllocationDefaults.Allocation("7", "3,4,5,6"), CpuAllocationDefaults.forDevice(model, "", thor)) - } - assertEquals(CpuAllocationDefaults.Allocation("7", "3,4,5,6"), CpuAllocationDefaults.forDevice("", "kalama", thor)) - } - - @Test fun coreNumbersAndClockVariantsAreDetectedInsteadOfHardcoded() { - val reordered = mapOf(0 to 3.36, 1 to 2.0, 2 to 2.0, 3 to 2.0, 4 to 2.8, 5 to 2.8, 6 to 2.8, 7 to 2.8) - assertEquals(CpuAllocationDefaults.Allocation("0", "4,5,6,7"), CpuAllocationDefaults.forDevice("SM8550-AC", "kalama", reordered)) - } - - @Test fun anotherOrUnknownChipDoesNotAcquireThisDefault() { - assertNull(CpuAllocationDefaults.forDevice("SM8650", "pineapple", thor)) - assertNull(CpuAllocationDefaults.forDevice("SM8650", "kalama", thor)) - assertNull(CpuAllocationDefaults.forDevice("", "", thor)) - } - - @Test fun missingOrUnexpectedTopologyKeepsTheSchedulerDefault() { - assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", thor - 7)) - assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", thor + (7 to null))) - assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", thor + (7 to 0.0))) - assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", thor + (7 to Double.NaN))) - assertNull(CpuAllocationDefaults.forDevice("SM8550", "kalama", (0..7).associateWith { 2.8 })) - } - - @Test fun allCoreGamesUndoTheClientsInheritedRestriction() { - val all = CpuCores.listOrAll("") - assertEquals(all, CpuCores.gameLaunchList("", clientPinned = true)) - assertEquals(all, CpuCores.gameLaunchList(all, clientPinned = true)) - assertEquals("", CpuCores.gameLaunchList("", clientPinned = false)) - assertEquals("0", CpuCores.gameLaunchList("0", clientPinned = true)) - } -} diff --git a/app/src/test/java/com/droiddeck/launcher/session/CoreAllocationPrefsTest.kt b/app/src/test/java/com/droiddeck/launcher/session/CoreAllocationPrefsTest.kt index 8a25bf4e72..901a82d3ff 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/CoreAllocationPrefsTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/CoreAllocationPrefsTest.kt @@ -1,7 +1,6 @@ package com.droiddeck.launcher.session import android.content.Context -import com.droiddeck.launcher.core.CpuAllocationDefaults import org.junit.Assert.* import org.junit.Before import org.junit.Test @@ -14,36 +13,22 @@ import org.robolectric.annotation.Config @Config(sdk = [33]) class CoreAllocationPrefsTest { private val app get() = RuntimeEnvironment.getApplication() - private val defaults = CpuAllocationDefaults.Allocation("7", "3,4,5,6") private val saved get() = app.getSharedPreferences("session", Context.MODE_PRIVATE) @Before fun clear() { saved.edit().clear().commit() } - @Test fun absentPreferencesUseTheDeviceDefaultWithoutWritingIt() { - assertEquals(SessionPrefs.CoreAllocation(true, "7", "3,4,5,6"), SessionPrefs.coreAllocation(app, defaults)) - assertTrue(saved.all.isEmpty()) - assertEquals(SessionPrefs.CoreAllocation(false, "", ""), SessionPrefs.coreAllocation(app, null)) + @Test fun absentPreferencesLeaveEveryCoreToTheScheduler() { + assertFalse(SessionPrefs.clientCpusOverride(app)) + assertEquals("", SessionPrefs.clientCpus(app)) + assertEquals("", SessionPrefs.gameCpus(app)) } - @Test fun explicitDisableAndAllCoreChoicesSurviveAnUpdate() { - saved.edit().putBoolean("clientCpusOverride", false).putString("clientCpus", "").putString("gameCpus", "").commit() - assertEquals(SessionPrefs.CoreAllocation(false, "", ""), SessionPrefs.coreAllocation(app, defaults)) - } - - @Test fun existingCustomMasksArePreserved() { - saved.edit().putBoolean("clientCpusOverride", true).putString("clientCpus", "0,1").putString("gameCpus", "2,7").commit() - assertEquals(SessionPrefs.CoreAllocation(true, "0,1", "2,7"), SessionPrefs.coreAllocation(app, defaults)) - } - - @Test fun anOldClientMaskIsNotEnabledWithoutAnOverrideChoice() { - saved.edit().putString("clientCpus", "0,1").commit() - assertEquals(SessionPrefs.CoreAllocation(false, "0,1", "3,4,5,6"), SessionPrefs.coreAllocation(app, defaults)) - } - - @Test fun changingOneChoiceDoesNotReplaceTheOtherDefaults() { - SessionPrefs.setGameCpus(app, "0,1,2,3,4,5,6,7") - assertEquals(SessionPrefs.CoreAllocation(true, "7", "0,1,2,3,4,5,6,7"), SessionPrefs.coreAllocation(app, defaults)) - SessionPrefs.setClientCpusOverride(app, false) - assertEquals(SessionPrefs.CoreAllocation(false, "7", "0,1,2,3,4,5,6,7"), SessionPrefs.coreAllocation(app, defaults)) + @Test fun savedChoicesAreKept() { + SessionPrefs.setClientCpusOverride(app, true) + SessionPrefs.setClientCpus(app, "7") + SessionPrefs.setGameCpus(app, "3,4,5,6") + assertTrue(SessionPrefs.clientCpusOverride(app)) + assertEquals("7", SessionPrefs.clientCpus(app)) + assertEquals("3,4,5,6", SessionPrefs.gameCpus(app)) } } From a0c6545e77c75bcf61cff5329d148d3387dc007c Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 20:22:05 -0400 Subject: [PATCH 31/50] fix: a link that joins DroidDeck's open task still returns to the caller --- app/src/main/java/com/droiddeck/launcher/SessionActivity.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index 7c4a19b9a0..0d87bc1f10 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -3555,6 +3555,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback { com.droiddeck.launcher.ui.QuitFlood.take() com.droiddeck.launcher.ui.LaunchOrigin.flooding = null closeLinkTasks() + if (!isTaskRoot) moveTaskToBack(true) super.finishAndRemoveTask() } else super.finish() if (quitFlooded) overridePendingTransition(0, 0) From 4a57c6f6f1e4a6758cfabb4216ff0631b3ea882b Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 20:45:14 -0400 Subject: [PATCH 32/50] chore: drop the comments this change added --- .../launcher/session/LoadingState.kt | 4 ---- .../launcher/session/SessionService.kt | 11 ----------- .../launcher/session/SteamDownloadMonitor.kt | 6 ------ .../launcher/session/LoadingStateTest.kt | 1 - .../session/SteamDownloadMonitorTest.kt | 1 - .../overlay/usr/local/bin/droiddeck-session | 2 -- .../usr/local/bin/droiddeck-steam-install | 19 ------------------- tools/tests/test_steam_install.py | 2 -- 8 files changed, 46 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt b/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt index e7a32fbad2..0180d67b74 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt @@ -131,10 +131,6 @@ class LoadingState(context: Context, private val steam: Boolean = true) { } } - /** - * What a Steam client download line says to show and how far it is: megabytes when the - * runtime counts them (" (2/17), 45 of 360 MB"), else the part and its number. - */ internal fun clientDownload(line: String): Pair? { val count = INSTALL_COUNT.find(line) ?: return null val mb = INSTALL_MEGABYTES.find(line.substring(count.range.last + 1)) diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt index 558e978e0a..e81fa0f12c 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -71,11 +71,6 @@ class SessionService : Service() { private val steamDownloadMonitor = SteamDownloadMonitor() private var downloadMonitorTask: Runnable? = null private var downloadActive = false - /** - * The runtime is fetching the Steam client itself (a first run, a repair), before anything is on - * screen. That download keeps the session awake whatever the downloads setting says: paused, a - * first run never gets as far as showing Steam. - */ private var clientInstallActive = false @Volatile private var steamLibraryMounts = emptyMap() private var suspendDownloadNow = false @@ -647,7 +642,6 @@ class SessionService : Service() { } }, ) - // Watching first: a first run's client download must be known before anything is paused. updateDownloadMonitoring() mainHandler.post { updateSuspendPolicy() } } @@ -1863,15 +1857,10 @@ class SessionService : Service() { getSystemService(NotificationManager::class.java)?.notify(NOTIFICATION_ID, buildNotification()) } - /** A download is under way that holds the session awake while it is out of sight. */ private fun downloadsKeepAwake(): Boolean = downloadActive && (steamDownloadsInBackground || clientInstallActive) && SessionState.mode == MODE_STEAM && suspendPolicy != SessionPrefs.SUSPEND_NEVER - /** - * Steam's own downloads with the downloads setting on, and the Steam client's download until the - * session shows its first frame whatever the setting: once Steam is on screen it was fetched. - */ private fun downloadWatchWanted(): Boolean = SessionState.running && SessionState.mode == MODE_STEAM && suspendPolicy != SessionPrefs.SUSPEND_NEVER && (steamDownloadsInBackground || !SessionState.firstFrameSeen) diff --git a/app/src/main/java/com/droiddeck/launcher/session/SteamDownloadMonitor.kt b/app/src/main/java/com/droiddeck/launcher/session/SteamDownloadMonitor.kt index 007b0b27a3..c125e59b80 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SteamDownloadMonitor.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SteamDownloadMonitor.kt @@ -139,11 +139,6 @@ internal class SteamDownloadMonitor { Regex("\"$key\"\\s+\"([^\"]*)\"").find(text)?.groupValues?.get(1) companion object { - /** - * The runtime has yet to fetch the Steam client: a first run, or a repair asked for or begun - * (droiddeck-steam-install drops its stamp as it starts one). That download runs before - * anything is on screen, and a paused session pauses it with the rest. - */ fun clientInstallPending(runtimeRoot: File): Boolean { val home = File(runtimeRoot, "root") val steam = File(home, ".local/share/Steam") @@ -153,7 +148,6 @@ internal class SteamDownloadMonitor { } private const val MANIFEST_PROGRESS_GRACE_MS = 8_000L - // Longer than Steam's ~60 s between rate lines, for when no traffic counter is available. private const val CONTENT_ACTIVITY_GRACE_MS = 90_000L private const val MIN_RECEIVE_BYTES_PER_SEC = 64L * 1024L private val PATH = Regex("\"path\"\\s+\"([^\"]+)\"") diff --git a/app/src/test/java/com/droiddeck/launcher/session/LoadingStateTest.kt b/app/src/test/java/com/droiddeck/launcher/session/LoadingStateTest.kt index dd545f1f51..c062823494 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/LoadingStateTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/LoadingStateTest.kt @@ -27,7 +27,6 @@ class LoadingStateTest { "bins_linuxarm64_linuxarm64" to 11, LoadingState.clientDownload("== STEP 17:38:17 downloading Steam: bins_linuxarm64_linuxarm64 (2/17)"), ) - // Under a megabyte in all: nothing to count yet. assertEquals("a_all" to 50, LoadingState.clientDownload("== STEP 00:00:00 downloading Steam: a_all (1/2), 0 of 0 MB")) } diff --git a/app/src/test/java/com/droiddeck/launcher/session/SteamDownloadMonitorTest.kt b/app/src/test/java/com/droiddeck/launcher/session/SteamDownloadMonitorTest.kt index db9639f7af..4da943020d 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/SteamDownloadMonitorTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/SteamDownloadMonitorTest.kt @@ -210,7 +210,6 @@ class SteamDownloadMonitorTest { assertTrue(SteamDownloadMonitor.clientInstallPending(root)) File(steam, "steamrtarm64").mkdirs() File(steam, "steamrtarm64/steam").writeText("client") - // Unpacked but not finished: droiddeck-steam-install stamps the client last. assertTrue(SteamDownloadMonitor.clientInstallPending(root)) File(steam, "package").mkdirs() File(steam, "package/droiddeck-installed").writeText("1791686101\n") diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session index 3eb5ff17ab..d8a44be52f 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-session +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-session @@ -397,8 +397,6 @@ case $mode in steam_cef_gpu=0 fi else - # A first run downloads the client (about 360 MB in 2026): minutes on a slow connection, with - # the progress in megabytes on the loading screen. step "checking the Steam client (first run downloads it, ~1-2 min with nothing on screen)" droiddeck-steam-install || steam_setup_failed $? step "Steam client ready" diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install index 291ec8ed43..334ac8f051 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install @@ -25,8 +25,6 @@ stamp=$steam_root/package/droiddeck-installed legacy_stamp=$steam_root/package/bannerlator-installed unconfirmed=$steam_root/package/droiddeck-unconfirmed repair_request=$HOME/.bl-steam-repair -# The parts of an unfinished download: a session that ends, or loses its connection, part way -# through picks up where it stopped instead of fetching the whole client again. parts=$steam_root/package/droiddeck-download if [ -f "$legacy_stamp" ] && [ ! -f "$stamp" ]; then mv -f "$legacy_stamp" "$stamp" || true @@ -50,7 +48,6 @@ if [ -n "$fallback" ]; then fi if [ -n "$repair" ]; then echo "== STEP $(date -u +%H:%M:%S) repairing the Steam client ($repair)" - # A repair unpacks every part again - once: an interrupted one keeps what it has redone. if [ ! -f "$parts/.repair" ]; then rm -rf "$parts" mkdir -p "$parts" && : > "$parts/.repair" @@ -78,7 +75,6 @@ fi work=$(mktemp -d) trap 'rm -rf "$work"' EXIT -# A sleep that starts no process (droiddeck-session's nap): read -t on a pipe nothing writes to. nap() { [ -n "${nap_fd:-}" ] || exec {nap_fd}<> <(:) read -r -t "$1" -u "$nap_fd" _ 2>/dev/null || : @@ -88,16 +84,10 @@ size_of() { [ -f "$1" ] && n=$(wc -c < "$1") echo $((n)) } -# A connection can stall without closing (Wi-Fi power save, a phone changing networks), and -# curl's default then is to wait for ever with nothing on screen. A transfer under 4 KB/s for a -# minute is dropped and resumed from the bytes already on disk. limits=(--connect-timeout 30 --speed-limit 4096 --speed-time 60) -# Seconds between attempts that made no progress; the download fails after the last one. read -r -a delays <<< "${BL_STEAM_RETRY_DELAYS:-5 10 20 30 30}" step() { echo "== STEP $(date -u +%H:%M:%S) $*"; } -# The line the app's loading screen reads: the part, its number, and megabytes overall. A third -# argument is said after it (a stall), and is always said; otherwise only a change is. progress() { local mb=$(( (done_bytes + $(size_of "$1")) / 1000000 )) [ -z "${3:-}" ] && [ "$mb" = "${shown_mb:-}" ] && [ "$2" = "${shown_part:-}" ] && return 0 @@ -105,21 +95,16 @@ progress() { step "downloading Steam: $2 ($i/$total), $mb of $((total_bytes / 1000000)) MB${3:+ - $3}" } -# fetch URL FILE SIZE SHA256 PART: FILE complete and checked, resuming whatever is already there. fetch() { local url=$1 dest=$2 size=$3 sum=$4 part=$5 failures=0 bad=0 finished=0 before rc fd wait while :; do - # Whole once it is as long as the manifest says, or (no size given) once curl finished it. if [ -f "$dest" ] && { [ "$finished" = 1 ] || { [ "$size" -gt 0 ] && [ "$(size_of "$dest")" -ge "$size" ]; }; }; then echo "$sum $dest" | sha256sum -c --quiet 2>/dev/null && return 0 - # Bytes that do not check out are fetched whole again, a few times at most. rm -f "$dest" finished=0 bad=$((bad + 1)) [ "$bad" -lt 3 ] || { echo "droiddeck-steam-install: $part does not match its checksum" >&2; return 1; } fi before=$(size_of "$dest") - # curl's status comes back through the pipe (|| keeps set -e from ending the subshell before it - # is said); until then a progress line every 5 s. exec {fd}< <(curl -fsSL "${limits[@]}" -C - -o "$dest" "$url" && echo 0 || echo $?) until read -r -t 5 -u "$fd" rc; do if [ $? -le 128 ]; then rc=1; break; fi @@ -127,7 +112,6 @@ fetch() { done exec {fd}<&- if [ "$rc" = 0 ]; then finished=1; continue; fi - # 33: the server would not resume. Start the part over. [ "$rc" = 33 ] && rm -f "$dest" if [ "$(size_of "$dest")" -gt "$before" ]; then failures=0; else failures=$((failures + 1)); fi if [ "$failures" -gt "${#delays[@]}" ]; then @@ -189,8 +173,6 @@ total=$(grep -c . "$work/parts" 2>/dev/null || echo 0) total_bytes=$(awk '{ n += $4 } END { print n + 0 }' "$work/parts") mkdir -p "$parts" -# What an earlier attempt left for another client version is no use to this one. A part's file -# name carries its own hash, so a name still listed is the same part. for left in "$parts"/*; do [ -e "$left" ] || continue name=${left##*/} @@ -218,7 +200,6 @@ while read -r block file sum size; do rm -f "$parts/$file" done_bytes=$((done_bytes + size)) done < "$work/parts" -# Some entries are zipped with Windows separators; unzip keeps the backslash in the file name. find "$steam_root" -depth -name '*\\*' | while read -r odd; do fixed=${odd//\\//} mkdir -p "$(dirname "$fixed")" diff --git a/tools/tests/test_steam_install.py b/tools/tests/test_steam_install.py index 75bc1c5e91..54028187ca 100644 --- a/tools/tests/test_steam_install.py +++ b/tools/tests/test_steam_install.py @@ -343,7 +343,6 @@ sys.exit(28 if end < len(data) else 0) self.requests.unlink() Path(str(self.requests) + '.offsets').unlink() self.assertEqual(0, self.install().returncode) - # The next session asks only for the rest of the part it did not finish. self.assertEqual(['steam_client_steamdeck_publicbeta_linuxarm64', client], self.requested()) self.assertEqual([400000], self.offsets(client)) self.assertFalse(self.download.exists()) @@ -383,7 +382,6 @@ sys.exit(28 if end < len(data) else 0) self.assertNotEqual(0, self.install().returncode) self.assertIn(files['a_all'], self.requested()) self.requests.unlink() - # Still a repair, but what the interrupted one redid is not done a third time. self.assertEqual(0, self.install().returncode) self.assertEqual(['steam_client_steamdeck_publicbeta_linuxarm64', files['client_linuxarm64_linuxarm64']], self.requested()) From 96e2bf992d4864baa8f546734554bf51107f2afe Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 21:20:50 -0400 Subject: [PATCH 33/50] fix: an HTTP 4xx part hands over to the next CDN at once --- .../usr/local/bin/droiddeck-steam-install | 12 +++++-- tools/tests/test_steam_install.py | 36 ++++++++++++++++--- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install index 334ac8f051..45bd96c259 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-install @@ -105,14 +105,20 @@ fetch() { [ "$bad" -lt 3 ] || { echo "droiddeck-steam-install: $part does not match its checksum" >&2; return 1; } fi before=$(size_of "$dest") - exec {fd}< <(curl -fsSL "${limits[@]}" -C - -o "$dest" "$url" && echo 0 || echo $?) - until read -r -t 5 -u "$fd" rc; do + exec {fd}< <(code=$(curl -fsSL "${limits[@]}" -w '%{http_code}' -C - -o "$dest" "$url") && echo "0 $code" || echo "$? $code") + until read -r -t 5 -u "$fd" rc http; do if [ $? -le 128 ]; then rc=1; break; fi progress "$dest" "$part" done exec {fd}<&- if [ "$rc" = 0 ]; then finished=1; continue; fi - [ "$rc" = 33 ] && rm -f "$dest" + case "$rc:${http:-}" in + 22:416 | 33:*) rm -f "$dest" ;; + 22:4??) + echo "droiddeck-steam-install: $part: HTTP $http from ${url%/*}" >&2 + return 1 + ;; + esac if [ "$(size_of "$dest")" -gt "$before" ]; then failures=0; else failures=$((failures + 1)); fi if [ "$failures" -gt "${#delays[@]}" ]; then echo "droiddeck-steam-install: could not download $part (curl exit $rc); what arrived is kept for the next try" >&2 diff --git a/tools/tests/test_steam_install.py b/tools/tests/test_steam_install.py index 54028187ca..6a02bcb0ae 100644 --- a/tools/tests/test_steam_install.py +++ b/tools/tests/test_steam_install.py @@ -37,9 +37,13 @@ with open(os.environ['TEST_REQUESTS'], 'a') as log: log.write(url + '\\n') with open(os.environ['TEST_REQUESTS'] + '.offsets', 'a') as log: log.write(f'{name} {offset}\\n') +def done(status, code='200'): + if '-w' in args: + sys.stdout.write(code) + sys.exit(status) host_fail = os.environ.get('TEST_FAIL_HOST') if host_fail and host_fail in url: - sys.exit(22) + done(22, '000') action = [] plan = os.environ.get('TEST_PLAN') if plan and os.path.exists(plan): @@ -51,14 +55,16 @@ if plan and os.path.exists(plan): open(plan, 'w').write(''.join(l + '\\n' for l in lines)) break if action[:1] == ['fail']: - sys.exit(int(action[1])) + done(int(action[1]), '000') +if action[:1] == ['http']: + done(22, action[1]) if action[:1] == ['norange'] and offset: - sys.exit(33) + done(33) data = open(os.path.join(os.environ['TEST_CDN'], name), 'rb').read() end = int(action[1]) if action[:1] == ['cut'] else len(data) with open(out, 'ab' if offset else 'wb') as target: target.write(data[offset:end]) -sys.exit(28 if end < len(data) else 0) +done(28 if end < len(data) else 0) ''') curl.chmod(0o755) self.plan = self.root / 'plan' @@ -355,6 +361,28 @@ sys.exit(28 if end < len(data) else 0) self.assertEqual(0, result.returncode, result.stderr) self.assertEqual([0, 400000, 0], self.offsets(client)) + def test_a_missing_part_hands_over_to_the_next_cdn_at_once(self): + files = self.two_parts() + client = files['client_linuxarm64_linuxarm64'] + self.plan_for(client, 'http 404') + result = self.install() + self.assertEqual(0, result.returncode, result.stderr) + self.assertEqual(['https://client-update.steamstatic.com/' + client, + 'https://client-update.akamai.steamstatic.com/' + client], + [line for line in self.requests.read_text().splitlines() if line.endswith(client)]) + self.assertIn('HTTP 404 from https://client-update.steamstatic.com', result.stderr) + self.assertNotIn('trying again', result.stdout) + + def test_a_server_error_is_retried_on_the_same_cdn(self): + files = self.two_parts() + client = files['client_linuxarm64_linuxarm64'] + self.plan_for(client, 'http 503') + result = self.install() + self.assertEqual(0, result.returncode, result.stderr) + self.assertEqual(['https://client-update.steamstatic.com/' + client] * 2, + [line for line in self.requests.read_text().splitlines() if line.endswith(client)]) + self.assertIn('interrupted (curl exit 22), trying again in 0 s', result.stdout) + def test_bytes_that_do_not_check_out_are_fetched_again(self): files = self.two_parts() client = files['client_linuxarm64_linuxarm64'] From 7419ba114f80fe2ab19793d5d4028e61ad638a80 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 22:22:14 -0400 Subject: [PATCH 34/50] fix: the client install stays awake until Steam's first frame and its end is recorded --- .../java/com/droiddeck/launcher/session/SessionService.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt index e81fa0f12c..762de4f93b 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -1872,6 +1872,7 @@ class SessionService : Service() { downloadMonitorTask = null steamDownloadMonitor.reset() downloadActive = false + if (clientInstallActive) SessionEvents.record("steam.client_download", mapOf("active" to false)) clientInstallActive = false if (wasActive) refreshNotification() return @@ -1889,7 +1890,8 @@ class SessionService : Service() { val root = LinuxRuntime.rootDir(this@SessionService) val wasActive = downloadActive val wasInstalling = clientInstallActive - clientInstallActive = !SessionState.firstFrameSeen && SteamDownloadMonitor.clientInstallPending(root) + clientInstallActive = !SessionState.firstFrameSeen && + (clientInstallActive || SteamDownloadMonitor.clientInstallPending(root)) downloadActive = clientInstallActive || steamDownloadsInBackground && steamDownloadMonitor.poll( root, receivedBytes = TrafficStats.getUidRxBytes(android.os.Process.myUid()), From 5981bbb1e2d8f7f6af7d7134d9c512109a9b76c8 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 22:51:28 -0400 Subject: [PATCH 35/50] fix: an oversized install step count falls back to the step text --- .../main/java/com/droiddeck/launcher/session/LoadingState.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt b/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt index 0180d67b74..f580b0af0e 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt @@ -139,7 +139,9 @@ class LoadingState(context: Context, private val steam: Boolean = true) { if (done != null && total != null && total > 0) { return "$done / $total MB" to (done * 100 / total).toInt().coerceIn(0, 100) } - return count.groupValues[1] to count.groupValues[2].toInt() * 100 / maxOf(1, count.groupValues[3].toInt()) + val part = count.groupValues[2].toIntOrNull() ?: return null + val all = count.groupValues[3].toIntOrNull() ?: return null + return count.groupValues[1] to part * 100 / maxOf(1, all) } internal fun readableScriptStep(scriptStep: String): Boolean { From 132f40ac97ac3acb9b41e3b21f5d65f093f882f3 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 23:11:34 -0400 Subject: [PATCH 36/50] fix: install step progress cannot overflow --- .../main/java/com/droiddeck/launcher/session/LoadingState.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt b/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt index f580b0af0e..f69983f0db 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/LoadingState.kt @@ -141,7 +141,7 @@ class LoadingState(context: Context, private val steam: Boolean = true) { } val part = count.groupValues[2].toIntOrNull() ?: return null val all = count.groupValues[3].toIntOrNull() ?: return null - return count.groupValues[1] to part * 100 / maxOf(1, all) + return count.groupValues[1] to (part.toLong() * 100 / maxOf(1, all)).coerceIn(0L, 100L).toInt() } internal fun readableScriptStep(scriptStep: String): Boolean { From 2c8ae3753c8c69704891f4453e1dfcc847f9031c Mon Sep 17 00:00:00 2001 From: XxJSONDeruloxX Date: Fri, 23 Oct 2026 17:30:54 -0400 Subject: [PATCH 37/50] fix(xbox): mount external storage for downloads --- .../launcher/stores/StoreInstallRoot.kt | 22 +++++++++++++++--- .../launcher/stores/xbox/XboxInstaller.kt | 3 ++- .../launcher/stores/xbox/XboxRuntime.kt | 2 +- .../droiddeck/launcher/stores/xbox/Xodus.kt | 4 +++- .../launcher/stores/StoreInstallRootTest.kt | 23 +++++++++++++++++++ 5 files changed, 48 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt index 611b7f3dba..ad17bd8172 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt @@ -104,6 +104,15 @@ object StoreInstallRoot { .map { it to guestFor(context, it) } } + fun externalBindSpecs(context: Context): List = externalBindSpecs(externalRoots(context), LinuxRuntime.rootDir(context)) + + internal fun externalBindSpecs(roots: List>, guestRoot: File): List = + roots.mapNotNull { (host, guest) -> + if (!host.isDirectory || !host.canRead()) return@mapNotNull null + val target = File(guestRoot, guest.removePrefix("/")) + if (target.isDirectory || target.mkdirs()) "${host.path}:$guest" else null + } + private fun guestFor(context: Context, root: File): String { val sm = context.getSystemService(StorageManager::class.java) val uuid = runCatching { sm?.getStorageVolume(root)?.uuid }.getOrNull()?.takeIf { it.isNotBlank() }?.replace(Regex("[^A-Za-z0-9-]"), "") @@ -114,11 +123,18 @@ object StoreInstallRoot { fun isInternal(context: Context, root: File): Boolean = root.absolutePath == internalRoot(context).absolutePath fun externalGuestPath(context: Context, host: File): String? { + return externalGuestPath(host, externalRoots(context)) + } + + fun guestPath(context: Context, host: File): String = externalGuestPath(context, host) ?: host.path + + internal fun externalGuestPath(host: File, roots: List>): String? { val path = host.absolutePath - for ((root, guest) in externalRoots(context)) { - val dir = root.absolutePath + for ((root, guest) in roots.sortedByDescending { it.first.absolutePath.length }) { + val dir = root.absolutePath.trimEnd(File.separatorChar) if (path == dir) return guest - if (path.startsWith("$dir/")) return guest + "/" + path.removePrefix("$dir/") + val prefix = dir + File.separator + if (path.startsWith(prefix)) return guest + "/" + path.removePrefix(prefix).replace(File.separatorChar, '/') } return null } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt index 44e9ceff33..09e5561588 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt @@ -39,8 +39,9 @@ internal class XboxInstaller(private val app: Context, private val item: Catalog var sequence = -1L try { val source = if (content) selected else item.id + val guestFolder = StoreInstallRoot.guestPath(app, folder) val selection = if (content) emptyList() else listOf("--selected-content-id", selected) - Xodus.start(app, listOf("streaming", source, folder.path, "--market", market, + Xodus.start(app, listOf("streaming", source, guestFolder, "--market", market, "--progress-json", "--control-stdin") + selection).use { process -> child = process val diagnostics = Xodus.diagnostics(process) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxRuntime.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxRuntime.kt index 28d6c12d99..3263dcb33b 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxRuntime.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxRuntime.kt @@ -46,7 +46,7 @@ internal object XboxRuntime { val market = game.second.extra["market"]?.takeIf { it.matches(Regex("[A-Z]{2}")) } ?: Xodus.market() val directory = views.create(app.filesDir) val process = try { - Xodus.start(app, listOf("run", game.first.path, "droiddeck:prepare", "--exe", game.second.exe, + Xodus.start(app, listOf("run", StoreInstallRoot.guestPath(app, game.first), "droiddeck:prepare", "--exe", game.second.exe, "--materialize-chain", "--market", market), launchDirectory = directory, credentialGeneration = credentials) } catch (e: Exception) { XboxLaunchViews.remove(directory); throw e } if (!launches.attach(token, process)) { process.close(); error("Xbox launch was cancelled") } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt index fde5b0650c..0444acfef4 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt @@ -6,6 +6,7 @@ import com.droiddeck.launcher.core.AddonPack import com.droiddeck.launcher.runtime.LinuxNetworkLinkComponent import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.session.SessionPrefs +import com.droiddeck.launcher.stores.StoreInstallRoot import org.json.JSONObject import java.io.Closeable import java.io.File @@ -79,7 +80,8 @@ internal object Xodus { networkLink.publish() networkLink.start() val runtime = (runtimeDirectory ?: File(app.filesDir, "xbox-runtime")).apply { mkdirs() } - val command = LinuxRuntime.command(app, null, null, Environment.getExternalStorageDirectory(), listOf( + val command = LinuxRuntime.command(app, null, null, Environment.getExternalStorageDirectory(), + StoreInstallRoot.externalBindSpecs(app), listOf( "/usr/bin/env", "HOME=/root", "XODUS_LOG=off", "RUST_LOG=off", "XDG_RUNTIME_DIR=${runtime.path}", "DROIDDECK_XBOX_CREDENTIAL_SOCKET=${credentials.name}", binary, ) + args) diff --git a/app/src/test/java/com/droiddeck/launcher/stores/StoreInstallRootTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/StoreInstallRootTest.kt index c40ef5b201..4a4611374f 100644 --- a/app/src/test/java/com/droiddeck/launcher/stores/StoreInstallRootTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/stores/StoreInstallRootTest.kt @@ -38,6 +38,29 @@ class StoreInstallRootTest { assertEquals(1, StoreInstallRoot.targets(app).size) } + @Test fun externalStoreInstallPathsMapIntoTheirGuestMountWithoutPrefixCollisions() { + val cardRoot = File(app.filesDir, "card/Games").apply { mkdirs() } + val guestRoot = "/mnt/droiddeck-stores/card" + val roots = listOf(cardRoot to guestRoot) + + assertEquals("$guestRoot/Stores/Xbox/Doom", StoreInstallRoot.externalGuestPath( + File(cardRoot, "Stores/Xbox/Doom"), roots)) + assertEquals(null, StoreInstallRoot.externalGuestPath( + File(cardRoot.parentFile, "Games-old/Stores/Xbox/Doom"), roots)) + } + + @Test fun externalStoreBindsCreateGuestTargetsAndSkipUnavailableVolumes() { + val host = File(app.filesDir, "card/Games").apply { mkdirs() } + val guestRoot = "/mnt/droiddeck-stores/card" + val guestFs = File(app.filesDir, "linuxfs").apply { mkdirs() } + val missing = File(app.filesDir, "missing/Games") + + assertEquals(listOf("${host.path}:$guestRoot"), StoreInstallRoot.externalBindSpecs( + listOf(host to guestRoot, missing to "/mnt/droiddeck-stores/missing"), guestFs)) + assertTrue(File(guestFs, "mnt/droiddeck-stores/card").isDirectory) + assertFalse(File(guestFs, "mnt/droiddeck-stores/missing").exists()) + } + @Test fun anExistingInstallWinsOverAFreshFolderUnderTheChosenRoot() { SessionPrefs.setGameStorage(app, SessionPrefs.GAME_STORAGE_OFF, "") val existing = File(StoreInstallRoot.storeDir(StoreInstallRoot.internalRoot(app), Store.GOG), "Old Name").apply { mkdirs() } From 4a0eb14d1fac305494b5a9c6aa2908d8160ad41a Mon Sep 17 00:00:00 2001 From: XxJSONDeruloxX Date: Fri, 23 Oct 2026 19:24:45 -0400 Subject: [PATCH 38/50] fix(xbox): mount selected SD library in Xodus --- .../launcher/stores/StoreInstallRoot.kt | 17 +++++++++++++++++ .../launcher/stores/xbox/XboxInstaller.kt | 2 +- .../launcher/stores/xbox/XboxRuntime.kt | 2 +- .../com/droiddeck/launcher/stores/xbox/Xodus.kt | 2 +- .../launcher/stores/StoreInstallRootTest.kt | 14 ++++++++++++++ 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt index ad17bd8172..91a0f96f5b 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/StoreInstallRoot.kt @@ -104,8 +104,22 @@ object StoreInstallRoot { .map { it to guestFor(context, it) } } + /** Xodus has its own PRoot mount table and cannot see the selected Steam library's SD bind. */ + fun externalRootsForXodus(context: Context): List> { + val roots = externalRoots(context).toMutableList() + val selectedLibrary = GameStorage.effective(context)?.let { File(it.path, ON_VOLUME) } + ?.takeUnless { isInternal(context, it) } + if (selectedLibrary != null && roots.none { it.first.absolutePath == selectedLibrary.absolutePath }) { + roots += selectedLibrary to guestFor(context, selectedLibrary) + } + return roots + } + fun externalBindSpecs(context: Context): List = externalBindSpecs(externalRoots(context), LinuxRuntime.rootDir(context)) + fun externalBindSpecsForXodus(context: Context): List = + externalBindSpecs(externalRootsForXodus(context), LinuxRuntime.rootDir(context)) + internal fun externalBindSpecs(roots: List>, guestRoot: File): List = roots.mapNotNull { (host, guest) -> if (!host.isDirectory || !host.canRead()) return@mapNotNull null @@ -128,6 +142,9 @@ object StoreInstallRoot { fun guestPath(context: Context, host: File): String = externalGuestPath(context, host) ?: host.path + fun guestPathForXodus(context: Context, host: File): String = + externalGuestPath(host, externalRootsForXodus(context)) ?: host.path + internal fun externalGuestPath(host: File, roots: List>): String? { val path = host.absolutePath for ((root, guest) in roots.sortedByDescending { it.first.absolutePath.length }) { diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt index 09e5561588..296ff050b8 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxInstaller.kt @@ -39,7 +39,7 @@ internal class XboxInstaller(private val app: Context, private val item: Catalog var sequence = -1L try { val source = if (content) selected else item.id - val guestFolder = StoreInstallRoot.guestPath(app, folder) + val guestFolder = StoreInstallRoot.guestPathForXodus(app, folder) val selection = if (content) emptyList() else listOf("--selected-content-id", selected) Xodus.start(app, listOf("streaming", source, guestFolder, "--market", market, "--progress-json", "--control-stdin") + selection).use { process -> diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxRuntime.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxRuntime.kt index 3263dcb33b..d1ba4a52e7 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxRuntime.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/XboxRuntime.kt @@ -46,7 +46,7 @@ internal object XboxRuntime { val market = game.second.extra["market"]?.takeIf { it.matches(Regex("[A-Z]{2}")) } ?: Xodus.market() val directory = views.create(app.filesDir) val process = try { - Xodus.start(app, listOf("run", StoreInstallRoot.guestPath(app, game.first), "droiddeck:prepare", "--exe", game.second.exe, + Xodus.start(app, listOf("run", StoreInstallRoot.guestPathForXodus(app, game.first), "droiddeck:prepare", "--exe", game.second.exe, "--materialize-chain", "--market", market), launchDirectory = directory, credentialGeneration = credentials) } catch (e: Exception) { XboxLaunchViews.remove(directory); throw e } if (!launches.attach(token, process)) { process.close(); error("Xbox launch was cancelled") } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt index 0444acfef4..c7f706d268 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt @@ -81,7 +81,7 @@ internal object Xodus { networkLink.start() val runtime = (runtimeDirectory ?: File(app.filesDir, "xbox-runtime")).apply { mkdirs() } val command = LinuxRuntime.command(app, null, null, Environment.getExternalStorageDirectory(), - StoreInstallRoot.externalBindSpecs(app), listOf( + StoreInstallRoot.externalBindSpecsForXodus(app), listOf( "/usr/bin/env", "HOME=/root", "XODUS_LOG=off", "RUST_LOG=off", "XDG_RUNTIME_DIR=${runtime.path}", "DROIDDECK_XBOX_CREDENTIAL_SOCKET=${credentials.name}", binary, ) + args) diff --git a/app/src/test/java/com/droiddeck/launcher/stores/StoreInstallRootTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/StoreInstallRootTest.kt index 4a4611374f..78e9bbc0d0 100644 --- a/app/src/test/java/com/droiddeck/launcher/stores/StoreInstallRootTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/stores/StoreInstallRootTest.kt @@ -49,6 +49,20 @@ class StoreInstallRootTest { File(cardRoot.parentFile, "Games-old/Stores/Xbox/Doom"), roots)) } + @Test fun xodusMapsTheSelectedSteamLibraryOnAnExternalVolume() { + val library = File(app.filesDir, "card/steam").apply { mkdirs() } + val storeRoot = File(library, "Games").apply { mkdirs() } + SessionPrefs.setGameStorage(app, library.path, "Card") + + val xodusRoot = StoreInstallRoot.externalRootsForXodus(app).single { it.first.absolutePath == storeRoot.absolutePath } + val gameFolder = File(storeRoot, "Xbox/Doom") + assertEquals("${xodusRoot.second}/Xbox/Doom", StoreInstallRoot.guestPathForXodus(app, gameFolder)) + + val bindSpecs = StoreInstallRoot.externalBindSpecsForXodus(app) + assertTrue(bindSpecs.contains("${storeRoot.path}:${xodusRoot.second}")) + assertTrue(File(LinuxRuntime.rootDir(app), xodusRoot.second.removePrefix("/")).isDirectory) + } + @Test fun externalStoreBindsCreateGuestTargetsAndSkipUnavailableVolumes() { val host = File(app.filesDir, "card/Games").apply { mkdirs() } val guestRoot = "/mnt/droiddeck-stores/card" From b1ab55856ed761cf9686ce0e2c39452190843f89 Mon Sep 17 00:00:00 2001 From: XxJSONDeruloxX Date: Fri, 23 Oct 2026 19:36:15 -0400 Subject: [PATCH 39/50] fix(ui): clear search focus and use store accents --- .../java/com/droiddeck/launcher/ui/StoresPage.kt | 16 +++++++++++++--- .../droiddeck/launcher/ui/WirelessAdbFixPage.kt | 6 ++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt index 175cbecd85..db9fe6ed08 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/StoresPage.kt @@ -128,6 +128,7 @@ import androidx.compose.ui.graphics.lerp import androidx.compose.ui.graphics.graphicsLayer import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalFocusManager import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.Role import androidx.compose.ui.semantics.contentDescription @@ -172,6 +173,7 @@ private data class PaneKey(val chip: String, val tab: String, val signedIn: Bool @Composable internal fun StoresPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier) { val ctx = LocalContext.current + val focusManager = LocalFocusManager.current com.droiddeck.launcher.stores.xbox.XboxContent.plan?.let { content -> androidx.compose.material3.AlertDialog( onDismissRequest = { com.droiddeck.launcher.stores.xbox.XboxContent.dismiss() }, @@ -279,7 +281,7 @@ internal fun StoresPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier val heroFocus = remember { androidx.compose.ui.focus.FocusRequester() } var detailFocused by remember { mutableStateOf(false) } fun move(kind: String) { focusMove = kind to (focusMove?.second ?: 0) + 1 } - fun open(key: String) { lastOpened = key; openGame = key; move("detail") } + fun open(key: String) { focusManager.clearFocus(force = true); lastOpened = key; openGame = key; move("detail") } fun closeGame() { openGame = null; move("card") } fun switchTab(to: String) { tab = to; move("first") } val pickChip: (String) -> Unit = { id -> @@ -477,7 +479,11 @@ internal fun StoresPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier androidx.compose.material3.LinearProgressIndicator(Modifier.fillMaxWidth().height(3.dp)) } !k.signedIn -> Box(Modifier.fillMaxWidth().verticalScroll(scroll).padding(top = 4.dp, bottom = 16.dp)) { SignInCard(st, viewportH - 20.dp) } - else -> Storefront(st, k.tab, query, s, a, grids.getOrPut(k) { LazyGridState() }, onQuery = { query = it }, onOpen = { open(it) }, onTab = { switchTab(it) }) + else -> Storefront( + st, k.tab, query, s, a, grids.getOrPut(k) { LazyGridState() }, + clearSearchFocus = openGame != null, + onQuery = { query = it }, onOpen = { open(it) }, onTab = { switchTab(it) }, + ) } } } @@ -538,7 +544,7 @@ internal fun StoresPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier seenActive.clear(); seenActive.addAll(activeKeys) if (fresh.isNotEmpty()) StoresMotion.takeInstall()?.let { StoresMotion.fly(it) } } - StoresState.pendingInstall?.let { item -> InstallWhere(item) } + StoresState.pendingInstall?.let { item -> StoreTheme(item.store) { InstallWhere(item) } } } @Composable @@ -937,6 +943,7 @@ internal fun StoreLogo(store: Store, size: Dp) { private fun Storefront( store: Store, tab: String, query: String, s: FrontEndState, a: FrontEndActions, grid: LazyGridState, + clearSearchFocus: Boolean, onQuery: (String) -> Unit, onOpen: (String) -> Unit, onTab: (String) -> Unit, ) { val ctx = LocalContext.current @@ -1072,6 +1079,7 @@ private fun Storefront( libraryLabel, query, onQuery, placeholder = if (tab == "store") stringResource(R.string.stores_search_catalog, store.label) else stringResource(R.string.stores_search_library), + clearSearchFocus = clearSearchFocus, lead = if (tabs.size < 2) null else { { val labels = tabs.map { if (it == "store") stringResource(R.string.stores_tab_store) else libraryLabel } HeaderTabs(labels, tabs.indexOf(tab).coerceAtLeast(0)) { onTab(tabs[it]) } @@ -1172,6 +1180,7 @@ private fun HeaderTabs(labels: List, selected: Int, onSelect: (Int) -> U @Composable internal fun ModeHeader( title: String, query: String, onQuery: (String) -> Unit, placeholder: String, + clearSearchFocus: Boolean = false, lead: (@Composable () -> Unit)? = null, trailing: @Composable () -> Unit, ) { val colors = MaterialTheme.colorScheme @@ -1193,6 +1202,7 @@ internal fun ModeHeader( AdbTextField( value = query, onValueChange = onQuery, label = "", keyboardType = KeyboardType.Text, imeAction = ImeAction.Search, placeholder = placeholder, compact = true, focusOnShow = focusOnOpen, + clearFocus = clearSearchFocus, onFocusChange = { focused -> if (!focused && query.isEmpty()) { searching = false; focusOnOpen = false } }, ) } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/WirelessAdbFixPage.kt b/app/src/main/java/com/droiddeck/launcher/ui/WirelessAdbFixPage.kt index 8117c3ee5e..5c719ca90d 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/WirelessAdbFixPage.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/WirelessAdbFixPage.kt @@ -356,6 +356,7 @@ internal fun AdbTextField( placeholder: String? = null, compact: Boolean = false, onFocusChange: (Boolean) -> Unit = {}, + clearFocus: Boolean = false, onNext: (() -> Unit)? = null, onDone: (() -> Unit)? = null, focusOnShow: Boolean = false, @@ -444,6 +445,11 @@ internal fun AdbTextField( ?.showSoftInput(editText, android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT) } } + if (clearFocus && editText.hasFocus()) { + editText.clearFocus() + (editText.context.getSystemService(android.content.Context.INPUT_METHOD_SERVICE) as? android.view.inputmethod.InputMethodManager) + ?.hideSoftInputFromWindow(editText.windowToken, 0) + } editText.setTextColor(colors.onBackground.toArgb()) editText.setHintTextColor(colors.onSurfaceVariant.toArgb()) editText.hint = placeholder From 546574e982806a9ff8042987cbd6d18a7cbcf7ed Mon Sep 17 00:00:00 2001 From: XxJSONDeruloxX Date: Fri, 23 Oct 2026 20:58:25 -0400 Subject: [PATCH 40/50] fix(xbox): enable proot fast path in Xodus --- .../launcher/runtime/LinuxRuntime.java | 5 +++++ .../droiddeck/launcher/stores/xbox/Xodus.kt | 21 ++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java index 11be5bf9b4..6d17f2d75a 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java +++ b/app/src/main/java/com/droiddeck/launcher/runtime/LinuxRuntime.java @@ -110,6 +110,11 @@ public final class LinuxRuntime { File root = rootDir(context); List binds = binds(context, sessionRoot, runtimeDir, externalStorage, extraBinds); if (sessionRoot != null) lastBinds = binds; + return commandWithBinds(context, root, binds, guestCommand); + } + + public static List commandWithBinds(Context context, File root, List binds, + List guestCommand) { List cmd = prootPrefix(context, root, "/root"); for (String spec : binds) bind(cmd, spec); cmd.addAll(guestCommand); diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt index c7f706d268..94b8138253 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt @@ -5,6 +5,7 @@ import android.os.Environment import com.droiddeck.launcher.core.AddonPack import com.droiddeck.launcher.runtime.LinuxNetworkLinkComponent import com.droiddeck.launcher.runtime.LinuxRuntime +import com.droiddeck.launcher.runtime.ProotFastPath import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.stores.StoreInstallRoot import org.json.JSONObject @@ -80,11 +81,24 @@ internal object Xodus { networkLink.publish() networkLink.start() val runtime = (runtimeDirectory ?: File(app.filesDir, "xbox-runtime")).apply { mkdirs() } - val command = LinuxRuntime.command(app, null, null, Environment.getExternalStorageDirectory(), - StoreInstallRoot.externalBindSpecsForXodus(app), listOf( + val root = LinuxRuntime.rootDir(app) + val external = Environment.getExternalStorageDirectory() + val extraBinds = StoreInstallRoot.externalBindSpecsForXodus(app) + val binds = LinuxRuntime.binds(app, null, null, external, extraBinds) + val fastPathPreloaded = runCatching { + File(root, "etc/ld.so.preload").useLines { lines -> lines.any { it.trim() == ProotFastPath.LIBRARY } } + }.getOrDefault(false) + val fastPathKey = if (ProotFastPath.enabled(app) && fastPathPreloaded && + File(root, ProotFastPath.LIBRARY.removePrefix("/")).isFile) ProotFastPath.key(root, binds) else null + val guestCommand = mutableListOf( "/usr/bin/env", "HOME=/root", "XODUS_LOG=off", "RUST_LOG=off", "XDG_RUNTIME_DIR=${runtime.path}", "DROIDDECK_XBOX_CREDENTIAL_SOCKET=${credentials.name}", binary, - ) + args) + ) + fastPathKey?.let { key -> + guestCommand.addAll(guestCommand.lastIndex, ProotFastPath.guestEnv(root, binds, key)) + } + guestCommand.addAll(args) + val command = LinuxRuntime.commandWithBinds(app, root, binds, guestCommand) val builder = ProcessBuilder(command).directory(LinuxRuntime.rootDir(app)) if (launchDirectory != null) builder.environment()["TMPDIR"] = launchDirectory.path builder.environment().apply { @@ -92,6 +106,7 @@ internal object Xodus { put("PROOT_LOADER", LinuxRuntime.prootLoader(app).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(app).path) if (SessionPrefs.prootNoSeccomp(app)) put("PROOT_NO_SECCOMP", "1") + fastPathKey?.let { ProotFastPath.hostEnv(it).let { (key, value) -> put(key, value) } } LinuxRuntime.prootLibraryPath(app).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } val digest = java.security.MessageDigest.getInstance("SHA-256") From 6e1621fe535deb18e8146606e4d7cee5128c31d5 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 23:41:22 -0400 Subject: [PATCH 41/50] fix: Steam's Ubisoft games install Ubisoft Connect again The redistributable seeder marked every process in a game's install scripts as already run, so the Ubisoft Connect installer that Ubisoft games list was skipped and they stopped with "Unable to locate Uplay PC". It is now left to run like the Vulkan runtime installer, and a marker an earlier seeding wrote is taken back out. --- .../usr/local/bin/droiddeck-seed-redists | 4 +- tools/tests/test_seed_redists.py | 48 +++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-seed-redists b/tools/linuxfs/overlay/usr/local/bin/droiddeck-seed-redists index 831a0e4cee..86d3f1c31a 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-seed-redists +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-seed-redists @@ -24,7 +24,7 @@ read_scripts() { xargs -0 -r awk -v want="${1:-redists}" ' proc[depth] = 1 program = tolower(part[4]) sub(/.*[\\\/]/, "", program) - if (program ~ /vulkan/) vulkan[depth] = 1 + if (program ~ /vulkan|uplay|ubisoft/) vulkan[depth] = 1 next } if (n == 3) pending = part[2] @@ -243,7 +243,7 @@ for system in "${regs[@]}"; do had=() for line in "${kept[@]}"; do had[$line]=1; done printf '%s\n' "${other[@]}" "${kept[@]}" >"$seeded" - echo "== took Vulkan runtime markers out of $reg" + echo "== took Vulkan runtime and Ubisoft Connect markers out of $reg" fi if [ ${#had[@]} -gt 0 ] && { [ -z "$id" ] || [ "$id" != "$prev" ]; }; then declare -A held=() diff --git a/tools/tests/test_seed_redists.py b/tools/tests/test_seed_redists.py index 042ab87d4e..bc71403f8b 100644 --- a/tools/tests/test_seed_redists.py +++ b/tools/tests/test_seed_redists.py @@ -45,6 +45,26 @@ VULKAN_SCRIPT = r'''"InstallScript" ''' +UBISOFT_SCRIPT = r'''"installscript" +{ + "Run Process" + { + "Ubisoft Connect PC Client" + { + "process 1" "%INSTALLDIR%\\UbisoftConnectInstaller.exe" + "command 1" "/S" + } + "easyanticheat" + { + "HasRunKey" "HKEY_CURRENT_USER\\SOFTWARE\\Ubisoft\\WatchDogs2EAC" + "process 1" "%INSTALLDIR%\\EasyAntiCheat\\InstallWD2EAC.cmd" + "command 1" "" + } + } +} +''' + + class SeedRedistsTest(unittest.TestCase): def setUp(self): self.tmp = Path(tempfile.mkdtemp()) @@ -353,5 +373,33 @@ class SeedRedistsTest(unittest.TestCase): self.assertEqual(self.reg.read_text().count('"Vulkan111080"'), 2) + def ubisoft(self): + script = self.tmp / "legacycompat/evaluatorscript_447040.vdf" + script.parent.mkdir(parents=True) + script.write_text('"evaluatorscript"\n{\n\t"appid"\t\t"447040"\n\t"1"\n' + + "\n".join("\t" + line for line in UBISOFT_SCRIPT.splitlines()) + "\n}\n") + env = dict(os.environ, DROIDDECK_LIBRARIES="", DROIDDECK_SEED_SCRIPTS=str(script)) + return subprocess.run(["bash", str(SCRIPT), str(self.steam)], env=env, capture_output=True, text=True, check=True) + + def test_the_ubisoft_connect_installer_is_left_to_run(self): + self.ubisoft() + self.assertIn('"easyanticheat"=dword:00000001', self.user.read_text()) + self.assertNotIn("Ubisoft Connect PC Client", self.reg.read_text()) + self.assertNotIn("Ubisoft Connect PC Client", (self.reg.parent / ".droiddeck-redists").read_text()) + + def test_a_ubisoft_connect_marker_an_earlier_seeding_wrote_comes_out(self): + marker = "HKEY_LOCAL_MACHINE\\\\Software\\\\Valve\\\\Steam\\\\Apps\\\\447040\tUbisoft Connect PC Client" + self.reg.write_text( + "WINE REGISTRY Version 2\n" + "\n[Software\\\\Valve\\\\Steam\\\\Apps\\\\447040] 1791729070\n" + '"Ubisoft Connect PC Client"=dword:00000001\n' + "\n[Software\\\\Wow6432Node\\\\Valve\\\\Steam\\\\Apps\\\\447040] 1791729070\n" + '"Ubisoft Connect PC Client"=dword:00000001\n') + (self.reg.parent / ".droiddeck-redists").write_text(marker + "\n") + result = self.ubisoft() + self.assertNotIn("Ubisoft Connect PC Client", self.reg.read_text()) + self.assertNotIn("Ubisoft Connect PC Client", (self.reg.parent / ".droiddeck-redists").read_text()) + self.assertIn("Ubisoft Connect markers out", result.stdout) + if __name__ == "__main__": unittest.main() From 46cd8e17776d311e81bf493f50a6ac4df5e4e02f Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 22:37:45 -0400 Subject: [PATCH 42/50] fix: Epic games get their manifest launch command Epic manifests carry a launch command next to the launch executable, which the Epic launcher passes to the game. It was read and dropped, so Caravan SandWitch never got -PCStore=EGS and quit with "started outside of any known PC store". The manifest's launch command now joins the game's arguments, including for games already installed. --- .../launcher/stores/epic/EpicClientLibrary.kt | 23 ++++++++++- app/src/main/rust/stores/JNI.md | 3 +- app/src/main/rust/stores/src/epic/launch.rs | 40 +++++++++++++++++++ app/src/main/rust/stores/src/epic/manifest.rs | 11 ++++- app/src/main/rust/stores/src/epic/service.rs | 4 ++ .../launcher/stores/epic/EpicClientTest.kt | 17 ++++++++ 6 files changed, 94 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt index 8521a90f5d..65b5b5614c 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt @@ -358,7 +358,11 @@ internal object EpicClientLibrary { write(File(manifests, "$guid.item"), item(install, tags, ownership == true).toString(2)) runCatching { egstore(install, guid) { token } }.onFailure { Log.w(TAG, "${install.appName}: .egstore not written (${it.javaClass.simpleName})") } after.put(install.appName, JSONObject().put("guid", guid).put("signature", install.signature).apply { if (ownership != null) put("ownership", ownership) }) - StoreGameSidecar.read(install.folder)?.let { StoreLaunch.refreshLauncher(install.folder, it) } + StoreGameSidecar.read(install.folder)?.let { sidecar -> + val next = runCatching { manifestArgs(install, guid) }.getOrNull()?.let { withLaunchArgs(sidecar, it) } ?: sidecar + if (next !== sidecar) next.write(install.folder) + StoreLaunch.refreshLauncher(install.folder, next) + } } for (name in before.keys().asSequence().toList()) { if (after.has(name)) continue @@ -376,6 +380,23 @@ internal object EpicClientLibrary { return changed } + private const val LAUNCH_ARGS = "launchArgs" + + private fun manifestArgs(install: Install, guid: String): List? { + val manifest = File(install.folder, ".egstore/$guid.manifest").takeIf { it.isFile } ?: return null + val args = EpicNative.inspect(manifest.readBytes(), JSONObject().put("op", "launch"))?.optJSONArray("args") ?: return null + return List(args.length()) { args.optString(it) }.filter { it.isNotEmpty() } + } + + internal fun withLaunchArgs(sidecar: StoreGameSidecar, args: List): StoreGameSidecar { + val previous = sidecar.extra[LAUNCH_ARGS]?.split('\n')?.filter { it.isNotEmpty() }.orEmpty() + val kept = sidecar.args.filterNot { it in previous } + val next = kept + args.filterNot { it in kept } + val extra = LinkedHashMap(sidecar.extra).apply { if (args.isEmpty()) remove(LAUNCH_ARGS) else put(LAUNCH_ARGS, args.joinToString("\n")) } + if (next == sidecar.args && extra == sidecar.extra) return sidecar + return sidecar.copy(args = next, extra = extra) + } + private fun ownershipToken(token: String, install: Install): Boolean? = runCatching { EpicApiClient.getCustomAttribute(token, install.namespace, install.catalogItemId, "OwnershipToken") } .getOrNull()?.trim()?.lowercase()?.let { it == "true" } diff --git a/app/src/main/rust/stores/JNI.md b/app/src/main/rust/stores/JNI.md index c5cd077443..9ea0ae8305 100644 --- a/app/src/main/rust/stores/JNI.md +++ b/app/src/main/rust/stores/JNI.md @@ -166,7 +166,8 @@ synchronous on the calling thread (network calls block: call them off the main t `cloud.read` (`url`) → the file. `null` = failed. `nativeSend` op: `cloud.write` (`url`) with the body → `{"ok": true}` or an error. `nativeInspect` parses manifest bytes: `{"op":"summary"}` → `buildVersion`, `launchExe`, `prereqName`, `prereqPath`, `prereqRead`, `files[]` (`path`, `size`, -`tags`); `{"op":"select","tags":[…]}` → `indices[]` of the files an install with those tags gets. +`tags`); `{"op":"select","tags":[…]}` → `indices[]` of the files an install with those tags gets; +`{"op":"launch"}` → the manifest's `command` line and its `args[]`. ### `nativeInstall` diff --git a/app/src/main/rust/stores/src/epic/launch.rs b/app/src/main/rust/stores/src/epic/launch.rs index 481e9b8255..d2afe582a2 100644 --- a/app/src/main/rust/stores/src/epic/launch.rs +++ b/app/src/main/rust/stores/src/epic/launch.rs @@ -39,10 +39,50 @@ pub fn arguments(d: &LaunchData) -> Vec { args } +pub fn split_command(command: &str) -> Vec { + let mut args = Vec::new(); + let mut current = String::new(); + let mut quoted = false; + let mut started = false; + for c in command.chars().map(|c| if c == '\t' { ' ' } else { c }).filter(|&c| c >= ' ' && c != '\u{7f}') { + match c { + '"' => { + quoted = !quoted; + started = true; + } + ' ' if !quoted => { + if started { + args.push(std::mem::take(&mut current)); + started = false; + } + } + _ => { + current.push(c); + started = true; + } + } + } + if started { + args.push(current); + } + args.retain(|a| !a.is_empty()); + args +} + #[cfg(test)] mod tests { use super::*; + #[test] + fn launch_command_splits_like_a_command_line() { + assert_eq!(split_command("-PCStore=EGS"), vec!["-PCStore=EGS"]); + assert_eq!( + split_command(" -a\t-b=\"c d\" \"-e f\" \"\" -g\r\n"), + vec!["-a", "-b=c d", "-e f", "-g"] + ); + assert!(split_command(" ").is_empty()); + } + #[test] fn arguments_in_order() { let args = arguments(&LaunchData { diff --git a/app/src/main/rust/stores/src/epic/manifest.rs b/app/src/main/rust/stores/src/epic/manifest.rs index 2690e0f19d..98d31f3d9d 100644 --- a/app/src/main/rust/stores/src/epic/manifest.rs +++ b/app/src/main/rust/stores/src/epic/manifest.rs @@ -68,6 +68,7 @@ pub struct Manifest { pub version: i64, pub build_version: String, pub launch_exe: String, + pub launch_command: String, pub prereq_name: String, pub prereq_path: String, pub prereq_read: bool, @@ -279,6 +280,7 @@ fn parse_binary(bytes: &[u8]) -> Result { version, build_version: meta.build_version, launch_exe: meta.launch_exe, + launch_command: meta.launch_command, prereq_name: meta.prereq_name, prereq_path: meta.prereq_path, prereq_read: meta.complete, @@ -292,6 +294,7 @@ fn parse_binary(bytes: &[u8]) -> Result { struct Meta { build_version: String, launch_exe: String, + launch_command: String, prereq_name: String, prereq_path: String, complete: bool, @@ -308,7 +311,7 @@ fn read_meta(data: &[u8]) -> Meta { r.fstring()?; meta.build_version = r.fstring()?; meta.launch_exe = normalise_path(&r.fstring()?); - r.fstring()?; + meta.launch_command = r.fstring()?; let ids = r.count(4)?; for _ in 0..ids { r.fstring()?; @@ -548,6 +551,7 @@ fn parse_json(bytes: &[u8]) -> Result { version, build_version: str_field("BuildVersionString"), launch_exe: normalise_path(launch), + launch_command: str_field("LaunchCommand"), prereq_name: str_field("PrereqName"), prereq_path: normalise_path(&str_field("PrereqPath")), prereq_read: true, @@ -611,7 +615,7 @@ pub mod testing { fstring(&mut meta, "App"); fstring(&mut meta, &m.build); fstring(&mut meta, &m.exe); - fstring(&mut meta, ""); + fstring(&mut meta, "-PCStore=EGS \"-log=a b.txt\""); if let Some((name, path)) = &m.prereq { meta.extend_from_slice(&1i32.to_le_bytes()); fstring(&mut meta, "prereq-id"); @@ -763,6 +767,7 @@ mod tests { assert_eq!(m.chunk_folder(), "ChunksV4"); assert_eq!(m.build_version, "1.2.3-CL-99"); assert_eq!(m.launch_exe, "Binaries/Win64/Game.exe"); + assert_eq!(m.launch_command, "-PCStore=EGS \"-log=a b.txt\""); assert_eq!(m.prereq_name, "UE4 Prerequisites (x64)"); assert_eq!(m.prereq_path, "Engine/Extras/UE4PrereqSetup_x64.exe"); assert!(m.prereq_read); @@ -851,6 +856,7 @@ mod tests { let doc = r#"{ "ManifestFileVersion": "013000000000", "LaunchExeString": "Bin\\Game.exe", + "LaunchCommand": "-PCStore=EGS", "BuildVersionString": "++Game+Release-1.0", "PrereqName": "Redist", "PrereqPath": "Redist\\setup.exe", "ChunkHashList": { @@ -872,6 +878,7 @@ mod tests { assert_eq!(m.version, 13); assert_eq!(m.chunk_folder(), "ChunksV3"); assert_eq!(m.launch_exe, "Bin/Game.exe"); + assert_eq!(m.launch_command, "-PCStore=EGS"); assert!(m.prereq_read); assert_eq!(m.prereq_path, "Redist/setup.exe"); assert_eq!(m.chunks.len(), 2); diff --git a/app/src/main/rust/stores/src/epic/service.rs b/app/src/main/rust/stores/src/epic/service.rs index 67c1995bdf..79cd29d3fd 100644 --- a/app/src/main/rust/stores/src/epic/service.rs +++ b/app/src/main/rust/stores/src/epic/service.rs @@ -160,6 +160,7 @@ pub fn inspect(bytes: &[u8], request: &str) -> String { .map(|a| a.iter().filter_map(|t| t.as_str()).map(str::to_string).collect()); json!({ "indices": locale::select(&m.files, tags.as_deref()) }) } + "launch" => json!({ "command": m.launch_command, "args": launch::split_command(&m.launch_command) }), _ => json!({ "buildVersion": m.build_version, "launchExe": m.launch_exe, @@ -210,6 +211,9 @@ mod tests { assert_eq!(v["files"].as_array().unwrap().len(), 2); let v: Value = serde_json::from_str(&inspect(&bytes, r#"{"op":"select","tags":["English"]}"#)).unwrap(); assert_eq!(v["indices"], json!([0])); + let v: Value = serde_json::from_str(&inspect(&bytes, r#"{"op":"launch"}"#)).unwrap(); + assert_eq!(v["command"], "-PCStore=EGS \"-log=a b.txt\""); + assert_eq!(v["args"], json!(["-PCStore=EGS", "-log=a b.txt"])); let v: Value = serde_json::from_str(&inspect(b"nonsense", "{}")).unwrap(); assert!(v["error"].is_string()); } diff --git a/app/src/test/java/com/droiddeck/launcher/stores/epic/EpicClientTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/epic/EpicClientTest.kt index 720e122c19..de8a440283 100644 --- a/app/src/test/java/com/droiddeck/launcher/stores/epic/EpicClientTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/stores/epic/EpicClientTest.kt @@ -285,6 +285,23 @@ class EpicClientTest { assertTrue(EpicClient.loopback("http://localhost:5/launcher/authorized?code=1")) } + @Test fun theManifestLaunchCommandJoinsTheGameArguments() { + val store = com.droiddeck.launcher.stores.Store.EPIC + val epicArgs = listOf("-EpicPortal", "-epicapp=Fig", "-epicenv=Prod") + val installed = com.droiddeck.launcher.stores.StoreGameSidecar(store, "Fig", "Fig Game", exe = "Fig.exe", args = epicArgs) + val first = EpicClientLibrary.withLaunchArgs(installed, listOf("-PCStore=EGS")) + assertEquals(epicArgs + "-PCStore=EGS", first.args) + assertTrue(EpicClientLibrary.withLaunchArgs(first, listOf("-PCStore=EGS")) === first) + val updated = EpicClientLibrary.withLaunchArgs(first, listOf("-PCStore=EGS", "-log=a b.txt")) + assertEquals(epicArgs + listOf("-PCStore=EGS", "-log=a b.txt"), updated.args) + val dropped = EpicClientLibrary.withLaunchArgs(updated, emptyList()) + assertEquals(epicArgs, dropped.args) + assertFalse(dropped.extra.containsKey("launchArgs")) + val reinstalled = first.copy(args = epicArgs) + assertEquals(epicArgs + "-PCStore=EGS", EpicClientLibrary.withLaunchArgs(reinstalled, listOf("-PCStore=EGS")).args) + assertTrue(EpicClientLibrary.withLaunchArgs(installed, emptyList()) === installed) + } + @Test fun itemsDescribeTheInstallForTheLauncher() { val install = EpicClientLibrary.Install( "Fig", "ns1", "item1", "Fig Game", "1.0.5", "Binaries/Win64/Fig.exe", "/root/Games/Stores/Epic/Fig Game", From 8209a707f4708be78440d9a386f390bba5de5357 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 22:37:45 -0400 Subject: [PATCH 43/50] fix: Caravan SandWitch and Cyberpunk 2077 run at D3D12 feature level 12_1 Feature level 12_2 makes vkd3d-proton report mesh shaders and ray tracing that Turnip doesn't provide. Caravan SandWitch (Unreal Engine 5) then builds mesh shader pipelines without a pipeline layout and the driver crashes; Cyberpunk 2077 stops at ray tracing initialization. Only these two games get 12_1, and a value set in a game's own settings still wins. --- .../overlay/usr/local/bin/droiddeck-game-env | 12 ++++++++ tools/tests/test_game_environment.py | 28 +++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env index 75154ab6df..03707c1d70 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env @@ -120,6 +120,18 @@ def arkham_city_x87(game): return {"FEX_X87REDUCEDPRECISION": "0"}, [], "Batman: Arkham City: FEX with full x87 precision" + +@fix +def caravan_sandwitch_feature_level(game): + if "caravansandwitch.exe" in game.files or game.stem == "caravansandwitch-win64-shipping": + return {"VKD3D_FEATURE_LEVEL": "12_1"}, [], "Caravan SandWitch: D3D12 feature level 12_1 (12_2 hands it mesh shader pipelines vkd3d-proton cannot build)" + + +@fix +def cyberpunk_feature_level(game): + if game.stem in ("cyberpunk2077", "redprelauncher"): + return {"VKD3D_FEATURE_LEVEL": "12_1"}, [], "Cyberpunk 2077: D3D12 feature level 12_1" + def skip_red_launcher(command): """Cyberpunk 2077's prelauncher opens REDlauncher, a Qt WebEngine window that hands over to the game half a minute later and then stays up beside it, well over a core busy for as long as the diff --git a/tools/tests/test_game_environment.py b/tools/tests/test_game_environment.py index bbae1b3a7d..5e7cf1b56e 100644 --- a/tools/tests/test_game_environment.py +++ b/tools/tests/test_game_environment.py @@ -357,6 +357,34 @@ class GameEnvironmentTest(unittest.TestCase): (asylum / name).touch() self.assertEqual(MODULE["engine_fixes"](str(asylum / "BmLauncher.exe"), []), ({}, [], [])) + def test_caravan_sandwitch_and_cyberpunk_run_at_feature_level_12_1(self): + with tempfile.TemporaryDirectory() as tmp: + caravan = Path(tmp) / "Caravan SandWitch" + shipping = caravan / "CaravanSandWitch/Binaries/Win64" + shipping.mkdir(parents=True) + for name in ("CaravanSandWitch.exe", ".droiddeck-launch.bat"): + (caravan / name).touch() + (shipping / "CaravanSandWitch-Win64-Shipping.exe").touch() + cyberpunk = Path(tmp) / "Cyberpunk 2077" + (cyberpunk / "bin/x64").mkdir(parents=True) + for name in ("REDprelauncher.exe", "bin/x64/Cyberpunk2077.exe"): + (cyberpunk / name).touch() + games = [caravan / "CaravanSandWitch.exe", caravan / ".droiddeck-launch.bat", + shipping / "CaravanSandWitch-Win64-Shipping.exe", + cyberpunk / "REDprelauncher.exe", cyberpunk / "bin/x64/Cyberpunk2077.exe"] + for exe in games: + env, extra, notes = MODULE["engine_fixes"](str(exe), []) + self.assertEqual((env, extra), ({"VKD3D_FEATURE_LEVEL": "12_1"}, []), exe) + self.assertTrue(notes) + config = {"version": 1, "shared": {"VKD3D_FEATURE_LEVEL": "12_2"}} + self.assertEqual(MODULE["apply_config"]({}, config, "1582650", env)["VKD3D_FEATURE_LEVEL"], "12_1") + config["games"] = {"1582650": {"VKD3D_FEATURE_LEVEL": "12_2"}} + self.assertEqual(MODULE["apply_config"]({}, config, "1582650", env)["VKD3D_FEATURE_LEVEL"], "12_2") + other = Path(tmp) / "Other/Binaries/Win64" + other.mkdir(parents=True) + (other / "Other-Win64-Shipping.exe").touch() + self.assertEqual(MODULE["engine_fixes"](str(other / "Other-Win64-Shipping.exe"), []), ({}, [], [])) + def test_unity_players_keep_tso_over_the_preset(self): with tempfile.TemporaryDirectory() as tmp: def game(*names): From 42026b382f6e0ea0c022a7647ea92d7383f70098 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 23:11:17 -0400 Subject: [PATCH 44/50] fix: keep manifest launch arguments to the installed build and their own additions The manifest's arguments apply only when its build matches the installed version, only arguments the merge inserted are tracked as its own, escaped quotes split like a Windows command line, and the REDprelauncher rule needs Cyberpunk2077.exe beside it. --- .../launcher/stores/epic/EpicClientLibrary.kt | 10 +++-- app/src/main/rust/stores/JNI.md | 2 +- app/src/main/rust/stores/src/epic/launch.rs | 41 +++++++++++++------ app/src/main/rust/stores/src/epic/service.rs | 7 +++- .../launcher/stores/epic/EpicClientTest.kt | 5 +++ .../overlay/usr/local/bin/droiddeck-game-env | 5 ++- tools/tests/test_game_environment.py | 4 ++ 7 files changed, 56 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt index 65b5b5614c..4591b12e43 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt @@ -384,15 +384,19 @@ internal object EpicClientLibrary { private fun manifestArgs(install: Install, guid: String): List? { val manifest = File(install.folder, ".egstore/$guid.manifest").takeIf { it.isFile } ?: return null - val args = EpicNative.inspect(manifest.readBytes(), JSONObject().put("op", "launch"))?.optJSONArray("args") ?: return null + val launch = EpicNative.inspect(manifest.readBytes(), JSONObject().put("op", "launch")) ?: return null + val build = launch.optString("buildVersion") + if (install.version.isNotEmpty() && build.isNotEmpty() && build != install.version) return null + val args = launch.optJSONArray("args") ?: return null return List(args.length()) { args.optString(it) }.filter { it.isNotEmpty() } } internal fun withLaunchArgs(sidecar: StoreGameSidecar, args: List): StoreGameSidecar { val previous = sidecar.extra[LAUNCH_ARGS]?.split('\n')?.filter { it.isNotEmpty() }.orEmpty() val kept = sidecar.args.filterNot { it in previous } - val next = kept + args.filterNot { it in kept } - val extra = LinkedHashMap(sidecar.extra).apply { if (args.isEmpty()) remove(LAUNCH_ARGS) else put(LAUNCH_ARGS, args.joinToString("\n")) } + val added = args.filterNot { it in kept } + val next = kept + added + val extra = LinkedHashMap(sidecar.extra).apply { if (added.isEmpty()) remove(LAUNCH_ARGS) else put(LAUNCH_ARGS, added.joinToString("\n")) } if (next == sidecar.args && extra == sidecar.extra) return sidecar return sidecar.copy(args = next, extra = extra) } diff --git a/app/src/main/rust/stores/JNI.md b/app/src/main/rust/stores/JNI.md index 9ea0ae8305..b160ace3c1 100644 --- a/app/src/main/rust/stores/JNI.md +++ b/app/src/main/rust/stores/JNI.md @@ -167,7 +167,7 @@ synchronous on the calling thread (network calls block: call them off the main t body → `{"ok": true}` or an error. `nativeInspect` parses manifest bytes: `{"op":"summary"}` → `buildVersion`, `launchExe`, `prereqName`, `prereqPath`, `prereqRead`, `files[]` (`path`, `size`, `tags`); `{"op":"select","tags":[…]}` → `indices[]` of the files an install with those tags gets; -`{"op":"launch"}` → the manifest's `command` line and its `args[]`. +`{"op":"launch"}` → the manifest's `buildVersion`, its `command` line and the `args[]` split from it. ### `nativeInstall` diff --git a/app/src/main/rust/stores/src/epic/launch.rs b/app/src/main/rust/stores/src/epic/launch.rs index d2afe582a2..24e35db608 100644 --- a/app/src/main/rust/stores/src/epic/launch.rs +++ b/app/src/main/rust/stores/src/epic/launch.rs @@ -44,24 +44,37 @@ pub fn split_command(command: &str) -> Vec { let mut current = String::new(); let mut quoted = false; let mut started = false; + let mut slashes = 0usize; for c in command.chars().map(|c| if c == '\t' { ' ' } else { c }).filter(|&c| c >= ' ' && c != '\u{7f}') { - match c { - '"' => { + if c == '\\' { + slashes += 1; + started = true; + continue; + } + if c == '"' { + current.extend(std::iter::repeat('\\').take(slashes / 2)); + if slashes % 2 == 1 { + current.push('"'); + } else { quoted = !quoted; - started = true; } - ' ' if !quoted => { - if started { - args.push(std::mem::take(&mut current)); - started = false; - } - } - _ => { - current.push(c); - started = true; + slashes = 0; + started = true; + continue; + } + current.extend(std::iter::repeat('\\').take(slashes)); + slashes = 0; + if c == ' ' && !quoted { + if started { + args.push(std::mem::take(&mut current)); + started = false; } + } else { + current.push(c); + started = true; } } + current.extend(std::iter::repeat('\\').take(slashes)); if started { args.push(current); } @@ -80,6 +93,10 @@ mod tests { split_command(" -a\t-b=\"c d\" \"-e f\" \"\" -g\r\n"), vec!["-a", "-b=c d", "-e f", "-g"] ); + assert_eq!( + split_command(r#"-name="a\" b" -dir=C:\Games\ "-q=\\" -r"#), + vec![r#"-name=a" b"#, r"-dir=C:\Games\", r"-q=\", "-r"] + ); assert!(split_command(" ").is_empty()); } diff --git a/app/src/main/rust/stores/src/epic/service.rs b/app/src/main/rust/stores/src/epic/service.rs index 79cd29d3fd..7248342866 100644 --- a/app/src/main/rust/stores/src/epic/service.rs +++ b/app/src/main/rust/stores/src/epic/service.rs @@ -160,7 +160,11 @@ pub fn inspect(bytes: &[u8], request: &str) -> String { .map(|a| a.iter().filter_map(|t| t.as_str()).map(str::to_string).collect()); json!({ "indices": locale::select(&m.files, tags.as_deref()) }) } - "launch" => json!({ "command": m.launch_command, "args": launch::split_command(&m.launch_command) }), + "launch" => json!({ + "buildVersion": m.build_version, + "command": m.launch_command, + "args": launch::split_command(&m.launch_command), + }), _ => json!({ "buildVersion": m.build_version, "launchExe": m.launch_exe, @@ -212,6 +216,7 @@ mod tests { let v: Value = serde_json::from_str(&inspect(&bytes, r#"{"op":"select","tags":["English"]}"#)).unwrap(); assert_eq!(v["indices"], json!([0])); let v: Value = serde_json::from_str(&inspect(&bytes, r#"{"op":"launch"}"#)).unwrap(); + assert_eq!(v["buildVersion"], "b"); assert_eq!(v["command"], "-PCStore=EGS \"-log=a b.txt\""); assert_eq!(v["args"], json!(["-PCStore=EGS", "-log=a b.txt"])); let v: Value = serde_json::from_str(&inspect(b"nonsense", "{}")).unwrap(); diff --git a/app/src/test/java/com/droiddeck/launcher/stores/epic/EpicClientTest.kt b/app/src/test/java/com/droiddeck/launcher/stores/epic/EpicClientTest.kt index de8a440283..c0687db98c 100644 --- a/app/src/test/java/com/droiddeck/launcher/stores/epic/EpicClientTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/stores/epic/EpicClientTest.kt @@ -300,6 +300,11 @@ class EpicClientTest { val reinstalled = first.copy(args = epicArgs) assertEquals(epicArgs + "-PCStore=EGS", EpicClientLibrary.withLaunchArgs(reinstalled, listOf("-PCStore=EGS")).args) assertTrue(EpicClientLibrary.withLaunchArgs(installed, emptyList()) === installed) + val own = installed.copy(args = epicArgs + "-PCStore=EGS") + assertTrue(EpicClientLibrary.withLaunchArgs(own, listOf("-PCStore=EGS")) === own) + val ownUpdated = EpicClientLibrary.withLaunchArgs(own, listOf("-PCStore=EGS", "-log=a b.txt")) + assertEquals(epicArgs + listOf("-PCStore=EGS", "-log=a b.txt"), ownUpdated.args) + assertEquals(epicArgs + "-PCStore=EGS", EpicClientLibrary.withLaunchArgs(ownUpdated, emptyList()).args) } @Test fun itemsDescribeTheInstallForTheLauncher() { diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env index 03707c1d70..53537c072f 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env @@ -129,7 +129,10 @@ def caravan_sandwitch_feature_level(game): @fix def cyberpunk_feature_level(game): - if game.stem in ("cyberpunk2077", "redprelauncher"): + if game.stem == "cyberpunk2077" or ( + game.stem == "redprelauncher" + and os.path.isfile(os.path.join(os.path.dirname(game.exe), "bin", "x64", "Cyberpunk2077.exe")) + ): return {"VKD3D_FEATURE_LEVEL": "12_1"}, [], "Cyberpunk 2077: D3D12 feature level 12_1" def skip_red_launcher(command): diff --git a/tools/tests/test_game_environment.py b/tools/tests/test_game_environment.py index 5e7cf1b56e..13b31f7435 100644 --- a/tools/tests/test_game_environment.py +++ b/tools/tests/test_game_environment.py @@ -384,6 +384,10 @@ class GameEnvironmentTest(unittest.TestCase): other.mkdir(parents=True) (other / "Other-Win64-Shipping.exe").touch() self.assertEqual(MODULE["engine_fixes"](str(other / "Other-Win64-Shipping.exe"), []), ({}, [], [])) + witcher = Path(tmp) / "The Witcher 3" + witcher.mkdir() + (witcher / "REDprelauncher.exe").touch() + self.assertNotIn("VKD3D_FEATURE_LEVEL", MODULE["engine_fixes"](str(witcher / "REDprelauncher.exe"), [])[0]) def test_unity_players_keep_tso_over_the_preset(self): with tempfile.TemporaryDirectory() as tmp: From b0e405ebf33ae5de6a611b6bb6169f69303881fd Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Fri, 23 Oct 2026 23:30:21 -0400 Subject: [PATCH 45/50] fix: Epic client imports get the launch command, versioned installs need a matching manifest build Games the Epic client installed now carry their LaunchCommand arguments too, split by a new launch.split op. A doubled quote inside a quoted argument is one literal quote, and an install with a version ignores a manifest without the same build. --- .../launcher/stores/epic/EpicClientLibrary.kt | 13 ++++++++++--- app/src/main/rust/stores/JNI.md | 1 + app/src/main/rust/stores/src/epic/launch.rs | 7 ++++++- app/src/main/rust/stores/src/epic/service.rs | 3 +++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt index 4591b12e43..e5ea933d83 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/epic/EpicClientLibrary.kt @@ -251,7 +251,7 @@ internal object EpicClientLibrary { SessionPrefs.addedGameStoredAppId(app, oldFolder.path)?.let { SteamLiveShortcuts.remove(app, it) } changed = true } - val next = StoreGameSidecar( + val next = withLaunchArgs(StoreGameSidecar( Store.EPIC, appName, item.optString("DisplayName").ifEmpty { appName }, exe, installVersion = item.optString("AppVersionString"), installedAt = existing?.installedAt?.takeIf { it > 0 } ?: folder.lastModified(), cover = existing?.cover, hero = existing?.hero, @@ -260,7 +260,7 @@ internal object EpicClientLibrary { epic = existing?.epic ?: com.droiddeck.launcher.stores.EpicOptions(), cloud = existing?.cloud ?: true, launcher = StoreLaunch.LAUNCHER, - ) + ), commandArgs(item.optString("LaunchCommand"))) val sidecarChanged = existing?.toJson()?.toString(2) != next.toJson().toString(2) val launcher = File(folder, StoreLaunch.LAUNCHER) if (sidecarChanged || runCatching { launcher.readText() }.getOrNull() != StoreLaunch.launcherText(next)) { @@ -328,6 +328,7 @@ internal object EpicClientLibrary { .put("CatalogItemId", record.optString("itemId")) .put("InstallLocation", dir) .put("LaunchExecutable", record.optString("launchExecutable")) + .put("LaunchCommand", record.optString("launchCommand")) .put("AppVersionString", record.optString("version")) .put("SidecarDeploymentId", record.optJSONObject("sidecar")?.optString("deploymentId").orEmpty()) .put("DisplayName", title?.takeIf(String::isNotBlank) ?: dir.substringAfterLast('/')) @@ -386,11 +387,17 @@ internal object EpicClientLibrary { val manifest = File(install.folder, ".egstore/$guid.manifest").takeIf { it.isFile } ?: return null val launch = EpicNative.inspect(manifest.readBytes(), JSONObject().put("op", "launch")) ?: return null val build = launch.optString("buildVersion") - if (install.version.isNotEmpty() && build.isNotEmpty() && build != install.version) return null + if (install.version.isNotEmpty() && build != install.version) return null val args = launch.optJSONArray("args") ?: return null return List(args.length()) { args.optString(it) }.filter { it.isNotEmpty() } } + private fun commandArgs(command: String): List { + if (command.isBlank()) return emptyList() + val args = EpicNative.call("launch.split", JSONObject().put("command", command))?.optJSONArray("args") ?: return emptyList() + return List(args.length()) { args.optString(it) }.filter { it.isNotEmpty() } + } + internal fun withLaunchArgs(sidecar: StoreGameSidecar, args: List): StoreGameSidecar { val previous = sidecar.extra[LAUNCH_ARGS]?.split('\n')?.filter { it.isNotEmpty() }.orEmpty() val kept = sidecar.args.filterNot { it in previous } diff --git a/app/src/main/rust/stores/JNI.md b/app/src/main/rust/stores/JNI.md index b160ace3c1..0d2308fa27 100644 --- a/app/src/main/rust/stores/JNI.md +++ b/app/src/main/rust/stores/JNI.md @@ -160,6 +160,7 @@ synchronous on the calling thread (network calls block: call them off the main t | `cloud.list` | `accessToken`, `accountId`, `appName` | `files[]` of `name`, `modified` (ms, -1 unknown), `hash`, `readLink` | | `cloud.writeLinks` | `accessToken`, `accountId`, `appName`, `names[]` | `links`: name → write link | | `launch.args` | `displayName`, `accountId`, `namespace`, `locale`, `appName`, `deploymentId`, `additional` | `args[]` | +| `launch.split` | `command` | `args[]` | | `locale` | `language`, `region` | `key`, `tags[]`, `launchLocale` | `nativeFetch` ops: `manifest.download` (`info`, optional `cdns`) → the manifest bytes; diff --git a/app/src/main/rust/stores/src/epic/launch.rs b/app/src/main/rust/stores/src/epic/launch.rs index 24e35db608..8c5a104999 100644 --- a/app/src/main/rust/stores/src/epic/launch.rs +++ b/app/src/main/rust/stores/src/epic/launch.rs @@ -45,7 +45,8 @@ pub fn split_command(command: &str) -> Vec { let mut quoted = false; let mut started = false; let mut slashes = 0usize; - for c in command.chars().map(|c| if c == '\t' { ' ' } else { c }).filter(|&c| c >= ' ' && c != '\u{7f}') { + let mut chars = command.chars().map(|c| if c == '\t' { ' ' } else { c }).filter(|&c| c >= ' ' && c != '\u{7f}').peekable(); + while let Some(c) = chars.next() { if c == '\\' { slashes += 1; started = true; @@ -55,6 +56,9 @@ pub fn split_command(command: &str) -> Vec { current.extend(std::iter::repeat('\\').take(slashes / 2)); if slashes % 2 == 1 { current.push('"'); + } else if quoted && chars.peek() == Some(&'"') { + chars.next(); + current.push('"'); } else { quoted = !quoted; } @@ -97,6 +101,7 @@ mod tests { split_command(r#"-name="a\" b" -dir=C:\Games\ "-q=\\" -r"#), vec![r#"-name=a" b"#, r"-dir=C:\Games\", r"-q=\", "-r"] ); + assert_eq!(split_command("-name=\"a\"\" b\" -s=\"\"\""), vec!["-name=a\" b", "-s=\""]); assert!(split_command(" ").is_empty()); } diff --git a/app/src/main/rust/stores/src/epic/service.rs b/app/src/main/rust/stores/src/epic/service.rs index 7248342866..2264f6c775 100644 --- a/app/src/main/rust/stores/src/epic/service.rs +++ b/app/src/main/rust/stores/src/epic/service.rs @@ -113,6 +113,7 @@ fn dispatch(op: &str, req: &Value) -> Value { }; json!({ "args": launch::arguments(&data) }) } + "launch.split" => json!({ "args": launch::split_command(str_of(req, "command")) }), "locale" => { let key = locale::language_key(str_of(req, "language"), str_of(req, "region")); json!({ "key": key, "tags": locale::tags_for_key(key), "launchLocale": locale::launch_locale(key) }) @@ -192,6 +193,8 @@ mod tests { assert!(v["error"].is_string()); let v: Value = serde_json::from_str(&call("launch.args", r#"{"namespace":"ns","appName":"A"}"#)).unwrap(); assert_eq!(v["args"][0], "-EpicPortal"); + let v: Value = serde_json::from_str(&call("launch.split", r#"{"command":"-PCStore=EGS \"-log=a b.txt\""}"#)).unwrap(); + assert_eq!(v["args"], json!(["-PCStore=EGS", "-log=a b.txt"])); } #[test] From dd79f44b3a05b858c6801da2d69f49f3785b7b9a Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Sat, 24 Oct 2026 00:09:16 -0400 Subject: [PATCH 46/50] fix: the Steam download monitor no longer stalls the main thread on a long content log The content log was read with RandomAccessFile.readLine, one byte per read, on the main thread. A 4 MB log took about 2 s on the first poll, enough for an ANR on slower devices while a download runs. It is now read through a buffered reader with the same Latin-1 lines and offset, and the per-line regexes only run on lines that can match. --- .../launcher/session/SteamDownloadMonitor.kt | 16 ++++++++------ .../session/SteamDownloadMonitorTest.kt | 22 +++++++++++++++++++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/session/SteamDownloadMonitor.kt b/app/src/main/java/com/droiddeck/launcher/session/SteamDownloadMonitor.kt index c125e59b80..ff3602c1bd 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SteamDownloadMonitor.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SteamDownloadMonitor.kt @@ -1,7 +1,7 @@ package com.droiddeck.launcher.session import java.io.File -import java.io.RandomAccessFile +import java.io.FileInputStream internal class SteamDownloadMonitor { private data class ManifestState( @@ -63,16 +63,17 @@ internal class SteamDownloadMonitor { lastContentActivityAt = 0L } runCatching { - RandomAccessFile(log, "r").use { input -> - input.seek(contentLogOffset) + FileInputStream(log).use { input -> + input.channel.position(contentLogOffset) + val reader = input.bufferedReader(Charsets.ISO_8859_1) while (true) { - val line = input.readLine() ?: break + val line = reader.readLine() ?: break when { "Client version:" in line -> { activeContentUpdates.clear() lastContentActivityAt = 0L } - CONTENT_UPDATE.find(line)?.let { match -> + " update changed : " in line && CONTENT_UPDATE.find(line)?.let { match -> val appId = match.groupValues[1] val updateType = match.groupValues[2] val state = match.groupValues[3] @@ -85,14 +86,15 @@ internal class SteamDownloadMonitor { } true } == true -> Unit - CURRENT_RATE.find(line)?.groupValues?.get(1)?.toDoubleOrNull()?.let { it > 0.0 } == true -> + "Current download rate: " in line && + CURRENT_RATE.find(line)?.groupValues?.get(1)?.toDoubleOrNull()?.let { it > 0.0 } == true -> lastContentActivityAt = now "Downloading " in line && " chunks for depot " in line -> lastContentActivityAt = now } if (activeContentUpdates.isNotEmpty()) lastContentActivityAt = now } - contentLogOffset = input.filePointer + contentLogOffset = input.channel.position() } } return activeContentUpdates.isNotEmpty() && lastContentActivityAt > 0L && diff --git a/app/src/test/java/com/droiddeck/launcher/session/SteamDownloadMonitorTest.kt b/app/src/test/java/com/droiddeck/launcher/session/SteamDownloadMonitorTest.kt index 4da943020d..52920aefca 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/SteamDownloadMonitorTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/SteamDownloadMonitorTest.kt @@ -101,6 +101,28 @@ class SteamDownloadMonitorTest { } } + @Test fun aLongLogIsFollowedFromWhereTheLastPollStopped() { + val root = Files.createTempDirectory("droiddeck-steam-download-").toFile() + try { + val contentLog = File(root, "root/.local/share/Steam/logs/content_log.txt").apply { + check(parentFile?.mkdirs() != false) + writeText(buildString { + repeat(5_000) { append("[2026-10-06 14:40:00] Detected write gap 64 MB in file \"data_$it.dat\"\r\n") } + append("[2026-10-06 14:44:17] AppID 44 App update changed : Running Update,Downloading,\r\n") + }) + } + val monitor = SteamDownloadMonitor() + + assertTrue(monitor.poll(root, now = 1_000L)) + contentLog.appendText("[2026-10-06 14:45:03] AppID 44 App update changed : None\r\n") + assertFalse(monitor.poll(root, now = 2_000L)) + contentLog.appendText("[2026-10-06 14:46:00] AppID 45 App update changed : Running Update,Downloading,\r\n") + assertTrue(monitor.poll(root, now = 3_000L)) + } finally { + root.deleteRecursively() + } + } + @Test fun theOtherClientsLogIsReadFromItsStart() { val root = Files.createTempDirectory("droiddeck-steam-download-").toFile() try { From f89dc0407231a3144b7d207d5276b7eae74bcc27 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Sat, 24 Oct 2026 00:26:47 -0400 Subject: [PATCH 47/50] fix: Proton's EasyAntiCheat and BattlEye runtimes are not listed as games Steam installs Proton EasyAntiCheat Runtime (1826330) and Proton BattlEye Runtime (1161040) as tool depots. The launcher's Games tab and the desktop's game entries now skip them like the other runtimes. --- app/src/main/java/com/droiddeck/launcher/frontend/Library.kt | 2 ++ tools/linuxfs/overlay/usr/local/bin/droiddeck-desktop-games | 2 +- tools/tests/test_steam_libraries.py | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt b/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt index 91691cb1e7..e3fa25ac59 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/Library.kt @@ -46,12 +46,14 @@ object Library { 1054830, 1070560, 1113280, + 1161040, 1245040, 1391110, 1420170, 1493710, 1580130, 1628350, + 1826330, 1887720, 2180100, 228980, diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-desktop-games b/tools/linuxfs/overlay/usr/local/bin/droiddeck-desktop-games index d86d10b6cc..fe1cf0d971 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-desktop-games +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-desktop-games @@ -8,7 +8,7 @@ X64 = os.environ.get("BL_STEAM_CLIENT_ARCH") == "x86_64" CLIENT_HOME = (os.environ.get("BL_X64_HOME") or os.path.join(HOME, ".droiddeck-x64")) if X64 else HOME STEAM_ROOT = sys.argv[1] if len(sys.argv) > 1 else os.path.join(CLIENT_HOME, ".local/share/Steam") LIBRARIES = ((STEAM_ROOT, "Steam Games"), ("/mnt/droiddeck-sd/x86-64" if X64 else "/mnt/droiddeck-sd", "SD Games")) -NOT_GAMES = {228980, 1070560, 1391110, 1493710, 1628350, 3127680, 4183110, 4185400, 4427310, 4628740} +NOT_GAMES = {228980, 1070560, 1161040, 1391110, 1493710, 1628350, 1826330, 3127680, 4183110, 4185400, 4427310, 4628740} APPS_DIR = os.path.join(HOME, ".local/share/applications") PREFIX = "droiddeck-game-" NAME = re.compile(r'^\s*"name"\s*"([^"]*)"', re.M) diff --git a/tools/tests/test_steam_libraries.py b/tools/tests/test_steam_libraries.py index 4f416a8401..95ae20c24a 100644 --- a/tools/tests/test_steam_libraries.py +++ b/tools/tests/test_steam_libraries.py @@ -153,6 +153,8 @@ class DesktopGamesTest(unittest.TestCase): steam = root / "Steam" manifest(steam / "steamapps", 40, name="Game") manifest(steam / "steamapps", 1628350, name="Steam Linux Runtime 3.0 (sniper)", installdir="SteamLinuxRuntime_sniper") + manifest(steam / "steamapps", 1826330, name="Proton EasyAntiCheat Runtime", installdir="Proton EasyAntiCheat Runtime") + manifest(steam / "steamapps", 1161040, name="Proton BattlEye Runtime", installdir="Proton BattlEye Runtime") manifest(steam / "steamapps", 5000, name="Some Proton", installdir="Some Proton") (steam / "steamapps/common/Some Proton").mkdir(parents=True) (steam / "steamapps/common/Some Proton/toolmanifest.vdf").write_text('"manifest"\n{\n}\n') From 473ac666b3ef461b5be0f0dc608a3f1052045b67 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Sat, 24 Oct 2026 00:46:59 -0400 Subject: [PATCH 48/50] Take over Steam's Default startup movie pick --- .../droiddeck/launcher/session/BootMovie.kt | 12 ++++---- .../launcher/session/BootMovieLibrary.kt | 16 +++++++---- .../launcher/session/SessionFiles.kt | 6 ++-- .../launcher/session/BootMovieLibraryTest.kt | 28 +++++++++++++++++-- 4 files changed, 46 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/session/BootMovie.kt b/app/src/main/java/com/droiddeck/launcher/session/BootMovie.kt index 8267edd57a..953196900c 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/BootMovie.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/BootMovie.kt @@ -51,7 +51,7 @@ object BootMovie { SessionPrefs.setBootMovieApplyNext(context, true) BootMovieReport.note(context, "picked $id here; Steam names ${SessionFiles.startupMoviePath(BootMovieLibrary.steamConfig(context))}") // Whatever Steam names right now is about to be replaced, so it is not a pick to adopt later. - SessionFiles.startupMoviePath(BootMovieLibrary.steamConfig(context))?.let { SessionPrefs.setBootMovieSteamSeen(context, it) } + SessionFiles.startupMovieLocalPath(BootMovieLibrary.steamConfig(context))?.let { SessionPrefs.setBootMovieSteamSeen(context, it) } } fun customName(context: Context): String? = @@ -167,10 +167,12 @@ object BootMovie { * that movie becomes the choice here. Steam already plays it, so nothing is staged over it. True when the choice changed. */ fun syncFromSteam(context: Context): Boolean { - val path = SessionFiles.startupMoviePath(BootMovieLibrary.steamConfig(context)) ?: return false - if (path == SessionPrefs.bootMovieSteamSeen(context)) return false - SessionPrefs.setBootMovieSteamSeen(context, path) - if (path == SessionFiles.BOOT_MOVIE_PATH) return false + val named = SessionFiles.startupMovieLocalPath(BootMovieLibrary.steamConfig(context)) ?: return false + val seen = SessionPrefs.bootMovieSteamSeen(context) + if (named == seen) return false + SessionPrefs.setBootMovieSteamSeen(context, named) + if (named == SessionFiles.BOOT_MOVIE_PATH || (named.isEmpty() && seen == null)) return false + val path = named.ifEmpty { "/movies/steam_os_startup.webm" } val prefix = "/uioverrides/movies/" // The list names a bought movie from the Steam folder (/config/communityitemscache/...), Steam's config from its config folder. val id = if (path.startsWith(prefix)) BootMovieLibrary.idOf(path.removePrefix(prefix)) else { diff --git a/app/src/main/java/com/droiddeck/launcher/session/BootMovieLibrary.kt b/app/src/main/java/com/droiddeck/launcher/session/BootMovieLibrary.kt index 7c125e8196..0dd7a0fadf 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/BootMovieLibrary.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/BootMovieLibrary.kt @@ -79,8 +79,9 @@ object BootMovieLibrary { return customMovieDirs(context).map { File(it, name) }.firstOrNull { it.isFile && it.length() > 0L } } - private fun isMovie(file: File) = file.isFile && file.length() > 0L && file.name.endsWith(".webm", ignoreCase = true) && - file.name !in STAGED && !file.name.startsWith(".") + private fun isMovie(file: File) = isWebm(file) && file.name !in STAGED + + private fun isWebm(file: File) = file.isFile && file.length() > 0L && file.name.endsWith(".webm", ignoreCase = true) && !file.name.startsWith(".") private fun readMeta(context: Context): JSONObject = runCatching { JSONObject(metaFile(context).readText()) }.getOrDefault(JSONObject()) @@ -136,7 +137,7 @@ object BootMovieLibrary { } val bought = HashMap() for (root in steamRoots(context)) { - File(root, "steamui/movies").listFiles { f -> isMovie(f) && f.nameWithoutExtension.lowercase() in NATIVE }.orEmpty() + File(root, "steamui/movies").listFiles { f -> isWebm(f) && f.nameWithoutExtension.lowercase() in NATIVE }.orEmpty() .sortedBy { it.name.lowercase() }.forEach { steam.putIfAbsent(STEAM_PREFIX + "/movies/" + it.name, it) } val scan = pointShopMovies(root) bought.putAll(scan.titles) @@ -144,8 +145,8 @@ object BootMovieLibrary { } val seen = HashSet() for ((id, file) in steam) { - if (file.name in STAGED || !seen.add(file.canonicalPath)) continue val native = file.nameWithoutExtension.lowercase() in NATIVE + if ((file.name in STAGED && !native) || !seen.add(file.canonicalPath)) continue // Steam names a bought movie by an item number and a hash; the points shop's own title is shown when Steam has it. val title = if (native) NATIVE[file.nameWithoutExtension.lowercase()] ?: file.nameWithoutExtension else bought[file.path] ?: boughtId(file)?.let { "#$it" } ?: file.nameWithoutExtension out.add(Entry(id, title, if (native) SOURCE_STEAM else SOURCE_POINTSHOP, file, removable = false)) @@ -153,8 +154,11 @@ object BootMovieLibrary { return out } - /** The three startup movies Steam ships with; Steam's movies folder holds many more videos that are not startup movies. */ - private val NATIVE = mapOf("deck_startup" to "Deck startup", "oled_startup" to "Oled startup", "startup_machine" to "Machine startup") + /** The four startup movies Steam ships with; Steam's movies folder holds many more videos that are not startup movies. */ + private val NATIVE = mapOf( + "deck_startup" to "Deck startup", "oled_startup" to "Oled startup", "startup_machine" to "Machine startup", + "steam_os_startup" to "SteamOS startup", + ) private val skippedFolders = setOf("uioverrides", "steamapps", "librarycache", "httpcache", "logs", "compatdata", "shadercache") diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt index 4824a44424..8cd846513d 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt @@ -390,10 +390,12 @@ object SessionFiles { private fun activeStartupMovie(text: String): VdfBlock? = customizationMovie(text) ?: olderMovie(text) /** The movie Steam's config selects, as a path like `/uioverrides/movies/x.webm`; null when none is named. */ - internal fun startupMoviePath(config: File): String? { + internal fun startupMoviePath(config: File): String? = startupMovieLocalPath(config)?.takeIf { it.isNotEmpty() } + + internal fun startupMovieLocalPath(config: File): String? { val text = runCatching { config.readText() }.getOrNull() ?: return null val movie = activeStartupMovie(text) ?: return null - return scalar(text.substring(movie.keyStart, movie.close + 1), "LocalPath")?.takeIf { it.isNotEmpty() } + return scalar(text.substring(movie.keyStart, movie.close + 1), "LocalPath") } /** Both `StartupMovie` sections of Steam's config as written there, for the report; null when there is none. */ diff --git a/app/src/test/java/com/droiddeck/launcher/session/BootMovieLibraryTest.kt b/app/src/test/java/com/droiddeck/launcher/session/BootMovieLibraryTest.kt index ca68f58678..2c1d90ca0c 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/BootMovieLibraryTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/BootMovieLibraryTest.kt @@ -178,17 +178,39 @@ class BootMovieLibraryTest { assertNull(SessionFiles.startupMoviePath(BootMovieLibrary.steamConfig(app))) } - @Test fun onlyTheThreeStartupMoviesOfSteamAreListed() { - listOf("deck_startup", "oled_startup", "startup_machine", "controller_generic_thumbstick_move").forEach { + @Test fun onlyTheStartupMoviesOfSteamAreListed() { + listOf("deck_startup", "oled_startup", "startup_machine", "steam_os_startup", "controller_generic_thumbstick_move").forEach { File(BootMovieLibrary.steamRoot(app), "steamui/movies/$it.webm").also { f -> f.parentFile!!.mkdirs(); f.writeText("movie") } } val ids = BootMovieLibrary.list(app).map { it.id }.filter { it.startsWith("steam:") } assertEquals( - listOf("steam:/movies/deck_startup.webm", "steam:/movies/oled_startup.webm", "steam:/movies/startup_machine.webm"), + listOf( + "steam:/movies/deck_startup.webm", "steam:/movies/oled_startup.webm", "steam:/movies/startup_machine.webm", + "steam:/movies/steam_os_startup.webm", + ), ids.sorted(), ) } + @Test fun steamsDefaultPickIsTakenOverAsItsOwnStartupMovie() { + val native = File(BootMovieLibrary.steamRoot(app), "steamui/movies/steam_os_startup.webm").also { it.parentFile!!.mkdirs(); it.writeText("movie") } + movie("a.webm") + steamPicksAt(SessionFiles.BOOT_MOVIE_PATH) + BootMovie.select(app, "file:a.webm") + steamPicksAt("") + assertTrue(BootMovie.syncFromSteam(app)) + assertEquals("steam:/movies/steam_os_startup.webm", BootMovie.choice(app)) + assertEquals(native, BootMovie.currentFile(app)) + assertFalse(BootMovie.syncFromSteam(app)) + } + + @Test fun anEmptySteamPickThatWasNeverSeenChangesNothing() { + File(BootMovieLibrary.steamRoot(app), "steamui/movies/steam_os_startup.webm").also { it.parentFile!!.mkdirs(); it.writeText("movie") } + steamPicksAt("") + assertFalse(BootMovie.syncFromSteam(app)) + assertEquals(BootMovie.DROIDDECK_30, BootMovie.choice(app)) + } + @Test fun aMovieBoughtInThePointsShopIsListedAndAdopted() { val file = File(BootMovieLibrary.steamRoot(app), "appcache/startupmovies/Bought.webm").also { it.parentFile!!.mkdirs(); it.writeText("movie") } val entry = BootMovieLibrary.list(app).first { it.id == "steam:/appcache/startupmovies/Bought.webm" } From 8c86b718a0694d5f562d06627d3355e15dc64637 Mon Sep 17 00:00:00 2001 From: Nikolay Nadorichev Date: Fri, 23 Oct 2026 15:59:59 +0300 Subject: [PATCH 49/50] fix: find the signed-in Steam account when loginusers.vdf has no MostRecent droiddeck-steam-shortcuts and AddedGames.accountConfig took the account marked "MostRecent" in loginusers.vdf, else the only userdata folder. The arm64 client here writes no MostRecent, so with two accounts in one install nothing was picked: no added or store game reached shortcuts.vdf ("no signed-in account yet; nothing written") and Steam answered their launch with "App configuration unavailable". Without MostRecent, take the account marked AutoLogin, then the one with the latest timestamp. Both sides use the same order so the app reads the config the guest script writes. --- .../droiddeck/launcher/frontend/AddedGames.kt | 13 ++++-- .../frontend/AddedGamesAccountTest.kt | 43 +++++++++++++++++++ .../usr/local/bin/droiddeck-steam-shortcuts | 13 ++++-- tools/tests/test_steam_shortcuts.py | 24 +++++++++++ 4 files changed, 86 insertions(+), 7 deletions(-) create mode 100644 app/src/test/java/com/droiddeck/launcher/frontend/AddedGamesAccountTest.kt diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt index 2a83d57e5b..93ddf80ed1 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt @@ -387,11 +387,18 @@ object AddedGames { } } + private class LoginUser(val id: String, val mostRecent: Boolean, val autoLogin: Boolean, val timestamp: Long) + + /** The signed-in account's config, chosen as droiddeck-steam-shortcuts chooses it: MostRecent, else AutoLogin, else the latest timestamp. */ internal fun accountConfig(root: File): File? { val users = runCatching { File(root, "config/loginusers.vdf").readText() }.getOrDefault("") - val recent = Regex(""""(\d{5,})"\s*\{([^}]*)\}""").findAll(users) - .lastOrNull { Regex(""""MostRecent"\s*"1"""").containsMatchIn(it.groupValues[2]) } - val account = recent?.groupValues?.get(1)?.toLongOrNull()?.let { (it - 76561197960265728L).toString() } + val recent = Regex(""""(\d{5,})"\s*\{([^}]*)\}""").findAll(users).map { + val body = it.groupValues[2] + LoginUser(it.groupValues[1], Regex(""""MostRecent"\s*"1"""").containsMatchIn(body), Regex(""""AutoLogin"\s*"1"""").containsMatchIn(body), + Regex(""""timestamp"\s*"(\d+)"""").find(body)?.groupValues?.get(1)?.toLongOrNull() ?: 0L) + }.filter { it.mostRecent || it.autoLogin || it.timestamp > 0 }.toList().asReversed() + .maxWithOrNull(compareBy({ it.mostRecent }, { it.autoLogin }, { it.timestamp })) + val account = recent?.id?.toLongOrNull()?.let { (it - 76561197960265728L).toString() } ?: File(root, "userdata").list()?.filter { it.isNotEmpty() && it.all(Char::isDigit) && it != "0" }?.singleOrNull() return account?.let { File(root, "userdata/$it/config") } } diff --git a/app/src/test/java/com/droiddeck/launcher/frontend/AddedGamesAccountTest.kt b/app/src/test/java/com/droiddeck/launcher/frontend/AddedGamesAccountTest.kt new file mode 100644 index 0000000000..610f00bb4e --- /dev/null +++ b/app/src/test/java/com/droiddeck/launcher/frontend/AddedGamesAccountTest.kt @@ -0,0 +1,43 @@ +package com.droiddeck.launcher.frontend + +import java.io.File +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull +import org.junit.Rule +import org.junit.Test +import org.junit.rules.TemporaryFolder + +class AddedGamesAccountTest { + @get:Rule val tmp = TemporaryFolder() + + private fun steamRoot(vararg blocks: Pair>): File = tmp.newFolder("Steam").also { root -> + File(root, "config").mkdirs() + File(root, "userdata/123/config").mkdirs() + File(root, "userdata/456/config").mkdirs() + val body = blocks.joinToString("") { (account, keys) -> + "\t\"${76561197960265728L + account}\"\n\t{\n" + keys.entries.joinToString("") { "\t\t\"${it.key}\"\t\t\"${it.value}\"\n" } + "\t}\n" + } + File(root, "config/loginusers.vdf").writeText("\"users\"\n{\n$body}\n") + } + + @Test fun theAccountMarkedMostRecentIsUsed() { + val root = steamRoot(123L to mapOf("MostRecent" to "1", "AutoLogin" to "0", "timestamp" to "100"), + 456L to mapOf("MostRecent" to "0", "AutoLogin" to "1", "timestamp" to "200")) + assertEquals(File(root, "userdata/123/config"), AddedGames.accountConfig(root)) + } + + @Test fun withoutMostRecentTheAccountThatSignsInIsUsed() { + val root = steamRoot(123L to mapOf("AutoLogin" to "1", "timestamp" to "100"), 456L to mapOf("AutoLogin" to "0", "timestamp" to "200")) + assertEquals(File(root, "userdata/123/config"), AddedGames.accountConfig(root)) + } + + @Test fun withoutEitherMarkTheAccountUsedLastIsUsed() { + val root = steamRoot(456L to mapOf("AutoLogin" to "0", "timestamp" to "100"), 123L to mapOf("AutoLogin" to "0", "timestamp" to "200")) + assertEquals(File(root, "userdata/123/config"), AddedGames.accountConfig(root)) + } + + @Test fun twoAccountsWithoutAnyMarkGiveNoAccount() { + val root = steamRoot(123L to mapOf("AccountName" to "a"), 456L to mapOf("AccountName" to "b")) + assertNull(AddedGames.accountConfig(root)) + } +} diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-shortcuts b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-shortcuts index 3764e4a92c..68cf8f775b 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-shortcuts +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-shortcuts @@ -16,15 +16,20 @@ TAG = "droiddeck-app" def account_dir(steam_root): - """The most recent account's userdata folder, else the only one that is not 0.""" + """The signed-in account's userdata folder, else the only one that is not 0. Clients that do not + write MostRecent still mark that account AutoLogin; the latest timestamp breaks the remaining ties.""" users = os.path.join(steam_root, "config", "loginusers.vdf") - recent = None + recent, best = None, None try: with open(users, encoding="utf-8", errors="replace") as f: text = f.read() for block in re.finditer(r'"(\d{5,})"\s*\{([^}]*)\}', text): - if re.search(r'"MostRecent"\s*"1"', block.group(2)): - recent = int(block.group(1)) + stamp = re.search(r'"timestamp"\s*"(\d+)"', block.group(2)) + rank = (bool(re.search(r'"MostRecent"\s*"1"', block.group(2))), + bool(re.search(r'"AutoLogin"\s*"1"', block.group(2))), + int(stamp.group(1)) if stamp else 0) + if any(rank) and (best is None or rank >= best): + recent, best = int(block.group(1)), rank except OSError: pass userdata = os.path.join(steam_root, "userdata") diff --git a/tools/tests/test_steam_shortcuts.py b/tools/tests/test_steam_shortcuts.py index 60a2998a60..a927d4db07 100644 --- a/tools/tests/test_steam_shortcuts.py +++ b/tools/tests/test_steam_shortcuts.py @@ -203,6 +203,30 @@ class ShortcutsTest(unittest.TestCase): self.assertEqual('-vulkan', steam['LaunchOptions']) self.assertEqual('Mine', steam['AppName']) + def users(self, *blocks): + body = ''.join('\t"%d"\n\t{\n%s\t}\n' % (76561197960265728 + acct, ''.join('\t\t"%s"\t\t"%s"\n' % kv for kv in keys.items())) + for acct, keys in blocks) + (self.steam / 'config').mkdir(exist_ok=True) + (self.steam / 'config/loginusers.vdf').write_text('"users"\n{\n%s}\n' % body) + (self.steam / 'userdata/456/config').mkdir(parents=True, exist_ok=True) + + def test_the_account_marked_most_recent_is_used(self): + self.users((123, dict(MostRecent='1', AutoLogin='0', timestamp='100')), (456, dict(MostRecent='0', AutoLogin='1', timestamp='200'))) + self.assertEqual(str(self.steam / 'userdata/123'), shortcuts.account_dir(str(self.steam))) + + def test_without_most_recent_the_account_that_signs_in_is_used(self): + self.users((123, dict(AutoLogin='1', timestamp='100')), (456, dict(AutoLogin='0', timestamp='200'))) + self.assertEqual(str(self.steam / 'userdata/123'), shortcuts.account_dir(str(self.steam))) + self.assertIn(APPID, self.run_writer(self.game())) + + def test_without_either_mark_the_account_used_last_is_used(self): + self.users((456, dict(AutoLogin='0', timestamp='100')), (123, dict(AutoLogin='0', timestamp='200'))) + self.assertEqual(str(self.steam / 'userdata/123'), shortcuts.account_dir(str(self.steam))) + + def test_two_accounts_without_any_mark_write_nothing(self): + self.users((123, dict(AccountName='a')), (456, dict(AccountName='b'))) + self.assertIsNone(shortcuts.account_dir(str(self.steam))) + def test_an_older_record_without_launch_options_still_takes_the_apps(self): self.run_writer(self.game()) record = self.record() From 476642be7168a1c9e872b8644231c68b52b1d100 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Sat, 24 Oct 2026 00:11:55 -0400 Subject: [PATCH 50/50] chore: drop the added comments --- .../main/java/com/droiddeck/launcher/frontend/AddedGames.kt | 1 - tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-shortcuts | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt index 93ddf80ed1..340bc83ce0 100644 --- a/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt +++ b/app/src/main/java/com/droiddeck/launcher/frontend/AddedGames.kt @@ -389,7 +389,6 @@ object AddedGames { private class LoginUser(val id: String, val mostRecent: Boolean, val autoLogin: Boolean, val timestamp: Long) - /** The signed-in account's config, chosen as droiddeck-steam-shortcuts chooses it: MostRecent, else AutoLogin, else the latest timestamp. */ internal fun accountConfig(root: File): File? { val users = runCatching { File(root, "config/loginusers.vdf").readText() }.getOrDefault("") val recent = Regex(""""(\d{5,})"\s*\{([^}]*)\}""").findAll(users).map { diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-shortcuts b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-shortcuts index 68cf8f775b..0910cf6faf 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-shortcuts +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-shortcuts @@ -16,8 +16,7 @@ TAG = "droiddeck-app" def account_dir(steam_root): - """The signed-in account's userdata folder, else the only one that is not 0. Clients that do not - write MostRecent still mark that account AutoLogin; the latest timestamp breaks the remaining ties.""" + """The most recent account's userdata folder, else the only one that is not 0.""" users = os.path.join(steam_root, "config", "loginusers.vdf") recent, best = None, None try: