Compare commits

..
6 changed files with 94 additions and 175 deletions

No files matched your search

+3 -36
View File
@@ -754,17 +754,12 @@ jobs:
ln -sfn "$(cd "$jars" && pwd)" "$m2"
echo "cache=true" >> "$GITHUB_OUTPUT"
fi
- name: Restore Robolectric's Android jars
id: robolectric-cache
- name: Cache Robolectric's Android jars
if: steps.robolectric-jars.outputs.cache == 'true'
uses: actions/cache/restore@v4
uses: actions/cache@v4
with:
path: ../robolectric-jars
key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }}
restore-keys: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-
- name: Count the restored Robolectric jars
if: steps.robolectric-jars.outputs.cache == 'true'
run: echo "ROBOLECTRIC_JARS_BEFORE=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)" >> "$GITHUB_ENV"
key: robolectric-android-all-v2-${{ steps.robolectric.outputs.version }}
- name: Unit tests
id: unit-tests
env:
@@ -775,34 +770,6 @@ jobs:
mkdir -p app/build
./gradlew testReleaseUnitTest --console=plain --info --stacktrace -Drobolectric.logging=stderr -PndkVersion="$NDK_VERSION" 2>&1 | tee app/build/unit-tests.log
# actions/cache only saves when the job succeeds, so a run whose tests died on a Maven 429 never filled the cache.
# Save the complete jars even after a failed test step, when this run added some; a partial download is dropped first.
- name: Save Robolectric's Android jars
id: robolectric-jars-final
if: always() && steps.robolectric-jars.outputs.cache == 'true'
run: |
python3 - <<'PY'
import glob, os, zipfile
root = os.path.join(os.environ['GITHUB_WORKSPACE'], '..', 'robolectric-jars')
for f in glob.glob(os.path.join(root, '**', '*'), recursive=True):
if not os.path.isfile(f):
continue
try:
ok = f.endswith('.jar') and zipfile.ZipFile(f).testzip() is None
except Exception:
ok = False
if not ok:
os.remove(f)
PY
after=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)
[ "$after" -gt "${ROBOLECTRIC_JARS_BEFORE:-0}" ] && echo "save=true" >> "$GITHUB_OUTPUT" || true
- name: Store Robolectric's Android jars
if: always() && steps.robolectric-jars-final.outputs.save == 'true'
uses: actions/cache/save@v4
with:
path: ../robolectric-jars
key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }}
- name: Upload unit test diagnostics
id: unit-test-diagnostics
if: always() && steps.unit-tests.outcome != 'skipped'
+2 -2
View File
@@ -10,7 +10,7 @@ DroidDeck brings the SteamOS experience to Android: Steam Gaming Mode, full Linu
<p align="center"><b>100% open source. No ads. No Subscriptions. No telemetry. No proprietary components. No source withheld.</b></p>
<p align="center">
<a href="https://github.com/Droid-Deck/DroidDeck/releases/download/0.7.11/DroidDeck-0.7.11.apk"><img src="https://img.shields.io/badge/Download-DroidDeck%200.7.11%20APK-3DDC84?style=for-the-badge&logo=android&logoColor=white" alt="Download DroidDeck 0.7.11"></a>
<a href="https://github.com/Droid-Deck/DroidDeck/releases/download/0.7.1/DroidDeck-0.7.1.apk"><img src="https://img.shields.io/badge/Download-DroidDeck%200.7.1%20APK-3DDC84?style=for-the-badge&logo=android&logoColor=white" alt="Download DroidDeck 0.7.1"></a>
<a href="https://discord.gg/JRGAvawjsm"><img src="https://img.shields.io/badge/Discord-Join%20us-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Join the DroidDeck Discord"></a>
</p>
@@ -38,7 +38,7 @@ DroidDeck brings the SteamOS experience to Android: Steam Gaming Mode, full Linu
1. Android 9 or newer on Adreno 730 or newer, or any 8xx. Adreno 6xx, Mali, Xclipse and PowerVR are experimental. Adreno 710 is currently unsupported. No root needed.
2. About 3 GB free for the runtime, plus 1.1 GB for the desktop and emulators.
3. Install the [APK](https://github.com/Droid-Deck/DroidDeck/releases/download/0.7.11/DroidDeck-0.7.11.apk), install the Linux runtime, press **Play** and sign in to Steam.
3. Install the [APK](https://github.com/Droid-Deck/DroidDeck/releases/download/0.7.1/DroidDeck-0.7.1.apk), install the Linux runtime, press **Play** and sign in to Steam.
4. On Android 14 and newer, turn on **Disable child process restrictions** in Developer options. On Android 12 and 13, Steam's first launch shows a **Fix it for me** button that walks you through it.
Smart glasses setup is in the [support matrix](docs/smart-glasses-support.md). Release notes are in [docs/releases](docs/releases).
@@ -477,6 +477,28 @@ def stage_playfab_proxy(folder):
return staged
RUNTIME_LOGS = (('NEXUS_STORE_METADATA_LOG', 'xbox-store-calls.log'), ('XUSER_AUTH_METADATA_LOG', 'xbox-sign-in.log'),
('XUSER_AUTH_REJECTION_LOG', 'xbox-sign-in-rejections.log'))
def runtime_logs(env):
folder = env.get('PROTON_LOG_DIR')
if not isinstance(folder, str) or not os.path.isabs(folder) or os.path.islink(folder) or not os.path.isdir(folder):
return {}
found = {}
for name, file in RUNTIME_LOGS:
path = Path(folder) / file
windows = 'Z:' + str(path).replace('/', '\\')
if len(windows) >= 260:
continue
try:
os.close(os.open(path, os.O_WRONLY | os.O_CREAT | os.O_APPEND | os.O_NOFOLLOW, 0o644))
except OSError:
continue
found[name] = windows
return found
def renew_lease(ask, channel, product, lease, stopped):
while not stopped.wait(15):
response = ask(channel, {'op': 'xbox-renew', 'id': product, 'lease': lease}, timeout=10)
@@ -521,6 +543,7 @@ def launch(command, env):
XODUS_LOG='off', RUST_LOG='off', XODUS_SAVE_SYNC='auto' if sidecar.get('cloud', True) else 'none')
for name in ('DROIDDECK_XBOX_CREDENTIAL_SOCKET', 'DROIDDECK_XBOX_CREDENTIAL_PORT', 'DROIDDECK_XBOX_CREDENTIAL_KEY'):
owned_env.pop(name, None)
owned_env.update(runtime_logs(env))
if reply.get('playfab'):
owned_env['XODUS_XSTS_PLAYFAB'] = reply['playfab']
# The runtime mounts DLC only inside this backend-owned workspace (E_NOTIMPL without it).
+3 -55
View File
@@ -16,7 +16,6 @@
#include <limits.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <net/route.h>
#include <netpacket/packet.h>
#include <netinet/in.h>
#include <pthread.h>
@@ -534,8 +533,6 @@ static void write_table(FILE *out, const char *table, const struct link *link) {
}
}
#define ROUTE_TABLE 0
#define IPV6_ROUTE_TABLE 1
#define CARRIER_TABLE 5
#define SOCKET_TABLES 6
@@ -609,48 +606,6 @@ static FILE *synthesize(int table) {
return out;
}
static int link_has_gateway(int family) {
struct link link;
if (!load_link(&link)) return 0;
for (int i = 0; i < link.gateway_count; i++) {
if (link.gateways[i].family == family) return 1;
}
return 0;
}
static int default_route_line(const char *line, int table) {
unsigned flags, prefix;
if (table == ROUTE_TABLE) {
unsigned destination, gateway, mask;
return sscanf(line, "%*s %x %x %x %*d %*d %*d %x", &destination, &gateway, &flags, &mask) == 4
&& destination == 0 && mask == 0 && (flags & RTF_UP);
}
char destination[33];
return sscanf(line, "%32s %x %*s %*x %*s %*x %*x %*x %x", destination, &prefix, &flags) == 3
&& prefix == 0 && strspn(destination, "0") == 32 && (flags & RTF_UP) && !(flags & RTF_REJECT);
}
static int misses_default_route(int fd, int table) {
if (table != ROUTE_TABLE && table != IPV6_ROUTE_TABLE) return 0;
if (!link_has_gateway(table == ROUTE_TABLE ? AF_INET : AF_INET6)) return 0;
size_t capacity = 65536, size = 0;
char *text = malloc(capacity + 1);
if (text == NULL) return 0;
ssize_t got = 1;
while (size < capacity && (got = pread(fd, text + size, capacity - size, (off_t) size)) > 0) size += (size_t) got;
int misses = got == 0;
text[size] = '\0';
for (char *line = text; misses && *line;) {
char *end = strchr(line, '\n');
if (end) *end = '\0';
if (default_route_line(line, table)) misses = 0;
if (end == NULL) break;
line = end + 1;
}
free(text);
return misses;
}
int dd_status_without_tracer(const char *path, int flags, const void *caller) __attribute__((visibility("hidden")));
const char *dd_oom_adj_redirect(const char *path, int writing) __attribute__((visibility("hidden")));
@@ -668,12 +623,6 @@ static FILE *open_stream(fopen_fn real, const char *path, const char *mode, cons
FILE *f;
if (table >= 0 && denied_recently(table, path) && (f = synthesize(table)) != NULL) return f;
f = real(path, mode);
if (f && table >= 0 && misses_default_route(fileno(f), table)) {
FILE *link_table = synthesize(table);
if (link_table == NULL) return f;
fclose(f);
return link_table;
}
if (f || table < 0) return f;
int saved = errno;
if ((f = synthesize(table)) != NULL) {
@@ -687,9 +636,9 @@ static FILE *open_stream(fopen_fn real, const char *path, const char *mode, cons
int dd_net_open(const char *path, int flags, int fd) __attribute__((visibility("hidden")));
int dd_net_open(const char *path, int flags, int fd) {
if (path == NULL || (flags & O_ACCMODE) != O_RDONLY || (flags & O_DIRECTORY)) return fd;
if (fd >= 0 || path == NULL || (flags & O_ACCMODE) != O_RDONLY || (flags & O_DIRECTORY)) return fd;
int table = denied_table(path);
if (table < 0 || (fd >= 0 && !misses_default_route(fd, table))) return fd;
if (table < 0) return fd;
int saved = errno;
FILE *f = synthesize(table);
if (f == NULL) {
@@ -707,8 +656,7 @@ int dd_net_open(const char *path, int flags, int fd) {
errno = saved;
return fd;
}
if (fd >= 0) close(fd);
else if (saved == EACCES) remember_denial(table, path);
if (saved == EACCES) remember_denial(table, path);
return copy;
}
+5 -82
View File
@@ -87,21 +87,12 @@ int getsockopt(int fd, int level, int option, void *value, socklen_t *len) {
return real(fd, level, option, value, len);
}
static __thread char fixture_path[4096];
static const char *table_fixture(const char *path) {
const char *directory = getenv("NETLINK_TEST_TABLES");
if (!directory || !path || strncmp(path, "/proc/net/", 10)) return path;
snprintf(fixture_path, sizeof(fixture_path), "%s/%s", directory, path + 10);
return access(fixture_path, F_OK) == 0 ? fixture_path : path;
}
FILE *fopen(const char *path, const char *mode) {
static FILE *(*real)(const char *, const char *);
if (!real) real = dlsym(RTLD_NEXT, "fopen");
const char *snapshot = getenv("NETLINK_TEST_SNAPSHOT");
if (snapshot && !strcmp(path, "/etc/droiddeck-net")) path = snapshot;
return real(table_fixture(path), mode);
return real(path, mode);
}
static int denied(const char *path) {
@@ -125,13 +116,13 @@ int open(const char *path, int flags, ...) {
va_start(ap, flags);
mode_t mode = va_arg(ap, mode_t);
va_end(ap);
return denied(path) ? -1 : real(table_fixture(path), flags, mode);
return denied(path) ? -1 : real(path, flags, mode);
}
int __open_2(const char *path, int flags) {
static int (*real)(const char *, int);
if (!real) real = dlsym(RTLD_NEXT, "__open_2");
return denied(path) ? -1 : real(table_fixture(path), flags);
return denied(path) ? -1 : real(path, flags);
}
int openat(int dirfd, const char *path, int flags, ...) {
@@ -141,7 +132,7 @@ int openat(int dirfd, const char *path, int flags, ...) {
va_start(ap, flags);
mode_t mode = va_arg(ap, mode_t);
va_end(ap);
return denied(path) ? -1 : real(dirfd, table_fixture(path), flags, mode);
return denied(path) ? -1 : real(dirfd, path, flags, mode);
}
int close_range(unsigned int first, unsigned int last, int flags) {
@@ -223,37 +214,6 @@ static void proc_net_test(int denied, int sealed) {
}
}
static const char *table_source(int descriptor) {
char link[64], target[4096];
snprintf(link, sizeof(link), "/proc/self/fd/%d", descriptor);
ssize_t length = readlink(link, target, sizeof(target) - 1);
require(length > 0, "route table target");
target[length] = 0;
return strncmp(target, "/memfd:droiddeck-net", 20) == 0 ? "link" : "real";
}
static void route_tables_test(void) {
static const char *const tables[] = {"/proc/net/route", "/proc/net/ipv6_route"};
static const char *const gateways[] = {"\t00000000\t0101A8C0\t0003\t", "20010db8000000000000000000000001 "};
char text[4096];
for (unsigned i = 0; i < 2; i++) {
FILE *stream = fopen(tables[i], "r");
require(stream != NULL, "route table fopen");
const char *source = table_source(fileno(stream));
size_t total = fread(text, 1, sizeof(text) - 1, stream);
text[total] = 0;
require(strcmp(source, "link") || strstr(text, gateways[i]), "link table lists the default gateway");
printf("%s ", source);
fclose(stream);
int descriptor = i ? openat(AT_FDCWD, tables[i], O_RDONLY | O_CLOEXEC) : open(tables[i], O_RDONLY | O_CLOEXEC);
require(descriptor >= 0, "route table open");
require(fcntl(descriptor, F_GETFD) & FD_CLOEXEC, "route table keeps close-on-exec");
printf("%s ", table_source(descriptor));
close(descriptor);
}
printf("\n");
}
static unsigned port_of(int descriptor) {
struct sockaddr_nl address;
socklen_t length = sizeof(address);
@@ -1249,7 +1209,6 @@ int main(int argc, char **argv) {
}
else if (!strcmp(argv[1], "range") || !strcmp(argv[1], "cloexec") || !strcmp(argv[1], "closefrom"))
close_range_test(argv[1]);
else if (!strcmp(argv[1], "route_tables")) route_tables_test();
else if (!strcmp(argv[1], "proc_net")) proc_net_test(argc > 2 && strcmp(argv[2], "allowed"), argc > 2 && !strcmp(argv[2], "sealed"));
else if (!strcmp(argv[1], "route")) {
require(argc >= 3, "route destination");
@@ -1259,21 +1218,6 @@ int main(int argc, char **argv) {
}
"""
ROUTE_HEADER = "Iface\tDestination\tGateway \tFlags\tRefCnt\tUse\tMetric\tMask\t\tMTU\tWindow\tIRTT\n"
ZERO_V6 = "0" * 32
ANDROID_ROUTE_TABLES = {
"route": ROUTE_HEADER + "wlan0\t0001A8C0\t00000000\t0001\t0\t0\t0\t00FFFFFF\t0\t0\t0\n",
"ipv6_route": f"fe800000000000000000000000000000 40 {ZERO_V6} 00 {ZERO_V6} 00000100 00000001 00000000 00000001 wlan0\n"
f"{ZERO_V6} 00 {ZERO_V6} 00 {ZERO_V6} ffffffff 00000001 00000000 00200200 lo\n",
}
DEFAULT_ROUTE_TABLES = {
"route": ANDROID_ROUTE_TABLES["route"] + "wlan0\t00000000\t0101A8C0\t0003\t0\t0\t600\t00000000\t0\t0\t0\n",
"ipv6_route": ANDROID_ROUTE_TABLES["ipv6_route"]
+ f"{ZERO_V6} 00 {ZERO_V6} 00 fe800000000000000000000000000001 00000400 00000001 00000000 00450003 wlan0\n",
}
SNAPSHOT = """if wlan0 2 1500
mac 02:11:22:33:44:55
addr 192.168.1.10 24
@@ -1313,14 +1257,12 @@ class NetlinkPreloadTest(unittest.TestCase):
def tearDownClass(cls):
cls.temp.cleanup()
def run_program(self, mode, *arguments, snapshot=None, denied=None, tables=None):
def run_program(self, mode, *arguments, snapshot=None, denied=None):
env = dict(os.environ, LD_PRELOAD=f"{self.preload}:{self.shim}",
NETLINK_TEST_SNAPSHOT=str(snapshot or self.snapshot),
DD_SYSV_DIR=str(self.directory / "sysv"))
if denied:
env["NETLINK_TEST_DENIED"] = denied
if tables:
env["NETLINK_TEST_TABLES"] = str(tables)
result = subprocess.run([str(self.program), mode, *arguments], env=env,
capture_output=True, text=True, timeout=5)
self.assertEqual(0, result.returncode, result.stdout + result.stderr)
@@ -1449,25 +1391,6 @@ class NetlinkPreloadTest(unittest.TestCase):
def test_readable_socket_tables_stay_real(self):
self.run_program("proc_net")
def route_tables(self, name, contents):
directory = self.directory / name
directory.mkdir(exist_ok=True)
for table, text in contents.items():
(directory / table).write_text(text)
return directory
def test_route_tables_without_a_default_route_answer_from_the_link(self):
tables = self.route_tables("android-routes", ANDROID_ROUTE_TABLES)
self.assertEqual(["link"] * 4, self.run_program("route_tables", tables=tables))
def test_route_tables_with_a_default_route_stay_real(self):
tables = self.route_tables("default-routes", DEFAULT_ROUTE_TABLES)
self.assertEqual(["real"] * 4, self.run_program("route_tables", tables=tables))
def test_route_tables_stay_real_when_the_link_has_no_gateway(self):
tables = self.route_tables("android-routes", ANDROID_ROUTE_TABLES)
self.assertEqual(["real"] * 4, self.run_program("route_tables", tables=tables, snapshot=self.direct))
def test_loopback_and_own_addresses_are_local_routes(self):
for destination, source in (("127.0.0.2", "127.0.0.1"), ("::1", "::1"),
("192.168.1.10", "192.168.1.10"), ("2001:db8::10", "2001:db8::10")):
+58
View File
@@ -69,6 +69,64 @@ class XboxLaunchTest(unittest.TestCase):
close.assert_called_once()
self.assertEqual(store['ask'].call_args.args[1], {'op': 'xbox-released', 'lease': 'lease-1'})
def launch_env(self, env):
with tempfile.TemporaryDirectory() as root:
root = Path(root)
runtime = root / 'runtime/windows'
runtime.mkdir(parents=True)
for name in xbox['DLLS']:
(runtime / name).write_bytes(b'MZ')
store = {'find_store_game': lambda argv: (root, {'store': 'xbox', 'id': 'GAME'}),
'ask': unittest.mock.Mock(return_value={'ok': True, 'socket': '/service', 'lease': 'lease-1',
'exe': '/private/Game.exe'})}
wine = unittest.mock.Mock(return_value=0)
with patch('runpy.run_path', return_value=store), \
patch.dict(xbox['launch'].__globals__, RUNTIME=runtime.parent, wine=wine,
bridge=lambda path: (1234, 'key', lambda: None)):
self.assertEqual(xbox['launch'](['/proton', 'waitforexitandrun', '/encrypted/Game.exe'],
dict(env, DD_LAUNCH_DIR='/launch')), 0)
return wine.call_args.args[1]
def test_game_logs_get_the_runtime_store_and_sign_in_results(self):
with tempfile.TemporaryDirectory() as logs:
env = self.launch_env({'PROTON_LOG_DIR': logs})
for name, file in xbox['RUNTIME_LOGS']:
self.assertEqual(env[name], 'Z:' + str(Path(logs) / file).replace('/', '\\'))
self.assertEqual((Path(logs) / file).read_bytes(), b'')
def test_runtime_results_stay_off_without_game_logs(self):
for env in ({}, {'PROTON_LOG_DIR': ''}, {'PROTON_LOG_DIR': 'relative/logs'}, {'PROTON_LOG_DIR': '/missing/logs'}):
with self.subTest(env=env):
launched = self.launch_env(env)
for name, _ in xbox['RUNTIME_LOGS']:
self.assertNotIn(name, launched)
def test_runtime_results_keep_earlier_lines_and_never_follow_links(self):
with tempfile.TemporaryDirectory() as root:
root = Path(root)
logs = root / 'logs'
logs.mkdir()
outside = root / 'outside.txt'
outside.write_text('private')
store, sign_in, rejections = (logs / file for _, file in xbox['RUNTIME_LOGS'])
store.write_text('STORE_META api=20\n')
sign_in.symlink_to(outside)
found = xbox['runtime_logs']({'PROTON_LOG_DIR': str(logs)})
self.assertEqual(store.read_text(), 'STORE_META api=20\n')
self.assertNotIn('XUSER_AUTH_METADATA_LOG', found)
self.assertEqual(outside.read_text(), 'private')
self.assertEqual(found['XUSER_AUTH_REJECTION_LOG'], 'Z:' + str(rejections).replace('/', '\\'))
linked = root / 'linked'
linked.symlink_to(logs)
self.assertEqual(xbox['runtime_logs']({'PROTON_LOG_DIR': str(linked)}), {})
def test_runtime_results_need_a_path_the_runtime_can_open(self):
with tempfile.TemporaryDirectory() as root:
logs = Path(root) / ('g' * 240)
logs.mkdir()
self.assertEqual(xbox['runtime_logs']({'PROTON_LOG_DIR': str(logs)}), {})
self.assertEqual(list(logs.iterdir()), [])
def test_bridge_start_failure_still_releases_the_lease(self):
with tempfile.TemporaryDirectory() as root:
root = Path(root)