mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e63444be59 | ||
|
|
d164749a7f | ||
|
|
50c5fd79f7 |
No files matched your search
@@ -754,12 +754,17 @@ jobs:
|
||||
ln -sfn "$(cd "$jars" && pwd)" "$m2"
|
||||
echo "cache=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
- name: Cache Robolectric's Android jars
|
||||
- name: Restore Robolectric's Android jars
|
||||
id: robolectric-cache
|
||||
if: steps.robolectric-jars.outputs.cache == 'true'
|
||||
uses: actions/cache@v4
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: ../robolectric-jars
|
||||
key: robolectric-android-all-v2-${{ steps.robolectric.outputs.version }}
|
||||
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"
|
||||
- name: Unit tests
|
||||
id: unit-tests
|
||||
env:
|
||||
@@ -770,6 +775,34 @@ 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'
|
||||
|
||||
@@ -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.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://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://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.1/DroidDeck-0.7.1.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.11/DroidDeck-0.7.11.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).
|
||||
|
||||
@@ -87,7 +87,8 @@ object Syncthing {
|
||||
fun storageRoots(context: Context): List<File> =
|
||||
listOf(context.dataDir) + context.getExternalFilesDirs(null).filterNotNull().mapNotNull { it.parentFile }
|
||||
|
||||
fun guard(context: Context) = SyncthingGuard(folderRoot(context), storageRoots(context), listOf(home(context)))
|
||||
fun guard(context: Context, extraRoots: List<File> = emptyList()) =
|
||||
SyncthingGuard(folderRoot(context), storageRoots(context) + extraRoots, listOf(home(context)))
|
||||
|
||||
fun init(application: Application) {
|
||||
app = application.applicationContext
|
||||
|
||||
@@ -578,7 +578,7 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
|
||||
else GameDetail(key, s, a, lead, backLabel, hopRail = "games", onBack = back)
|
||||
}
|
||||
if (savedDialog) SavedDialog(emptyList(), onOpen = { id -> onSelect("sound:$id") }) { savedDialog = false }
|
||||
if (addingSoundtrack) SyncFolderPicker(stringResource(R.string.soundtracks_add_title), null, onDismiss = { addingSoundtrack = false }) { dir ->
|
||||
if (addingSoundtrack) SyncFolderPicker(stringResource(R.string.soundtracks_add_title), null, sharedStorage = true, onDismiss = { addingSoundtrack = false }) { dir ->
|
||||
addingSoundtrack = false
|
||||
a.onSoundtrackAdded(dir)
|
||||
}
|
||||
|
||||
@@ -48,8 +48,11 @@ internal class SyncLocation(val root: File, val label: String, val icon: ImageVe
|
||||
|
||||
internal fun containerHome(context: Context) = File(LinuxRuntime.rootDir(context), "root")
|
||||
|
||||
internal fun syncLocations(context: Context): List<SyncLocation> {
|
||||
internal fun syncLocations(context: Context, sharedStorage: Boolean = false): List<SyncLocation> {
|
||||
val volumes = pickVolumes(context)
|
||||
val storage = if (!sharedStorage) emptyList() else volumes.map {
|
||||
SyncLocation(it.root, it.label, if (it.removable) Icons.Outlined.SdCard else Icons.Outlined.Smartphone)
|
||||
}
|
||||
val roots = Syncthing.storageRoots(context)
|
||||
val shared = roots.drop(1).mapIndexed { i, root ->
|
||||
val volume = volumes.firstOrNull { root.path.startsWith(it.root.path + "/") }
|
||||
@@ -58,18 +61,23 @@ internal fun syncLocations(context: Context): List<SyncLocation> {
|
||||
}
|
||||
val home = containerHome(context).takeIf { it.isDirectory }?.let { SyncLocation(it, context.getString(R.string.sync_location_home), Icons.Outlined.Home) }
|
||||
return listOfNotNull(home, SyncLocation(Syncthing.folderRoot(context), context.getString(R.string.sync_location_sync), Icons.Outlined.FolderSpecial)) +
|
||||
shared + SyncLocation(roots.first(), context.getString(R.string.sync_location_app), Icons.Outlined.Folder)
|
||||
storage + shared + SyncLocation(roots.first(), context.getString(R.string.sync_location_app), Icons.Outlined.Folder)
|
||||
}
|
||||
|
||||
internal fun syncPickerGuard(context: Context, locations: List<SyncLocation>, sharedStorage: Boolean) =
|
||||
Syncthing.guard(context, if (sharedStorage) locations.map { it.root } else emptyList())
|
||||
|
||||
@Composable
|
||||
internal fun SyncFolderPicker(title: String, suggestedName: String?, onDismiss: () -> Unit, onPick: (File) -> Unit) {
|
||||
internal fun SyncFolderPicker(
|
||||
title: String, suggestedName: String?, sharedStorage: Boolean = false, onDismiss: () -> Unit, onPick: (File) -> Unit,
|
||||
) {
|
||||
val ctx = LocalContext.current
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val density = LocalDensity.current
|
||||
val shown = rememberShown(onDismiss)
|
||||
val close = { shown.targetState = false }
|
||||
val locations = remember { syncLocations(ctx) }
|
||||
val guard = remember { Syncthing.guard(ctx) }
|
||||
val locations = remember { syncLocations(ctx, sharedStorage) }
|
||||
val guard = remember { syncPickerGuard(ctx, locations, sharedStorage) }
|
||||
fun locationOf(d: File) = locations.filter { d.path == it.root.path || d.path.startsWith(it.root.path + "/") }.maxByOrNull { it.root.path.length }
|
||||
var dir by remember { mutableStateOf<File?>(containerHome(ctx).takeIf { it.isDirectory } ?: Syncthing.folderRoot(ctx).also { it.mkdirs() }) }
|
||||
var refresh by remember { mutableIntStateOf(0) }
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.os.Environment
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.sync.Syncthing
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
import java.io.File
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [33])
|
||||
class SyncFolderPickerTest {
|
||||
private val context = RuntimeEnvironment.getApplication()
|
||||
private val internal = Environment.getExternalStorageDirectory()
|
||||
private val music = File(internal, "Music")
|
||||
|
||||
@Test fun sharedStorageListsInternalStorageAndAllowsItsMusicFolder() {
|
||||
val locations = syncLocations(context, sharedStorage = true)
|
||||
val guard = syncPickerGuard(context, locations, sharedStorage = true)
|
||||
|
||||
assertTrue(locations.any { it.root.path == internal.path && it.label == context.getString(R.string.games_internal) })
|
||||
assertTrue(guard.allows(music.path))
|
||||
assertTrue(guard.browsable(music))
|
||||
}
|
||||
|
||||
@Test fun sharedStorageKeepsTheSyncthingConfigBlocked() {
|
||||
val guard = syncPickerGuard(context, syncLocations(context, sharedStorage = true), sharedStorage = true)
|
||||
|
||||
assertFalse(guard.allows(Syncthing.home(context).path))
|
||||
assertFalse(guard.browsable(Syncthing.home(context)))
|
||||
}
|
||||
|
||||
@Test fun theSyncthingPickerStaysInsideAppStorage() {
|
||||
val locations = syncLocations(context)
|
||||
val guard = syncPickerGuard(context, locations, sharedStorage = false)
|
||||
|
||||
assertFalse(locations.any { it.root.path == internal.path })
|
||||
assertFalse(guard.allows(music.path))
|
||||
assertTrue(guard.allows(Syncthing.folderRoot(context).path))
|
||||
}
|
||||
}
|
||||
@@ -477,28 +477,6 @@ 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)
|
||||
@@ -543,7 +521,6 @@ 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).
|
||||
|
||||
@@ -69,64 +69,6 @@ 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)
|
||||
|
||||
Reference in new issue
Block a user