mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94ae2ce846 | ||
|
|
0438887e91 | ||
|
|
2def4735fc | ||
|
|
4df3f775e1 | ||
|
|
6b570c573b |
No files matched your search
@@ -2384,6 +2384,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
homeScreenEnabled = HomeApp.isHomeScreenEnabled(this)
|
||||
homeAppSelected = homeScreenEnabled && HomeApp.isDefault(this)
|
||||
defaultHomeLabel = HomeApp.defaultLabel(this)
|
||||
com.droiddeck.launcher.ui.NavTabs.syncHomeApps(this, homeAppSelected)
|
||||
refreshAndroidApps()
|
||||
integrationState = readIntegration()
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class RuntimeInstallService : Service() {
|
||||
if (intent?.action == ACTION_PACKAGE) return holdPackage(startId)
|
||||
val removal = intent?.action == ACTION_REMOVE
|
||||
val release = intent?.let(::releaseFrom)
|
||||
startForeground(NOTIFICATION_ID, notification(getString(if (LinuxRuntimeInstaller.isMaintaining()) R.string.desktop_removing else if (removal) R.string.rtinst_removing else R.string.user_apps_starting), -1))
|
||||
val foreground = enterForeground(notification(getString(if (LinuxRuntimeInstaller.isMaintaining()) R.string.desktop_removing else if (removal) R.string.rtinst_removing else R.string.user_apps_starting), -1))
|
||||
if (release == null && !removal) {
|
||||
stopSelf(startId)
|
||||
return START_NOT_STICKY
|
||||
@@ -31,7 +31,7 @@ class RuntimeInstallService : Service() {
|
||||
val manager = getSystemService(NotificationManager::class.java)
|
||||
var shown = ""
|
||||
val progress = LinuxRuntimeInstaller.ProgressListener { stage, percent ->
|
||||
if ("$stage:$percent" != shown) {
|
||||
if (foreground && "$stage:$percent" != shown) {
|
||||
shown = "$stage:$percent"
|
||||
manager?.notify(NOTIFICATION_ID, notification(stage, percent))
|
||||
}
|
||||
@@ -46,7 +46,10 @@ class RuntimeInstallService : Service() {
|
||||
}
|
||||
|
||||
private fun holdPackage(startId: Int): Int {
|
||||
startForeground(NOTIFICATION_ID, notification(packageStage, packagePercent, packageTitle))
|
||||
if (!enterForeground(notification(packageStage, packagePercent, packageTitle))) {
|
||||
stopSelf(startId)
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
Thread({
|
||||
val manager = getSystemService(NotificationManager::class.java)
|
||||
var shown = ""
|
||||
@@ -65,6 +68,15 @@ class RuntimeInstallService : Service() {
|
||||
return START_NOT_STICKY
|
||||
}
|
||||
|
||||
/** Android 12+ refuses a foreground start while the app is in the background; the work then goes on without the notification. */
|
||||
private fun enterForeground(notification: Notification): Boolean = try {
|
||||
startForeground(NOTIFICATION_ID, notification)
|
||||
true
|
||||
} catch (e: IllegalStateException) {
|
||||
android.util.Log.w("RuntimeInstallService", "running without a foreground service: $e")
|
||||
false
|
||||
}
|
||||
|
||||
private fun notification(stage: String, percent: Int, title: String? = null): Notification {
|
||||
val manager = getSystemService(NotificationManager::class.java)
|
||||
manager?.createNotificationChannel(NotificationChannel(CHANNEL_ID, getString(R.string.setup_runtime),
|
||||
|
||||
@@ -448,6 +448,13 @@ object SessionPrefs {
|
||||
prefs(context).edit().putString("navTabHidden", keys.joinToString(",")).apply()
|
||||
}
|
||||
|
||||
fun appsTabHomeSeen(context: Context): Boolean? =
|
||||
prefs(context).takeIf { it.contains("appsTabHomeSeen") }?.getBoolean("appsTabHomeSeen", false)
|
||||
|
||||
fun setAppsTabHomeSeen(context: Context, seen: Boolean) {
|
||||
prefs(context).edit().putBoolean("appsTabHomeSeen", seen).apply()
|
||||
}
|
||||
|
||||
private fun idList(raw: String?): List<String> = raw.orEmpty().split(',').map { it.trim() }.filter { it.isNotEmpty() }
|
||||
|
||||
val STORES_SORTS = listOf("lastPlayed", "recentlyInstalled", "titleAsc", "titleDesc", "sizeDesc", "sizeAsc", "releaseDateDesc")
|
||||
|
||||
@@ -27,9 +27,9 @@ internal object DeveloperTools {
|
||||
internal object NavTabs {
|
||||
const val MORE = "more"
|
||||
val ALL = listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "android-apps", "agent")
|
||||
val DEFAULT_SHELVED = setOf("soundtracks", "components", "storage", "sync", "decky", "boot-movies", "android-apps", "agent")
|
||||
val DEFAULT_SHELVED = setOf("soundtracks", "components", "storage", "sync", "decky", "boot-movies", "agent")
|
||||
val DEFAULT_HIDDEN = setOf("android-apps", "agent")
|
||||
private val SHELVED_WHEN_NEW = setOf("storage", "sync", "decky", "boot-movies", "android-apps", "agent")
|
||||
private val SHELVED_WHEN_NEW = setOf("storage", "sync", "decky", "boot-movies", "agent")
|
||||
private val OLD_ORDER = listOf("steam", "games", "soundtracks", "stores", "downloads", "desktop", "agent", "components", "android-apps", "storage", "sync", "setup", "updates")
|
||||
private val OLD_SHELVED = setOf("soundtracks", "agent", "storage", "sync")
|
||||
private const val LAYOUT_VERSION = 2
|
||||
@@ -95,6 +95,15 @@ internal object NavTabs {
|
||||
else -> true
|
||||
}
|
||||
|
||||
// Apps only has content when DroidDeck is the home app, so it follows that state on each change and
|
||||
// otherwise stays wherever the user put it.
|
||||
fun syncHomeApps(context: Context, homeSelected: Boolean) {
|
||||
val seen = SessionPrefs.appsTabHomeSeen(context)
|
||||
SessionPrefs.setAppsTabHomeSeen(context, homeSelected)
|
||||
if (seen == homeSelected || (seen == null && !homeSelected)) return
|
||||
setHidden(context, "android-apps", !homeSelected)
|
||||
}
|
||||
|
||||
fun hideable(key: String) = key != "setup"
|
||||
|
||||
fun place(s: FrontEndState, key: String): TabPlace = when {
|
||||
|
||||
@@ -48,6 +48,21 @@ class NavTabsTest {
|
||||
assertTrue(NavTabs.isDefault())
|
||||
}
|
||||
|
||||
@Test fun appsFollowsTheHomeAppOnEachChangeAndOtherwiseKeepsTheUsersChoice() {
|
||||
NavTabs.syncHomeApps(ctx, false)
|
||||
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "android-apps"))
|
||||
NavTabs.syncHomeApps(ctx, true)
|
||||
assertEquals(TabPlace.BAR, NavTabs.place(state(), "android-apps"))
|
||||
NavTabs.setHidden(ctx, "android-apps", true)
|
||||
NavTabs.syncHomeApps(ctx, true)
|
||||
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "android-apps"))
|
||||
NavTabs.syncHomeApps(ctx, false)
|
||||
NavTabs.syncHomeApps(ctx, true)
|
||||
assertEquals(TabPlace.BAR, NavTabs.place(state(), "android-apps"))
|
||||
NavTabs.syncHomeApps(ctx, false)
|
||||
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "android-apps"))
|
||||
}
|
||||
|
||||
@Test fun showingMusicOnceKeepsItShownAfterReload() {
|
||||
place("soundtracks", TabPlace.BAR)
|
||||
NavTabs.load(ctx)
|
||||
@@ -219,12 +234,12 @@ class NavTabsTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
val last = navigationKeys(state()).last { it != NavTabs.MORE }
|
||||
val last = NavTabs.listed(state()).last { it !in NavTabs.shelved }
|
||||
compose.onNodeWithTag("tab-row-$last").requestFocus()
|
||||
compose.onNodeWithTag("tab-row-$last").performKeyPress(pad(android.view.KeyEvent.KEYCODE_BUTTON_Y))
|
||||
compose.onNodeWithTag("tab-row-$last").performKeyPress(pad(android.view.KeyEvent.KEYCODE_DPAD_DOWN))
|
||||
compose.onNodeWithTag("tab-row-$last").performKeyPress(pad(android.view.KeyEvent.KEYCODE_BUTTON_Y))
|
||||
compose.runOnIdle { assertEquals(last, NavTabs.more(state()).first()) }
|
||||
compose.runOnIdle { assertTrue(last in NavTabs.shelved) }
|
||||
compose.onNodeWithTag("tab-shown-desktop").performClick()
|
||||
compose.runOnIdle { assertFalse("desktop" in navigationKeys(state())) }
|
||||
compose.onNodeWithTag("tab-shown-setup").performClick()
|
||||
|
||||
@@ -158,7 +158,17 @@ def ask(channel, request, timeout=TIMEOUT, claim=False):
|
||||
|
||||
def windows_path(unix):
|
||||
tool = bionic_tool(os.environ.get("DD_STORE_PROTON", ""))
|
||||
return (tool and bionic_path(tool, unix)) or "Z:" + unix.replace("/", "\\")
|
||||
if tool:
|
||||
return bionic_path(tool, unix) or "Z:" + unix.replace("/", "\\")
|
||||
return "Z:" + guest_path(unix).replace("/", "\\")
|
||||
|
||||
|
||||
def guest_path(unix):
|
||||
root = os.environ.get("DDNATV_ROOT", "").rstrip("/")
|
||||
for host in dict.fromkeys(filter(None, (root, root and os.path.realpath(root)))):
|
||||
if unix == host or unix.startswith(host + "/"):
|
||||
return unix[len(host):] or "/"
|
||||
return unix
|
||||
|
||||
|
||||
def bionic_tool(proton):
|
||||
|
||||
@@ -170,10 +170,28 @@ class StorePaths(unittest.TestCase):
|
||||
os.environ.pop('DDNATV_ROOT', None)
|
||||
self.assertEqual('Z:\\home\\games\\b.reg', store.windows_path('/home/games/b.reg'))
|
||||
|
||||
def test_other_tools_name_rootfs_host_paths_by_their_guest_paths(self):
|
||||
(self.tool / 'bionic/launch.sh').unlink()
|
||||
with self.env():
|
||||
self.assertEqual('Z:\\tmp\\droiddeck-ea-1\\probe.bat', store.windows_path(ANDROID + '/tmp/droiddeck-ea-1/probe.bat'))
|
||||
self.assertEqual('Z:\\', store.windows_path(ANDROID))
|
||||
self.assertEqual('Z:\\data\\user\\0\\com.droiddeck.launcher\\files\\linuxfs2\\a.reg',
|
||||
store.windows_path(ANDROID + '2/a.reg'))
|
||||
self.assertEqual('Z:\\storage\\emulated\\0\\Games\\a.reg', store.windows_path('/storage/emulated/0/Games/a.reg'))
|
||||
real = '/data/data/com.droiddeck.launcher/files/linuxfs'
|
||||
with self.env(), patch.object(store.os.path, 'realpath', lambda path: real if path == ANDROID else path):
|
||||
self.assertEqual('Z:\\tmp\\droiddeck-ea-2\\registry.reg', store.windows_path(real + '/tmp/droiddeck-ea-2/registry.reg'))
|
||||
with patch.dict(os.environ, {'DD_STORE_PROTON': str(self.tool / 'proton')}):
|
||||
os.environ.pop('DDNATV_ROOT', None)
|
||||
self.assertEqual('Z:\\data\\user\\0\\com.droiddeck.launcher\\files\\linuxfs\\tmp\\c.reg',
|
||||
store.windows_path(ANDROID + '/tmp/c.reg'))
|
||||
|
||||
def test_a_failing_tool_keeps_the_guest_path(self):
|
||||
(self.tool / 'proton').write_text('#!/bin/sh\nexit 1\n')
|
||||
with self.env():
|
||||
self.assertEqual('Z:\\home\\games\\c.reg', store.windows_path('/home/games/c.reg'))
|
||||
self.assertEqual('Z:\\data\\user\\0\\com.droiddeck.launcher\\files\\linuxfs\\tmp\\c.reg',
|
||||
store.windows_path(ANDROID + '/tmp/c.reg'))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -921,6 +921,31 @@ class GogRegistry(unittest.TestCase):
|
||||
self.assertFalse((Path(root) / 'compat/pfx' / store.GOG_REGISTRY_MARK).exists())
|
||||
self.assertEqual('no-proton', store.apply_gog_registry(folder, root + '/compat', root + '/missing'))
|
||||
|
||||
def test_a_native_import_names_its_file_and_the_game_by_their_guest_paths(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp) / 'linuxfs'
|
||||
(root / 'tmp').mkdir(parents=True)
|
||||
folder = game(root / 'root', store_id='gog', ident='7')
|
||||
gog_script(folder, '7', [set_registry(root='HKLM', subkey='Software\\Game', valueName='Path',
|
||||
valueData='{app}', valueType='string')])
|
||||
proton = Path(tmp) / 'proton'
|
||||
proton.write_text('selected Proton')
|
||||
data = root / 'root/compat'
|
||||
imported = []
|
||||
def run(argv, **kwargs):
|
||||
source = argv[4]
|
||||
self.assertTrue(source.startswith('Z:\\tmp\\droiddeck-gog-'), source)
|
||||
self.assertTrue(source.endswith('\\registry.reg'), source)
|
||||
imported.append((root / source[3:].replace('\\', '/')).read_bytes()[2:].decode('utf-16-le'))
|
||||
(data / 'pfx').mkdir(parents=True, exist_ok=True)
|
||||
(data / 'pfx/system.reg').write_text('Wine registry')
|
||||
return subprocess.CompletedProcess(argv, 0)
|
||||
with patch.dict(os.environ, {'DDNATV_ROOT': str(root), 'DD_STORE_PROTON': str(proton)}), \
|
||||
patch.object(tempfile, 'tempdir', str(root / 'tmp')), \
|
||||
patch.object(store.subprocess, 'run', side_effect=run):
|
||||
self.assertEqual('written=1', store.apply_gog_registry(folder, str(data), str(proton)))
|
||||
self.assertIn('"Path"="Z:\\\\root\\\\Games\\\\Stores\\\\Epic\\\\Metalstorm"', imported[0])
|
||||
|
||||
def test_every_gog_launch_brings_the_registry_in(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder = game(root, store_id='gog')
|
||||
|
||||
@@ -3,6 +3,7 @@ import importlib.machinery
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
@@ -171,6 +172,53 @@ class EaHook(unittest.TestCase):
|
||||
(pfx / store.EA_HARDWARE).write_text(json.dumps(whole))
|
||||
self.assertEqual(store.ea_hardware(tmp, ''), (whole, 'cached'))
|
||||
|
||||
def native_session(self, tmp):
|
||||
root = Path(tmp) / 'linuxfs'
|
||||
(root / 'tmp').mkdir(parents=True)
|
||||
compat = root / 'root/compat'
|
||||
(compat / 'pfx').mkdir(parents=True)
|
||||
(compat / 'pfx/system.reg').write_text('')
|
||||
proton = Path(tmp) / 'proton'
|
||||
proton.write_text('')
|
||||
env = patch.dict('os.environ', {'DDNATV_ROOT': str(root), 'DD_STORE_PROTON': str(proton)})
|
||||
return root, compat, str(proton), env, patch.object(tempfile, 'tempdir', str(root / 'tmp'))
|
||||
|
||||
def test_a_native_probe_names_its_files_by_their_guest_paths(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root, compat, proton, env, tmpdir = self.native_session(tmp)
|
||||
seen = []
|
||||
|
||||
def run(command, **kwargs):
|
||||
bat = command[-1]
|
||||
seen.append(bat)
|
||||
text = (root / bat[3:].replace('\\', '/')).read_text()
|
||||
seen.extend(re.findall(r'"([A-Z]:[^"]*)"', text))
|
||||
return subprocess.CompletedProcess(command, 0)
|
||||
|
||||
with env, tmpdir, patch.object(store.subprocess, 'run', run):
|
||||
self.assertEqual('incomplete', store.ea_hardware(str(compat), proton)[1])
|
||||
self.assertTrue(seen)
|
||||
for path in seen:
|
||||
self.assertTrue(path.startswith('Z:\\tmp\\droiddeck-ea-'), path)
|
||||
|
||||
def test_a_native_registry_import_names_its_file_by_its_guest_path(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root, compat, proton, env, tmpdir = self.native_session(tmp)
|
||||
sources = []
|
||||
|
||||
def run(command, **kwargs):
|
||||
source = command[4]
|
||||
sources.append(source)
|
||||
self.assertTrue((root / source[3:].replace('\\', '/')).is_file(), source)
|
||||
return subprocess.CompletedProcess(command, 0)
|
||||
|
||||
sidecar = {'id': 'OFB-EAST:1', 'title': 'Game', 'extra': {'contentIds': '1'}}
|
||||
with env, tmpdir, patch.object(store.subprocess, 'run', run):
|
||||
self.assertEqual('written', store.ea_registry(root / 'root/Games/Game', sidecar, str(compat), proton))
|
||||
self.assertEqual(2, len(sources))
|
||||
for source in sources:
|
||||
self.assertTrue(source.startswith('Z:\\tmp\\droiddeck-ea-'), source)
|
||||
|
||||
def touchup_setup(self, tmp):
|
||||
folder = Path(tmp) / 'game'
|
||||
(folder / 'Touchup').mkdir(parents=True)
|
||||
|
||||
Reference in new issue
Block a user