mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 13:05:47 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c24f7f0ea | ||
|
|
044c8ee475 |
No files matched your search
@@ -275,6 +275,7 @@ public final class LinuxRuntime {
|
||||
}
|
||||
}
|
||||
String[][] seeded = {
|
||||
{"filesystems", ""},
|
||||
{"file-max", "9223372036854775807\n"},
|
||||
{"overcommit_memory", "0\n"},
|
||||
};
|
||||
@@ -287,6 +288,7 @@ public final class LinuxRuntime {
|
||||
}
|
||||
}
|
||||
String[][] procFiles = {
|
||||
{"filesystems", "/proc/filesystems"},
|
||||
{"pci_devices", "/proc/bus/pci/devices"},
|
||||
{"stat", "/proc/stat"},
|
||||
{"version", "/proc/version"},
|
||||
|
||||
@@ -4,6 +4,8 @@ import android.content.ContextWrapper
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -35,4 +37,26 @@ class LinuxRuntimeProcFilesTest {
|
||||
LinuxRuntime.binds(context, null, null, null, null)
|
||||
assertEquals("1\n", File(fakeProc, "overcommit_memory").readText())
|
||||
}
|
||||
@Test fun restrictedFilesystemsHaveAConservativeFallback() {
|
||||
val binds = LinuxRuntime.binds(context, null, null, null, null)
|
||||
val fallback = File(fakeProc, "filesystems")
|
||||
assertEquals("", fallback.readText())
|
||||
assertEquals(!File("/proc/filesystems").canRead(), binds.contains("${fallback.path}:/proc/filesystems"))
|
||||
assertTrue(binds.contains("/proc"))
|
||||
assertFalse(binds.any { it.endsWith(":/proc/self/status") })
|
||||
}
|
||||
|
||||
@Test fun explicitFilesystemsBindingWins() {
|
||||
val source = File(root, "supported-fs").apply { writeText("nodev\ttmpfs\n") }
|
||||
val explicit = "${source.path}:/proc/filesystems"
|
||||
val binds = LinuxRuntime.binds(context, null, null, null, listOf(explicit))
|
||||
assertEquals(listOf(explicit), binds.filter { it.endsWith(":/proc/filesystems") })
|
||||
}
|
||||
|
||||
@Test fun existingFilesystemsDataIsPreserved() {
|
||||
val fallback = File(fakeProc, "filesystems").apply { parentFile!!.mkdirs(); writeText("nodev\ttmpfs\n") }
|
||||
LinuxRuntime.binds(context, null, null, null, null)
|
||||
assertEquals("nodev\ttmpfs\n", fallback.readText())
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,9 +21,10 @@ library list, before anything is published.
|
||||
trip to Xwayland on the paint thread; with no image, wlserver's position is used as upstream does.
|
||||
- `0101-nested-wayland-cursor-routing.patch` - this app: `gamescope_cursor_composite=2` lets the
|
||||
nested Wayland session paint its cursor in the output using the real X pointer position; client
|
||||
cursor surfaces are cleared to prevent a duplicate at the host pointer, while Gamescope's original
|
||||
default host-cursor fallback is preserved when its no-keyboard-focus policy selects it. Empty
|
||||
client cursor images and Gamescope's hidden flag still suppress the painted cursor.
|
||||
cursor surfaces are cleared to prevent a duplicate at the host pointer, and so is Gamescope's
|
||||
default host-cursor fallback, which would otherwise show a second arrow until Gamescope gets
|
||||
keyboard focus. Empty client cursor images and Gamescope's hidden flag still suppress the
|
||||
painted cursor.
|
||||
- `0110-wayland-backend-touch.patch` - this app: the nested Wayland backend bound only the host's
|
||||
pointer and keyboard, so a finger on the phone's screen never reached Steam. It now binds
|
||||
`wl_touch` too and hands each finger to wlserver's touch path (`wlserver_touchdown` / `motion` /
|
||||
|
||||
@@ -74,7 +74,7 @@ index 0000000..d7c21da
|
||||
+
|
||||
+ constexpr bool CursorShouldBeForwardedToHost( int cursorCompositeMode, bool useHostCursorFallback )
|
||||
+ {
|
||||
+ return cursorCompositeMode != 2 || useHostCursorFallback;
|
||||
+ return cursorCompositeMode != 2;
|
||||
+ }
|
||||
+
|
||||
+ constexpr bool CursorImageShouldBePainted( bool imageEmpty, bool cursorHidden )
|
||||
@@ -176,10 +176,10 @@ index 0000000..9c622db
|
||||
+ REQUIRE( CursorShouldBeComposited( 2, false, false, true, false ) );
|
||||
+}
|
||||
+
|
||||
+TEST_CASE("manual composition retains only the no-focus default cursor fallback", "[cursor_routing]")
|
||||
+TEST_CASE("manual composition never forwards a cursor to the host", "[cursor_routing]")
|
||||
+{
|
||||
+ REQUIRE_FALSE( CursorShouldBeForwardedToHost( 2, false ) );
|
||||
+ REQUIRE( CursorShouldBeForwardedToHost( 2, true ) );
|
||||
+ REQUIRE_FALSE( CursorShouldBeForwardedToHost( 2, true ) );
|
||||
+ REQUIRE( CursorShouldBeForwardedToHost( 1, false ) );
|
||||
+ REQUIRE( CursorShouldBeForwardedToHost( 0, false ) );
|
||||
+}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
GAMESCOPE_REPO=Droid-Deck/DroidDeck-Components
|
||||
GAMESCOPE_TAG=gamescope-3.16.29-f3a45b31
|
||||
GAMESCOPE_SHA256=3908af87b2ee8a328e9780fc805c6a7bddd11d7405b9992d717b94e16c019313
|
||||
GAMESCOPE_TAG=gamescope-3.16.29-f7dd44d2
|
||||
GAMESCOPE_SHA256=a034c36d44f9bca4abc804bda3958c8d303f1ce304fb677375e5d7aa233287a9
|
||||
@@ -992,22 +992,11 @@ def steam_clear_pending_interstitial(agent_dir, app_id):
|
||||
if (typeof apps?.GetActiveGameActions !== 'function' || typeof apps.ContinueGameAction !== 'function') return false;
|
||||
const active = await apps.GetActiveGameActions() || [];
|
||||
for (const action of active) {
|
||||
const gameid = String(action?.strAppID ?? action?.gameid ?? action?.nAppID ?? '');
|
||||
if (!/^[0-9]+$/.test(gameid)) continue;
|
||||
const numericId = BigInt(gameid);
|
||||
const appid = String(numericId > 0xffffffffn ? numericId >> 32n : numericId);
|
||||
if (appid !== %s || action?.strActionName !== 'LaunchApp' || action?.bWaitingForUI !== true) continue;
|
||||
const task = action.strTaskName;
|
||||
let response;
|
||||
if (task === 'ShowLaunchOption') {
|
||||
response = String(Number.isInteger(action.nLaunchOption) && action.nLaunchOption >= 0 ? action.nLaunchOption : 0);
|
||||
} else if (task === 'ShowInterstitials' || task === 'CreatingProcess') {
|
||||
response = task;
|
||||
} else {
|
||||
continue;
|
||||
const appid = String(action?.strAppID ?? action?.gameid ?? action?.nAppID ?? '');
|
||||
if (appid === %s && action?.strTaskName === 'ShowInterstitials') {
|
||||
apps.ContinueGameAction(action.nGameActionID, appid, 'ShowInterstitials');
|
||||
return true;
|
||||
}
|
||||
apps.ContinueGameAction(action.nGameActionID, response);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
})()""" % json.dumps(app_id)
|
||||
|
||||
@@ -1308,9 +1308,9 @@ case $mode in
|
||||
done < <(xprop -spy -root "${atoms[@]}" 2>/dev/null)
|
||||
) &
|
||||
steam_hold_launch() {
|
||||
local game=$1 appid=$1 shortcut= waited=0 status=0
|
||||
local game=$1 shortcut= waited=0 status=0
|
||||
_dd_focused() { xprop -root GAMESCOPE_FOCUSED_APP 2>/dev/null | sed -n 's/.*= *//p'; }
|
||||
_dd_starting() { pgrep -f "reaper SteamLaunch AppId=$appid( |$)" >/dev/null 2>&1; }
|
||||
_dd_starting() { pgrep -f "reaper SteamLaunch AppId=$(((game >> 32) & 0xffffffff))( |$)" >/dev/null 2>&1; }
|
||||
_dd_hand_off() {
|
||||
printf '%s\n' "$game" > "$DD_LAUNCH_DIR/steam-game.tmp" && mv -f "$DD_LAUNCH_DIR/steam-game.tmp" "$DD_LAUNCH_DIR/steam-game"
|
||||
}
|
||||
@@ -1318,10 +1318,7 @@ case $mode in
|
||||
until [ "$(_dd_focused)" = 769 ] || [ "$SECONDS" -ge "$_dd_end" ]; do
|
||||
sleep 1
|
||||
done
|
||||
if [ "${#game}" -gt 10 ]; then
|
||||
shortcut=1
|
||||
appid=$(((game >> 32) & 0xffffffff))
|
||||
fi
|
||||
[ "${#game}" -gt 10 ] && shortcut=1
|
||||
_dd_ready_end=$((SECONDS + 30))
|
||||
while [ "$waited" -lt 30 ] && [ "$((_dd_ready_end - SECONDS))" -gt 0 ]; do
|
||||
timeout "$((_dd_ready_end - SECONDS))" /usr/local/bin/droiddeck-agent --steam-ready >/dev/null 2>&1 && break
|
||||
@@ -1332,36 +1329,30 @@ case $mode in
|
||||
waited=0
|
||||
echo "== steam: interface up; launching the requested game $game"
|
||||
_dd_hand_off
|
||||
while [ "$(_dd_focused)" = 769 ] && [ "$waited" -lt 120 ]; do
|
||||
if /usr/local/bin/droiddeck-agent --steam-clear-pending-interstitial "$appid" >/dev/null 2>&1; then
|
||||
echo "== steam: continued a pending launch step for $game"
|
||||
fi
|
||||
[ -n "$shortcut" ] || return 0
|
||||
while [ "$(_dd_focused)" = 769 ] && [ "$waited" -lt 20 ]; do
|
||||
sleep 1
|
||||
waited=$((waited + 1))
|
||||
if [ -n "$shortcut" ] && [ "$waited" -eq 20 ]; then
|
||||
if _dd_starting; then
|
||||
echo "== steam: the requested game is already starting; not launching again"
|
||||
return 0
|
||||
fi
|
||||
echo "== steam: the game is not in front after about 20 s; waiting for the shortcut overview"
|
||||
/usr/local/bin/droiddeck-agent --wait-steam-shortcut-overview "$game" 45 || status=$?
|
||||
if [ "$status" -eq 3 ]; then
|
||||
echo "== steam: not a shortcut CGameID; not launching again"
|
||||
elif _dd_starting; then
|
||||
echo "== steam: the requested game started while waiting; not launching again"
|
||||
return 0
|
||||
elif [ "$(_dd_focused)" = 769 ]; then
|
||||
echo "== steam: clearing the pending launch interstitial for $game (overview status $status)"
|
||||
if ! /usr/local/bin/droiddeck-agent --steam-clear-pending-interstitial "$appid" >/dev/null 2>&1; then
|
||||
echo "== steam: launching the requested game again $game"
|
||||
_dd_hand_off
|
||||
fi
|
||||
else
|
||||
echo "== steam: the game took focus while waiting; not launching again"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
done
|
||||
[ "$(_dd_focused)" = 769 ] || return 0
|
||||
if _dd_starting; then
|
||||
echo "== steam: the requested game is already starting; not launching again"
|
||||
return 0
|
||||
fi
|
||||
echo "== steam: the game is not in front after about 20 s; waiting for the shortcut overview"
|
||||
/usr/local/bin/droiddeck-agent --wait-steam-shortcut-overview "$game" 45 || status=$?
|
||||
if [ "$status" -eq 3 ]; then
|
||||
echo "== steam: not a shortcut CGameID; not launching again"
|
||||
elif _dd_starting; then
|
||||
echo "== steam: the requested game started while waiting; not launching again"
|
||||
elif [ "$(_dd_focused)" = 769 ]; then
|
||||
echo "== steam: clearing the pending launch interstitial for $game (overview status $status)"
|
||||
/usr/local/bin/droiddeck-agent --steam-clear-pending-interstitial "$(((game >> 32) & 0xffffffff))" >/dev/null 2>&1 && return 0
|
||||
echo "== steam: launching the requested game again $game"
|
||||
_dd_hand_off
|
||||
else
|
||||
echo "== steam: the game took focus while waiting; not launching again"
|
||||
fi
|
||||
}
|
||||
if [ -n "${DD_LAUNCH_DIR:-}" ] && [ -z "${DD_DESKTOP:-}" ]; then
|
||||
_dd_held=
|
||||
|
||||
@@ -532,44 +532,6 @@ class AgentTest(unittest.TestCase):
|
||||
with self.assertRaises(agent.AgentError):
|
||||
agent.steam_clear_pending_interstitial(self.dir, "0")
|
||||
|
||||
@unittest.skipUnless(shutil.which("node"), "node is not installed")
|
||||
def test_pending_launch_responses_match_the_waiting_task(self):
|
||||
with patch.object(agent, "cdp_eval", return_value={"value": False}) as evaluate:
|
||||
agent.steam_clear_pending_interstitial(self.dir, "413150")
|
||||
expression = evaluate.call_args.args[1]
|
||||
cases = [
|
||||
({"strTaskName": "ShowInterstitials"}, [[7, "ShowInterstitials"]]),
|
||||
({"strTaskName": "ShowInterstitials", "gameid": str((413150 << 32) | 0x02000000)}, [[7, "ShowInterstitials"]]),
|
||||
({"strTaskName": "ShowInterstitials", "gameid": "invalid"}, []),
|
||||
({"strTaskName": "CreatingProcess"}, [[7, "CreatingProcess"]]),
|
||||
({"strTaskName": "ShowLaunchOption", "nLaunchOption": 2}, [[7, "2"]]),
|
||||
({"strTaskName": "ShowLaunchOption", "nLaunchOption": -1}, [[7, "0"]]),
|
||||
({"strTaskName": "ShowLaunchOption", "nLaunchOption": 0}, [[7, "0"]]),
|
||||
({"strTaskName": "SynchronizingCloud"}, []),
|
||||
({"strTaskName": "ShowEula"}, []),
|
||||
({"strTaskName": "DownloadingDepots"}, []),
|
||||
({"strTaskName": "ShowInterstitials", "bWaitingForUI": False}, []),
|
||||
({"strTaskName": "ShowInterstitials", "strActionName": "VerifyApp"}, []),
|
||||
({"strTaskName": "ShowInterstitials", "gameid": "123"}, []),
|
||||
]
|
||||
for changes, expected in cases:
|
||||
action = dict(nGameActionID=7, gameid="413150", strActionName="LaunchApp", bWaitingForUI=True)
|
||||
action.update(changes)
|
||||
harness = """
|
||||
const calls = [];
|
||||
globalThis.SteamClient = {Apps: {
|
||||
GetActiveGameActions: async () => %s,
|
||||
ContinueGameAction: (...args) => calls.push(args)
|
||||
}};
|
||||
(async () => {
|
||||
const result = await %s;
|
||||
process.stdout.write(JSON.stringify({result, calls}));
|
||||
})().catch(error => { console.error(error); process.exit(1); });
|
||||
""" % (json.dumps([action]), expression)
|
||||
with self.subTest(changes=changes):
|
||||
result = subprocess.run(["node", "-e", harness], text=True, capture_output=True, check=True, timeout=5)
|
||||
self.assertEqual({"result": bool(expected), "calls": expected}, json.loads(result.stdout))
|
||||
|
||||
def test_asleep_command_reports_steams_own_sleep_state(self):
|
||||
with patch.dict(os.environ, {"DD_LAUNCH_DIR": str(self.dir.parent)}):
|
||||
for value, code in (("yes", 0), ("no", 5), ("unknown", 1), (None, 1)):
|
||||
|
||||
@@ -32,7 +32,6 @@ class SteamColdLaunchTest(unittest.TestCase):
|
||||
xprop.write_text(
|
||||
"#!/bin/sh\n"
|
||||
"n=$(cat \"$FOCUS_COUNT\" 2>/dev/null || echo 0); n=$((n + 1)); echo $n > \"$FOCUS_COUNT\"\n"
|
||||
"[ ! -f \"$HOME/overview-focus\" ] || { echo \"GAMESCOPE_FOCUSED_APP(CARDINAL) = $(cat \"$HOME/overview-focus\")\"; exit; }\n"
|
||||
"i=0; last=769\n"
|
||||
"for f in $FOCUS; do i=$((i + 1)); last=$f; [ \"$i\" -eq \"$n\" ] && break; done\n"
|
||||
"echo \"GAMESCOPE_FOCUSED_APP(CARDINAL) = $last\"\n")
|
||||
@@ -43,7 +42,6 @@ class SteamColdLaunchTest(unittest.TestCase):
|
||||
"printf '%s\n' \"$@\" > \"$AGENT_ARGS\"\n"
|
||||
"n=$(cat \"$AGENT_COUNT\" 2>/dev/null || echo 0); n=$((n + 1)); echo $n > \"$AGENT_COUNT\"\n"
|
||||
"[ \"$1\" = --steam-ready ] && exit \"${READY_STATUS:-0}\"\n"
|
||||
"if [ \"$1\" = --wait-steam-shortcut-overview ] && [ -n \"$OVERVIEW_FOCUS\" ]; then echo \"$OVERVIEW_FOCUS\" > \"$HOME/overview-focus\"; fi\n"
|
||||
"exit \"$AGENT_STATUS\"\n")
|
||||
agent.chmod(0o755)
|
||||
sleep = self.bin / "sleep"
|
||||
@@ -58,13 +56,13 @@ class SteamColdLaunchTest(unittest.TestCase):
|
||||
pgrep.chmod(0o755)
|
||||
self.block = LAUNCH_BLOCK.replace("/usr/local/bin/droiddeck-agent", str(agent))
|
||||
|
||||
def run_launch(self, target, focus="769", helper_status=0, running_after=999, ready_status=0, overview_focus=""):
|
||||
def run_launch(self, target, focus="769", helper_status=0, running_after=999, ready_status=0):
|
||||
env = dict(os.environ, HOME=str(self.root), DD_LAUNCH_DIR=str(self.launch_dir),
|
||||
PATH=str(self.bin) + os.pathsep + os.environ["PATH"],
|
||||
AGENT_ARGS=str(self.agent_args), SLEEP_ARGS=str(self.sleep_args),
|
||||
AGENT_COUNT=str(self.agent_count), AGENT_STATUS=str(helper_status),
|
||||
FOCUS=focus, FOCUS_COUNT=str(self.focus_count), RUNNING_AFTER=str(running_after),
|
||||
READY_STATUS=str(ready_status), OVERVIEW_FOCUS=overview_focus)
|
||||
READY_STATUS=str(ready_status))
|
||||
script = self.block + "\nprintf 'ARG:%s\n' \"$@\"\nwait\n"
|
||||
url = target if target.startswith("steam://") else "steam://rungameid/" + target
|
||||
result = subprocess.run(["bash", "-c", script, "cold-launch", url],
|
||||
@@ -87,7 +85,7 @@ class SteamColdLaunchTest(unittest.TestCase):
|
||||
self.assertEqual(1, len(self.hand_offs(result)), result.stdout)
|
||||
self.assertIn("clearing the pending launch interstitial", result.stdout)
|
||||
self.assertEqual(["--steam-clear-pending-interstitial", "3551182975"], self.agent_args.read_text().splitlines())
|
||||
self.assertEqual(["1"] * 120, self.sleep_args.read_text().split())
|
||||
self.assertEqual(["1"] * 20, self.sleep_args.read_text().split())
|
||||
|
||||
def test_a_timed_out_overview_still_gets_one_more_hand_off(self):
|
||||
result = self.run_launch(SHORTCUT, focus="769", helper_status=1)
|
||||
@@ -99,7 +97,7 @@ class SteamColdLaunchTest(unittest.TestCase):
|
||||
result = self.run_launch("413150", ready_status=1)
|
||||
self.assertEqual("413150", (self.launch_dir / "steam-game").read_text().strip())
|
||||
self.assertEqual(1, len(self.hand_offs(result)), result.stdout)
|
||||
self.assertEqual(["1"] * 150, self.sleep_args.read_text().split())
|
||||
self.assertEqual(["1"] * 30, self.sleep_args.read_text().split())
|
||||
|
||||
def test_a_focus_change_does_not_end_the_readiness_wait(self):
|
||||
result = self.run_launch("413150", focus="769 4242", ready_status=1)
|
||||
@@ -109,7 +107,7 @@ class SteamColdLaunchTest(unittest.TestCase):
|
||||
def test_a_game_still_starting_without_a_window_is_not_launched_twice(self):
|
||||
result = self.run_launch(SHORTCUT, running_after=1)
|
||||
self.assertEqual(1, len(self.hand_offs(result)), result.stdout)
|
||||
self.assertEqual(["--steam-clear-pending-interstitial", "3551182975"], self.agent_args.read_text().splitlines())
|
||||
self.assertIn("--steam-ready", self.agent_args.read_text())
|
||||
self.assertEqual(["-f", "reaper SteamLaunch AppId=3551182975( |$)"],
|
||||
(self.root / "pgrep-args").read_text().splitlines())
|
||||
self.assertIn("already starting", result.stdout)
|
||||
@@ -121,24 +119,18 @@ class SteamColdLaunchTest(unittest.TestCase):
|
||||
self.assertIn("started while waiting", result.stdout)
|
||||
|
||||
def test_a_game_that_takes_focus_during_the_overview_wait_is_not_started_twice(self):
|
||||
result = self.run_launch(SHORTCUT, helper_status=0, overview_focus="4242")
|
||||
focus = " ".join(["769"] * 23) + " 4242"
|
||||
result = self.run_launch(SHORTCUT, focus=focus, helper_status=0)
|
||||
self.assertEqual(1, len(self.hand_offs(result)), result.stdout)
|
||||
self.assertNotIn("clearing the pending launch interstitial", result.stdout)
|
||||
self.assertNotIn("launching the requested game again", result.stdout)
|
||||
|
||||
def test_native_app_id_recovers_pending_steps_without_relaunching(self):
|
||||
def test_native_app_id_keeps_the_short_delay_and_is_handed_over_once(self):
|
||||
result = self.run_launch("413150")
|
||||
self.assertEqual("413150", (self.launch_dir / "steam-game").read_text().strip())
|
||||
self.assertEqual(1, len(self.hand_offs(result)), result.stdout)
|
||||
self.assertEqual(["1"] * 120, self.sleep_args.read_text().split())
|
||||
self.assertEqual(["--steam-clear-pending-interstitial", "413150"], self.agent_args.read_text().splitlines())
|
||||
self.assertEqual(121, int(self.agent_count.read_text()))
|
||||
|
||||
def test_native_app_recovery_does_not_stop_for_an_install_script_or_repeat_a_failed_launch(self):
|
||||
result = self.run_launch("413150", helper_status=1, running_after=1)
|
||||
self.assertEqual(1, len(self.hand_offs(result)), result.stdout)
|
||||
self.assertEqual(121, int(self.agent_count.read_text()))
|
||||
self.assertEqual(["--steam-clear-pending-interstitial", "413150"], self.agent_args.read_text().splitlines())
|
||||
self.assertFalse(self.sleep_args.exists())
|
||||
self.assertIn("--steam-ready", self.agent_args.read_text())
|
||||
|
||||
def test_a_restart_for_a_game_uses_the_same_hand_off(self):
|
||||
loop = SOURCE[SOURCE.index(' if [ -s "$HOME/.dd-restart-game" ]; then'):SOURCE.index(' if [ -f "$HOME/.dd-restart-once" ]; then')]
|
||||
|
||||
Reference in new issue
Block a user