Compare commits

...
Author SHA1 Message Date
The412Banner 94ae2ce846 test(stores): cover the GOG registry import without proot 2026-12-05 21:57:50 +00:00
The412Banner 0438887e91 fix(stores): keep host paths on Z: when the Bionic path lookup fails 2026-11-25 20:47:19 +00:00
The412Banner 2def4735fc fix(stores): name prepared Wine input files by their guest path without proot 2026-11-25 20:39:37 +00:00
The412Banner 4df3f775e1 fix(runtime): first-run setup no longer crashes when the app is in the background (#3212)
With targetSdk 34, Android refuses startForeground() while the app is in the background. RuntimeInstallService called it unguarded on the main thread, so the refusal (ForegroundServiceStartNotAllowedException) killed the app during first-run setup when the runtime finished while DroidDeck-Proton was still downloading (RuntimeInstallService.kt:49 via onStartCommand :22).

Both foreground starts now catch the refusal: a package hold stops the service and the downloads go on in the app, as when startForegroundService() itself is refused; a runtime install or removal still runs, without progress notifications.
2026-11-25 15:15:49 -05:00
Kurt Himebauch 6b570c573b fix(tabs): Apps tab shows when DroidDeck is the home app (#3215)
fix(tabs): Apps tab sits in the rail but hidden, and shows when DroidDeck becomes the home app
2026-11-25 14:47:18 -05:00
9 changed files with 153 additions and 8 deletions

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):
+18
View File
@@ -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__':
+25
View File
@@ -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')
+48
View File
@@ -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)