mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 21:15:43 +00:00
Merge remote-tracking branch 'origin/main' into android-apps-in-steam
This commit is contained in:
commit
936df2ed3e
4 files changed
+121
-3
No files matched your search
+2
-1
@@ -14,7 +14,8 @@ after restarting. If no complete copy exists, the pack uses the checkout's pin.
|
||||
- `tools/agent/dd-lab-build` builds the checkout with Gradle on the device (`processReleaseResources`
|
||||
and `mergeDexRelease`), packs the linked resources and dex files into `overlay.apk`, writes
|
||||
`overlay.json`, and stages both in the app's `files/lab/next`. It then recompiles the app without
|
||||
an app image and restarts DroidDeck.
|
||||
an app image and restarts DroidDeck. The resource linker uses IDs from the installed APK so
|
||||
base and overlay code resolve the same resource names.
|
||||
- Run by the app's own agent (`DD_AGENT` set), it writes `files/agent/lab-request` instead, and the
|
||||
app runs the build in a process of its own, logging to `~/.cache/dd-lab-build.log`; the agent's
|
||||
copy follows that log and exits with the build. A turn's processes end with the turn, so a build
|
||||
|
||||
@@ -134,6 +134,54 @@ fi
|
||||
gradle=(./gradlew :app:processReleaseResources :app:mergeDexRelease --max-workers=2 -PskipRust=true -x buildVkBridgeServer
|
||||
-Pandroid.aapt2FromMavenOverride=$HOME/aapt2/aapt2 -Pkotlin.compiler.execution.strategy=daemon
|
||||
-Pkotlin.daemon.jvmargs=-Xmx${kotlin_heap}m -Dorg.gradle.jvmargs=-Xmx${gradle_heap}m --console=plain)
|
||||
# Release package aliases rewrite the manifest but keep the resource table under the linker package.
|
||||
resource_package=com.droiddeck.launcher
|
||||
resource_cache=$cache/dd-lab-resource-ids
|
||||
mkdir -p "$resource_cache"
|
||||
resource_key=$(printf '%s\n' "$pkg" "$base" "$apk" | sha256sum | cut -d ' ' -f1)
|
||||
stable_ids=$resource_cache/$resource_key.txt
|
||||
if [ ! -s "$stable_ids" ]; then
|
||||
progress checking 0 "reading the installed APK resource IDs"
|
||||
if ! (
|
||||
resource_work=$(mktemp -d "$resource_cache/.extract.XXXXXX") || exit 1
|
||||
trap 'rm -rf "$resource_work"' EXIT
|
||||
adb -s "$serial" pull "$apk" "$resource_work/base.apk" >/dev/null &&
|
||||
"$HOME/aapt2/aapt2" dump resources "$resource_work/base.apk" > "$resource_work/resources.txt" &&
|
||||
awk -v package="$resource_package" '
|
||||
$1 == "Package" { in_package = ($2 == "name=" package) }
|
||||
in_package && $1 == "resource" && $2 ~ /^0x[[:xdigit:]]+$/ {
|
||||
print package ":" $3 " = " $2
|
||||
count++
|
||||
}
|
||||
END { if (!count) exit 1 }
|
||||
' "$resource_work/resources.txt" > "$resource_work/ids.txt" &&
|
||||
mv "$resource_work/ids.txt" "$stable_ids"
|
||||
); then
|
||||
fail "could not read resource IDs from the installed APK"
|
||||
fi
|
||||
fi
|
||||
|
||||
resource_init=$resource_cache/link.gradle
|
||||
cat > "$resource_init.part.$$" <<'EOF'
|
||||
gradle.beforeProject { project ->
|
||||
if (project.path == ':app') {
|
||||
project.pluginManager.withPlugin('com.android.application') {
|
||||
project.androidComponents.finalizeDsl { android ->
|
||||
android.androidResources.additionalParameters.addAll([
|
||||
'--stable-ids', project.providers.gradleProperty('droiddeckLabStableIds').get()
|
||||
])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
if cmp -s "$resource_init.part.$$" "$resource_init"; then
|
||||
rm "$resource_init.part.$$"
|
||||
else
|
||||
mv "$resource_init.part.$$" "$resource_init"
|
||||
fi
|
||||
gradle+=(--init-script "$resource_init" "-PdroiddeckLabStableIds=$stable_ids")
|
||||
|
||||
progress planning
|
||||
plan_file=$cache/dd-lab-build-plan
|
||||
plan_key=$(
|
||||
|
||||
@@ -1658,6 +1658,16 @@ def system_graphics_launch(command, env):
|
||||
return [str(wrapper), *command], result
|
||||
|
||||
|
||||
AUDIO_STREAMS_PROBE = (
|
||||
'folder=$1; launch=$2; shift 2; n=0; '
|
||||
'for t in "$@"; do '
|
||||
'while [ "$n" -lt "$t" ]; do kill -0 "$launch" 2>/dev/null || exit 0; sleep 1; n=$((n + 1)); done; '
|
||||
'kill -0 "$launch" 2>/dev/null || exit 0; '
|
||||
'{ echo "== $(date +%T)"; pactl list sink-inputs 2>&1 | head -80; } >> "$folder/audio-streams.txt"; '
|
||||
'done'
|
||||
)
|
||||
|
||||
|
||||
def game_logs(command, env, app_id, now=None):
|
||||
"""Detailed graphics logs for one game launch, in the session's log folder: Proton's own log,
|
||||
DXVK's and vkd3d-proton's, and the Vulkan driver's startup messages. The app turns this on
|
||||
@@ -1703,8 +1713,7 @@ def game_logs(command, env, app_id, now=None):
|
||||
pass
|
||||
# Whether the game's sound reaches PulseAudio: the streams 20 s and 60 s in, without waiting.
|
||||
try:
|
||||
subprocess.Popen(["sh", "-c", 'for t in 20 40; do sleep $t; { echo "== $(date +%T)"; '
|
||||
'pactl list sink-inputs 2>&1 | head -80; } >> "$1/audio-streams.txt"; done', "audio", str(folder)],
|
||||
subprocess.Popen(["sh", "-c", AUDIO_STREAMS_PROBE, "audio", str(folder), str(os.getpid()), "20", "60"],
|
||||
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
start_new_session=True)
|
||||
except OSError:
|
||||
|
||||
@@ -13,6 +13,7 @@ import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
from unittest import mock
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
@@ -2499,6 +2500,65 @@ class GameEnvironmentTest(unittest.TestCase):
|
||||
self.assertIn("exe: first.exe", (Path(first["PROTON_LOG_DIR"]) / "launch.txt").read_text())
|
||||
self.assertIn("exe: second.exe", (Path(second["PROTON_LOG_DIR"]) / "launch.txt").read_text())
|
||||
|
||||
def test_audio_probe_watches_this_launch(self):
|
||||
with tempfile.TemporaryDirectory() as tmp, mock.patch("subprocess.Popen") as popen:
|
||||
env = {"DD_GAME_LOGS": "1", "DD_DEBUG_DIR": tmp}
|
||||
result = MODULE["game_logs"](["/proton", "waitforexitandrun", "game.exe"], env, "42", now=0)
|
||||
self.assertEqual(popen.call_args.args[0], [
|
||||
"sh", "-c", MODULE["AUDIO_STREAMS_PROBE"], "audio", result["PROTON_LOG_DIR"], str(os.getpid()), "20", "60",
|
||||
])
|
||||
|
||||
def test_audio_probe_ends_with_the_game_and_keeps_its_samples_while_it_runs(self):
|
||||
probe = ["sh", "-c", MODULE["AUDIO_STREAMS_PROBE"], "audio"]
|
||||
|
||||
def samples(folder):
|
||||
path = Path(folder) / "audio-streams.txt"
|
||||
return sum(line.startswith("== ") for line in path.read_text().splitlines()) if path.exists() else 0
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
game = subprocess.Popen(["sleep", "60"])
|
||||
try:
|
||||
subprocess.run(probe + [tmp, str(game.pid), "1", "2"], timeout=15, check=True)
|
||||
self.assertEqual(samples(tmp), 2)
|
||||
finally:
|
||||
game.kill()
|
||||
game.wait()
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
game = subprocess.Popen(["sleep", "60"])
|
||||
running = subprocess.Popen(probe + [tmp, str(game.pid), "1", "600"])
|
||||
try:
|
||||
deadline = time.monotonic() + 15
|
||||
while samples(tmp) < 1 and time.monotonic() < deadline:
|
||||
time.sleep(0.1)
|
||||
self.assertEqual(samples(tmp), 1)
|
||||
game.kill()
|
||||
game.wait()
|
||||
self.assertEqual(running.wait(timeout=10), 0)
|
||||
self.assertEqual(samples(tmp), 1)
|
||||
finally:
|
||||
game.kill()
|
||||
game.wait()
|
||||
running.kill()
|
||||
running.wait()
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
ended = subprocess.Popen(["true"])
|
||||
ended.wait()
|
||||
subprocess.run(probe + [tmp, str(ended.pid), "20", "60"], timeout=10, check=True)
|
||||
self.assertEqual(samples(tmp), 0)
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
game = subprocess.Popen(["sleep", "0.5"])
|
||||
running = subprocess.Popen(probe + [tmp, str(game.pid), "1"])
|
||||
try:
|
||||
game.wait()
|
||||
self.assertEqual(running.wait(timeout=10), 0)
|
||||
self.assertEqual(samples(tmp), 0)
|
||||
finally:
|
||||
running.kill()
|
||||
running.wait()
|
||||
|
||||
def test_open_driver_pairs_report_the_drivers_own_vkd3d_caps(self):
|
||||
apply = MODULE["apply_config"]
|
||||
config = {"version": 1, "shared": {"VKD3D_FEATURE_LEVEL": "12_2", "VKD3D_SHADER_MODEL": "6_9"},
|
||||
|
||||
Reference in new issue
Block a user