mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9cf0a7e43f |
No files matched your search
@@ -141,7 +141,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
private var glThread by mutableStateOf(true)
|
||||
private var noGlError by mutableStateOf(true)
|
||||
private var returnAfterGame by mutableStateOf(true)
|
||||
private var valveProtonOnDemand by mutableStateOf(true)
|
||||
private var shaderPrecache by mutableStateOf<Boolean?>(null)
|
||||
private var steamRepairQueued by mutableStateOf(false)
|
||||
private var mangoapp by mutableStateOf(true)
|
||||
@@ -2786,7 +2785,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
steamClientArch = if (mode == SessionService.MODE_STEAM) steamClientArch else null,
|
||||
returnAfterGame = if (mode == SessionService.MODE_STEAM) returnAfterGame else null,
|
||||
shaderPrecache = if (mode == SessionService.MODE_STEAM) shaderPrecache else null,
|
||||
valveProtonOnDemand = if (mode == SessionService.MODE_STEAM) valveProtonOnDemand else null,
|
||||
steamRepairQueued = steamRepairQueued,
|
||||
mangoapp = mangoapp,
|
||||
steamController = if (mode == SessionService.MODE_STEAM) steamController else null,
|
||||
@@ -2894,7 +2892,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
onMangoapp = { on -> SessionPrefs.setMangoapp(this, on); mangoapp = on },
|
||||
onReturnAfterGame = { on -> SessionPrefs.setReturnAfterGame(this, on); returnAfterGame = on },
|
||||
onShaderPrecache = { on -> SessionPrefs.setShaderPrecache(this, on); shaderPrecache = on },
|
||||
onValveProtonOnDemand = { on -> SessionPrefs.setValveProtonOnDemand(this, on); valveProtonOnDemand = on },
|
||||
onSteamController = { id -> SessionPrefs.setSteamController(this, id); steamController = id },
|
||||
onStartupSession = { id ->
|
||||
SessionPrefs.setStartupSession(this, id)
|
||||
@@ -3167,7 +3164,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
steamRepairQueued = SteamRepair.queued(this)
|
||||
mangoapp = SessionPrefs.mangoapp(this)
|
||||
returnAfterGame = SessionPrefs.returnAfterGame(this)
|
||||
valveProtonOnDemand = SessionPrefs.valveProtonOnDemand(this)
|
||||
loadShaderPrecache(mode)
|
||||
steamController = SessionPrefs.steamController(this)
|
||||
startupSession = SessionPrefs.startupSession(this)
|
||||
|
||||
@@ -49,7 +49,7 @@ internal class ProtonMenu(
|
||||
@VisibleForTesting internal var latestCheck: (Boolean) -> Boolean = { force -> ProtonExtras.checkLatest(activity, force) }
|
||||
@VisibleForTesting internal var experimentalRefresh: () -> List<ExperimentalProtons.Release>? = { ExperimentalProtons.refresh(activity) }
|
||||
@VisibleForTesting internal var installer: (ProtonExtras.Tool, (String, Int) -> Unit) -> String? =
|
||||
{ tool, progress -> ProtonExtras.install(activity, tool, onProgress = progress) }
|
||||
{ tool, progress -> ProtonExtras.install(activity, tool, progress) }
|
||||
|
||||
fun installProton(id: String, automatic: Boolean = false) {
|
||||
val tool = ProtonExtras.tools.firstOrNull { it.id == id } ?: return
|
||||
|
||||
@@ -2834,7 +2834,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
private fun installProton(): String? {
|
||||
uiHandler.post { loading.percent = -1; loading.say(getString(PROTON_LINES.downloading), PROTON_LINES.topic, readable = true) }
|
||||
if (com.droiddeck.launcher.session.SessionPrefs.ownProtonFirst(this)) return installOwnProton()
|
||||
val catalog = com.droiddeck.launcher.runtime.DesktopCatalog
|
||||
val cancellation = com.droiddeck.launcher.core.Downloader.Cancellation { SessionState.stopRequested }
|
||||
SessionState.installCancellation = cancellation
|
||||
@@ -2847,24 +2846,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
}
|
||||
|
||||
private fun installOwnProton(): String? {
|
||||
val extras = com.droiddeck.launcher.session.ProtonExtras
|
||||
while ((extras.prefetching || extras.installInProgress) && !SessionState.stopRequested) {
|
||||
try { Thread.sleep(250) } catch (_: InterruptedException) { Thread.currentThread().interrupt(); return "interrupted" }
|
||||
}
|
||||
if (SessionState.stopRequested) return "cancelled"
|
||||
if (!com.droiddeck.launcher.runtime.DesktopCatalog.ownProtonMissing(this)) return null
|
||||
val cancellation = com.droiddeck.launcher.core.Downloader.Cancellation { SessionState.stopRequested }
|
||||
SessionState.installCancellation = cancellation
|
||||
return try {
|
||||
extras.install(this, extras.tools.first { it.id == extras.OWN }, cancellation) { label, percent ->
|
||||
uiHandler.post { loading.percent = percent; loading.say(label, PROTON_LINES.topic, readable = true) }
|
||||
}.also { if (it == null) com.droiddeck.launcher.session.Onboarding.recheck(this) }
|
||||
} finally {
|
||||
if (SessionState.installCancellation === cancellation) SessionState.installCancellation = null
|
||||
}
|
||||
}
|
||||
|
||||
override fun surfaceCreated(holder: SurfaceHolder) {
|
||||
if (holder !== outputHolder()) return
|
||||
if (installingRuntime || SessionState.stopRequested || ended) return
|
||||
@@ -3414,7 +3395,8 @@ 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))
|
||||
relaunch(next)
|
||||
setIntent(next)
|
||||
recreate()
|
||||
return@runOnUiThread
|
||||
}
|
||||
showEnded(status, hint)
|
||||
@@ -3422,16 +3404,6 @@ 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()
|
||||
@@ -6059,7 +6031,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
Log.w(TAG, "ignoring agent start while session phase is ${SessionState.phase}")
|
||||
return
|
||||
}
|
||||
relaunch(android.content.Intent(intent).setClass(this, SessionActivity::class.java))
|
||||
setIntent(intent)
|
||||
recreate()
|
||||
return
|
||||
}
|
||||
if (this.intent.getBooleanExtra(EXTRA_RETURN_HOME, false)) intent.putExtra(EXTRA_RETURN_HOME, true)
|
||||
|
||||
@@ -293,7 +293,6 @@ object DeviceReport {
|
||||
k("Stretch 16:9 to panel", SessionPrefs.stretch16x9(context))
|
||||
k("Avoid notch", SessionPrefs.avoidNotch(context))
|
||||
k("Return to launcher after a game", SessionPrefs.returnAfterGame(context))
|
||||
k("Valve Proton only when needed", SessionPrefs.valveProtonOnDemand(context))
|
||||
k("Microphone", SessionPrefs.micEnabled(context))
|
||||
k("On-screen controls", SessionPrefs.oscMode(context))
|
||||
k("Touch mode", SessionPrefs.touchMode(context))
|
||||
|
||||
@@ -33,13 +33,6 @@ 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 {
|
||||
|
||||
@@ -329,8 +329,8 @@ object BwrapSpawner {
|
||||
|
||||
private fun zypakShims(binds: List<Bind>, root: File, dir: File): List<Bind> {
|
||||
val wrappers = listOf("/app/bin/zypak-wrapper.sh", "/app/bin/zypak-wrapper").filter { guest ->
|
||||
val host = File(hostPath(binds, root.path, guest))
|
||||
host.isFile && !Files.isSymbolicLink(host.toPath())
|
||||
val host = File(hostPath(binds, root.path, guest)).toPath()
|
||||
Files.isRegularFile(host, java.nio.file.LinkOption.NOFOLLOW_LINKS) || Files.isSymbolicLink(host)
|
||||
}
|
||||
if (wrappers.isEmpty()) return emptyList()
|
||||
val shim = File(dir, "zypak-wrapper")
|
||||
|
||||
@@ -109,15 +109,9 @@ object DesktopCatalog {
|
||||
FileUtils.readString(marker(context, id))?.trim()?.takeIf { it.isNotEmpty() }
|
||||
|
||||
fun protonSeedNeeded(context: Context): Boolean =
|
||||
if (com.droiddeck.launcher.session.SessionPrefs.ownProtonFirst(context)) ownProtonMissing(context)
|
||||
else installed(context, PROTON_SEED_ID) == null &&
|
||||
installed(context, PROTON_SEED_ID) == null &&
|
||||
!File(LinuxRuntime.rootDir(context), "root/.local/share/Steam/steamapps/appmanifest_4427310.acf").isFile
|
||||
|
||||
fun ownProtonMissing(context: Context): Boolean {
|
||||
val extras = com.droiddeck.launcher.session.ProtonExtras
|
||||
return extras.installedAll(context, extras.tools.first { it.id == extras.OWN }).isEmpty()
|
||||
}
|
||||
|
||||
const val DESKTOP_ID = "desktop-kde"
|
||||
const val EMULATORS_ID = "emulators"
|
||||
private const val EMULATORS_SCRIPT = "/usr/local/bin/droiddeck-emulators"
|
||||
|
||||
@@ -249,24 +249,21 @@ object ProtonExtras {
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun install(context: Context, tool: Tool, cancelled: java.util.function.BooleanSupplier? = null,
|
||||
onProgress: (String, Int) -> Unit): String? {
|
||||
fun install(context: Context, tool: Tool, onProgress: (String, Int) -> Unit): String? {
|
||||
if (installInProgress || prefetching) return context.getString(R.string.pextra_busy)
|
||||
installInProgress = true
|
||||
return try { installNow(context, tool, cancelled, onProgress) } finally { installInProgress = false }
|
||||
return try { installNow(context, tool, onProgress) } finally { installInProgress = false }
|
||||
}
|
||||
|
||||
private fun fetchArchive(context: Context, tool: Tool, asset: Asset, archive: File, onProgress: (String, Int) -> Unit,
|
||||
cancelled: java.util.function.BooleanSupplier? = null): String? {
|
||||
private fun fetchArchive(context: Context, tool: Tool, asset: Asset, archive: File, onProgress: (String, Int) -> Unit): String? {
|
||||
val downloading = context.getString(R.string.pextra_downloading, tool.name, asset.tag)
|
||||
onProgress(downloading, 0)
|
||||
var downloaded = false
|
||||
for (attempt in 0 until 5) {
|
||||
downloaded = Downloader.downloadFile(asset.url, archive, true, asset.sha256, cancelled) { fraction ->
|
||||
downloaded = Downloader.downloadFile(asset.url, archive, true, asset.sha256) { fraction ->
|
||||
onProgress(downloading, if (fraction < 0) -1 else (fraction * 100f).toInt().coerceIn(0, 100))
|
||||
}
|
||||
if (downloaded) break
|
||||
if (cancelled?.asBoolean == true) return context.getString(R.string.pextra_interrupted)
|
||||
if (attempt < 4) {
|
||||
onProgress(context.getString(R.string.pextra_retrying, attempt + 2, 5), -1)
|
||||
try { Thread.sleep(3_000) } catch (_: InterruptedException) {
|
||||
@@ -300,8 +297,7 @@ object ProtonExtras {
|
||||
return problem
|
||||
}
|
||||
|
||||
private fun installNow(context: Context, tool: Tool, cancelled: java.util.function.BooleanSupplier?,
|
||||
onProgress: (String, Int) -> Unit): String? {
|
||||
private fun installNow(context: Context, tool: Tool, onProgress: (String, Int) -> Unit): String? {
|
||||
if (SessionState.running) return context.getString(R.string.pextra_stop_session)
|
||||
if (!LinuxRuntime.isInstalled(context)) return context.getString(R.string.user_apps_runtime_required)
|
||||
|
||||
@@ -316,7 +312,7 @@ object ProtonExtras {
|
||||
|
||||
val checked = asset.sha256 != null && asset.size > 0 && checkedArchive == fingerprint(archive) &&
|
||||
checkedDigest.equals(asset.sha256, ignoreCase = true)
|
||||
if (!checked) fetchArchive(context, tool, asset, archive, onProgress, cancelled)?.let { return it }
|
||||
if (!checked) fetchArchive(context, tool, asset, archive, onProgress)?.let { return it }
|
||||
if (asset.size > 0 && archive.length() != asset.size) {
|
||||
if (archive.length() > asset.size) {
|
||||
archive.delete()
|
||||
|
||||
@@ -28,14 +28,12 @@ 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(
|
||||
|
||||
@@ -845,15 +845,6 @@ object SessionPrefs {
|
||||
|
||||
fun returnAfterGame(context: Context): Boolean = prefs(context).getBoolean("returnAfterGame", true)
|
||||
|
||||
fun valveProtonOnDemand(context: Context): Boolean = prefs(context).getBoolean("valveProtonOnDemand", true)
|
||||
|
||||
fun setValveProtonOnDemand(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("valveProtonOnDemand", on).apply()
|
||||
}
|
||||
|
||||
/** DroidDeck-Proton is the Proton placed before the client starts; Valve's ARM64 Proton waits for a title that needs it. */
|
||||
fun ownProtonFirst(context: Context): Boolean = valveProtonOnDemand(context) && !ProtonExtras.declined(context)
|
||||
|
||||
fun setReturnAfterGame(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("returnAfterGame", on).apply()
|
||||
}
|
||||
|
||||
@@ -669,8 +669,6 @@ 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")
|
||||
@@ -1004,7 +1002,6 @@ class SessionService : Service() {
|
||||
))
|
||||
guest.add("TZ=" + java.util.TimeZone.getDefault().id)
|
||||
if (SessionState.mode == MODE_STEAM) SessionPrefs.pendingShaderPrecache(this)?.let { guest.add("DD_SHADER_PRECACHE=" + if (it) "1" else "0") }
|
||||
guest.add("DD_VALVE_PROTON=" + if (SessionPrefs.ownProtonFirst(this)) "0" else "1")
|
||||
guest.add("XDG_RUNTIME_DIR=" + LinuxRuntime.GUEST_RUNTIME_DIR)
|
||||
guest.add("XDG_SESSION_TYPE=wayland")
|
||||
guest.add("WAYLAND_DISPLAY=wayland-0")
|
||||
|
||||
@@ -93,7 +93,6 @@ class ModeSettings(
|
||||
val steamClientArch: String? = null,
|
||||
val returnAfterGame: Boolean? = null,
|
||||
val shaderPrecache: Boolean? = null,
|
||||
val valveProtonOnDemand: Boolean? = null,
|
||||
val steamRepairQueued: Boolean = false,
|
||||
val mangoapp: Boolean = true,
|
||||
val steamController: String? = null,
|
||||
@@ -159,7 +158,6 @@ class ModeSettingsActions(
|
||||
val onMangoapp: (Boolean) -> Unit = {},
|
||||
val onReturnAfterGame: (Boolean) -> Unit = {},
|
||||
val onShaderPrecache: (Boolean) -> Unit = {},
|
||||
val onValveProtonOnDemand: (Boolean) -> Unit = {},
|
||||
val onSteamController: (String) -> Unit = {},
|
||||
val onUnfoldedControls: (Boolean) -> Unit = {},
|
||||
val onUnfoldedControlsWithController: (Boolean) -> Unit = {},
|
||||
@@ -536,10 +534,6 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
|
||||
stringResource(R.string.mode_shader_precache_hint),
|
||||
s.shaderPrecache, onChange = a.onShaderPrecache,
|
||||
)
|
||||
if (s.valveProtonOnDemand != null) ToggleRow(
|
||||
host, "valveprotonondemand", stringResource(R.string.mode_valve_proton_on_demand), null,
|
||||
s.valveProtonOnDemand, onChange = a.onValveProtonOnDemand,
|
||||
)
|
||||
SettingsRow(
|
||||
stringResource(R.string.mode_steam_repair),
|
||||
stringResource(if (s.steamRepairQueued) R.string.mode_steam_repair_queued else R.string.mode_steam_repair_hint),
|
||||
|
||||
@@ -383,7 +383,6 @@
|
||||
<string name="mode_return_after_game">Return to DroidDeck after a game</string>
|
||||
<string name="mode_return_after_game_hint">When a game you started from DroidDeck or another launcher closes, Steam exits cleanly (cloud saves finish first) and you go back there. Off: stay in Steam.</string>
|
||||
<string name="mode_shader_precache">Shader pre-caching</string>
|
||||
<string name="mode_valve_proton_on_demand">Valve Proton only when needed</string>
|
||||
<string name="mode_shader_precache_hint">Steam downloads shaders prebuilt for your games and processes them in the background, so games stutter less. Off saves data, storage and battery; games build shaders as they play instead. The same setting as Steam’s Downloads > Shader Pre-Caching. Applies next session.</string>
|
||||
<string name="mode_steam_repair">Repair Steam client</string>
|
||||
<string name="mode_steam_repair_hint">Downloads the Steam client again the next time Steam starts. Use it if Steam stays on its loading screen. Games, sign-in and settings are kept.</string>
|
||||
|
||||
@@ -64,19 +64,11 @@ impl Done {
|
||||
}
|
||||
|
||||
pub fn safe_path(root: &Path, name: &str) -> Result<PathBuf, String> {
|
||||
let unsafe_path = || format!("The manifest names an unsafe path: {name}");
|
||||
let mut out = root.to_path_buf();
|
||||
for component in Path::new(name.trim_start_matches('/')).components() {
|
||||
match component {
|
||||
Component::Normal(part) => out.push(part),
|
||||
Component::CurDir => {}
|
||||
_ => return Err(unsafe_path()),
|
||||
}
|
||||
let rel = Path::new(name.trim_start_matches('/'));
|
||||
if rel.components().any(|c| !matches!(c, Component::Normal(_))) {
|
||||
return Err(format!("The manifest names an unsafe path: {name}"));
|
||||
}
|
||||
if out == root {
|
||||
return Err(unsafe_path());
|
||||
}
|
||||
Ok(out)
|
||||
Ok(root.join(rel))
|
||||
}
|
||||
|
||||
fn sha1(b: &[u8]) -> Vec<u8> {
|
||||
@@ -401,23 +393,6 @@ mod tests {
|
||||
assert!(safe_path(root, "../evil").is_err());
|
||||
assert!(safe_path(root, "a/../../evil").is_err());
|
||||
assert_eq!(safe_path(root, "/bin/game.exe").unwrap(), root.join("bin/game.exe"));
|
||||
assert!(safe_path(root, "./../evil").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn accepts_names_that_start_in_the_current_folder() {
|
||||
let root = Path::new("/games/x");
|
||||
assert_eq!(safe_path(root, "./alut.dll").unwrap(), root.join("alut.dll"));
|
||||
assert_eq!(safe_path(root, "./bin/./game.exe").unwrap(), root.join("bin/game.exe"));
|
||||
assert_eq!(safe_path(root, "alut.dll").unwrap(), root.join("alut.dll"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn refuses_names_without_a_file_name() {
|
||||
let root = Path::new("/games/x");
|
||||
for name in [".", "./", "/./", "", "/"] {
|
||||
assert!(safe_path(root, name).is_err(), "{name:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
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,9 +32,4 @@ 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", ""))
|
||||
}
|
||||
}
|
||||
@@ -263,8 +263,26 @@ class BwrapSpawnerPlanTest {
|
||||
val shim = plan.binds.single { it.guest == "/app/bin/zypak-wrapper.sh" }
|
||||
assertTrue(shim.host.startsWith(dir.path))
|
||||
assertTrue(File(shim.host).readText().contains("exec \"\$program\" --no-sandbox \"\$@\""))
|
||||
assertFalse(plan.binds.any { it.guest == "/app/bin/zypak-wrapper" })
|
||||
assertEquals(shim.host, plan.binds.single { it.guest == "/app/bin/zypak-wrapper" }.host)
|
||||
assertTrue(File(app, "bin/zypak-wrapper.sh").readText().contains("zypak-helper"))
|
||||
assertEquals("/app/bin/zypak-wrapper.sh", Files.readSymbolicLink(File(app, "bin/zypak-wrapper").toPath()).toString())
|
||||
}
|
||||
|
||||
@Test fun zypakWrapperLinkThatDoesNotResolveOnTheHostGetsTheShim() {
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
val app = File(runtime, "app").apply { File(this, "bin").mkdirs() }
|
||||
File(app, "bin/zypak-wrapper.sh").writeText("#!/usr/bin/bash\nexec zypak-helper host - \"\$@\"\n")
|
||||
val dangling = java.nio.file.Paths.get(LinuxRuntime.rootDir(context).path, "app/bin/zypak-wrapper.sh")
|
||||
Files.createSymbolicLink(File(app, "bin/zypak-wrapper").toPath(), dangling)
|
||||
val plan = BwrapSpawner.plan(context, request(
|
||||
op("t" to "bind", "src" to "/runtime-files/app", "dest" to "/app", "ro" to true),
|
||||
), dir)
|
||||
|
||||
assertFalse(Files.exists(dangling))
|
||||
val shim = plan.binds.single { it.guest == "/app/bin/zypak-wrapper" }
|
||||
assertTrue(shim.host.startsWith(dir.path))
|
||||
assertTrue(File(shim.host).readText().contains("exec \"\$program\" --no-sandbox \"\$@\""))
|
||||
assertEquals(shim.host, plan.binds.single { it.guest == "/app/bin/zypak-wrapper.sh" }.host)
|
||||
}
|
||||
|
||||
@Test fun appsWithoutZypakKeepTheirFiles() {
|
||||
|
||||
@@ -38,9 +38,8 @@ 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
|
||||
if cat > "$dd_layout/org.kde.plasma.desktop-layout.js" <<'LAYOUT'
|
||||
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";
|
||||
@@ -112,13 +111,10 @@ 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 [ "$dd_layout_installed" -eq 1 ] && [ "$(cat "$dd_panel_stamp" 2>/dev/null)" != steamos-2 ]; then
|
||||
if [ "$(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
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#!/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
|
||||
@@ -1,25 +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",
|
||||
{ "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"
|
||||
]
|
||||
}
|
||||
@@ -1169,10 +1169,7 @@ case $mode in
|
||||
"${DD_X64_HOME:-$HOME/.droiddeck-x64}/.local/share/Steam" &&
|
||||
echo "$DD_SHADER_PRECACHE" > "$HOME/.dd-shader-precache-applied" || true
|
||||
fi
|
||||
if [ "$steam_x64" = 0 ] && [ ! -f "$steam_root/steamapps/appmanifest_4427310.acf" ] &&
|
||||
! steam-compatibility "$steam_root" --valve-proton-needed; then
|
||||
step "leaving Valve's ARM64 Proton until a title needs it"
|
||||
elif [ "$steam_x64" = 0 ] && [ ! -f "$steam_root/steamapps/appmanifest_4427310.acf" ]; then
|
||||
if [ "$steam_x64" = 0 ] && [ ! -f "$steam_root/steamapps/appmanifest_4427310.acf" ]; then
|
||||
step "asking the client to fetch the ARM64 Proton"
|
||||
set -- "$@" steam://install/4427310
|
||||
(
|
||||
|
||||
@@ -966,7 +966,6 @@ class Helper:
|
||||
self.fex_asked = set()
|
||||
self.tools_asked = {}
|
||||
self.tools_checked = None
|
||||
self.valve_names = None
|
||||
self.vr_launch = None
|
||||
self.chooser = None
|
||||
self.controls_state = None
|
||||
@@ -1257,10 +1256,6 @@ class Helper:
|
||||
page.compat("set(%d, %s)" % (int(app), json.dumps(tool if tool is not None else "")))
|
||||
say("%s -> %s" % ("default" if app == "0" else "app %s" % app,
|
||||
tool if tool is not None else "Steam native default"))
|
||||
names = set(dict(current, **changes).values()) | {default}
|
||||
if COMPAT["uses_valve_proton"](names) and not COMPAT["uses_valve_proton"](self.valve_names or ()):
|
||||
self.tools_checked = None
|
||||
self.valve_names = names
|
||||
state.update(
|
||||
auto={app: tool for app, tool in auto.items() if tool is not COMPAT["NATIVE_CHOICE"]},
|
||||
native_choices=sorted(refused_native | {app for app, tool in auto.items() if tool is COMPAT["NATIVE_CHOICE"]}),
|
||||
@@ -1281,8 +1276,7 @@ class Helper:
|
||||
self.tools_checked = now
|
||||
if COMPAT["game_running"]():
|
||||
return
|
||||
needed = COMPAT["valve_proton_needed"](self.steam_root, self.valve_names)
|
||||
for app, action in COMPAT["tool_downloads"](self.steam_root, needed):
|
||||
for app, action in COMPAT["tool_downloads"](self.steam_root):
|
||||
if now - self.tools_asked.get(app, -TOOL_RETRY_SECONDS) < TOOL_RETRY_SECONDS:
|
||||
continue
|
||||
self.tools_asked[app] = now
|
||||
|
||||
@@ -26,9 +26,6 @@ SNIPER_APPID = "1628350"
|
||||
SLR4_APPID = "4183110"
|
||||
FEX_DEPENDENCIES = (FEX_APPID, SNIPER_APPID, SLR4_APPID)
|
||||
REQUIRED_TOOLS = (PROTON_ARM64_APPID,) + FEX_DEPENDENCIES
|
||||
# "0" = the app's "Valve Proton only when needed": Valve's ARM64 Proton is fetched only for a title or
|
||||
# default set to a tool built from it, or while no own Proton build is installed.
|
||||
VALVE_PROTON_ENV = "DD_VALVE_PROTON"
|
||||
# Linux builds that bundle an arm64 binary their launcher starts; Steamworks offers no arm64
|
||||
# launch-option architecture, so appinfo cannot say so (#1774).
|
||||
FEX_DEFAULT_APPS = frozenset({"4385780"})
|
||||
@@ -1011,33 +1008,11 @@ def manifest_flags(tokens):
|
||||
return 0
|
||||
|
||||
|
||||
def valve_proton_on_demand():
|
||||
return os.environ.get(VALVE_PROTON_ENV) == "0"
|
||||
|
||||
|
||||
def uses_valve_proton(names):
|
||||
return any(name == TOOL or VALVE_DEPOTS.get(name) == SOURCES[0] for name in names if name)
|
||||
|
||||
|
||||
def valve_proton_needed(steam_root, names=None):
|
||||
if not valve_proton_on_demand():
|
||||
return True
|
||||
if not own_builds(tool_catalog(steam_root)):
|
||||
return True
|
||||
if names is None:
|
||||
names = set((read_config_mapping(os.path.join(steam_root, "config", "config.vdf")) or {}).values())
|
||||
names.add(read_json(state_path("state.json")).get("default"))
|
||||
return uses_valve_proton(names)
|
||||
|
||||
|
||||
def tool_downloads(steam_root, valve_needed=None):
|
||||
def tool_downloads(steam_root):
|
||||
wanted = []
|
||||
for app in REQUIRED_TOOLS:
|
||||
tokens = app_manifest(steam_root, app)
|
||||
if tokens is None:
|
||||
if app == PROTON_ARM64_APPID and not (
|
||||
valve_proton_needed(steam_root) if valve_needed is None else valve_needed):
|
||||
continue
|
||||
wanted.append((app, "install"))
|
||||
elif not manifest_flags(tokens) & FULLY_INSTALLED or manifest_flags(tokens) & UPDATE_REQUIRED:
|
||||
wanted.append((app, "update"))
|
||||
@@ -1780,8 +1755,6 @@ def x64_repoint(steam_root, tool, live=False):
|
||||
|
||||
def main():
|
||||
steam_root = sys.argv[1]
|
||||
if "--valve-proton-needed" in sys.argv[2:]:
|
||||
sys.exit(0 if valve_proton_needed(steam_root) else 1)
|
||||
if "--x64" in sys.argv[2:]:
|
||||
x64_repoint(steam_root, os.environ.get("DD_COMPAT_TOOL"), "--live" in sys.argv[2:])
|
||||
return
|
||||
@@ -1800,7 +1773,6 @@ def main():
|
||||
build_tool(os.path.join(tools, name), depot, sources, name)
|
||||
print("steam-compatibility: registered %s (%s)" % (
|
||||
name, "depot %s present" % os.path.basename(depot) if depot else
|
||||
"no ARM64 Proton depot yet; fetched when a title needs it" if valve_proton_on_demand() else
|
||||
"no ARM64 Proton depot yet; the session asks the client to fetch it"))
|
||||
build_fex_tool(os.path.join(tools, FEX_TOOL))
|
||||
print("steam-compatibility: registered %s" % FEX_TOOL)
|
||||
|
||||
@@ -27,12 +27,10 @@ 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', 'droiddeck-device-info',
|
||||
'kwin_wayland_wrapper']:
|
||||
for name in ['droiddeck-desktop', 'droiddeck-gpu', 'droiddeck-desktop-gpu', '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
|
||||
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
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,11 +19,10 @@ def block(first, last):
|
||||
return DESKTOP[start:DESKTOP.index(last, start) + len(last)]
|
||||
|
||||
|
||||
def run(script, home, layout_installed=True):
|
||||
def run(script, home):
|
||||
environment = {key: value for key, value in os.environ.items() if key != 'XDG_CONFIG_HOME'}
|
||||
environment['HOME'] = str(home)
|
||||
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)
|
||||
result = subprocess.run(['bash', '-c', script], env=environment, capture_output=True, text=True, timeout=5)
|
||||
if result.returncode != 0:
|
||||
raise AssertionError(result.stderr)
|
||||
|
||||
@@ -102,52 +101,6 @@ 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'))
|
||||
|
||||
@@ -1430,43 +1430,6 @@ class AppInfoTest(unittest.TestCase):
|
||||
self.manifest(steam, app)
|
||||
self.assertEqual(downloads(str(steam)), [])
|
||||
|
||||
def test_valve_proton_on_demand_waits_for_a_title_that_uses_it(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
steam = Path(tmp)
|
||||
for app in ("3127680", "1628350", "4183110"):
|
||||
self.manifest(steam, app)
|
||||
downloads, needed, tool = self.COMPAT["tool_downloads"], self.COMPAT["valve_proton_needed"], self.COMPAT["TOOL"]
|
||||
own = steam / "compatibilitytools.d/DroidDeck-Proton 11-14.1"
|
||||
with mock.patch.dict(os.environ, {"DD_VALVE_PROTON": "0"}):
|
||||
self.assertEqual(downloads(str(steam)), [("4427310", "install")])
|
||||
ge = steam / "compatibilitytools.d/GE-Proton10-25"
|
||||
ge.mkdir(parents=True)
|
||||
(ge / "droiddeck-proton-wrap").write_text("")
|
||||
(ge / "compatibilitytool.vdf").write_text(
|
||||
'"compatibilitytools" { "compat_tools" { "GE-Proton10-25" { "install_path" "." } } }')
|
||||
self.assertEqual(downloads(str(steam)), [("4427310", "install")])
|
||||
own.mkdir(parents=True)
|
||||
(own / "droiddeck-proton-wrap").write_text("")
|
||||
(own / "compatibilitytool.vdf").write_text(
|
||||
'"compatibilitytools" { "compat_tools" { "DroidDeck-Proton-11-14.1" { "install_path" "." } } }')
|
||||
self.assertEqual(downloads(str(steam)), [])
|
||||
self.assertFalse(needed(str(steam), {"DroidDeck-Proton-11-14.1", None}))
|
||||
self.assertTrue(needed(str(steam), {"DroidDeck-Proton-11-14.1", tool}))
|
||||
self.assertTrue(needed(str(steam), {"proton-experimental-arm64"}))
|
||||
self.assertEqual(downloads(str(steam), True), [("4427310", "install")])
|
||||
config = steam / "config/config.vdf"
|
||||
config.parent.mkdir()
|
||||
config.write_text('"InstallConfigStore" { "Software" { "Valve" { "Steam" { "CompatToolMapping" { '
|
||||
'"0" { "name" "DroidDeck-Proton-11-14.1" "config" "" "priority" "75" } '
|
||||
'"10" { "name" "%s" "config" "" "priority" "250" } } } } } }' % tool)
|
||||
self.assertEqual(downloads(str(steam)), [("4427310", "install")])
|
||||
config.unlink()
|
||||
self.manifest(steam, "4427310", flags="6")
|
||||
self.assertEqual(downloads(str(steam), False), [("4427310", "update")])
|
||||
with mock.patch.dict(os.environ, {"DD_VALVE_PROTON": "1"}):
|
||||
(steam / "steamapps/appmanifest_4427310.acf").unlink()
|
||||
self.assertEqual(downloads(str(steam)), [("4427310", "install")])
|
||||
|
||||
def test_titles_with_a_valve_pick_are_found_installed_or_not(self):
|
||||
def deck(oslist, runtime, kind="game"):
|
||||
common = {"type": kind, "oslist": oslist, "steam_deck_compatibility": {"configuration": {"recommended_runtime": runtime}}}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"$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,1527 @@
|
||||
@@ -0,0 +1,1406 @@
|
||||
+//! 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; retrying may require downloading the bundle again because containers are removed to save disk space");
|
||||
+ return fail("extract-failed", "Could not unpack the package; the download is kept for a retry");
|
||||
+ }
|
||||
+ // 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,24 +813,15 @@ 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();
|
||||
+ 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(),
|
||||
+ 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());
|
||||
+ }
|
||||
+ }
|
||||
+ names
|
||||
@@ -1003,8 +994,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();
|
||||
+ if identity_is_x64(&text) {
|
||||
+ let text = std::fs::read_to_string(&manifest).unwrap_or_default().to_ascii_lowercase();
|
||||
+ if text.contains("processorarchitecture=\"x64\"") {
|
||||
+ return Some(folder);
|
||||
+ }
|
||||
+ }
|
||||
@@ -1020,24 +1011,6 @@ 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> {
|
||||
@@ -1084,18 +1057,8 @@ 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();
|
||||
+ 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}"));
|
||||
+ }
|
||||
+ 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}"))?;
|
||||
+ Ok(())
|
||||
+}
|
||||
+
|
||||
@@ -1116,16 +1079,7 @@ index 0000000..d43c5fc
|
||||
+ if target.exists() {
|
||||
+ continue;
|
||||
+ }
|
||||
+ 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}"));
|
||||
+ }
|
||||
+ std::fs::copy(&path, &target).map_err(|error| format!("framework copy failed: {error}"))?;
|
||||
+ copied.push(file_name.to_string_lossy().into_owned());
|
||||
+ }
|
||||
+ Ok(())
|
||||
@@ -1165,19 +1119,10 @@ index 0000000..d43c5fc
|
||||
+ ));
|
||||
+ }
|
||||
+ let inner = candidates.remove(0);
|
||||
+ let entries: Vec<_> = std::fs::read_dir(&inner)
|
||||
+ for entry in 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);
|
||||
@@ -1197,41 +1142,16 @@ index 0000000..d43c5fc
|
||||
+ if !existing.is_empty() && !updating && !metadata {
|
||||
+ return Err(format!("Extraction would overwrite {}", target.display()));
|
||||
+ }
|
||||
+ 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}"))?;
|
||||
+ 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}"))?;
|
||||
+ }
|
||||
+ 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(())
|
||||
@@ -1245,9 +1165,7 @@ index 0000000..d43c5fc
|
||||
+ if applications.len() > 1 {
|
||||
+ let x64: Vec<PathBuf> = applications
|
||||
+ .iter()
|
||||
+ .filter(|folder| {
|
||||
+ identity_is_x64(&manifest_text_original(folder))
|
||||
+ })
|
||||
+ .filter(|folder| manifest_text(folder).contains("processorarchitecture=\"x64\""))
|
||||
+ .cloned()
|
||||
+ .collect();
|
||||
+ if x64.len() == 1 {
|
||||
@@ -1258,41 +1176,22 @@ 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("\n")
|
||||
+ .join("
|
||||
+")
|
||||
+ .to_ascii_lowercase()
|
||||
+}
|
||||
+
|
||||
+fn declares_application(folder: &Path) -> bool {
|
||||
+ 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
|
||||
+ let text = manifest_text(folder);
|
||||
+ opens_element(&text, "<application") || opens_element(&text, "<executable")
|
||||
+}
|
||||
+
|
||||
+/// Whether [text] opens [tag] as its own element, so `<Application Id=` and an attribute on the next
|
||||
+/// line count and `<Applications>` does not. Used by the focused parser test only.
|
||||
+#[cfg(test)]
|
||||
+/// line count and `<Applications>` does not.
|
||||
+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 == '/')
|
||||
@@ -1542,23 +1441,6 @@ 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"] {
|
||||
@@ -1583,9 +1465,6 @@ 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