mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 13:05:47 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fac175c3a | ||
|
|
3a752def58 | ||
|
|
07f2dc8e8f | ||
|
|
0f924aebb0 | ||
|
|
8ec499ae3f |
No files matched your search
@@ -3414,8 +3414,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (status == 0) SessionState.takeRelaunch()?.let { next ->
|
||||
next.putExtra(EXTRA_RETURN_HOME, intent.getBooleanExtra(EXTRA_RETURN_HOME, false))
|
||||
next.putExtra(EXTRA_LINK_TASK, intent.getIntExtra(EXTRA_LINK_TASK, -1))
|
||||
setIntent(next)
|
||||
recreate()
|
||||
relaunch(next)
|
||||
return@runOnUiThread
|
||||
}
|
||||
showEnded(status, hint)
|
||||
@@ -3423,6 +3422,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}, "session-end-hint").start()
|
||||
}
|
||||
|
||||
// recreate() keeps this window, and Compose content added to it afterwards never recomposes, so the
|
||||
// loading screen of the next session stays up over a running session. A new instance gets its own window.
|
||||
// This instance finishes first because the activity is singleTask and would otherwise take the intent itself.
|
||||
private fun relaunch(next: Intent) {
|
||||
closeAtOnce = true
|
||||
super.finish()
|
||||
startActivity(next)
|
||||
overridePendingTransition(0, 0)
|
||||
}
|
||||
|
||||
private fun showEnded(status: Int, hint: EndHint?) {
|
||||
if (status == 0 && hint?.evenOnSuccess != true) {
|
||||
finish()
|
||||
@@ -6050,8 +6059,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
Log.w(TAG, "ignoring agent start while session phase is ${SessionState.phase}")
|
||||
return
|
||||
}
|
||||
setIntent(intent)
|
||||
recreate()
|
||||
relaunch(android.content.Intent(intent).setClass(this, SessionActivity::class.java))
|
||||
return
|
||||
}
|
||||
if (this.intent.getBooleanExtra(EXTRA_RETURN_HOME, false)) intent.putExtra(EXTRA_RETURN_HOME, true)
|
||||
|
||||
@@ -33,6 +33,13 @@ object SocNames {
|
||||
fun name(model: String, platform: String = GpuInfo.systemProperty("ro.board.platform")): String? =
|
||||
MODELS[normalizedModel(model)] ?: PLATFORMS[platform.lowercase()]?.let { "$it family" }
|
||||
|
||||
// Without label's platform-family guess: a rebadged chip such as the Duo's CQ7790S reports a platform it is not.
|
||||
fun plainName(model: String = model(), maker: String = manufacturer()): String =
|
||||
MODELS[normalizedModel(model)]?.let { "$it ($model)" } ?: "$maker $model".trim()
|
||||
|
||||
private fun manufacturer(): String =
|
||||
if (Build.VERSION.SDK_INT >= 31) Build.SOC_MANUFACTURER.takeIf { it != Build.UNKNOWN }.orEmpty() else ""
|
||||
|
||||
fun label(model: String = model(), platform: String = GpuInfo.systemProperty("ro.board.platform")): String {
|
||||
val name = name(model, platform)
|
||||
return when {
|
||||
|
||||
@@ -28,12 +28,14 @@ object SessionFiles {
|
||||
"usr/local/bin/droiddeck-bottom-desktop" to "usr/local/bin/droiddeck-bottom-desktop",
|
||||
"usr/local/bin/droiddeck-gpu" to "usr/local/bin/droiddeck-gpu",
|
||||
"usr/local/bin/droiddeck-desktop-gpu" to "usr/local/bin/droiddeck-desktop-gpu",
|
||||
"usr/local/bin/droiddeck-device-info" to "usr/local/bin/droiddeck-device-info",
|
||||
"usr/local/bin/droiddeck-desktop-window-rules" to "usr/local/bin/droiddeck-desktop-window-rules",
|
||||
"usr/local/bin/droiddeck-library-perms" to "usr/local/bin/droiddeck-library-perms",
|
||||
"usr/local/bin/droiddeck-ime" to "usr/local/bin/droiddeck-ime",
|
||||
"usr/local/bin/kwin_wayland_wrapper" to "usr/local/bin/kwin_wayland_wrapper",
|
||||
"usr/lib/firefox/defaults/pref/droiddeck.js" to "usr/lib/firefox/defaults/pref/droiddeck.js",
|
||||
"etc/xdg/autostart/droiddeck-clipboard.desktop" to "etc/xdg/autostart/droiddeck-clipboard.desktop",
|
||||
"etc/xdg/fastfetch/config.jsonc" to "etc/xdg/fastfetch/config.jsonc",
|
||||
)
|
||||
|
||||
private val SERVICE_PACKS = mapOf(
|
||||
|
||||
@@ -669,6 +669,8 @@ class SessionService : Service() {
|
||||
guest.add("DROIDDECK_WSI_BYPASS_CHECK_MS=100")
|
||||
guest.add("WINE_OFFSCREEN_CHECK_MS=100")
|
||||
guest.add("DD_REFRESH=" + Math.round(SessionState.refreshHz))
|
||||
guest.add("DD_DEVICE_NAME=" + android.os.Build.MODEL)
|
||||
com.droiddeck.launcher.gpu.SocNames.plainName().takeIf { it.isNotEmpty() }?.let { guest.add("DD_SOC_NAME=$it") }
|
||||
guest.add("DD_LOG=" + sessionLog.path)
|
||||
guest.add("DD_DEBUG_DIR=" + sessionDir.path)
|
||||
if (EnhancedDiagnostics.isActive(this, sessionDir)) guest.add("DROIDDECK_ENHANCED_DIAGNOSTICS=1")
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.droiddeck.launcher
|
||||
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
class SessionRelaunchTest {
|
||||
// recreate() keeps the window, and Compose content set on it afterwards never recomposes (#2668):
|
||||
// a session relaunched that way kept its loading screen up over a running desktop.
|
||||
@Test fun sessionAndLauncherActivitiesNeverRecreateThemselves() {
|
||||
listOf("SessionActivity.kt", "FrontEndActivity.kt").forEach { name ->
|
||||
val code = File("src/main/java/com/droiddeck/launcher/$name").readLines()
|
||||
.map { it.substringBefore("//") }
|
||||
val calls = code.withIndex().filter { (_, line) -> Regex("""\brecreate\(\)""").containsMatchIn(line) }
|
||||
assertTrue("$name calls recreate() at line(s) ${calls.map { it.index + 1 }}", calls.isEmpty())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,4 +32,9 @@ class SocNamesTest {
|
||||
assertNull(SocNames.name("SM8975-PRO", ""))
|
||||
assertNull(SocNames.name("Qualcomm SM8975", ""))
|
||||
}
|
||||
@Test fun plainNameNeverGuessesFromThePlatform() {
|
||||
assertEquals("Snapdragon 8 Gen 2 (SM8550)", SocNames.plainName("SM8550", "QTI"))
|
||||
assertEquals("Moorechip CQ7790S", SocNames.plainName("CQ7790S", "Moorechip"))
|
||||
assertEquals("CQ7790S", SocNames.plainName("CQ7790S", ""))
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,8 @@ library list, before anything is published.
|
||||
moves (it sat frozen). The X pointer is asked for only while a cursor image is drawn - every
|
||||
vblank while shown, every 50 ms while hidden for inactivity - since each ask is a blocking round
|
||||
trip to Xwayland on the paint thread; with no image, wlserver's position is used as upstream does.
|
||||
Only a move of the X pointer is followed, not where the X server starts it (the screen centre):
|
||||
a window that gains focus is entered at the cursor, and Big Picture then hovered its centre tile.
|
||||
- `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
|
||||
|
||||
@@ -55,7 +55,7 @@ diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp
|
||||
index 10990b8..08afbc4 100644
|
||||
--- a/src/steamcompmgr.cpp
|
||||
+++ b/src/steamcompmgr.cpp
|
||||
@@ -2025,18 +2025,53 @@ void MouseCursor::UpdatePosition()
|
||||
@@ -2025,18 +2025,58 @@ void MouseCursor::UpdatePosition()
|
||||
if ( pConstraint && pConstraint->current.cursor_hint.enabled )
|
||||
{
|
||||
m_bConstrained = true;
|
||||
@@ -102,7 +102,12 @@ index 10990b8..08afbc4 100644
|
||||
+ &win_x, &win_y,
|
||||
+ &mask );
|
||||
+
|
||||
+ if ( root_x != m_x || root_y != m_y )
|
||||
+ // The X server starts its pointer at the screen centre; only a later move is input.
|
||||
+ const bool bRootMoved = m_bRootQueried && ( root_x != m_nRootX || root_y != m_nRootY );
|
||||
+ m_bRootQueried = true;
|
||||
+ m_nRootX = root_x;
|
||||
+ m_nRootY = root_y;
|
||||
+ if ( bRootMoved && ( root_x != m_x || root_y != m_y ) )
|
||||
+ {
|
||||
+ m_x = root_x;
|
||||
+ m_y = root_y;
|
||||
@@ -117,11 +122,13 @@ diff --git a/src/steamcompmgr.hpp b/src/steamcompmgr.hpp
|
||||
index c428784..bd62fd1 100644
|
||||
--- a/src/steamcompmgr.hpp
|
||||
+++ b/src/steamcompmgr.hpp
|
||||
@@ -109,6 +109,7 @@ private:
|
||||
@@ -109,6 +109,9 @@ private:
|
||||
|
||||
int m_x = 0, m_y = 0;
|
||||
bool m_bConstrained = false;
|
||||
+ uint64_t m_ulLastPointerQuery = 0;
|
||||
+ bool m_bRootQueried = false;
|
||||
+ int m_nRootX = 0, m_nRootY = 0;
|
||||
int m_hotspotX = 0, m_hotspotY = 0;
|
||||
|
||||
gamescope::OwningRc<CVulkanTexture> m_texture;
|
||||
@@ -0,0 +1,14 @@
|
||||
diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp
|
||||
--- a/src/steamcompmgr.cpp
|
||||
+++ b/src/steamcompmgr.cpp
|
||||
@@ -5818,7 +5818,9 @@
|
||||
if ( pFocus->inputFocusWindow->GetFocus()->bResetToCorner )
|
||||
{
|
||||
wlserver_lock();
|
||||
- wlserver_mousewarp( pFocus->inputFocusWindow->GetGeometry().nWidth / 2, pFocus->inputFocusWindow->GetGeometry().nHeight / 2, 0, true );
|
||||
+ // Only the corner reaches the client: a page that loads during this reset keeps the centre as its hover.
|
||||
+ wlserver.mouse_surface_cursorx = pFocus->inputFocusWindow->GetGeometry().nWidth / 2;
|
||||
+ wlserver.mouse_surface_cursory = pFocus->inputFocusWindow->GetGeometry().nHeight / 2;
|
||||
wlserver_fake_mouse_pos( pFocus->inputFocusWindow->GetGeometry().nWidth - 1, pFocus->inputFocusWindow->GetGeometry().nHeight - 1 );
|
||||
wlserver_unlock();
|
||||
}
|
||||
@@ -38,8 +38,9 @@ python3 /usr/local/bin/droiddeck-desktop-programs 2>&1 | sed 's/^/[programs] /'
|
||||
# start, and a panel made before this version (Kubuntu's own, or the first SteamOS one without the
|
||||
# pager, clock and Plasma's stock pins) is set aside once so Plasma lays out the current one.
|
||||
dd_layout=/usr/share/plasma/look-and-feel/com.valve.vapor.desktop/contents/layouts
|
||||
dd_layout_installed=0
|
||||
if [ -d "$dd_layout" ]; then
|
||||
cat > "$dd_layout/org.kde.plasma.desktop-layout.js" <<'LAYOUT'
|
||||
if cat > "$dd_layout/org.kde.plasma.desktop-layout.js" <<'LAYOUT'
|
||||
var desktops = desktopsForActivity(currentActivity());
|
||||
for (var i = 0; i < desktops.length; i++) {
|
||||
desktops[i].wallpaperPlugin = "org.kde.image";
|
||||
@@ -111,10 +112,13 @@ clock.currentConfigGroup = ["Appearance"];
|
||||
clock.writeConfig("dateFormat", "isoDate");
|
||||
panel.addWidget("org.kde.plasma.showdesktop");
|
||||
LAYOUT
|
||||
then
|
||||
dd_layout_installed=1
|
||||
fi
|
||||
fi
|
||||
dd_panel_rc="${XDG_CONFIG_HOME:-$HOME/.config}/plasma-org.kde.plasma.desktop-appletsrc"
|
||||
dd_panel_stamp="${XDG_CONFIG_HOME:-$HOME/.config}/droiddeck-panel-layout"
|
||||
if [ "$(cat "$dd_panel_stamp" 2>/dev/null)" != steamos-2 ]; then
|
||||
if [ "$dd_layout_installed" -eq 1 ] && [ "$(cat "$dd_panel_stamp" 2>/dev/null)" != steamos-2 ]; then
|
||||
dd_panel_backup="$dd_panel_rc.before-steamos-2"
|
||||
[ -e "$dd_panel_backup" ] && dd_panel_backup="$dd_panel_backup.$$"
|
||||
if [ ! -f "$dd_panel_rc" ] || mv "$dd_panel_rc" "$dd_panel_backup"; then
|
||||
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# The device tree on Android handhelds names the SoC vendor's reference board ("Kera MTP") and an
|
||||
# internal codename for the CPU, so the device and SoC names come from Android through the session.
|
||||
case "$1" in
|
||||
host)
|
||||
if [ -n "$DD_DEVICE_NAME" ]; then
|
||||
printf '%s\n' "$DD_DEVICE_NAME"
|
||||
else
|
||||
tr -d '\0' < /proc/device-tree/model 2>/dev/null
|
||||
echo
|
||||
fi
|
||||
;;
|
||||
cpu)
|
||||
name=${DD_SOC_NAME:-$(cat /sys/devices/soc0/machine 2>/dev/null)}
|
||||
cores=$(getconf _NPROCESSORS_CONF)
|
||||
mhz=$(cat /sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_max_freq 2>/dev/null | sort -n | tail -n 1)
|
||||
if [ -n "$mhz" ]; then
|
||||
printf '%s (%s) @ %s GHz\n' "$name" "$cores" "$(awk -v k="$mhz" 'BEGIN { printf "%.2f", k / 1000000 }')"
|
||||
else
|
||||
printf '%s (%s)\n' "$name" "$cores"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "usage: droiddeck-device-info host|cpu" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
|
||||
"logo": {
|
||||
"type": "file",
|
||||
"source": "/usr/share/droiddeck/fastfetch/logo.txt",
|
||||
"color": {
|
||||
"1": "38;2;255;255;255",
|
||||
"2": "38;2;26;159;255"
|
||||
},
|
||||
"padding": { "right": 3 }
|
||||
},
|
||||
"modules": [
|
||||
"title", "separator", "os",
|
||||
{ "type": "command", "key": "Host", "text": "droiddeck-device-info host" },
|
||||
"kernel", "uptime", "packages", "shell",
|
||||
"display", "de", "wm", "wmtheme", "theme", "icons", "font", "cursor",
|
||||
"terminal",
|
||||
{ "type": "command", "key": "CPU", "text": "droiddeck-device-info cpu" },
|
||||
"gpu", "memory", "swap",
|
||||
{ "type": "disk", "key": "Disk", "folders": "/", "format": "{size-used} / {size-total} ({size-percentage})" },
|
||||
{ "type": "battery", "key": "Battery" },
|
||||
"locale",
|
||||
"break", "colors"
|
||||
]
|
||||
}
|
||||
@@ -27,10 +27,12 @@ def source_assets(overlay=OVERLAY):
|
||||
result = {source: 'assets/linuxfs/' + source.relative_to(overlay).as_posix() for source in sources}
|
||||
if overlay == OVERLAY:
|
||||
desktop = overlay.parent / 'desktop'
|
||||
for name in ['droiddeck-desktop', 'droiddeck-gpu', 'droiddeck-desktop-gpu', 'kwin_wayland_wrapper']:
|
||||
for name in ['droiddeck-desktop', 'droiddeck-gpu', 'droiddeck-desktop-gpu', 'droiddeck-device-info',
|
||||
'kwin_wayland_wrapper']:
|
||||
result[desktop / name] = 'assets/linuxfs/usr/local/bin/' + name
|
||||
result[desktop / 'firefox-droiddeck.js'] = 'assets/linuxfs/usr/lib/firefox/defaults/pref/droiddeck.js'
|
||||
result[desktop / 'droiddeck-clipboard.desktop'] = 'assets/linuxfs/etc/xdg/autostart/droiddeck-clipboard.desktop'
|
||||
result[desktop / 'fastfetch.jsonc'] = 'assets/linuxfs/etc/xdg/fastfetch/config.jsonc'
|
||||
result[overlay.parent.parent / 'mangoapp/mangoapp'] = 'assets/linuxfs/usr/local/bin/mangoapp'
|
||||
return result
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
DESKTOP = Path(__file__).resolve().parents[1] / "linuxfs/desktop"
|
||||
|
||||
|
||||
class DesktopDeviceInfoTest(unittest.TestCase):
|
||||
def run_info(self, what, **env):
|
||||
return subprocess.run(["sh", str(DESKTOP / "droiddeck-device-info"), what], capture_output=True, text=True,
|
||||
env={**os.environ, **env}, check=True).stdout
|
||||
|
||||
def test_names_come_from_the_session(self):
|
||||
self.assertEqual(self.run_info("host", DD_DEVICE_NAME="Retroid Pocket Duo"), "Retroid Pocket Duo\n")
|
||||
self.assertRegex(self.run_info("cpu", DD_SOC_NAME="Moorechip CQ7790S"),
|
||||
r"^Moorechip CQ7790S \(\d+\)( @ \d+\.\d\d GHz)?\n$")
|
||||
|
||||
def test_fastfetch_uses_it_for_host_and_cpu(self):
|
||||
text = re.sub(r"^\s*//.*$", "", (DESKTOP / "fastfetch.jsonc").read_text(), flags=re.M)
|
||||
modules = {m["key"]: m["text"] for m in json.loads(text)["modules"] if isinstance(m, dict) and m.get("type") == "command"}
|
||||
self.assertEqual(modules, {"Host": "droiddeck-device-info host", "CPU": "droiddeck-device-info cpu"})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -19,10 +19,11 @@ def block(first, last):
|
||||
return DESKTOP[start:DESKTOP.index(last, start) + len(last)]
|
||||
|
||||
|
||||
def run(script, home):
|
||||
def run(script, home, layout_installed=True):
|
||||
environment = {key: value for key, value in os.environ.items() if key != 'XDG_CONFIG_HOME'}
|
||||
environment['HOME'] = str(home)
|
||||
result = subprocess.run(['bash', '-c', script], env=environment, capture_output=True, text=True, timeout=5)
|
||||
prefix = 'dd_layout_installed=1\n' if layout_installed else ''
|
||||
result = subprocess.run(['bash', '-c', prefix + script], env=environment, capture_output=True, text=True, timeout=5)
|
||||
if result.returncode != 0:
|
||||
raise AssertionError(result.stderr)
|
||||
|
||||
@@ -101,6 +102,52 @@ class DesktopSteamosPanelTest(unittest.TestCase):
|
||||
for language in ('ja', 'ko', 'th', 'zh_CN', 'zh_TW', 'hi'):
|
||||
self.assertIn('"' + language + '"', OVERLAY_LAYOUT)
|
||||
|
||||
def test_panel_migration_is_skipped_when_layout_directory_is_missing(self):
|
||||
with tempfile.TemporaryDirectory() as home:
|
||||
home = Path(home)
|
||||
config = home / '.config'
|
||||
config.mkdir()
|
||||
(config / RC).write_text('existing panel\n')
|
||||
layout_dir = home / 'missing-layout'
|
||||
script = block('dd_layout=', '# startplasma applies this file')
|
||||
script = script.replace('dd_layout=' + LAYOUT_DIR, 'dd_layout=' + layout_dir.as_posix())
|
||||
run(script, home)
|
||||
self.assertEqual('existing panel\n', (config / RC).read_text())
|
||||
self.assertFalse((config / (RC + '.before-steamos-2')).exists())
|
||||
self.assertFalse((config / STAMP).exists())
|
||||
|
||||
def test_panel_migration_is_skipped_when_layout_write_fails(self):
|
||||
with tempfile.TemporaryDirectory() as home:
|
||||
home = Path(home)
|
||||
config = home / '.config'
|
||||
config.mkdir()
|
||||
(config / RC).write_text('existing panel\n')
|
||||
layout_dir = home / 'layouts'
|
||||
layout_dir.mkdir()
|
||||
(layout_dir / 'org.kde.plasma.desktop-layout.js').mkdir()
|
||||
script = block('dd_layout=', '# startplasma applies this file')
|
||||
script = script.replace('dd_layout=' + LAYOUT_DIR, 'dd_layout=' + layout_dir.as_posix())
|
||||
run(script, home)
|
||||
self.assertEqual('existing panel\n', (config / RC).read_text())
|
||||
self.assertFalse((config / (RC + '.before-steamos-2')).exists())
|
||||
self.assertFalse((config / STAMP).exists())
|
||||
|
||||
def test_panel_migration_runs_after_layout_write_succeeds(self):
|
||||
with tempfile.TemporaryDirectory() as home:
|
||||
home = Path(home)
|
||||
config = home / '.config'
|
||||
config.mkdir()
|
||||
(config / RC).write_text('old panel\n')
|
||||
layout_dir = home / 'layouts'
|
||||
layout_dir.mkdir()
|
||||
script = block('dd_layout=', '# startplasma applies this file')
|
||||
script = script.replace('dd_layout=' + LAYOUT_DIR, 'dd_layout=' + layout_dir.as_posix())
|
||||
run(script, home)
|
||||
self.assertTrue((layout_dir / 'org.kde.plasma.desktop-layout.js').is_file())
|
||||
self.assertFalse((config / RC).exists())
|
||||
self.assertEqual('old panel\n', (config / (RC + '.before-steamos-2')).read_text())
|
||||
self.assertEqual('steamos-2', (config / STAMP).read_text().strip())
|
||||
|
||||
def test_the_panel_is_prepared_before_plasma_starts(self):
|
||||
for marker in ('dd_layout=', 'dd_panel_rc='):
|
||||
self.assertLess(DESKTOP.index(marker), DESKTOP.index('dbus-run-session -- startplasma-wayland'))
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
{
|
||||
"$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
|
||||
"logo": {
|
||||
"type": "file",
|
||||
"source": "/usr/share/droiddeck/fastfetch/logo.txt",
|
||||
"color": {
|
||||
"1": "38;2;255;255;255",
|
||||
"2": "38;2;26;159;255"
|
||||
},
|
||||
"padding": { "right": 3 }
|
||||
},
|
||||
"modules": [
|
||||
"title", "separator", "os", "host", "kernel", "uptime", "packages", "shell",
|
||||
"display", "de", "wm", "wmtheme", "theme", "icons", "font", "cursor",
|
||||
"terminal", "cpu", "gpu", "memory", "swap", "disk", "battery", "locale",
|
||||
"break", "colors"
|
||||
]
|
||||
}
|
||||
@@ -154,7 +154,7 @@ new file mode 100755
|
||||
index 0000000..d43c5fc
|
||||
--- /dev/null
|
||||
+++ b/crates/xodus-cli/src/commands/legacy_install.rs
|
||||
@@ -0,0 +1,1406 @@
|
||||
@@ -0,0 +1,1527 @@
|
||||
+//! Installs a legacy Store title: resolve, license, download, extract.
|
||||
+//!
|
||||
+//! `streaming` only understands MSIXVC, where the container *is* the game and
|
||||
@@ -739,7 +739,7 @@ index 0000000..d43c5fc
|
||||
+ progress.bytes(high, total);
|
||||
+ };
|
||||
+ if extracted != ExitCode::SUCCESS {
|
||||
+ return fail("extract-failed", "Could not unpack the package; the download is kept for a retry");
|
||||
+ return fail("extract-failed", "Could not unpack the package; retrying may require downloading the bundle again because containers are removed to save disk space");
|
||||
+ }
|
||||
+ // Drop each container as soon as it is unpacked: a full title is tens of
|
||||
+ // gigabytes, and holding the archive and its contents at once can fill
|
||||
@@ -813,15 +813,24 @@ index 0000000..d43c5fc
|
||||
+ let Ok(text) = std::fs::read_to_string(manifest) else {
|
||||
+ return Vec::new();
|
||||
+ };
|
||||
+ use quick_xml::events::Event;
|
||||
+ let mut reader = quick_xml::Reader::from_str(&text);
|
||||
+ let mut names: Vec<String> = Vec::new();
|
||||
+ for chunk in text.split("<PackageDependency").skip(1) {
|
||||
+ let Some(tag) = chunk.split('>').next() else { continue };
|
||||
+ let Some(start) = tag.find("Name=\"") else { continue };
|
||||
+ let rest = &tag[start + "Name=\"".len()..];
|
||||
+ let Some(end) = rest.find('"') else { continue };
|
||||
+ let name = rest[..end].trim();
|
||||
+ if !name.is_empty() && !names.iter().any(|seen| seen == name) {
|
||||
+ names.push(name.to_string());
|
||||
+ loop {
|
||||
+ match reader.read_event() {
|
||||
+ Ok(Event::Start(tag)) | Ok(Event::Empty(tag)) if tag.local_name().as_ref() == "PackageDependency" => {
|
||||
+ for attribute in tag.attributes().flatten() {
|
||||
+ if attribute.key.local_name().as_ref() != "Name" { continue; }
|
||||
+ let Ok(name) = attribute.unescape_value() else { continue };
|
||||
+ let name = name.trim();
|
||||
+ if !name.is_empty() && !names.iter().any(|seen| seen == name) {
|
||||
+ names.push(name.to_string());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ Ok(Event::Eof) => break,
|
||||
+ Ok(_) => {}
|
||||
+ Err(_) => return Vec::new(),
|
||||
+ }
|
||||
+ }
|
||||
+ names
|
||||
@@ -994,8 +1003,8 @@ index 0000000..d43c5fc
|
||||
+ for folder in level {
|
||||
+ let manifest = folder.join(LEGACY_MANIFEST);
|
||||
+ if manifest.is_file() {
|
||||
+ let text = std::fs::read_to_string(&manifest).unwrap_or_default().to_ascii_lowercase();
|
||||
+ if text.contains("processorarchitecture=\"x64\"") {
|
||||
+ let text = std::fs::read_to_string(&manifest).unwrap_or_default();
|
||||
+ if identity_is_x64(&text) {
|
||||
+ return Some(folder);
|
||||
+ }
|
||||
+ }
|
||||
@@ -1011,6 +1020,24 @@ index 0000000..d43c5fc
|
||||
+ None
|
||||
+}
|
||||
+
|
||||
+/// Reads ProcessorArchitecture only from an Identity element, ignoring comments and text.
|
||||
+fn identity_is_x64(text: &str) -> bool {
|
||||
+ use quick_xml::events::Event;
|
||||
+ let mut reader = quick_xml::Reader::from_str(text);
|
||||
+ loop {
|
||||
+ match reader.read_event() {
|
||||
+ Ok(Event::Start(tag)) | Ok(Event::Empty(tag)) if tag.local_name().as_ref() == "Identity" => {
|
||||
+ return tag.attributes().flatten().any(|attribute| {
|
||||
+ attribute.key.local_name().as_ref() == "ProcessorArchitecture"
|
||||
+ && attribute.unescape_value().is_ok_and(|value| value.eq_ignore_ascii_case("x64"))
|
||||
+ });
|
||||
+ }
|
||||
+ Ok(Event::Eof) | Err(_) => return false,
|
||||
+ Ok(_) => {}
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/// The Windows Update category of the framework's x64 package, or of whichever
|
||||
+/// package the product lists first when no package names an architecture.
|
||||
+fn framework_category(document: &serde_json::Value) -> Option<String> {
|
||||
@@ -1057,8 +1084,18 @@ index 0000000..d43c5fc
|
||||
+/// and records what it copied so a later attempt can take exactly that back.
|
||||
+fn copy_libraries(from: &Path, to: &Path) -> Result<(), String> {
|
||||
+ let mut copied: Vec<String> = Vec::new();
|
||||
+ copy_libraries_into(from, to, &mut copied)?;
|
||||
+ std::fs::write(from.join(COPIED), copied.join("\n")).map_err(|error| format!("framework copy list failed: {error}"))?;
|
||||
+ if let Err(error) = copy_libraries_into(from, to, &mut copied) {
|
||||
+ for name in &copied {
|
||||
+ let _ = std::fs::remove_file(to.join(name));
|
||||
+ }
|
||||
+ return Err(error);
|
||||
+ }
|
||||
+ if let Err(error) = std::fs::write(from.join(COPIED), copied.join("\n")) {
|
||||
+ for name in &copied {
|
||||
+ let _ = std::fs::remove_file(to.join(name));
|
||||
+ }
|
||||
+ return Err(format!("framework copy list failed: {error}"));
|
||||
+ }
|
||||
+ Ok(())
|
||||
+}
|
||||
+
|
||||
@@ -1079,7 +1116,16 @@ index 0000000..d43c5fc
|
||||
+ if target.exists() {
|
||||
+ continue;
|
||||
+ }
|
||||
+ std::fs::copy(&path, &target).map_err(|error| format!("framework copy failed: {error}"))?;
|
||||
+ let temporary = to.join(format!(".{}.copying-{}", file_name.to_string_lossy(), std::process::id()));
|
||||
+ let _ = std::fs::remove_file(&temporary);
|
||||
+ if let Err(error) = std::fs::copy(&path, &temporary) {
|
||||
+ let _ = std::fs::remove_file(&temporary);
|
||||
+ return Err(format!("framework copy failed: {error}"));
|
||||
+ }
|
||||
+ if let Err(error) = std::fs::rename(&temporary, &target) {
|
||||
+ let _ = std::fs::remove_file(&temporary);
|
||||
+ return Err(format!("framework publish failed: {error}"));
|
||||
+ }
|
||||
+ copied.push(file_name.to_string_lossy().into_owned());
|
||||
+ }
|
||||
+ Ok(())
|
||||
@@ -1119,10 +1165,19 @@ index 0000000..d43c5fc
|
||||
+ ));
|
||||
+ }
|
||||
+ let inner = candidates.remove(0);
|
||||
+ for entry in std::fs::read_dir(&inner)
|
||||
+ let entries: Vec<_> = std::fs::read_dir(&inner)
|
||||
+ .map_err(|error| format!("Could not list the package folder: {error}"))?
|
||||
+ .filter_map(Result::ok)
|
||||
+ {
|
||||
+ .collect();
|
||||
+ if !updating {
|
||||
+ for entry in &entries {
|
||||
+ let name = entry.file_name();
|
||||
+ if !is_package_metadata(&name) && destination.join(&name).exists() {
|
||||
+ return Err(format!("Extraction would overwrite {}", destination.join(name).display()));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ for entry in entries {
|
||||
+ let name = entry.file_name();
|
||||
+ let target = destination.join(&name);
|
||||
+ let metadata = is_package_metadata(&name);
|
||||
@@ -1142,16 +1197,41 @@ index 0000000..d43c5fc
|
||||
+ if !existing.is_empty() && !updating && !metadata {
|
||||
+ return Err(format!("Extraction would overwrite {}", target.display()));
|
||||
+ }
|
||||
+ for old in existing {
|
||||
+ let replaced = if old.is_dir() {
|
||||
+ std::fs::remove_dir_all(&old)
|
||||
+ } else {
|
||||
+ std::fs::remove_file(&old)
|
||||
+ };
|
||||
+ replaced.map_err(|error| format!("Could not replace an installed file: {error}"))?;
|
||||
+ let mut backups: Vec<(PathBuf, PathBuf)> = Vec::new();
|
||||
+ for (index, old) in existing.iter().enumerate() {
|
||||
+ let backup = destination.join(format!(".droiddeck-replace-backup-{}-{}", std::process::id(), index));
|
||||
+ if let Err(error) = std::fs::rename(old, &backup) {
|
||||
+ let mut restore_error = None;
|
||||
+ for (original, saved) in backups.iter().rev() {
|
||||
+ if let Err(error) = std::fs::rename(saved, original) {
|
||||
+ restore_error = Some(error);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ if let Some(restore_error) = restore_error {
|
||||
+ return Err(format!("Could not preserve the installed entry ({error}); restoring a backup also failed ({restore_error})"));
|
||||
+ }
|
||||
+ return Err(format!("Could not preserve the installed entry: {error}"));
|
||||
+ }
|
||||
+ backups.push((old.clone(), backup));
|
||||
+ }
|
||||
+ if let Err(error) = std::fs::rename(entry.path(), &target) {
|
||||
+ let mut restore_error = None;
|
||||
+ for (original, saved) in backups.iter().rev() {
|
||||
+ if let Err(error) = std::fs::rename(saved, original) {
|
||||
+ restore_error = Some(error);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ if let Some(restore_error) = restore_error {
|
||||
+ return Err(format!("Could not move extracted file ({error}); restoring a backup also failed ({restore_error})"));
|
||||
+ }
|
||||
+ return Err(format!("Could not move an extracted file: {error}"));
|
||||
+ }
|
||||
+ for (_, backup) in backups {
|
||||
+ let removed = if backup.is_dir() { std::fs::remove_dir_all(&backup) } else { std::fs::remove_file(&backup) };
|
||||
+ removed.map_err(|error| format!("Could not remove replaced backup: {error}"))?;
|
||||
+ }
|
||||
+ std::fs::rename(entry.path(), &target)
|
||||
+ .map_err(|error| format!("Could not move an extracted file: {error}"))?;
|
||||
+ }
|
||||
+ std::fs::remove_dir(&inner).map_err(|error| format!("Could not remove the package folder: {error}"))?;
|
||||
+ Ok(())
|
||||
@@ -1165,7 +1245,9 @@ index 0000000..d43c5fc
|
||||
+ if applications.len() > 1 {
|
||||
+ let x64: Vec<PathBuf> = applications
|
||||
+ .iter()
|
||||
+ .filter(|folder| manifest_text(folder).contains("processorarchitecture=\"x64\""))
|
||||
+ .filter(|folder| {
|
||||
+ identity_is_x64(&manifest_text_original(folder))
|
||||
+ })
|
||||
+ .cloned()
|
||||
+ .collect();
|
||||
+ if x64.len() == 1 {
|
||||
@@ -1176,22 +1258,41 @@ index 0000000..d43c5fc
|
||||
+}
|
||||
+
|
||||
+fn manifest_text(folder: &Path) -> String {
|
||||
+ manifest_text_original(folder).to_ascii_lowercase()
|
||||
+}
|
||||
+
|
||||
+fn manifest_text_original(folder: &Path) -> String {
|
||||
+ [LEGACY_MANIFEST, MANIFEST]
|
||||
+ .iter()
|
||||
+ .filter_map(|name| std::fs::read_to_string(folder.join(name)).ok())
|
||||
+ .collect::<Vec<_>>()
|
||||
+ .join("
|
||||
+")
|
||||
+ .to_ascii_lowercase()
|
||||
+ .join("\n")
|
||||
+}
|
||||
+
|
||||
+fn declares_application(folder: &Path) -> bool {
|
||||
+ let text = manifest_text(folder);
|
||||
+ opens_element(&text, "<application") || opens_element(&text, "<executable")
|
||||
+ use quick_xml::events::Event;
|
||||
+ for (name, expected) in [
|
||||
+ (LEGACY_MANIFEST, "Application"),
|
||||
+ (MANIFEST, "Application"),
|
||||
+ ("MicrosoftGame.config", "Executable"),
|
||||
+ ] {
|
||||
+ let Ok(text) = std::fs::read_to_string(folder.join(name)) else { continue };
|
||||
+ let mut reader = quick_xml::Reader::from_str(&text);
|
||||
+ loop {
|
||||
+ match reader.read_event() {
|
||||
+ Ok(Event::Start(tag)) | Ok(Event::Empty(tag))
|
||||
+ if tag.local_name().as_ref() == expected => return true,
|
||||
+ Ok(Event::Eof) | Err(_) => break,
|
||||
+ Ok(_) => {}
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ false
|
||||
+}
|
||||
+
|
||||
+/// Whether [text] opens [tag] as its own element, so `<Application Id=` and an attribute on the next
|
||||
+/// line count and `<Applications>` does not.
|
||||
+/// line count and `<Applications>` does not. Used by the focused parser test only.
|
||||
+#[cfg(test)]
|
||||
+fn opens_element(text: &str, tag: &str) -> bool {
|
||||
+ text.match_indices(tag).any(|(at, _)| {
|
||||
+ text[at + tag.len()..].chars().next().is_some_and(|next| next.is_whitespace() || next == '>' || next == '/')
|
||||
@@ -1441,6 +1542,23 @@ index 0000000..d43c5fc
|
||||
+ }
|
||||
+
|
||||
+ #[test]
|
||||
+ fn x64_identity_ignores_architecture_text_in_comments_and_other_elements() {
|
||||
+ assert!(!identity_is_x64(r#"<Package><!-- ProcessorArchitecture = "x64" --><Identity ProcessorArchitecture="x86"/></Package>"#));
|
||||
+ assert!(!identity_is_x64(r#"<Package><Other ProcessorArchitecture="x64"/><Identity ProcessorArchitecture="x86"/></Package>"#));
|
||||
+ assert!(identity_is_x64(r#"<Package><Identity ProcessorArchitecture = 'x64'/></Package>"#));
|
||||
+ }
|
||||
+
|
||||
+ #[test]
|
||||
+ fn application_scan_ignores_application_elements_inside_comments() {
|
||||
+ let root = scratch("commented-app");
|
||||
+ std::fs::write(root.join(LEGACY_MANIFEST), r#"<Package><!-- <Application Id="fake"/> --><Applications/></Package>"#).unwrap();
|
||||
+ assert!(!declares_application(&root));
|
||||
+ std::fs::write(root.join("MicrosoftGame.config"), r#"<Game><!-- <Executable Name="fake.exe"/> --></Game>"#).unwrap();
|
||||
+ assert!(!declares_application(&root));
|
||||
+ std::fs::remove_dir_all(&root).ok();
|
||||
+ }
|
||||
+
|
||||
+ #[test]
|
||||
+ fn hoist_still_refuses_when_several_packages_declare_an_application() {
|
||||
+ let root = scratch("ambiguous-applications");
|
||||
+ for name in ["One", "Two"] {
|
||||
@@ -1465,6 +1583,9 @@ index 0000000..d43c5fc
|
||||
+
|
||||
+ assert!(hoist(&root).unwrap_err().contains("would overwrite"));
|
||||
+ assert_eq!(std::fs::read(root.join("Game.exe")).unwrap(), b"other");
|
||||
+ assert!(hoist(&root).unwrap_err().contains("would overwrite"));
|
||||
+ assert_eq!(std::fs::read(root.join("Game.exe")).unwrap(), b"other");
|
||||
+ assert!(!root.join(LEGACY_MANIFEST).exists(), "failed hoist must not partially publish the manifest");
|
||||
+ std::fs::remove_dir_all(&root).ok();
|
||||
+ }
|
||||
+
|
||||
|
||||
Reference in new issue
Block a user