mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6bcc08c081 | ||
|
|
df2cfa40b3 | ||
|
|
e101a78791 | ||
|
|
aaa9fb129c |
No files matched your search
@@ -28,7 +28,8 @@ object AutoComponents {
|
||||
else -> game.appId.takeIf { it > 0 }?.toString()
|
||||
}
|
||||
|
||||
fun autoPicks(findings: List<WinCompSources.Finding>, catalog: Map<String, WinComponents.Component>): Map<String, WinComponents.AutoReason> {
|
||||
fun autoPicks(findings: List<WinCompSources.Finding>, catalog: Map<String, WinComponents.Component>,
|
||||
user: Map<String, Boolean> = emptyMap()): Map<String, WinComponents.AutoReason> {
|
||||
val out = LinkedHashMap<String, WinComponents.AutoReason>()
|
||||
for (f in findings) {
|
||||
if (!f.auto || f.component == null) continue
|
||||
@@ -37,6 +38,13 @@ object AutoComponents {
|
||||
if (WinComponents.support(c, catalog) != WinComponents.Support.READY) continue
|
||||
if (id !in out) out[id] = WinComponents.AutoReason(f.origin.name, listOf(f.original) + f.args)
|
||||
}
|
||||
if (user["d3dx9"] != false && (user["d3dx9"] == true || "d3dx9" in out)) {
|
||||
val reason = out["d3dx9"] ?: WinComponents.AutoReason(WinCompSources.Origin.FOLDER.name, listOf("d3dx9"))
|
||||
for (id in listOf("d3dcompiler_42", "d3dcompiler_43")) {
|
||||
val c = catalog[id] ?: continue
|
||||
if (WinComponents.support(c, catalog) == WinComponents.Support.READY) out.putIfAbsent(id, reason)
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
@@ -228,8 +236,8 @@ object AutoComponents {
|
||||
val findings = findings(context, game)
|
||||
val refreshed = if (knownCatalog == null && asked && online(context)) catalogOf(context, true) else null
|
||||
val catalog = knownCatalog ?: (refreshed ?: catalogOf(context, false) ?: catalogOf(context, true))?.associateBy { it.name } ?: return
|
||||
val wanted = autoPicks(findings, catalog)
|
||||
val user = WinComponents.selection(context, key).user
|
||||
val wanted = autoPicks(findings, catalog, user)
|
||||
val before = WinComponents.selection(context, key).auto
|
||||
val installed = installedOf(context)
|
||||
val kept = LinkedHashMap<String, WinComponents.AutoReason>()
|
||||
@@ -452,9 +460,9 @@ object AutoComponents {
|
||||
}
|
||||
return pendingSaved && pending.isEmpty()
|
||||
}
|
||||
val wanted = autoPicks(findings, catalog)
|
||||
val selection = WinComponents.selection(context, key)
|
||||
val user = selection.user
|
||||
val wanted = autoPicks(findings, catalog, user)
|
||||
val installed = installedOf(context)
|
||||
val roots = selection.effective + wanted.keys.filter { user[it] != false }
|
||||
val required = withParts(roots.filter { WinComponents.validId(it) }, catalog)
|
||||
|
||||
@@ -121,6 +121,8 @@ object StoresState {
|
||||
var unfinished by mutableStateOf<List<StoreInstallRoot.Unfinished>>(emptyList())
|
||||
internal set
|
||||
|
||||
var steamPicking by mutableStateOf<CatalogItem?>(null)
|
||||
|
||||
fun isUnfinished(item: CatalogItem): Boolean = unfinished.any {
|
||||
it.store == item.store && (it.id == item.id || (it.id == null && it.folder.name == StoreInstallRoot.folderName(item.title, item.id)))
|
||||
}
|
||||
|
||||
@@ -6,9 +6,6 @@ import android.net.Uri
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.frontend.Library
|
||||
import com.droiddeck.launcher.session.SessionService
|
||||
@@ -46,8 +43,6 @@ internal object SteamStore {
|
||||
/** InvalidPassword, AccessDenied, AccountNotFound, Revoked, Expired, AccountLogonDenied. */
|
||||
private val REFUSALS = setOf(5, 15, 18, 26, 27, 63)
|
||||
|
||||
var picking by mutableStateOf<CatalogItem?>(null)
|
||||
|
||||
class Plan(val installDir: String, val downloadBytes: Long, val installBytes: Long, val buildId: String, val linuxBuild: Boolean) {
|
||||
companion object {
|
||||
fun of(json: JSONObject): Plan? {
|
||||
@@ -222,7 +217,7 @@ internal object SteamStore {
|
||||
toast(context, R.string.steam_store_close_steam)
|
||||
return
|
||||
}
|
||||
picking = item
|
||||
StoresState.steamPicking = item
|
||||
}
|
||||
|
||||
fun install(context: Context, item: CatalogItem, target: SteamClient.Target) {
|
||||
|
||||
@@ -847,7 +847,7 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com
|
||||
com.droiddeck.launcher.stores.StoresState.pendingInstall?.let { item -> StoreTheme(item.store) { InstallWhere(item) } }
|
||||
com.droiddeck.launcher.stores.StoresState.itchPicking?.let { item -> StoreTheme(item.store) { ItchBuildPicker(item) { com.droiddeck.launcher.stores.StoresState.itchPicking = null } } }
|
||||
com.droiddeck.launcher.stores.StoresState.gameJoltPicking?.let { item -> StoreTheme(item.store) { GameJoltBuildPicker(item) { com.droiddeck.launcher.stores.StoresState.gameJoltPicking = null } } }
|
||||
com.droiddeck.launcher.stores.steam.SteamStore.picking?.let { item -> StoreTheme(item.store) { SteamInstallWhereDialog(item) { com.droiddeck.launcher.stores.steam.SteamStore.picking = null } } }
|
||||
com.droiddeck.launcher.stores.StoresState.steamPicking?.let { item -> StoreTheme(item.store) { SteamInstallWhereDialog(item) { com.droiddeck.launcher.stores.StoresState.steamPicking = null } } }
|
||||
StepsLayer(screenAt)
|
||||
UiZooSheet()
|
||||
SessionDrawerPreview(s.secondScreenDisplays)
|
||||
|
||||
@@ -205,6 +205,36 @@ class WinCompSourcesTest {
|
||||
assertEquals("GOG", picks.getValue("vcredist2015_dll").kind)
|
||||
}
|
||||
|
||||
@Test fun nativeD3dxSelectsItsEffectCompilersForEveryAutomaticSource() {
|
||||
val catalog = listOf(ready("d3dx9"), ready("d3dcompiler_42"), ready("d3dcompiler_43")).associateBy { it.name }
|
||||
for (origin in WinCompSources.Origin.values()) {
|
||||
val finding = WinCompSources.Finding("d3dx9", "DirectX", origin, true)
|
||||
val picks = AutoComponents.autoPicks(listOf(finding), catalog)
|
||||
assertEquals(setOf("d3dx9", "d3dcompiler_42", "d3dcompiler_43"), picks.keys)
|
||||
assertEquals(origin.name, picks.getValue("d3dcompiler_43").kind)
|
||||
assertEquals(picks.getValue("d3dx9").args, picks.getValue("d3dcompiler_43").args)
|
||||
assertEquals(setOf("d3dx9"), AutoComponents.autoPicks(listOf(finding), catalog, mapOf("d3dx9" to false)).keys)
|
||||
assertTrue(AutoComponents.autoPicks(listOf(finding.copy(auto = false)), catalog).isEmpty())
|
||||
}
|
||||
assertEquals(setOf("d3dcompiler_42", "d3dcompiler_43"),
|
||||
AutoComponents.autoPicks(emptyList(), catalog, mapOf("d3dx9" to true)).keys)
|
||||
assertTrue(AutoComponents.autoPicks(emptyList(), catalog, mapOf("xact" to true)).isEmpty())
|
||||
}
|
||||
|
||||
@Test fun effectCompilerSelectionKeepsIndependentFindingsAndSkipsUnavailableComponents() {
|
||||
val catalog = listOf(ready("d3dx9"), ready("d3dcompiler_43"),
|
||||
WinComponents.Component("d3dcompiler_42", "", "", "broken", emptyList(), emptyList())).associateBy { it.name }
|
||||
val findings = listOf(
|
||||
WinCompSources.Finding("d3dx9", "DirectX", WinCompSources.Origin.GOG, true),
|
||||
WinCompSources.Finding("d3dcompiler_43", "Compiler", WinCompSources.Origin.STEAM, true),
|
||||
)
|
||||
val picks = AutoComponents.autoPicks(findings, catalog)
|
||||
assertEquals(setOf("d3dx9", "d3dcompiler_43"), picks.keys)
|
||||
assertEquals("STEAM", picks.getValue("d3dcompiler_43").kind)
|
||||
assertEquals(picks.keys, AutoComponents.autoPicks(findings, catalog, mapOf("d3dx9" to false)).keys)
|
||||
assertEquals(setOf("d3dx9"), AutoComponents.autoPicks(findings.take(1), catalog - "d3dcompiler_43").keys)
|
||||
}
|
||||
|
||||
@Test fun theUsersSwitchWinsOverAnAutoPickEitherWay() {
|
||||
val key = "12345"
|
||||
WinComponents.setAuto(app, key, mapOf("d3dx9" to WinComponents.AutoReason("GOG", listOf("DirectX")), "xact" to WinComponents.AutoReason("GOG", listOf("XACT"))))
|
||||
@@ -279,6 +309,42 @@ class WinCompSourcesTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun installedD3dxGainsCompilersWithoutReplacingUserChoices() = withFakeWorker {
|
||||
AutoComponents.catalogOf = { _, _ -> catalog3 + ready("d3dcompiler_42") + ready("d3dcompiler_43") }
|
||||
installedNow.addAll(catalog3.map { it.name })
|
||||
val game = payback()
|
||||
WinComponents.setUser(app, "1262580", "d3dcompiler_42", false)
|
||||
AutoComponents.queueGame(app, game, asked = true)
|
||||
assertEquals(listOf("d3dcompiler_43"), downloaded)
|
||||
assertEquals(setOf("d3dx9", "vcredist2013_dll", "vcredist2019_dll", "d3dcompiler_43"), WinComponents.picks(app, "1262580").toSet())
|
||||
assertEquals(mapOf("d3dcompiler_42" to false), WinComponents.selection(app, "1262580").user)
|
||||
assertTrue(AutoComponents.Pending.ids(app, "1262580").isEmpty())
|
||||
AutoComponents.queueGame(app, game, asked = true)
|
||||
assertEquals(listOf("d3dcompiler_43"), downloaded)
|
||||
WinComponents.setUser(app, "1262580", "d3dx9", false)
|
||||
AutoComponents.queueGame(app, game, asked = true)
|
||||
assertEquals(setOf("vcredist2013_dll", "vcredist2019_dll"), WinComponents.picks(app, "1262580").toSet())
|
||||
}
|
||||
|
||||
@Test fun manuallySelectedD3dxQueuesCompilersBeforeLaunch() = withFakeWorker {
|
||||
AutoComponents.catalogOf = { _, _ -> catalog3 + ready("d3dcompiler_42") + ready("d3dcompiler_43") }
|
||||
installedNow.add("d3dx9")
|
||||
val game = game(tmp.newFolder("ManualEffects"), Library.ADDED)
|
||||
val key = AutoComponents.appKey(game)!!
|
||||
WinComponents.setUser(app, key, "d3dx9", true)
|
||||
WinComponents.setUser(app, key, "d3dcompiler_42", false)
|
||||
session = true
|
||||
gameUp = true
|
||||
assertTrue(AutoComponents.prepareLaunch(app, game))
|
||||
assertEquals(listOf("d3dcompiler_43"), AutoComponents.Pending.ids(app, key))
|
||||
assertTrue(downloaded.isEmpty())
|
||||
gameUp = false
|
||||
AutoComponents.drain(app)
|
||||
assertEquals(listOf("d3dcompiler_43"), downloaded)
|
||||
assertEquals(setOf("d3dx9", "d3dcompiler_43"), WinComponents.picks(app, key).toSet())
|
||||
assertTrue(AutoComponents.Pending.ids(app, key).isEmpty())
|
||||
}
|
||||
|
||||
@Test fun anExplicitCheckRefreshesTheCatalogAndAnOfflineCheckUsesTheCache() = withFakeWorker {
|
||||
installedNow.addAll(catalog3.map { it.name })
|
||||
val requests = ArrayList<Boolean>()
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.droiddeck.launcher.stores.steam
|
||||
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.snapshots.Snapshot
|
||||
import androidx.compose.runtime.snapshots.StateObject
|
||||
import com.droiddeck.launcher.stores.StoresState
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [33], manifest = Config.NONE)
|
||||
class SteamPickingSnapshotTest {
|
||||
@Test
|
||||
fun theInstallPickerIsReadableInASnapshotOpenedBeforeTheSteamEngineStarts() {
|
||||
StoresState.steamPicking = null
|
||||
val snapshot = Snapshot.takeMutableSnapshot()
|
||||
try {
|
||||
thread { SteamStore.hashCode() }.join()
|
||||
assertNull(snapshot.enter { StoresState.steamPicking })
|
||||
} finally {
|
||||
snapshot.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theSteamEngineHoldsNoComposeState() {
|
||||
val stateFields = SteamStore::class.java.declaredFields.filter {
|
||||
StateObject::class.java.isAssignableFrom(it.type) || State::class.java.isAssignableFrom(it.type)
|
||||
}
|
||||
assertTrue(stateFields.joinToString { it.name }, stateFields.isEmpty())
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,25 @@ import org.junit.Test
|
||||
class XodusDiagnosticsTest {
|
||||
private val rejected = Regex(Xodus.SIGN_IN_REJECTED)
|
||||
|
||||
@Test fun aDeviceLimitReachesTheInstallerWithoutBecomingASignInFailure() {
|
||||
val line = "NEXUS_CONTENT_LICENSE_DIAGNOSTIC_V1 content-device-limit 200"
|
||||
val tail = listOf(line).filter { it.matches(Xodus.reportable) }
|
||||
assertEquals(listOf(line), tail)
|
||||
assertFalse(line.matches(rejected))
|
||||
assertEquals(com.droiddeck.launcher.R.string.stores_xbox_device_group_full, XboxInstaller.licenseRefusal(tail))
|
||||
}
|
||||
|
||||
@Test fun aLaterLicenseSuccessClearsTheDeviceLimitThroughTheDiagnosticFilter() {
|
||||
val stderr = listOf(
|
||||
"NEXUS_CONTENT_LICENSE_DIAGNOSTIC_V1 content-device-limit 200",
|
||||
"NEXUS_CONTENT_LICENSE_DIAGNOSTIC_V1 content-parsed 200",
|
||||
"NEXUS_EXTRACT_DIAGNOSTIC_V1 extract-failed"
|
||||
)
|
||||
val tail = stderr.filter { it.matches(Xodus.reportable) }
|
||||
assertEquals(stderr, tail)
|
||||
assertNull(XboxInstaller.licenseRefusal(tail))
|
||||
}
|
||||
|
||||
@Test fun aContentLicenseRejectionIsRecognised() {
|
||||
assertTrue("Microsoft content licensing rejected sign-in (HTTP 401). Sign in again in Settings.".matches(rejected))
|
||||
}
|
||||
|
||||
@@ -452,7 +452,8 @@ static int ddnatv_execve(const char *filename, char *const argv[], char *const e
|
||||
char resolved_target[PATH_MAX];
|
||||
|
||||
// Only intercept binaries/scripts within DDNATV_ROOT
|
||||
if ((g_ddnatv_root[0] != '\0' && strncmp(target, g_ddnatv_root, g_ddnatv_root_len) == 0) || is_mapped_guest_path(filename)) {
|
||||
if ((g_ddnatv_root[0] != '\0' && strncmp(target, g_ddnatv_root, g_ddnatv_root_len) == 0) || is_mapped_guest_path(filename) ||
|
||||
is_bound_guest_program(target)) {
|
||||
struct exec_probe probe;
|
||||
const char *elf_target = select_exec_target(target, resolved_target, sizeof(resolved_target), &probe);
|
||||
if (probe.is_elf && !probe.is_dynamic) static_elf = elf_target;
|
||||
@@ -969,7 +970,8 @@ static int ddnatv_posix_spawn(pid_t *pid, const char *path,
|
||||
}
|
||||
|
||||
char *const *orig_ep = envp ? envp : environ;
|
||||
int in_root = (g_ddnatv_root[0] != '\0' && strncmp(target, g_ddnatv_root, g_ddnatv_root_len) == 0) || is_mapped_guest_path(path);
|
||||
int in_root = (g_ddnatv_root[0] != '\0' && strncmp(target, g_ddnatv_root, g_ddnatv_root_len) == 0) || is_mapped_guest_path(path) ||
|
||||
is_bound_guest_program(target);
|
||||
|
||||
struct exec_probe probe;
|
||||
char resolved_target[PATH_MAX];
|
||||
|
||||
@@ -983,6 +983,14 @@ static int is_host_interpreter(const char *interp, const char *rewritten) {
|
||||
return probe.android_interp;
|
||||
}
|
||||
|
||||
static int is_bound_guest_program(const char *path) {
|
||||
if (g_ddnatv_root[0] == '\0' || !is_identity_bound_path(path)) return 0;
|
||||
struct exec_probe probe;
|
||||
probe_exec_file(path, &probe);
|
||||
if (probe.is_elf) return probe.is_dynamic && !probe.android_interp;
|
||||
return probe.n >= 2 && probe.hdr[0] == '#' && probe.hdr[1] == '!';
|
||||
}
|
||||
|
||||
// argv for running `script` with its interpreter: interp [arg] script args... (the script's own
|
||||
// argv[0] is dropped, as the kernel does). free() the result.
|
||||
static char **build_script_argv(const char *interp, const char *interp_arg, const char *script, char *const argv[]) {
|
||||
|
||||
@@ -234,6 +234,13 @@ static int is_mapped_guest_path(const char *path) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int is_identity_bound_path(const char *path) {
|
||||
if (!path || path[0] != '/') return 0;
|
||||
for (int i = 0; i < g_nbinds; i++)
|
||||
if (g_binds[i].identity && is_path_prefix(path, g_binds[i].dst, g_binds[i].dst_len)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Android's own mounts and files, which must never be redirected into the rootfs.
|
||||
// `path` starts with '/'; a prefix can only match when its second character does.
|
||||
static int is_android_host_path(const char *path) {
|
||||
|
||||
@@ -120,6 +120,14 @@ class NativeHookLdsoSpawnTest(unittest.TestCase):
|
||||
script.parent.mkdir(exist_ok=True)
|
||||
script.write_text(f"#!{interpreter}\n")
|
||||
script.chmod(0o755)
|
||||
cls.app_files = tmp / "app-files"
|
||||
cls.app_files.mkdir()
|
||||
shutil.copy(cls.probe, cls.app_files / "tool")
|
||||
shutil.copy(cls.android / "sh", cls.app_files / "android-tool")
|
||||
for name, interpreter in (("guest.py", GUEST_TOOL), ("android.sh", f"{ANDROID_DIR}/sh")):
|
||||
(cls.app_files / name).write_text(f"#!{interpreter}\n")
|
||||
for entry in cls.app_files.iterdir():
|
||||
entry.chmod(0o755)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
@@ -220,6 +228,32 @@ class NativeHookLdsoSpawnTest(unittest.TestCase):
|
||||
call = self.call(how, "/opt/host.sh", "x", binds=f"{self.runtime}:{BOUND_DIR}")
|
||||
self.assertEqual([HOST_SHELL, HOST_SHELL, str(self.root / "opt/host.sh"), "x"], call)
|
||||
|
||||
def test_a_script_on_a_mount_at_its_host_path_runs_with_the_guest_interpreter(self):
|
||||
script = str(self.app_files / "guest.py")
|
||||
for how in ("exec", "spawn"):
|
||||
with self.subTest(how=how):
|
||||
call = self.call(how, script, "x", binds=f"{self.app_files}:{self.app_files}")
|
||||
self.assertEqual(str(self.root / GUEST_LDSO.lstrip("/")), call[0])
|
||||
self.assertEqual([str(self.root / GUEST_TOOL.lstrip("/")), script, "x"], call[-3:])
|
||||
|
||||
def test_a_glibc_program_on_a_mount_at_its_host_path_starts_through_the_guest_ldso(self):
|
||||
tool = str(self.app_files / "tool")
|
||||
for how in ("exec", "spawn"):
|
||||
with self.subTest(how=how):
|
||||
call = self.call(how, tool, "x", binds=f"{self.app_files}:{self.app_files}")
|
||||
self.assertEqual(str(self.root / GUEST_LDSO.lstrip("/")), call[0])
|
||||
self.assertEqual([tool, "x"], call[-2:])
|
||||
|
||||
def test_android_programs_on_a_mount_at_its_host_path_stay_on_the_host(self):
|
||||
tool = str(self.app_files / "android-tool")
|
||||
script = str(self.app_files / "android.sh")
|
||||
sh = str(self.android / "sh")
|
||||
binds = f"{self.app_files}:{self.app_files}|{self.android}:{ANDROID_DIR}"
|
||||
for how in ("exec", "spawn"):
|
||||
with self.subTest(how=how):
|
||||
self.assertEqual([tool, tool, "x"], self.call(how, tool, "x", binds=binds))
|
||||
self.assertEqual([sh, sh, script, "x"], self.call(how, script, "x", binds=binds))
|
||||
|
||||
def test_an_android_interpreter_reached_through_a_bind_stays_on_the_host(self):
|
||||
sh = str(self.android / "sh")
|
||||
for how in ("exec", "spawn"):
|
||||
|
||||
Reference in new issue
Block a user