mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed02f6a92b | ||
|
|
a8918c7a01 | ||
|
|
f211bbb5a8 | ||
|
|
36c807fbce | ||
|
|
5306b2ba03 | ||
|
|
a335cac006 | ||
|
|
2151db3883 | ||
|
|
823f70320f | ||
|
|
bf7f7ecda7 | ||
|
|
3b8b14b06c | ||
|
|
a305a91c66 | ||
|
|
3e558ab33e | ||
|
|
d5b9cf5b41 |
No files matched your search
@@ -232,6 +232,7 @@
|
||||
android:exported="false"
|
||||
android:screenOrientation="user"
|
||||
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|density"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:theme="@style/AppTheme" />
|
||||
|
||||
<activity
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#define SYS_munmap 215
|
||||
#define SYS_mmap 222
|
||||
#define SYS_mprotect 226
|
||||
#define SYS_getpid 172
|
||||
|
||||
#define AT_FDCWD_ (-100)
|
||||
#define O_RDONLY_ 0
|
||||
@@ -52,6 +53,21 @@ static size_t slen(const char *s) {
|
||||
return n;
|
||||
}
|
||||
|
||||
static int seq(const char *a, const char *b) {
|
||||
while (*a && *a == *b) a++, b++;
|
||||
return *a == *b;
|
||||
}
|
||||
|
||||
static const char *env_get(char **envp, const char *name) {
|
||||
size_t n = slen(name);
|
||||
for (; *envp; envp++) {
|
||||
size_t i = 0;
|
||||
while (i < n && (*envp)[i] == name[i]) i++;
|
||||
if (i == n && (*envp)[n] == '=') return *envp + n + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void out(const char *s) { sys6(SYS_write, 2, (long)s, (long)slen(s), 0, 0, 0); }
|
||||
|
||||
static void out_num(long v) {
|
||||
@@ -112,19 +128,43 @@ static int prot_of(uint32_t flags) {
|
||||
|
||||
static void map_failed(const char *path, long r) { die("cannot map a segment", path, r); }
|
||||
|
||||
static void load(const char *path, struct image *im, uintptr_t page) {
|
||||
static void read_interp(int fd, const Elf64_Phdr *ph, int phnum, char *interp, size_t size, const char *path) {
|
||||
interp[0] = 0;
|
||||
for (int i = 0; i < phnum; i++) {
|
||||
if (ph[i].p_type != PT_INTERP) continue;
|
||||
if (ph[i].p_filesz == 0 || ph[i].p_filesz >= size) die("bad PT_INTERP", path, 0);
|
||||
if (xpread(fd, interp, ph[i].p_filesz, (long)ph[i].p_offset) != (long)ph[i].p_filesz)
|
||||
die("truncated PT_INTERP", path, 0);
|
||||
interp[ph[i].p_filesz] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int read_headers(const char *path, Elf64_Ehdr *eh, Elf64_Phdr *ph) {
|
||||
int fd = (int)sys6(SYS_openat, AT_FDCWD_, (long)path, O_RDONLY_ | O_CLOEXEC_, 0, 0, 0);
|
||||
if (fd < 0) die("cannot open", path, fd);
|
||||
Elf64_Ehdr eh;
|
||||
if (xpread(fd, &eh, sizeof(eh), 0) != (long)sizeof(eh)) die("not an ELF file", path, 0);
|
||||
if (eh.e_ident[EI_MAG0] != ELFMAG0 || eh.e_ident[EI_MAG1] != ELFMAG1 || eh.e_ident[EI_MAG2] != ELFMAG2 ||
|
||||
eh.e_ident[EI_MAG3] != ELFMAG3 || eh.e_ident[EI_CLASS] != ELFCLASS64 || eh.e_machine != EM_AARCH64 ||
|
||||
(eh.e_type != ET_EXEC && eh.e_type != ET_DYN) || eh.e_phentsize != sizeof(Elf64_Phdr) ||
|
||||
eh.e_phnum == 0 || eh.e_phnum > MAX_PHDRS)
|
||||
if (xpread(fd, eh, sizeof(*eh), 0) != (long)sizeof(*eh)) die("not an ELF file", path, 0);
|
||||
if (eh->e_ident[EI_MAG0] != ELFMAG0 || eh->e_ident[EI_MAG1] != ELFMAG1 || eh->e_ident[EI_MAG2] != ELFMAG2 ||
|
||||
eh->e_ident[EI_MAG3] != ELFMAG3 || eh->e_ident[EI_CLASS] != ELFCLASS64 || eh->e_machine != EM_AARCH64 ||
|
||||
(eh->e_type != ET_EXEC && eh->e_type != ET_DYN) || eh->e_phentsize != sizeof(Elf64_Phdr) ||
|
||||
eh->e_phnum == 0 || eh->e_phnum > MAX_PHDRS)
|
||||
die("not a 64-bit ARM ELF program", path, 0);
|
||||
long size = (long)eh->e_phnum * (long)sizeof(Elf64_Phdr);
|
||||
if (xpread(fd, ph, (size_t)size, (long)eh->e_phoff) != size) die("truncated program headers", path, 0);
|
||||
return fd;
|
||||
}
|
||||
|
||||
static void interp_of(const char *path, char *interp, size_t size) {
|
||||
Elf64_Ehdr eh;
|
||||
Elf64_Phdr ph[MAX_PHDRS];
|
||||
long size = (long)eh.e_phnum * (long)sizeof(Elf64_Phdr);
|
||||
if (xpread(fd, ph, (size_t)size, (long)eh.e_phoff) != size) die("truncated program headers", path, 0);
|
||||
int fd = read_headers(path, &eh, ph);
|
||||
read_interp(fd, ph, eh.e_phnum, interp, size, path);
|
||||
sys6(SYS_close, fd, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
static void load(const char *path, struct image *im, uintptr_t page) {
|
||||
Elf64_Ehdr eh;
|
||||
Elf64_Phdr ph[MAX_PHDRS];
|
||||
int fd = read_headers(path, &eh, ph);
|
||||
|
||||
uintptr_t lo = UINTPTR_MAX, hi = 0;
|
||||
for (int i = 0; i < eh.e_phnum; i++) {
|
||||
@@ -173,16 +213,9 @@ static void load(const char *path, struct image *im, uintptr_t page) {
|
||||
im->phnum = eh.e_phnum;
|
||||
im->phent = eh.e_phentsize;
|
||||
im->phdr = 0;
|
||||
im->interp[0] = 0;
|
||||
for (int i = 0; i < eh.e_phnum; i++) {
|
||||
read_interp(fd, ph, eh.e_phnum, im->interp, sizeof(im->interp), path);
|
||||
for (int i = 0; i < eh.e_phnum; i++)
|
||||
if (ph[i].p_type == PT_PHDR) im->phdr = bias + ph[i].p_vaddr;
|
||||
if (ph[i].p_type == PT_INTERP) {
|
||||
if (ph[i].p_filesz == 0 || ph[i].p_filesz >= sizeof(im->interp)) die("bad PT_INTERP", path, 0);
|
||||
if (xpread(fd, im->interp, ph[i].p_filesz, (long)ph[i].p_offset) != (long)ph[i].p_filesz)
|
||||
die("truncated PT_INTERP", path, 0);
|
||||
im->interp[ph[i].p_filesz] = 0;
|
||||
}
|
||||
}
|
||||
if (!im->phdr) {
|
||||
for (int i = 0; i < eh.e_phnum; i++) {
|
||||
Elf64_Phdr *p = &ph[i];
|
||||
@@ -202,6 +235,36 @@ static unsigned long auxv_get(const uintptr_t *auxv, unsigned long type, unsigne
|
||||
return fallback;
|
||||
}
|
||||
|
||||
static int is_self_exe(const char *execfn) {
|
||||
if (!execfn) return 0;
|
||||
if (seq(execfn, "/proc/self/exe") || seq(execfn, "/proc/thread-self/exe")) return 1;
|
||||
const char *p = "/proc/";
|
||||
while (*p && *p == *execfn) p++, execfn++;
|
||||
if (*p) return 0;
|
||||
char num[24];
|
||||
int i = (int)sizeof(num) - 1;
|
||||
num[i] = 0;
|
||||
unsigned long pid = (unsigned long)sys6(SYS_getpid, 0, 0, 0, 0, 0, 0);
|
||||
do {
|
||||
num[--i] = (char)('0' + pid % 10);
|
||||
pid /= 10;
|
||||
} while (pid && i > 0);
|
||||
const char *d = num + i;
|
||||
while (*d && *d == *execfn) d++, execfn++;
|
||||
return !*d && seq(execfn, "/exe");
|
||||
}
|
||||
|
||||
static const char *guest_interp(char **envp, const char *interp, char *buf, size_t size) {
|
||||
const char *root = env_get(envp, "DDNATV_ROOT");
|
||||
if (!root || interp[0] != '/') return interp;
|
||||
size_t a = slen(root), b = slen(interp);
|
||||
if (a + b + 1 > size) return interp;
|
||||
for (size_t i = 0; i < a; i++) buf[i] = root[i];
|
||||
for (size_t i = 0; i <= b; i++) buf[a + i] = interp[i];
|
||||
if (sys6(SYS_faccessat, AT_FDCWD_, (long)buf, 0, 0, 0, 0) != 0) return interp;
|
||||
return buf;
|
||||
}
|
||||
|
||||
__attribute__((used, noreturn)) void ddexec_main(uintptr_t *sp) {
|
||||
long argc = (long)sp[0];
|
||||
char **argv = (char **)(sp + 1);
|
||||
@@ -211,25 +274,66 @@ __attribute__((used, noreturn)) void ddexec_main(uintptr_t *sp) {
|
||||
uintptr_t *auxv = (uintptr_t *)(envp + nenv + 1);
|
||||
long naux = 0;
|
||||
while (auxv[naux * 2] != AT_NULL) naux++;
|
||||
if (argc < 3) die("usage: libddexec.so <file> <argv0> [args...]", 0, 0);
|
||||
int reexec = is_self_exe((const char *)auxv_get(auxv, AT_EXECFN, 0));
|
||||
const char *path;
|
||||
char **args = argv + 2;
|
||||
long nargs = argc - 2;
|
||||
char interp_buf[4096];
|
||||
char hook_buf[4096];
|
||||
if (reexec) {
|
||||
path = env_get(envp, "DDNATV_REAL_EXE");
|
||||
if (!path || !path[0]) die("re-executed without DDNATV_REAL_EXE", 0, 0);
|
||||
args = argv;
|
||||
nargs = argc;
|
||||
const char *lib_path = env_get(envp, "DDNATV_LIBRARY_PATH");
|
||||
char prog_interp[256];
|
||||
interp_of(path, prog_interp, sizeof(prog_interp));
|
||||
if (prog_interp[0] && lib_path && lib_path[0]) {
|
||||
const char *ld_so = guest_interp(envp, prog_interp, interp_buf, sizeof(interp_buf));
|
||||
const char *hook = guest_interp(envp, "/usr/lib/libddnatv-hook.so", hook_buf, sizeof(hook_buf));
|
||||
if (hook != (const char *)hook_buf) hook = guest_interp(envp, "/lib/libddnatv-hook.so", hook_buf, sizeof(hook_buf));
|
||||
long n = argc > 1 ? argc - 1 : 0;
|
||||
char **v = (char **)__builtin_alloca((size_t)(n + 9) * sizeof(char *));
|
||||
long k = 0;
|
||||
v[k++] = (char *)ld_so;
|
||||
if (hook == (const char *)hook_buf) {
|
||||
v[k++] = (char *)"--preload";
|
||||
v[k++] = (char *)hook;
|
||||
}
|
||||
v[k++] = (char *)"--library-path";
|
||||
v[k++] = (char *)lib_path;
|
||||
v[k++] = (char *)"--argv0";
|
||||
v[k++] = argc > 0 ? argv[0] : (char *)path;
|
||||
v[k++] = (char *)path;
|
||||
for (long i = 0; i < n; i++) v[k++] = argv[1 + i];
|
||||
v[k] = 0;
|
||||
args = v;
|
||||
nargs = k;
|
||||
path = ld_so;
|
||||
}
|
||||
} else if (argc < 3) {
|
||||
die("usage: libddexec.so <file> <argv0> [args...]", 0, 0);
|
||||
} else {
|
||||
path = argv[1];
|
||||
}
|
||||
|
||||
uintptr_t page = auxv_get(auxv, AT_PAGESZ, 4096);
|
||||
const char *path = argv[1];
|
||||
struct image prog, interp;
|
||||
load(path, &prog, page);
|
||||
int has_interp = prog.interp[0] != 0;
|
||||
if (has_interp) load(prog.interp, &interp, page);
|
||||
if (has_interp) load(reexec ? guest_interp(envp, prog.interp, interp_buf, sizeof(interp_buf)) : prog.interp, &interp, page);
|
||||
|
||||
// The new stack: argc, argv, envp and auxv as the kernel lays them out, below the current one.
|
||||
// The strings stay where the kernel put them.
|
||||
static const unsigned long replaced[] = {AT_PHDR, AT_PHENT, AT_PHNUM, AT_BASE, AT_ENTRY, AT_EXECFN};
|
||||
long nreplaced = (long)(sizeof(replaced) / sizeof(replaced[0]));
|
||||
long new_argc = argc - 2;
|
||||
long new_argc = nargs;
|
||||
long words = 1 + (new_argc + 1) + (nenv + 1) + (naux + nreplaced + 1) * 2;
|
||||
uintptr_t *nsp = (uintptr_t *)(((uintptr_t)sp - STACK_GAP - (uintptr_t)words * sizeof(uintptr_t)) & ~(uintptr_t)15);
|
||||
uintptr_t top = (uintptr_t)args < (uintptr_t)sp ? (uintptr_t)args : (uintptr_t)sp;
|
||||
uintptr_t *nsp = (uintptr_t *)((top - STACK_GAP - (uintptr_t)words * sizeof(uintptr_t)) & ~(uintptr_t)15);
|
||||
uintptr_t *w = nsp;
|
||||
*w++ = (uintptr_t)new_argc;
|
||||
for (long i = 0; i < new_argc; i++) *w++ = (uintptr_t)argv[i + 2];
|
||||
for (long i = 0; i < new_argc; i++) *w++ = (uintptr_t)args[i];
|
||||
*w++ = 0;
|
||||
for (long i = 0; i < nenv; i++) *w++ = (uintptr_t)envp[i];
|
||||
*w++ = 0;
|
||||
|
||||
@@ -6,6 +6,7 @@ import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import com.droiddeck.launcher.runtime.DeckyManager
|
||||
import com.droiddeck.launcher.runtime.DeckyStore
|
||||
import com.droiddeck.launcher.session.SessionState
|
||||
import java.io.File
|
||||
|
||||
@@ -21,6 +22,59 @@ internal class DeckyMenu(private val activity: android.app.Activity, private val
|
||||
var deckySupervisor by mutableStateOf(false)
|
||||
var deckyPendingZip by mutableStateOf<File?>(null)
|
||||
var deckyReleaseRequest = 0
|
||||
var deckyPlugins by mutableStateOf<List<DeckyStore.Installed>>(emptyList())
|
||||
var deckyStore by mutableStateOf<List<DeckyStore.Plugin>?>(null)
|
||||
var deckyStoreFailed by mutableStateOf(false)
|
||||
private var storeRequest = 0
|
||||
|
||||
fun refreshPlugins() {
|
||||
Thread({
|
||||
val found = DeckyStore.installed(activity)
|
||||
ui.post { deckyPlugins = found }
|
||||
}, "decky-plugins").start()
|
||||
}
|
||||
|
||||
fun refreshStore() {
|
||||
val request = ++storeRequest
|
||||
deckyStore = null; deckyStoreFailed = false
|
||||
Thread({
|
||||
val listing = DeckyStore.fetch()
|
||||
ui.post {
|
||||
if (request != storeRequest) return@post
|
||||
deckyStore = listing.orEmpty(); deckyStoreFailed = listing == null
|
||||
}
|
||||
}, "decky-store").start()
|
||||
}
|
||||
|
||||
fun installStorePlugin(plugin: DeckyStore.Plugin) {
|
||||
val version = plugin.latest ?: return
|
||||
if (deckyStage != null || SessionState.running || deckyInstalled == null) return
|
||||
deckyStage = activity.getString(R.string.decky_plugin_starting); deckyPercent = -1
|
||||
Thread({
|
||||
val problem = runCatching {
|
||||
DeckyStore.install(activity, plugin, version) { label, value ->
|
||||
val binary = DeckyManager.downloadingBinary
|
||||
ui.post { deckyStage = label; deckyPercent = value; deckyDownloadingBinary = binary }
|
||||
}
|
||||
}.getOrElse { error -> activity.getString(R.string.decky_plugin_failed, error.message ?: error.javaClass.simpleName) }
|
||||
ui.post {
|
||||
deckyStage = null; deckyPercent = -1; deckyDownloadingBinary = false
|
||||
android.widget.Toast.makeText(activity, problem ?: activity.getString(R.string.decky_plugin_installed), android.widget.Toast.LENGTH_LONG).show()
|
||||
refreshPlugins()
|
||||
}
|
||||
}, "install-decky-store").start()
|
||||
}
|
||||
|
||||
fun removePlugin(plugin: DeckyStore.Installed) {
|
||||
if (deckyStage != null || SessionState.running) return
|
||||
Thread({
|
||||
val problem = DeckyStore.remove(activity, plugin)
|
||||
ui.post {
|
||||
if (problem != null) android.widget.Toast.makeText(activity, problem, android.widget.Toast.LENGTH_LONG).show()
|
||||
refreshPlugins()
|
||||
}
|
||||
}, "remove-decky-plugin").start()
|
||||
}
|
||||
|
||||
fun refreshDecky() {
|
||||
val request = ++deckyReleaseRequest
|
||||
@@ -90,6 +144,7 @@ internal class DeckyMenu(private val activity: android.app.Activity, private val
|
||||
deckyStage = null; deckyPercent = -1; deckyDownloadingBinary = false
|
||||
val message = problem ?: activity.getString(R.string.decky_plugin_installed)
|
||||
android.widget.Toast.makeText(activity, message, android.widget.Toast.LENGTH_LONG).show()
|
||||
refreshPlugins()
|
||||
}
|
||||
}, "import-decky-plugin").start()
|
||||
}
|
||||
|
||||
@@ -921,7 +921,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
request.getStringExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV)?.let { navRequest = it; request.removeExtra(com.droiddeck.launcher.stores.download.StoreDownloadService.EXTRA_NAV) }
|
||||
request.data?.takeIf { it.scheme == "droiddeck" && it.host == "settings" }?.let { uri ->
|
||||
val section = uri.pathSegments.firstOrNull()
|
||||
navRequest = if (section in setOf("storage", "sync", "downloads")) section
|
||||
navRequest = if (section in setOf("storage", "sync", "downloads", "decky", "boot-movies")) section
|
||||
else "settings:" + (com.droiddeck.launcher.ui.SettingsSection.of(section) ?: com.droiddeck.launcher.ui.SettingsSection.OVERVIEW).key
|
||||
request.data = null
|
||||
gameLinkReading = false
|
||||
@@ -2690,6 +2690,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
deckyChecking = decky.deckyChecking, deckyStage = decky.deckyStage, deckyPercent = decky.deckyPercent,
|
||||
deckyDownloadingBinary = decky.deckyDownloadingBinary,
|
||||
deckyEnabled = decky.deckySupervisor, deckySessionRunning = SessionState.running,
|
||||
deckyPlugins = decky.deckyPlugins, deckyStore = decky.deckyStore, deckyStoreFailed = decky.deckyStoreFailed,
|
||||
),
|
||||
ModeSettingsActions(
|
||||
onIntegration = ::configureIntegration,
|
||||
@@ -2800,6 +2801,9 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
decky.deckyInstalled = null
|
||||
decky.deckySupervisor = false
|
||||
},
|
||||
onDeckyStoreRefresh = { decky.refreshStore() },
|
||||
onDeckyStoreInstall = { plugin -> decky.installStorePlugin(plugin) },
|
||||
onDeckyRemove = { plugin -> decky.removePlugin(plugin) },
|
||||
onPickDeckyPluginZip = {
|
||||
pickDeckyPluginZip.launch(InAppFilePicker.buildIntent(this, ZIP_EXT, getString(R.string.main_pick_decky_zip)))
|
||||
},
|
||||
@@ -3090,6 +3094,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
decky.deckyInstalled = deckyInstalled
|
||||
decky.deckySupervisor = deckySupervisor
|
||||
decky.refreshDecky()
|
||||
decky.refreshPlugins()
|
||||
}
|
||||
fetchAddedGameArt()
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import androidx.compose.material.icons.filled.ArrowUpward
|
||||
import androidx.compose.material.icons.filled.Checklist
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material.icons.filled.FileCopy
|
||||
import androidx.compose.material.icons.filled.FileOpen
|
||||
import androidx.compose.material.icons.filled.Folder
|
||||
import androidx.compose.material.icons.filled.Info
|
||||
import androidx.compose.material.icons.filled.InsertDriveFile
|
||||
@@ -101,8 +102,18 @@ private fun FileContextMenuItems(
|
||||
onToggleFavorite: () -> Unit,
|
||||
onProperties: () -> Unit,
|
||||
onDismissMenu: () -> Unit,
|
||||
onOpen: () -> Unit,
|
||||
) {
|
||||
val isDir = file.isDirectory
|
||||
if (!isDir) {
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(R.string.fm_edit_open)) },
|
||||
leadingIcon = { Icon(Icons.Filled.FileOpen, null, tint = MaterialTheme.colorScheme.primary) },
|
||||
onClick = { onDismissMenu(); onOpen() },
|
||||
modifier = Modifier.focusGlide(),
|
||||
)
|
||||
MenuItemDivider()
|
||||
}
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(R.string.fm_select)) },
|
||||
leadingIcon = { Icon(Icons.Filled.Checklist, null, tint = MaterialTheme.colorScheme.primary) },
|
||||
@@ -180,6 +191,7 @@ internal fun FileItemRow(
|
||||
onCut: () -> Unit,
|
||||
onDelete: () -> Unit,
|
||||
onRename: () -> Unit,
|
||||
onOpen: () -> Unit = {},
|
||||
isFavorite: Boolean = false,
|
||||
onToggleFavorite: () -> Unit = {},
|
||||
onProperties: () -> Unit = {},
|
||||
@@ -291,6 +303,7 @@ internal fun FileItemRow(
|
||||
file = file,
|
||||
isFavorite = isFavorite,
|
||||
onSelect = onSelect,
|
||||
onOpen = onOpen,
|
||||
onRename = onRename,
|
||||
onCopy = onCopy,
|
||||
onCut = onCut,
|
||||
@@ -517,6 +530,7 @@ internal fun FileGridTile(
|
||||
isFavorite: Boolean = false,
|
||||
onSelect: () -> Unit = {},
|
||||
onRename: () -> Unit = {},
|
||||
onOpen: () -> Unit = {},
|
||||
onCopy: () -> Unit = {},
|
||||
onCut: () -> Unit = {},
|
||||
onDelete: () -> Unit = {},
|
||||
@@ -605,6 +619,7 @@ internal fun FileGridTile(
|
||||
file = file,
|
||||
isFavorite = isFavorite,
|
||||
onSelect = onSelect,
|
||||
onOpen = onOpen,
|
||||
onRename = onRename,
|
||||
onCopy = onCopy,
|
||||
onCut = onCut,
|
||||
|
||||
@@ -191,6 +191,7 @@ fun FileManagerScreen(
|
||||
var compactRows by remember { mutableStateOf(browsePrefs.getBoolean("fmCompactRows", false)) }
|
||||
var showNewFolderDialog by remember { mutableStateOf(false) }
|
||||
var renameTarget by remember { mutableStateOf<File?>(null) }
|
||||
var editingTarget by remember { mutableStateOf<File?>(null) }
|
||||
var propertiesTarget by remember { mutableStateOf<File?>(null) }
|
||||
var isOperationRunning by remember { mutableStateOf(false) }
|
||||
var operationLabel by remember { mutableStateOf("") }
|
||||
@@ -294,7 +295,7 @@ fun FileManagerScreen(
|
||||
if (isOperationActive()) pendingNavigation = action else navigate(action)
|
||||
}
|
||||
|
||||
BackHandler(enabled = operationActive || cancellingNavigation || showFavorites || currentDir != currentRoot || history.isNotEmpty()) {
|
||||
BackHandler(enabled = editingTarget == null && (operationActive || cancellingNavigation || showFavorites || currentDir != currentRoot || history.isNotEmpty())) {
|
||||
requestNavigation(FileManagerNavigation.BACK)
|
||||
}
|
||||
|
||||
@@ -696,6 +697,14 @@ fun FileManagerScreen(
|
||||
|
||||
val compactToolbar = LocalConfiguration.current.screenWidthDp < 600
|
||||
Column(modifier = Modifier.fillMaxSize()) {
|
||||
editingTarget?.let { target ->
|
||||
TextEditorScreen(
|
||||
file = target,
|
||||
onExit = { editingTarget = null },
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
)
|
||||
return@Column
|
||||
}
|
||||
if (pickMode && !pickerTitle.isNullOrEmpty()) {
|
||||
Text(
|
||||
text = pickerTitle,
|
||||
@@ -1194,6 +1203,8 @@ fun FileManagerScreen(
|
||||
pickPrefs.edit().putString("lastFilePickerDir", currentDir.absolutePath).apply()
|
||||
onPick?.invoke(file)
|
||||
}
|
||||
} else {
|
||||
editingTarget = file
|
||||
}
|
||||
},
|
||||
onMenu = { showMenuFor = file },
|
||||
@@ -1205,6 +1216,7 @@ fun FileManagerScreen(
|
||||
selectedPaths = selectedPaths + file.absolutePath
|
||||
showMenuFor = null
|
||||
},
|
||||
onOpen = { editingTarget = file; showMenuFor = null },
|
||||
onRename = { renameTarget = file; showMenuFor = null },
|
||||
onCopy = { clipboardFiles = listOf(file); isCutOperation = false; showMenuFor = null },
|
||||
onCut = { clipboardFiles = listOf(file); isCutOperation = true; showMenuFor = null },
|
||||
@@ -1273,6 +1285,8 @@ fun FileManagerScreen(
|
||||
pickPrefs.edit().putString("lastFilePickerDir", currentDir.absolutePath).apply()
|
||||
onPick?.invoke(file)
|
||||
}
|
||||
} else {
|
||||
editingTarget = file
|
||||
}
|
||||
},
|
||||
onMenu = { showMenuFor = file },
|
||||
@@ -1286,6 +1300,7 @@ fun FileManagerScreen(
|
||||
onCopy = { clipboardFiles = listOf(file); isCutOperation = false; showMenuFor = null },
|
||||
onCut = { clipboardFiles = listOf(file); isCutOperation = true; showMenuFor = null },
|
||||
onDelete = { selectedEntry = file; showMenuFor = null },
|
||||
onOpen = { editingTarget = file; showMenuFor = null },
|
||||
onRename = { renameTarget = file; showMenuFor = null },
|
||||
isFavorite = isFav,
|
||||
onToggleFavorite = {
|
||||
|
||||
@@ -0,0 +1,726 @@
|
||||
package com.droiddeck.launcher.files
|
||||
|
||||
import android.widget.Toast
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.ScrollState
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.horizontalScroll
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.IntrinsicSize
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.text.BasicTextField
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material.icons.filled.KeyboardArrowDown
|
||||
import androidx.compose.material.icons.filled.KeyboardArrowUp
|
||||
import androidx.compose.material.icons.filled.Save
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.SolidColor
|
||||
import androidx.compose.ui.layout.onSizeChanged
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.TextRange
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.input.ImeAction
|
||||
import androidx.compose.ui.text.input.KeyboardCapitalization
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.text.rememberTextMeasurer
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.ui.focusGlide
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.charset.CharacterCodingException
|
||||
import java.nio.charset.Charset
|
||||
import java.nio.charset.CodingErrorAction
|
||||
import java.nio.file.Files
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
internal const val EDITOR_FONT_SIZE_SP = 13
|
||||
internal const val EDITOR_LINE_HEIGHT_SP = 18
|
||||
internal const val EDITOR_TAB_WIDTH = 4
|
||||
internal const val EDITOR_MAX_OPEN_BYTES = 4L * 1024 * 1024
|
||||
internal const val EDITOR_MAX_EDIT_BYTES = 512L * 1024
|
||||
|
||||
internal enum class EditorCharset(val label: String, private val charsetName: String) {
|
||||
UTF8("UTF-8", "UTF-8"),
|
||||
GB18030("GB18030", "GB18030"),
|
||||
;
|
||||
|
||||
val charset: Charset get() = Charset.forName(charsetName)
|
||||
}
|
||||
|
||||
internal enum class EditorLock { NONE, BINARY, TOO_LARGE, PERMISSION, LOSSY }
|
||||
|
||||
internal enum class EditorLoadState { LOADING, READY, TOO_LARGE, UNREADABLE }
|
||||
|
||||
internal data class DecodedEditorText(val text: String, val charset: EditorCharset, val lossy: Boolean)
|
||||
|
||||
internal fun editorIsBinary(bytes: ByteArray, sample: Int = 8192): Boolean {
|
||||
val limit = minOf(bytes.size, sample)
|
||||
for (i in 0 until limit) if (bytes[i].toInt() == 0) return true
|
||||
return false
|
||||
}
|
||||
|
||||
private fun strictDecode(bytes: ByteArray, charset: Charset): String? = try {
|
||||
charset.newDecoder()
|
||||
.onMalformedInput(CodingErrorAction.REPORT)
|
||||
.onUnmappableCharacter(CodingErrorAction.REPORT)
|
||||
.decode(ByteBuffer.wrap(bytes))
|
||||
.toString()
|
||||
} catch (e: CharacterCodingException) {
|
||||
null
|
||||
}
|
||||
|
||||
internal fun decodeEditorText(bytes: ByteArray): DecodedEditorText {
|
||||
strictDecode(bytes, Charsets.UTF_8)?.let { return DecodedEditorText(it, EditorCharset.UTF8, false) }
|
||||
strictDecode(bytes, EditorCharset.GB18030.charset)?.let { return DecodedEditorText(it, EditorCharset.GB18030, false) }
|
||||
return DecodedEditorText(String(bytes, Charsets.UTF_8), EditorCharset.UTF8, true)
|
||||
}
|
||||
|
||||
internal fun resolveEditorSaveTarget(file: File): File {
|
||||
val isLink = runCatching { Files.isSymbolicLink(file.toPath()) }.getOrDefault(false)
|
||||
if (!isLink) return file
|
||||
// rename(2) replaces the link itself, so stage next to and rename onto the real target
|
||||
return runCatching { file.canonicalFile }.getOrDefault(file)
|
||||
}
|
||||
|
||||
internal fun readCapped(input: InputStream, limit: Long): ByteArray? {
|
||||
val out = ByteArrayOutputStream()
|
||||
val buffer = ByteArray(64 * 1024)
|
||||
var total = 0L
|
||||
while (true) {
|
||||
val n = input.read(buffer)
|
||||
if (n < 0) return out.toByteArray()
|
||||
total += n
|
||||
if (total > limit) return null
|
||||
out.write(buffer, 0, n)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun expandEditorTabs(text: String, width: Int = EDITOR_TAB_WIDTH): String {
|
||||
if (text.indexOf('\t') < 0) return text
|
||||
val out = StringBuilder(text.length)
|
||||
var column = 0
|
||||
for (c in text) {
|
||||
when (c) {
|
||||
'\n' -> {
|
||||
out.append(c)
|
||||
column = 0
|
||||
}
|
||||
'\t' -> {
|
||||
val pad = width - (column % width)
|
||||
repeat(pad) { out.append(' ') }
|
||||
column += pad
|
||||
}
|
||||
else -> {
|
||||
out.append(c)
|
||||
column++
|
||||
}
|
||||
}
|
||||
}
|
||||
return out.toString()
|
||||
}
|
||||
|
||||
internal fun lineCountOf(text: String): Int {
|
||||
var lines = 1
|
||||
for (i in text.indices) if (text[i] == '\n') lines++
|
||||
return lines
|
||||
}
|
||||
|
||||
internal fun lineIndexOfOffset(text: String, offset: Int): Int {
|
||||
val end = offset.coerceIn(0, text.length)
|
||||
var line = 0
|
||||
var i = 0
|
||||
while (i < end) {
|
||||
if (text[i] == '\n') line++
|
||||
i++
|
||||
}
|
||||
return line
|
||||
}
|
||||
|
||||
internal fun columnOfOffset(text: String, offset: Int): Int {
|
||||
val end = offset.coerceIn(0, text.length)
|
||||
var start = end
|
||||
while (start > 0 && text[start - 1] != '\n') start--
|
||||
return end - start + 1
|
||||
}
|
||||
|
||||
internal fun findEditorMatches(
|
||||
text: String,
|
||||
query: String,
|
||||
matchCase: Boolean = false,
|
||||
limit: Int = 10000,
|
||||
): List<IntRange> {
|
||||
if (query.isEmpty()) return emptyList()
|
||||
val out = ArrayList<IntRange>()
|
||||
var at = 0
|
||||
while (out.size < limit) {
|
||||
val found = text.indexOf(query, at, ignoreCase = !matchCase)
|
||||
if (found < 0) break
|
||||
out.add(found until found + query.length)
|
||||
at = found + query.length
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
internal fun replaceEditorMatches(text: String, matches: List<IntRange>, replacement: String): String {
|
||||
if (matches.isEmpty()) return text
|
||||
val out = StringBuilder(text.length)
|
||||
var cursor = 0
|
||||
for (m in matches) {
|
||||
if (m.first < cursor || m.last >= text.length) continue
|
||||
out.append(text, cursor, m.first).append(replacement)
|
||||
cursor = m.last + 1
|
||||
}
|
||||
out.append(text, cursor, text.length)
|
||||
return out.toString()
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun TextEditorScreen(
|
||||
file: File,
|
||||
onExit: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val scope = rememberCoroutineScope()
|
||||
val density = LocalDensity.current
|
||||
|
||||
var text by remember { mutableStateOf("") }
|
||||
var selection by remember { mutableStateOf(TextRange.Zero) }
|
||||
var composing by remember { mutableStateOf<TextRange?>(null) }
|
||||
var loadState by remember { mutableStateOf(EditorLoadState.LOADING) }
|
||||
var lock by remember { mutableStateOf(EditorLock.NONE) }
|
||||
var charset by remember { mutableStateOf(EditorCharset.UTF8) }
|
||||
var dirty by remember { mutableStateOf(false) }
|
||||
var saving by remember { mutableStateOf(false) }
|
||||
var showDiscard by remember { mutableStateOf(false) }
|
||||
var showSearch by remember { mutableStateOf(false) }
|
||||
var query by remember { mutableStateOf("") }
|
||||
var replacement by remember { mutableStateOf("") }
|
||||
var matchCase by remember { mutableStateOf(false) }
|
||||
var matchIndex by remember { mutableIntStateOf(0) }
|
||||
|
||||
val scrollState = rememberScrollState()
|
||||
val textHorizontalState = rememberScrollState()
|
||||
var viewportHeight by remember { mutableIntStateOf(0) }
|
||||
var viewportWidth by remember { mutableIntStateOf(0) }
|
||||
|
||||
val lineHeightDp = with(density) { EDITOR_LINE_HEIGHT_SP.sp.toDp() }
|
||||
val lineHeightPx = with(density) { lineHeightDp.toPx() }
|
||||
val totalLines = remember(text) { lineCountOf(text) }
|
||||
val cursorLine = lineIndexOfOffset(text, selection.end)
|
||||
val cursorColumn = columnOfOffset(text, selection.end)
|
||||
val matches = remember(text, query, matchCase) { findEditorMatches(text, query, matchCase) }
|
||||
val readOnly = lock != EditorLock.NONE
|
||||
val bodyStyle = TextStyle(
|
||||
fontFamily = FontFamily.Monospace,
|
||||
fontSize = EDITOR_FONT_SIZE_SP.sp,
|
||||
lineHeight = EDITOR_LINE_HEIGHT_SP.sp,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
)
|
||||
val textMeasurer = rememberTextMeasurer()
|
||||
val charWidthPx = remember(bodyStyle) { textMeasurer.measure(text = "0", style = bodyStyle).size.width.toFloat() }
|
||||
|
||||
LaunchedEffect(file) {
|
||||
loadState = EditorLoadState.LOADING
|
||||
val size = withContext(Dispatchers.IO) { file.length() }
|
||||
if (size > EDITOR_MAX_OPEN_BYTES) {
|
||||
loadState = EditorLoadState.TOO_LARGE
|
||||
return@LaunchedEffect
|
||||
}
|
||||
val read = withContext(Dispatchers.IO) {
|
||||
runCatching { file.inputStream().use { readCapped(it, EDITOR_MAX_OPEN_BYTES) } }
|
||||
}
|
||||
val bytes = read.getOrNull()
|
||||
if (bytes == null) {
|
||||
loadState = if (read.isFailure) EditorLoadState.UNREADABLE else EditorLoadState.TOO_LARGE
|
||||
return@LaunchedEffect
|
||||
}
|
||||
val decoded = decodeEditorText(bytes)
|
||||
text = expandEditorTabs(decoded.text)
|
||||
charset = decoded.charset
|
||||
lock = when {
|
||||
editorIsBinary(bytes) -> EditorLock.BINARY
|
||||
decoded.lossy -> EditorLock.LOSSY
|
||||
bytes.size > EDITOR_MAX_EDIT_BYTES -> EditorLock.TOO_LARGE
|
||||
!file.canWrite() -> EditorLock.PERMISSION
|
||||
else -> EditorLock.NONE
|
||||
}
|
||||
selection = TextRange.Zero
|
||||
loadState = EditorLoadState.READY
|
||||
}
|
||||
|
||||
suspend fun revealLine(line: Int) {
|
||||
val current = scrollState.value
|
||||
val top = line * lineHeightPx
|
||||
val target = when {
|
||||
top < current -> top
|
||||
top + lineHeightPx > current + viewportHeight -> top + lineHeightPx - viewportHeight
|
||||
else -> return
|
||||
}
|
||||
val clamped = target.roundToInt().coerceIn(0, scrollState.maxValue)
|
||||
if (clamped != current) scrollState.scrollTo(clamped)
|
||||
}
|
||||
|
||||
LaunchedEffect(text, selection.end, viewportHeight, viewportWidth) {
|
||||
if (loadState != EditorLoadState.READY) return@LaunchedEffect
|
||||
revealLine(lineIndexOfOffset(text, selection.end))
|
||||
if (viewportWidth > 0 && charWidthPx > 0) {
|
||||
val x = (columnOfOffset(text, selection.end) - 1) * charWidthPx
|
||||
val current = textHorizontalState.value
|
||||
val target = when {
|
||||
x < current -> x
|
||||
x + charWidthPx > current + viewportWidth -> x + charWidthPx - viewportWidth
|
||||
else -> null
|
||||
}
|
||||
if (target != null) {
|
||||
val clamped = target.roundToInt().coerceIn(0, textHorizontalState.maxValue)
|
||||
if (clamped != current) textHorizontalState.scrollTo(clamped)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LaunchedEffect(query, matchCase) {
|
||||
if (query.isEmpty()) return@LaunchedEffect
|
||||
matchIndex = 0
|
||||
val first = matches.firstOrNull() ?: return@LaunchedEffect
|
||||
selection = TextRange(first.first, first.last + 1)
|
||||
composing = TextRange.Zero
|
||||
}
|
||||
|
||||
LaunchedEffect(text) { matchIndex = 0 }
|
||||
|
||||
fun gotoMatch(delta: Int) {
|
||||
if (matches.isEmpty()) return
|
||||
matchIndex = Math.floorMod(matchIndex + delta, matches.size)
|
||||
val m = matches[matchIndex]
|
||||
selection = TextRange(m.first, m.last + 1)
|
||||
composing = TextRange.Zero
|
||||
}
|
||||
|
||||
fun replaceCurrent() {
|
||||
if (readOnly) return
|
||||
val m = matches.getOrNull(matchIndex) ?: return
|
||||
text = text.replaceRange(m.first, m.last + 1, replacement)
|
||||
dirty = true
|
||||
matchIndex = 0
|
||||
selection = TextRange(m.first + replacement.length)
|
||||
composing = TextRange.Zero
|
||||
}
|
||||
|
||||
fun replaceAll() {
|
||||
if (readOnly || matches.isEmpty()) return
|
||||
val all = findEditorMatches(text, query, matchCase, limit = Int.MAX_VALUE)
|
||||
text = replaceEditorMatches(text, all, replacement)
|
||||
dirty = true
|
||||
matchIndex = 0
|
||||
selection = TextRange.Zero
|
||||
composing = TextRange.Zero
|
||||
}
|
||||
|
||||
fun save() {
|
||||
if (readOnly || saving || loadState != EditorLoadState.READY) return
|
||||
val snapshot = text
|
||||
val bytes = snapshot.toByteArray(charset.charset)
|
||||
saving = true
|
||||
scope.launch {
|
||||
val ok = withContext(Dispatchers.IO) {
|
||||
runCatching {
|
||||
val target = resolveEditorSaveTarget(file)
|
||||
val parent = target.parentFile
|
||||
if (parent == null) {
|
||||
target.writeBytes(bytes)
|
||||
} else {
|
||||
val tmp = File.createTempFile(".${target.name}.", ".droiddeck-tmp", parent)
|
||||
try {
|
||||
tmp.writeBytes(bytes)
|
||||
runCatching {
|
||||
Files.setPosixFilePermissions(tmp.toPath(), Files.getPosixFilePermissions(target.toPath()))
|
||||
}
|
||||
if (!tmp.renameTo(target)) error("rename to ${target.name} failed")
|
||||
} finally {
|
||||
tmp.delete()
|
||||
}
|
||||
}
|
||||
}.isSuccess
|
||||
}
|
||||
saving = false
|
||||
if (ok) {
|
||||
if (text == snapshot) dirty = false
|
||||
} else {
|
||||
Toast.makeText(context, context.getString(R.string.fm_edit_save_failed, file.name), Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun tryExit() {
|
||||
if (saving) return
|
||||
if (dirty && !readOnly) showDiscard = true else onExit()
|
||||
}
|
||||
|
||||
BackHandler { tryExit() }
|
||||
|
||||
if (showDiscard) {
|
||||
OutlinedAlertDialog(
|
||||
onDismissRequest = { showDiscard = false },
|
||||
title = { Text(stringResource(R.string.fm_edit_discard_title)) },
|
||||
text = { Text(stringResource(R.string.fm_edit_discard_text, file.name)) },
|
||||
confirmButton = {
|
||||
TextButton(onClick = onExit, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
Text(stringResource(R.string.fm_edit_discard))
|
||||
}
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = { showDiscard = false }, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
Text(stringResource(R.string.common_cancel))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier = modifier
|
||||
.fillMaxSize()
|
||||
.background(MaterialTheme.colorScheme.background),
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.background(MaterialTheme.colorScheme.surfaceContainer)
|
||||
.padding(horizontal = 8.dp, vertical = 6.dp),
|
||||
) {
|
||||
IconButton(onClick = { tryExit() }, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
Icon(
|
||||
Icons.Filled.ArrowBack,
|
||||
stringResource(R.string.fm_back),
|
||||
tint = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
}
|
||||
Column(modifier = Modifier.weight(1f).padding(horizontal = 4.dp)) {
|
||||
Text(
|
||||
text = file.name,
|
||||
color = MaterialTheme.colorScheme.onBackground,
|
||||
fontSize = 14.sp,
|
||||
fontWeight = FontWeight.Medium,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
if (dirty) {
|
||||
Text(
|
||||
text = "\u2022 " + stringResource(R.string.fm_edit_modified),
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
fontSize = 11.sp,
|
||||
maxLines = 1,
|
||||
)
|
||||
}
|
||||
}
|
||||
if (loadState == EditorLoadState.READY && lock != EditorLock.NONE) {
|
||||
Text(
|
||||
text = stringResource(
|
||||
if (lock == EditorLock.BINARY) R.string.fm_edit_binary else R.string.fm_edit_read_only,
|
||||
),
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
fontSize = 10.sp,
|
||||
maxLines = 1,
|
||||
modifier = Modifier
|
||||
.background(MaterialTheme.colorScheme.surfaceVariant, MaterialTheme.shapes.small)
|
||||
.padding(horizontal = 6.dp, vertical = 2.dp),
|
||||
)
|
||||
Spacer(Modifier.width(6.dp))
|
||||
}
|
||||
IconButton(
|
||||
onClick = { showSearch = !showSearch },
|
||||
enabled = loadState == EditorLoadState.READY,
|
||||
modifier = Modifier.focusGlide(CircleShape),
|
||||
) {
|
||||
Icon(
|
||||
Icons.Filled.Search,
|
||||
stringResource(R.string.fm_edit_find),
|
||||
tint = if (showSearch) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
IconButton(
|
||||
onClick = { save() },
|
||||
enabled = loadState == EditorLoadState.READY && !readOnly && dirty && !saving,
|
||||
modifier = Modifier.focusGlide(CircleShape),
|
||||
) {
|
||||
Icon(
|
||||
Icons.Filled.Save,
|
||||
stringResource(R.string.fm_edit_save),
|
||||
tint = if (dirty) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (showSearch && loadState == EditorLoadState.READY) {
|
||||
Column(Modifier.fillMaxWidth().background(MaterialTheme.colorScheme.surfaceContainer)) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxWidth().padding(start = 8.dp, end = 4.dp, top = 4.dp),
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = query,
|
||||
onValueChange = { query = it; matchIndex = 0 },
|
||||
singleLine = true,
|
||||
placeholder = { Text(stringResource(R.string.fm_edit_find), fontSize = 13.sp) },
|
||||
textStyle = MaterialTheme.typography.bodySmall,
|
||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
|
||||
keyboardActions = KeyboardActions(onSearch = { gotoMatch(1) }),
|
||||
modifier = Modifier.weight(1f).focusGlide(),
|
||||
)
|
||||
Text(
|
||||
text = if (matches.isEmpty()) "0/${matches.size}" else "${matchIndex.coerceAtMost(matches.size - 1) + 1}/${matches.size}",
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
fontSize = 12.sp,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.padding(horizontal = 6.dp).widthIn(min = 44.dp, max = 80.dp),
|
||||
)
|
||||
IconButton(
|
||||
onClick = { gotoMatch(-1) },
|
||||
enabled = matches.isNotEmpty(),
|
||||
modifier = Modifier.focusGlide(CircleShape),
|
||||
) {
|
||||
Icon(
|
||||
Icons.Filled.KeyboardArrowUp,
|
||||
stringResource(R.string.fm_edit_find_previous),
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.size(20.dp),
|
||||
)
|
||||
}
|
||||
IconButton(
|
||||
onClick = { gotoMatch(1) },
|
||||
enabled = matches.isNotEmpty(),
|
||||
modifier = Modifier.focusGlide(CircleShape),
|
||||
) {
|
||||
Icon(
|
||||
Icons.Filled.KeyboardArrowDown,
|
||||
stringResource(R.string.fm_edit_find_next),
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.size(20.dp),
|
||||
)
|
||||
}
|
||||
TextButton(onClick = { matchCase = !matchCase }, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
Text(
|
||||
text = "Aa",
|
||||
color = if (matchCase) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
fontSize = 13.sp,
|
||||
)
|
||||
}
|
||||
IconButton(onClick = { showSearch = false }, modifier = Modifier.focusGlide(CircleShape)) {
|
||||
Icon(
|
||||
Icons.Filled.Close,
|
||||
stringResource(R.string.common_cancel),
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.size(20.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxWidth().padding(start = 8.dp, top = 2.dp, end = 4.dp, bottom = 2.dp),
|
||||
) {
|
||||
OutlinedTextField(
|
||||
value = replacement,
|
||||
onValueChange = { replacement = it },
|
||||
singleLine = true,
|
||||
placeholder = { Text(stringResource(R.string.fm_edit_replace), fontSize = 13.sp) },
|
||||
textStyle = MaterialTheme.typography.bodySmall,
|
||||
modifier = Modifier.weight(1f).focusGlide(),
|
||||
)
|
||||
TextButton(
|
||||
onClick = { replaceCurrent() },
|
||||
enabled = !readOnly && matches.isNotEmpty(),
|
||||
modifier = Modifier.focusGlide(CircleShape),
|
||||
) {
|
||||
Text(stringResource(R.string.fm_edit_replace), fontSize = 13.sp)
|
||||
}
|
||||
TextButton(
|
||||
onClick = { replaceAll() },
|
||||
enabled = !readOnly && matches.isNotEmpty(),
|
||||
modifier = Modifier.focusGlide(CircleShape),
|
||||
) {
|
||||
Text(stringResource(R.string.fm_edit_replace_all), fontSize = 13.sp)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.fillMaxWidth()
|
||||
.onSizeChanged { viewportHeight = it.height },
|
||||
) {
|
||||
when (loadState) {
|
||||
EditorLoadState.LOADING -> CircularProgressIndicator(
|
||||
modifier = Modifier.align(Alignment.Center),
|
||||
)
|
||||
|
||||
EditorLoadState.TOO_LARGE, EditorLoadState.UNREADABLE -> Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier.align(Alignment.Center).padding(24.dp),
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(
|
||||
if (loadState == EditorLoadState.TOO_LARGE) R.string.fm_edit_too_large
|
||||
else R.string.fm_edit_open_failed,
|
||||
if (loadState == EditorLoadState.TOO_LARGE) FileOps.formatBytes(context, file.length())
|
||||
else file.name,
|
||||
),
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
fontSize = 14.sp,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
}
|
||||
|
||||
EditorLoadState.READY -> Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.verticalScroll(scrollState),
|
||||
) {
|
||||
Row(modifier = Modifier.fillMaxWidth().height(lineHeightDp * totalLines.toFloat())) {
|
||||
LineNumbers(
|
||||
scrollState = scrollState,
|
||||
viewportHeight = viewportHeight,
|
||||
lineHeightDp = lineHeightDp,
|
||||
lineHeightPx = lineHeightPx,
|
||||
totalLines = totalLines,
|
||||
cursorLine = cursorLine,
|
||||
style = bodyStyle,
|
||||
mutedColor = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
cursorColor = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
Box(modifier = Modifier.weight(1f).onSizeChanged { viewportWidth = it.width }.horizontalScroll(textHorizontalState)) {
|
||||
BasicTextField(
|
||||
value = TextFieldValue(text = text, selection = selection, composition = composing),
|
||||
onValueChange = { next ->
|
||||
val changed = next.text != text
|
||||
text = next.text
|
||||
selection = next.selection
|
||||
composing = next.composition
|
||||
if (changed) dirty = true
|
||||
},
|
||||
readOnly = readOnly,
|
||||
textStyle = bodyStyle,
|
||||
cursorBrush = SolidColor(MaterialTheme.colorScheme.primary),
|
||||
keyboardOptions = KeyboardOptions(
|
||||
keyboardType = KeyboardType.Text,
|
||||
capitalization = KeyboardCapitalization.None,
|
||||
),
|
||||
modifier = Modifier.fillMaxHeight().focusGlide(),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (loadState == EditorLoadState.READY) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxWidth().padding(horizontal = 12.dp, vertical = 4.dp),
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(R.string.fm_edit_position, cursorLine + 1, cursorColumn),
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
fontSize = 12.sp,
|
||||
maxLines = 1,
|
||||
)
|
||||
Spacer(Modifier.weight(1f))
|
||||
Text(
|
||||
text = charset.label + " \u2022 " + FileOps.formatBytes(context, file.length()),
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
fontSize = 12.sp,
|
||||
maxLines = 1,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LineNumbers(
|
||||
scrollState: ScrollState,
|
||||
viewportHeight: Int,
|
||||
lineHeightDp: Dp,
|
||||
lineHeightPx: Float,
|
||||
totalLines: Int,
|
||||
cursorLine: Int,
|
||||
style: TextStyle,
|
||||
mutedColor: Color,
|
||||
cursorColor: Color,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val firstLine = (scrollState.value / lineHeightPx).toInt().coerceIn(0, totalLines - 1)
|
||||
val lastLine = ((scrollState.value + viewportHeight) / lineHeightPx)
|
||||
.toInt()
|
||||
.coerceIn(firstLine, totalLines - 1)
|
||||
Column(
|
||||
horizontalAlignment = Alignment.End,
|
||||
modifier = modifier
|
||||
.width(IntrinsicSize.Min)
|
||||
.padding(top = lineHeightDp * firstLine.toFloat()),
|
||||
) {
|
||||
for (line in firstLine..lastLine) {
|
||||
Text(
|
||||
text = (line + 1).toString(),
|
||||
color = if (line == cursorLine) cursorColor else mutedColor,
|
||||
textAlign = TextAlign.End,
|
||||
maxLines = 1,
|
||||
style = style,
|
||||
modifier = Modifier.fillMaxWidth().height(lineHeightDp),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ object BattleNet {
|
||||
Title("aqua", "Avowed", "AQUA", 2457220, shop = "avowed", product = "aqua"),
|
||||
)
|
||||
|
||||
val STORE: List<Title> get() = TITLES.distinctBy { it.code }.filter { it.uid != "d3cn" && it.code != "WoWC" && it.code != "WoWF" }
|
||||
val STORE: List<Title> get() = TITLES.distinctBy { it.code }.filter { it.uid != "d3cn" && it.code != "WoWC" }
|
||||
|
||||
// Blizzard's China client installs some products under a CN uid; they are the same games and keep their store identity.
|
||||
private val CN_UIDS = mapOf("s2_cn" to "s2", "osic" to "osi", "anbs_cn" to "anbs")
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.core.Downloader
|
||||
import com.droiddeck.launcher.session.SessionState
|
||||
import java.io.File
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONObject
|
||||
|
||||
object DeckyStore {
|
||||
private const val TAG = "DeckyStore"
|
||||
private const val LISTING = "https://plugins.deckbrew.xyz/plugins"
|
||||
private const val ARTIFACTS = "https://cdn.tzatzikiweeb.moe/file/steam-deck-homebrew/versions/"
|
||||
|
||||
data class Version(val name: String, val hash: String)
|
||||
data class Plugin(val name: String, val author: String, val description: String, val tags: List<String>, val downloads: Long, val imageUrl: String, val versions: List<Version>) {
|
||||
val latest: Version? get() = versions.firstOrNull()
|
||||
}
|
||||
data class Installed(val name: String, val folder: String, val author: String, val version: String)
|
||||
|
||||
fun parseListing(body: String): List<Plugin> {
|
||||
val array = JSONArray(body)
|
||||
return (0 until array.length()).mapNotNull { i ->
|
||||
val row = array.optJSONObject(i) ?: return@mapNotNull null
|
||||
val name = row.optString("name").takeIf { it.isNotBlank() } ?: return@mapNotNull null
|
||||
val versions = row.optJSONArray("versions")?.let { list ->
|
||||
(0 until list.length()).mapNotNull { v ->
|
||||
val version = list.optJSONObject(v) ?: return@mapNotNull null
|
||||
val hash = version.optString("hash")
|
||||
if (!hash.matches(Regex("(?i)[0-9a-f]{64}"))) null else Version(version.optString("name"), hash.lowercase())
|
||||
}
|
||||
}.orEmpty()
|
||||
if (versions.isEmpty()) return@mapNotNull null
|
||||
val tags = row.optJSONArray("tags")?.let { list -> (0 until list.length()).map { list.optString(it) } }.orEmpty()
|
||||
val downloads = row.optJSONArray("versions")?.let { list -> (0 until list.length()).sumOf { list.optJSONObject(it)?.optLong("downloads") ?: 0L } } ?: 0L
|
||||
val image = row.optString("image_url").takeIf { it.startsWith("https://") }.orEmpty()
|
||||
Plugin(name, row.optString("author"), row.optString("description"), tags, downloads, image, versions)
|
||||
}
|
||||
}
|
||||
|
||||
fun fetch(): List<Plugin>? {
|
||||
val body = Downloader.downloadString(LISTING) ?: return null
|
||||
return runCatching { parseListing(body) }.onFailure { Log.w(TAG, "store listing", it) }.getOrNull()
|
||||
}
|
||||
|
||||
fun pluginsDir(context: Context) = File(LinuxRuntime.rootDir(context), "root/homebrew/plugins")
|
||||
|
||||
fun installed(context: Context): List<Installed> =
|
||||
pluginsDir(context).listFiles().orEmpty()
|
||||
.filter { it.isDirectory && !it.name.startsWith(".droiddeck-") }
|
||||
.mapNotNull { folder ->
|
||||
runCatching {
|
||||
val meta = JSONObject(File(folder, "plugin.json").readText())
|
||||
val version = runCatching { JSONObject(File(folder, "package.json").readText()).optString("version") }.getOrDefault("")
|
||||
Installed(meta.getString("name"), folder.name, meta.optString("author"), version)
|
||||
}.getOrNull()
|
||||
}
|
||||
.sortedBy { it.name.lowercase() }
|
||||
|
||||
fun updateAvailable(installed: Installed, plugin: Plugin?): Boolean {
|
||||
val latest = plugin?.latest?.name ?: return false
|
||||
return installed.version.isNotEmpty() && latest != installed.version
|
||||
}
|
||||
|
||||
fun install(context: Context, plugin: Plugin, version: Version, progress: (String, Int) -> Unit): String? {
|
||||
if (SessionState.running) return context.getString(R.string.deckymgr_stop_session_plugin)
|
||||
if (DeckyManager.installed(context) == null) return context.getString(R.string.deckymgr_loader_required)
|
||||
val cache = File(context.cacheDir, "decky-store").apply { mkdirs() }
|
||||
val zip = File(cache, "${version.hash}.zip")
|
||||
try {
|
||||
val label = context.getString(R.string.decky_store_downloading, plugin.name)
|
||||
progress(label, -1)
|
||||
val ok = Downloader.downloadFile("$ARTIFACTS${version.hash}.zip", zip, true, version.hash) { fraction ->
|
||||
progress(label, if (fraction < 0) -1 else (fraction * 100).toInt().coerceIn(0, 100))
|
||||
}
|
||||
if (!ok) return context.getString(R.string.decky_store_download_failed, plugin.name)
|
||||
return DeckyManager.installPluginZip(context, zip, progress)
|
||||
} finally {
|
||||
zip.delete()
|
||||
}
|
||||
}
|
||||
|
||||
fun remove(context: Context, plugin: Installed): String? {
|
||||
if (SessionState.running) return context.getString(R.string.deckymgr_stop_session_plugin)
|
||||
val plugins = pluginsDir(context)
|
||||
val folder = File(plugins, plugin.folder)
|
||||
if (folder.parentFile?.canonicalFile != plugins.canonicalFile) return context.getString(R.string.decky_store_remove_failed)
|
||||
if (!folder.deleteRecursively()) return context.getString(R.string.decky_store_remove_failed)
|
||||
val settings = File(plugins.parentFile, "settings/loader.json")
|
||||
runCatching {
|
||||
val json = JSONObject(settings.readText())
|
||||
for (key in listOf("pluginOrder", "frozenPlugins", "hiddenPlugins", "disabled_plugins")) {
|
||||
val values = json.optJSONArray(key) ?: continue
|
||||
json.put(key, JSONArray((0 until values.length()).map { values.get(it) }.filter { it != plugin.name }))
|
||||
}
|
||||
settings.writeText(json.toString(4))
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.animation.expandVertically
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.shrinkHorizontally
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.expandHorizontally
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.shrinkVertically
|
||||
@@ -228,8 +229,14 @@ private fun AgentPageContent(
|
||||
}
|
||||
val topBar: @Composable () -> Unit = { AgentTopBar(panel, togglePanel, inputModifier, menu) }
|
||||
val inlineControls: (@Composable () -> Unit)? = if (inline) ({
|
||||
ModelChip(panel, togglePanel, inputModifier, compact = true)
|
||||
ContextRing("agent-usage", onClick = { togglePanel(AgentPanel.USAGE) })
|
||||
// The open menu needs the row's width for its own buttons.
|
||||
androidx.compose.animation.AnimatedVisibility(!menuOpen, enter = expandHorizontally(expandFrom = Alignment.Start) + fadeIn(),
|
||||
exit = shrinkHorizontally(shrinkTowards = Alignment.Start) + fadeOut()) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
ModelChip(panel, togglePanel, inputModifier, compact = true)
|
||||
ContextRing("agent-usage", onClick = { togglePanel(AgentPanel.USAGE) })
|
||||
}
|
||||
}
|
||||
menu()
|
||||
}) else null
|
||||
// A host with a title bar shows the top bar there.
|
||||
@@ -245,8 +252,11 @@ private fun AgentPageContent(
|
||||
LaunchedEffect(AgentHost.approvals.size, panel) {
|
||||
if (AgentHost.approvals.isNotEmpty() && (panel == AgentPanel.HISTORY || panel == AgentPanel.PROCESSES || panel == AgentPanel.TOOLS)) panel = AgentPanel.NONE
|
||||
}
|
||||
androidx.compose.foundation.layout.BoxWithConstraints(modifier.fillMaxSize()) {
|
||||
// On a short page the picker would take it all and leave no conversation, so it scrolls within a share of the page.
|
||||
val panelMax = maxHeight * 0.5f
|
||||
Column(
|
||||
modifier.fillMaxSize().imePadding().onPreviewKeyEvent { e ->
|
||||
Modifier.fillMaxSize().imePadding().onPreviewKeyEvent { e ->
|
||||
val k = e.nativeKeyEvent
|
||||
if (k.keyCode != KeyEvent.KEYCODE_BUTTON_Y || composer.focused) return@onPreviewKeyEvent false
|
||||
if (k.action == KeyEvent.ACTION_UP) composer.open()
|
||||
@@ -269,8 +279,8 @@ private fun AgentPageContent(
|
||||
else -> {
|
||||
if (menuSlot == null && !inline) Box(Modifier.padding(bottom = 6.dp)) { topBar() }
|
||||
when (panel) {
|
||||
AgentPanel.MODEL -> Box(Modifier.padding(bottom = 8.dp)) { AgentModelPicker() }
|
||||
AgentPanel.USAGE -> Box(Modifier.padding(bottom = 8.dp)) { AgentUsage() }
|
||||
AgentPanel.MODEL -> Box(Modifier.heightIn(max = panelMax).verticalScroll(rememberScrollState()).padding(bottom = 8.dp)) { AgentModelPicker() }
|
||||
AgentPanel.USAGE -> Box(Modifier.heightIn(max = panelMax).verticalScroll(rememberScrollState()).padding(bottom = 8.dp)) { AgentUsage() }
|
||||
else -> Unit
|
||||
}
|
||||
val list = rememberLazyListState()
|
||||
@@ -322,11 +332,12 @@ private fun AgentPageContent(
|
||||
}
|
||||
}
|
||||
androidx.compose.animation.AnimatedVisibility(!hidden, enter = expandVertically() + fadeIn(), exit = shrinkVertically() + fadeOut()) {
|
||||
AgentComposer(composer, draft, visible && started, inlineControls, onPanel = { panel = it }, onSent = toLatest)
|
||||
AgentComposer(composer, draft, visible && started, inlineControls, onPanel = { panel = it }, onSent = toLatest, hideAttach = inline && menuOpen)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Whether the editor has the cursor; [open] puts it there. */
|
||||
@@ -397,10 +408,12 @@ private fun AgentMenu(open: Boolean, onOpen: (Boolean) -> Unit, onPanel: (AgentP
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val working = AgentHost.state == AgentHost.State.WORKING
|
||||
// Closed, the outline sits flush against the lone button.
|
||||
val shape = if (open) Shape16 else Shape12
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.clip(Shape16).background(colors.surface.copy(alpha = if (open) 0.97f else 0.88f))
|
||||
.border(1.dp, pal.line, Shape16).padding(end = 2.dp),
|
||||
modifier = Modifier.clip(shape).background(colors.surface.copy(alpha = if (open) 0.97f else 0.88f))
|
||||
.border(1.dp, pal.line, shape).then(if (open) Modifier.padding(top = 3.dp, bottom = 3.dp, end = 4.dp) else Modifier),
|
||||
) {
|
||||
androidx.compose.animation.AnimatedVisibility(open, enter = expandHorizontally(expandFrom = Alignment.End) + fadeIn(),
|
||||
exit = shrinkHorizontally(shrinkTowards = Alignment.End) + fadeOut()) {
|
||||
@@ -423,7 +436,7 @@ private fun AgentMenu(open: Boolean, onOpen: (Boolean) -> Unit, onPanel: (AgentP
|
||||
}
|
||||
}
|
||||
}
|
||||
HeaderAction(Icons.Outlined.MoreHoriz, stringResource(R.string.agent_more), selected = open, size = 36.dp, tag = "agent-menu") { onOpen(!open) }
|
||||
HeaderAction(Icons.Outlined.MoreHoriz, stringResource(R.string.agent_more), selected = open, size = 36.dp, tag = "agent-menu", startPadding = if (open) null else 0.dp) { onOpen(!open) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,12 +450,13 @@ private fun AgentPanelBar(title: String, onClose: () -> Unit) {
|
||||
|
||||
@Composable
|
||||
internal fun HeaderAction(
|
||||
icon: ImageVector, label: String, enabled: Boolean = true, selected: Boolean = false, tag: String? = null, size: Dp = 44.dp, onClick: () -> Unit,
|
||||
icon: ImageVector, label: String, enabled: Boolean = true, selected: Boolean = false, tag: String? = null, size: Dp = 44.dp,
|
||||
startPadding: Dp? = null, onClick: () -> Unit,
|
||||
) {
|
||||
val pal = LocalPalette.current
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier.padding(start = if (size < 44.dp) 4.dp else 8.dp).size(size).clip(Shape12)
|
||||
modifier = Modifier.padding(start = startPadding ?: if (size < 44.dp) 4.dp else 8.dp).size(size).clip(Shape12)
|
||||
.background(if (selected) pal.primary.copy(alpha = 0.2f) else pal.surfaceVariant)
|
||||
.clickable(enabled = enabled, onClick = onClick)
|
||||
.then(if (tag != null) Modifier.testTag(tag) else Modifier),
|
||||
@@ -715,7 +729,7 @@ internal fun liveUsed(limit: AgentHost.Limit) = if (limit.resetsAt > 0 && limit.
|
||||
@Composable
|
||||
private fun AgentComposer(
|
||||
composer: ComposerState, draftState: MutableState<String>, visible: Boolean, controls: (@Composable () -> Unit)?,
|
||||
onPanel: (AgentPanel) -> Unit, onSent: () -> Unit,
|
||||
onPanel: (AgentPanel) -> Unit, onSent: () -> Unit, hideAttach: Boolean = false,
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
var draft by draftState
|
||||
@@ -747,13 +761,13 @@ private fun AgentComposer(
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.padding(top = 8.dp).fillMaxWidth().horizontalScroll(rememberScrollState()),
|
||||
) { AgentActivity(labOpen) { labOpen = !labOpen } }
|
||||
AgentEditor(composer, draftState, visible, controls, send)
|
||||
AgentEditor(composer, draftState, visible, controls, send, hideAttach)
|
||||
}
|
||||
}
|
||||
|
||||
/** The text with attach, stop and send beside it, and [controls] while the text is not being typed in. */
|
||||
@Composable
|
||||
private fun AgentEditor(composer: ComposerState, draftState: MutableState<String>, visible: Boolean, controls: (@Composable () -> Unit)?, send: () -> Unit) {
|
||||
private fun AgentEditor(composer: ComposerState, draftState: MutableState<String>, visible: Boolean, controls: (@Composable () -> Unit)?, send: () -> Unit, hideAttach: Boolean = false) {
|
||||
val context = LocalContext.current
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
@@ -852,14 +866,14 @@ private fun AgentEditor(composer: ComposerState, draftState: MutableState<String
|
||||
if (stacked) Column {
|
||||
text(Modifier.fillMaxWidth())
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.fillMaxWidth()) {
|
||||
if (attach) AttachButton()
|
||||
if (AgentAttachments.gameFrame != null) GameFrameButton()
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.weight(1f).height(42.dp)) { if (controls != null && !focused) controls() }
|
||||
AnimatedVisibility(attach && !hideAttach, enter = expandHorizontally() + fadeIn(), exit = shrinkHorizontally() + fadeOut()) { AttachButton() }
|
||||
AnimatedVisibility(AgentAttachments.gameFrame != null && !hideAttach, enter = expandHorizontally() + fadeIn(), exit = shrinkHorizontally() + fadeOut()) { GameFrameButton() }
|
||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.weight(1f).height(42.dp).horizontalScroll(rememberScrollState(), reverseScrolling = true)) { if (controls != null && !focused) controls() }
|
||||
actions()
|
||||
}
|
||||
} else Row(verticalAlignment = Alignment.Bottom) {
|
||||
if (attach) AttachButton()
|
||||
if (AgentAttachments.gameFrame != null) GameFrameButton()
|
||||
AnimatedVisibility(attach && !hideAttach, enter = expandHorizontally() + fadeIn(), exit = shrinkHorizontally() + fadeOut()) { AttachButton() }
|
||||
AnimatedVisibility(AgentAttachments.gameFrame != null && !hideAttach, enter = expandHorizontally() + fadeIn(), exit = shrinkHorizontally() + fadeOut()) { GameFrameButton() }
|
||||
text(Modifier.weight(1f))
|
||||
if (controls != null && !focused) Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.height(42.dp)) { controls() }
|
||||
actions()
|
||||
|
||||
@@ -117,7 +117,7 @@ private fun rememberMovies(refresh: Int, onSelectionChanged: () -> Unit): MovieS
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun TabChip(label: String, selected: Boolean, modifier: Modifier = Modifier, onClick: () -> Unit) {
|
||||
internal fun TabChip(label: String, selected: Boolean, modifier: Modifier = Modifier, onClick: () -> Unit) {
|
||||
val pal = LocalPalette.current
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val hot = rememberHot(src)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.SolidColor
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.graphics.vector.addPathNodes
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
internal val DeckyIcon: ImageVector = ImageVector.Builder("Decky", 24.dp, 24.dp, 24f, 24f).apply {
|
||||
for (d in listOf(
|
||||
"M8,2h2v6H8Z",
|
||||
"M14,2h2v6h-2Z",
|
||||
"M5,8h14v3a7,7 0 0 1 -5,6.7V19h-4v-1.3A7,7 0 0 1 5,11Z",
|
||||
"M11,19h2v3h-2Z",
|
||||
)) addPath(addPathNodes(d), fill = SolidColor(Color.Black))
|
||||
}.build()
|
||||
@@ -0,0 +1,245 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import coil.compose.AsyncImage
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.runtime.DeckyManager
|
||||
import com.droiddeck.launcher.runtime.DeckyStore
|
||||
|
||||
private enum class DeckyTab { INSTALLED, STORE, ZIP }
|
||||
|
||||
private const val STORE_PAGE = 30
|
||||
|
||||
internal fun deckyStoreMatches(plugins: List<DeckyStore.Plugin>, query: String): List<DeckyStore.Plugin> {
|
||||
val words = query.trim().lowercase().split(Regex("\\s+")).filter { it.isNotEmpty() }
|
||||
return plugins.filter { p ->
|
||||
val haystack = (p.name + " " + p.author + " " + p.description + " " + p.tags.joinToString(" ")).lowercase()
|
||||
words.all { it in haystack }
|
||||
}.sortedByDescending { it.downloads }
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun DeckyGroups(s: ModeSettings, a: ModeSettingsActions, host: MenuHost) {
|
||||
val idle = s.deckyStage == null && !s.deckySessionRunning
|
||||
SettingsGroup(stringResource(R.string.mode_decky_loader)) {
|
||||
val updateAvailable = s.deckyInstalled != null && s.deckyLatestRelease != null &&
|
||||
s.deckyInstalled != s.deckyLatestRelease.tag
|
||||
val status = when {
|
||||
s.deckyStage != null -> s.deckyStage
|
||||
s.deckyChecking -> stringResource(R.string.mode_decky_checking)
|
||||
s.deckyInstalled == null && s.deckyLatestRelease != null -> stringResource(R.string.mode_decky_ready, s.deckyLatestRelease.tag)
|
||||
s.deckyInstalled == null -> stringResource(R.string.mode_decky_none)
|
||||
s.deckyLatestRelease == null -> stringResource(R.string.mode_decky_installed, s.deckyInstalled)
|
||||
updateAvailable -> stringResource(R.string.mode_decky_update, s.deckyLatestRelease.tag)
|
||||
else -> stringResource(R.string.mode_decky_current, s.deckyInstalled)
|
||||
}
|
||||
SettingsRow(stringResource(R.string.decky_status), status) {
|
||||
val action = when {
|
||||
s.deckyStage != null -> stringResource(R.string.common_working)
|
||||
s.deckyChecking -> stringResource(R.string.common_checking)
|
||||
s.deckyInstalled == null && s.deckyLatestRelease != null -> stringResource(R.string.mode_decky_install_latest)
|
||||
s.deckyInstalled != null && updateAvailable -> stringResource(R.string.common_update)
|
||||
else -> stringResource(R.string.common_check)
|
||||
}
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
SecondaryButton(action, enabled = s.deckyStage == null && !s.deckyChecking && !s.deckySessionRunning) {
|
||||
if (s.deckyLatestRelease == null || (s.deckyInstalled != null && !updateAvailable)) a.onDeckyCheck()
|
||||
else s.deckyLatestRelease?.let(a.onDeckyInstall)
|
||||
}
|
||||
if (s.deckyInstalled != null) DeckyUninstall(enabled = idle, onUninstall = a.onDeckyUninstall)
|
||||
}
|
||||
}
|
||||
if (s.deckyInstalled != null) ToggleRow(
|
||||
host, "decky-enabled", stringResource(R.string.decky_enable),
|
||||
null,
|
||||
s.deckyEnabled,
|
||||
enabled = idle,
|
||||
onChange = a.onDeckyEnabled,
|
||||
)
|
||||
ChoiceRow(
|
||||
host, "decky-channel", stringResource(R.string.decky_release_channel),
|
||||
null,
|
||||
listOf(
|
||||
DeckyManager.BRANCH_STABLE to stringResource(R.string.decky_channel_stable),
|
||||
DeckyManager.BRANCH_PRERELEASE to stringResource(R.string.decky_channel_prerelease),
|
||||
) + if (s.deckyBranch == DeckyManager.BRANCH_TESTING) listOf(
|
||||
DeckyManager.BRANCH_TESTING to stringResource(R.string.decky_channel_testing),
|
||||
) else emptyList(),
|
||||
s.deckyBranch,
|
||||
enabled = idle,
|
||||
onPick = a.onDeckyBranch,
|
||||
)
|
||||
if (s.deckyStage != null && s.deckyPercent >= 0) {
|
||||
LinearProgressIndicator(
|
||||
progress = { s.deckyPercent / 100f },
|
||||
modifier = Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 8.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
if (s.deckyInstalled == null) return
|
||||
var tab by rememberSaveable { mutableStateOf(DeckyTab.INSTALLED) }
|
||||
SettingsGroup(stringResource(R.string.mode_decky_plugins)) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(6.dp), modifier = Modifier.fillMaxWidth().padding(horizontal = 10.dp, vertical = 10.dp)) {
|
||||
TabChip(stringResource(R.string.decky_tab_installed, s.deckyPlugins.size), tab == DeckyTab.INSTALLED, Modifier.weight(1f)) { tab = DeckyTab.INSTALLED }
|
||||
TabChip(stringResource(R.string.decky_tab_store), tab == DeckyTab.STORE, Modifier.weight(1f)) { tab = DeckyTab.STORE }
|
||||
TabChip(stringResource(R.string.decky_tab_zip), tab == DeckyTab.ZIP, Modifier.weight(1f)) { tab = DeckyTab.ZIP }
|
||||
}
|
||||
LaunchedEffect(tab) { if (tab != DeckyTab.ZIP && s.deckyStore == null && !s.deckyStoreFailed) a.onDeckyStoreRefresh() }
|
||||
when (tab) {
|
||||
DeckyTab.INSTALLED -> InstalledPlugins(s, a, idle)
|
||||
DeckyTab.STORE -> PluginStore(s, a, idle)
|
||||
DeckyTab.ZIP -> SettingsRow(
|
||||
stringResource(R.string.decky_tab_zip),
|
||||
stringResource(R.string.mode_decky_plugins_hint),
|
||||
) {
|
||||
SecondaryButton(
|
||||
if (s.deckyStage != null && s.deckyDownloadingBinary) stringResource(R.string.mode_decky_plugin_downloading) else stringResource(R.string.mode_decky_plugin_install_zip),
|
||||
enabled = idle,
|
||||
modifier = Modifier.testTag("decky-install-zip"),
|
||||
onClick = a.onPickDeckyPluginZip,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun InstalledPlugins(s: ModeSettings, a: ModeSettingsActions, idle: Boolean) {
|
||||
var removing by remember { mutableStateOf<DeckyStore.Installed?>(null) }
|
||||
if (s.deckyPlugins.isEmpty()) {
|
||||
Text(stringResource(R.string.decky_none_installed), fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
modifier = Modifier.padding(horizontal = 14.dp, vertical = 12.dp))
|
||||
}
|
||||
for (plugin in s.deckyPlugins) {
|
||||
val listed = s.deckyStore?.firstOrNull { it.name == plugin.name }
|
||||
val update = listed?.takeIf { DeckyStore.updateAvailable(plugin, it) }
|
||||
PluginRow(
|
||||
plugin.name,
|
||||
listOf(plugin.version, plugin.author).filter { it.isNotBlank() }.joinToString(" · ") +
|
||||
(update?.latest?.let { " · " + stringResource(R.string.decky_update_to, it.name) } ?: ""),
|
||||
listed?.imageUrl.orEmpty(),
|
||||
) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {
|
||||
if (update != null) SecondaryButton(stringResource(R.string.common_update), enabled = idle, compact = true) { a.onDeckyStoreInstall(update) }
|
||||
SecondaryButton(stringResource(R.string.decky_remove), enabled = idle, compact = true, modifier = Modifier.testTag("decky-remove-${plugin.folder}")) { removing = plugin }
|
||||
}
|
||||
}
|
||||
}
|
||||
if (s.deckyPlugins.isNotEmpty()) Text(stringResource(R.string.decky_changes_next_session), fontSize = 12.sp,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(horizontal = 14.dp, vertical = 8.dp))
|
||||
removing?.let { plugin ->
|
||||
androidx.compose.material3.AlertDialog(
|
||||
onDismissRequest = { removing = null },
|
||||
title = { Text(stringResource(R.string.decky_remove_confirm, plugin.name)) },
|
||||
text = { Text(stringResource(R.string.decky_remove_confirm_body)) },
|
||||
confirmButton = { androidx.compose.material3.TextButton(onClick = { removing = null; a.onDeckyRemove(plugin) }) { Text(stringResource(R.string.decky_remove)) } },
|
||||
dismissButton = { androidx.compose.material3.TextButton(onClick = { removing = null }) { Text(stringResource(R.string.common_cancel)) } },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PluginStore(s: ModeSettings, a: ModeSettingsActions, idle: Boolean) {
|
||||
var query by rememberSaveable { mutableStateOf("") }
|
||||
var searching by remember { mutableStateOf(false) }
|
||||
var shown by rememberSaveable { mutableIntStateOf(STORE_PAGE) }
|
||||
val plugins = s.deckyStore
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth().padding(horizontal = 10.dp).padding(bottom = 12.dp)) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(6.dp), modifier = Modifier.fillMaxWidth()) {
|
||||
Box(Modifier.weight(1f)) {
|
||||
ListRow(tall = true, onClick = { searching = true }) {
|
||||
androidx.compose.material3.Icon(Icons.Filled.Search, contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.size(18.dp))
|
||||
Text(
|
||||
query.ifEmpty { stringResource(R.string.decky_store_search) }, fontSize = 14.sp, maxLines = 1, overflow = TextOverflow.Ellipsis,
|
||||
color = if (query.isEmpty()) MaterialTheme.colorScheme.onSurfaceVariant else MaterialTheme.colorScheme.onBackground,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
}
|
||||
}
|
||||
if (query.isNotEmpty()) SecondaryButton(stringResource(R.string.boot_movie_repo_clear), compact = true) { query = ""; shown = STORE_PAGE }
|
||||
}
|
||||
when {
|
||||
plugins == null -> Text(stringResource(R.string.common_working), fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(vertical = 12.dp))
|
||||
s.deckyStoreFailed -> Row(verticalAlignment = androidx.compose.ui.Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text(stringResource(R.string.decky_store_failed), fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.weight(1f))
|
||||
SecondaryButton(stringResource(R.string.boot_movie_repo_retry), compact = true) { a.onDeckyStoreRefresh() }
|
||||
}
|
||||
else -> {
|
||||
val matches = remember(plugins, query) { deckyStoreMatches(plugins, query) }
|
||||
if (matches.isEmpty()) Text(stringResource(R.string.decky_store_empty), fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(vertical = 12.dp))
|
||||
for (plugin in matches.take(shown)) {
|
||||
val have = s.deckyPlugins.firstOrNull { it.name == plugin.name }
|
||||
val current = have != null && !DeckyStore.updateAvailable(have, plugin)
|
||||
PluginRow(
|
||||
plugin.name,
|
||||
listOf(plugin.latest?.name.orEmpty(), plugin.author, plugin.description).filter { it.isNotBlank() }.joinToString(" · "),
|
||||
plugin.imageUrl,
|
||||
) {
|
||||
SecondaryButton(
|
||||
stringResource(when { current -> R.string.setup_installed; have != null -> R.string.common_update; else -> R.string.boot_movie_repo_install }),
|
||||
enabled = idle && !current, compact = true,
|
||||
modifier = Modifier.testTag("decky-store-${plugin.name}"),
|
||||
) { a.onDeckyStoreInstall(plugin) }
|
||||
}
|
||||
}
|
||||
if (matches.size > shown) SecondaryButton(stringResource(R.string.decky_store_more, matches.size - shown), compact = true) { shown += STORE_PAGE }
|
||||
}
|
||||
}
|
||||
}
|
||||
if (searching) TextEntryDialog(
|
||||
stringResource(R.string.decky_store_search), query, number = false, confirm = stringResource(R.string.stores_search_open),
|
||||
onSubmit = { query = it; shown = STORE_PAGE; searching = false }, onDismiss = { searching = false }, id = "decky-store-entry",
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PluginRow(name: String, detail: String, imageUrl: String, actions: @Composable () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 10.dp)) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(12.dp), verticalAlignment = androidx.compose.ui.Alignment.CenterVertically) {
|
||||
val shape = RoundedCornerShape(8.dp)
|
||||
Box(Modifier.width(96.dp).aspectRatio(16f / 9f).clip(shape).background(Color(0xFF0E1218))) {
|
||||
if (imageUrl.isNotEmpty()) AsyncImage(model = imageUrl, contentDescription = null, contentScale = ContentScale.Crop, modifier = Modifier.fillMaxSize())
|
||||
}
|
||||
Column(Modifier.weight(1f)) {
|
||||
Text(name, fontSize = 15.sp, fontWeight = androidx.compose.ui.text.font.FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
Text(detail, fontSize = 12.sp, color = colors.onSurfaceVariant, maxLines = 2, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
}
|
||||
Row(horizontalArrangement = Arrangement.End, modifier = Modifier.fillMaxWidth()) { actions() }
|
||||
}
|
||||
}
|
||||
@@ -263,6 +263,10 @@ private fun Content(
|
||||
SyncTabPage(s, modifier.padding(horizontal = padH).padding(top = padV))
|
||||
return
|
||||
}
|
||||
if (selected == "decky" || selected == "boot-movies") {
|
||||
SteamTabPage(selected, a, modifier.padding(horizontal = padH).padding(top = padV))
|
||||
return
|
||||
}
|
||||
if (selected == "updates") {
|
||||
UpdatesPage(s, a, modifier.padding(horizontal = padH).padding(top = padV))
|
||||
return
|
||||
|
||||
@@ -56,9 +56,9 @@ import androidx.compose.material.icons.filled.Terminal
|
||||
import androidx.compose.material.icons.filled.Apps
|
||||
import androidx.compose.material.icons.filled.Settings
|
||||
import androidx.compose.material.icons.filled.SdStorage
|
||||
import androidx.compose.material.icons.filled.Movie
|
||||
import androidx.compose.material.icons.filled.Sync
|
||||
import androidx.compose.material.icons.filled.MoreHoriz
|
||||
import androidx.compose.material.icons.filled.SystemUpdate
|
||||
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.material3.Icon
|
||||
@@ -207,8 +207,10 @@ internal fun railLabelIcon(key: String): Pair<Int, ImageVector> = when (key) {
|
||||
"setup" -> R.string.rail_setup to Icons.Filled.Settings
|
||||
"storage" -> R.string.rail_storage to Icons.Filled.SdStorage
|
||||
"sync" -> R.string.rail_sync to Icons.Filled.Sync
|
||||
"decky" -> R.string.rail_decky to DeckyIcon
|
||||
"boot-movies" -> R.string.rail_boot_movies to Icons.Filled.Movie
|
||||
NavTabs.MORE -> R.string.rail_more to Icons.Filled.MoreHoriz
|
||||
else -> R.string.rail_updates to Icons.Filled.SystemUpdate
|
||||
else -> R.string.rail_updates to updatesIcon(RunningBuild.kind())
|
||||
}
|
||||
|
||||
internal fun setupNeedsAttention(s: FrontEndState): Boolean = !s.ready || (s.available != null && s.available != s.installed) ||
|
||||
|
||||
@@ -454,6 +454,7 @@ internal suspend fun focusSoon(target: () -> FocusRequester) {
|
||||
@Composable
|
||||
fun FrontEndScreen(s: FrontEndState, a: FrontEndActions, page: (@Composable () -> Unit)? = null) {
|
||||
val frontFocus = remember { FrontFocus() }
|
||||
androidx.compose.runtime.SideEffect { RunningBuild.channel = s.updates.follow.channel }
|
||||
val textInput = androidx.compose.ui.platform.LocalTextInputService.current
|
||||
val bottomTextInput = remember(textInput) { textInput?.let { androidx.compose.ui.text.input.TextInputService(BottomScreenTextInput(it)) } }
|
||||
androidx.compose.foundation.layout.BoxWithConstraints(Modifier.fillMaxSize().pointerInput(Unit) {
|
||||
|
||||
@@ -126,6 +126,8 @@ internal object SheetTab {
|
||||
const val LIBRARY = "library"
|
||||
const val STEAM = "steam"
|
||||
const val FILES = "files"
|
||||
const val DECKY = "decky"
|
||||
const val BOOT_MOVIES = "boot-movies"
|
||||
}
|
||||
|
||||
internal fun sheetTop(paneH: Float, buttonH: Float, minAbove: Float, ride: Float): Float =
|
||||
|
||||
@@ -113,6 +113,9 @@ class ModeSettings(
|
||||
val deckyDownloadingBinary: Boolean = false,
|
||||
val deckyEnabled: Boolean = false,
|
||||
val deckySessionRunning: Boolean = false,
|
||||
val deckyPlugins: List<com.droiddeck.launcher.runtime.DeckyStore.Installed> = emptyList(),
|
||||
val deckyStore: List<com.droiddeck.launcher.runtime.DeckyStore.Plugin>? = null,
|
||||
val deckyStoreFailed: Boolean = false,
|
||||
)
|
||||
|
||||
class ModeSettingsActions(
|
||||
@@ -171,6 +174,9 @@ class ModeSettingsActions(
|
||||
val onDeckyEnabled: (Boolean) -> Unit = {},
|
||||
val onDeckyUninstall: () -> Unit = {},
|
||||
val onPickDeckyPluginZip: () -> Unit = {},
|
||||
val onDeckyStoreRefresh: () -> Unit = {},
|
||||
val onDeckyStoreInstall: (com.droiddeck.launcher.runtime.DeckyStore.Plugin) -> Unit = {},
|
||||
val onDeckyRemove: (com.droiddeck.launcher.runtime.DeckyStore.Installed) -> Unit = {},
|
||||
val onDismiss: () -> Unit,
|
||||
)
|
||||
|
||||
@@ -220,6 +226,8 @@ class SheetExtras(
|
||||
fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras: SheetExtras = SheetExtras()) {
|
||||
val steam = s.mode == SessionService.MODE_STEAM
|
||||
val host = rememberMenuHost()
|
||||
if (tab == SheetTab.DECKY) { DeckyGroups(s, a, host); return }
|
||||
if (tab == SheetTab.BOOT_MOVIES) { if (s.bootMovie != null) BootMovieGroup(s, a, host); return }
|
||||
Text(
|
||||
stringResource(when (s.mode) {
|
||||
SessionService.MODE_STEAM -> R.string.sheet_scope_steam
|
||||
@@ -509,75 +517,6 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
|
||||
}
|
||||
if (tab == SheetTab.STEAM && steam) {
|
||||
extras.account(host)
|
||||
SettingsGroup(stringResource(R.string.mode_decky)) {
|
||||
val updateAvailable = s.deckyInstalled != null && s.deckyLatestRelease != null &&
|
||||
s.deckyInstalled != s.deckyLatestRelease.tag
|
||||
val status = when {
|
||||
s.deckyStage != null -> s.deckyStage
|
||||
s.deckyChecking -> stringResource(R.string.mode_decky_checking)
|
||||
s.deckyInstalled == null && s.deckyLatestRelease != null -> stringResource(R.string.mode_decky_ready, s.deckyLatestRelease.tag)
|
||||
s.deckyInstalled == null -> stringResource(R.string.mode_decky_none)
|
||||
s.deckyLatestRelease == null -> stringResource(R.string.mode_decky_installed, s.deckyInstalled)
|
||||
updateAvailable -> stringResource(R.string.mode_decky_update, s.deckyLatestRelease.tag)
|
||||
else -> stringResource(R.string.mode_decky_current, s.deckyInstalled)
|
||||
}
|
||||
SettingsRow(stringResource(R.string.mode_decky_loader), status) {
|
||||
val action = when {
|
||||
s.deckyStage != null -> stringResource(R.string.common_working)
|
||||
s.deckyChecking -> stringResource(R.string.common_checking)
|
||||
s.deckyInstalled == null && s.deckyLatestRelease != null -> stringResource(R.string.mode_decky_install_latest)
|
||||
s.deckyInstalled != null && updateAvailable -> stringResource(R.string.common_update)
|
||||
else -> stringResource(R.string.common_check)
|
||||
}
|
||||
Row(horizontalArrangement = androidx.compose.foundation.layout.Arrangement.spacedBy(6.dp)) {
|
||||
SecondaryButton(
|
||||
action,
|
||||
enabled = s.deckyStage == null && !s.deckyChecking && !s.deckySessionRunning,
|
||||
) {
|
||||
if (s.deckyLatestRelease == null || (s.deckyInstalled != null && !updateAvailable)) a.onDeckyCheck()
|
||||
else s.deckyLatestRelease?.let(a.onDeckyInstall)
|
||||
}
|
||||
if (s.deckyInstalled != null) DeckyUninstall(enabled = s.deckyStage == null && !s.deckySessionRunning, onUninstall = a.onDeckyUninstall)
|
||||
}
|
||||
}
|
||||
ChoiceRow(
|
||||
host, "decky-channel", stringResource(R.string.decky_channel),
|
||||
stringResource(R.string.decky_channel_hint),
|
||||
listOf(
|
||||
DeckyManager.BRANCH_STABLE to stringResource(R.string.decky_channel_stable),
|
||||
DeckyManager.BRANCH_PRERELEASE to stringResource(R.string.decky_channel_prerelease),
|
||||
) + if (s.deckyBranch == DeckyManager.BRANCH_TESTING) listOf(
|
||||
DeckyManager.BRANCH_TESTING to stringResource(R.string.decky_channel_testing),
|
||||
) else emptyList(),
|
||||
s.deckyBranch,
|
||||
enabled = s.deckyStage == null && !s.deckySessionRunning,
|
||||
onPick = a.onDeckyBranch,
|
||||
)
|
||||
if (s.deckyInstalled != null) ToggleRow(
|
||||
host, "decky-enabled", stringResource(R.string.mode_decky),
|
||||
if (s.deckyEnabled) stringResource(R.string.mode_decky_on)
|
||||
else stringResource(R.string.mode_decky_off),
|
||||
s.deckyEnabled,
|
||||
enabled = !s.deckySessionRunning && s.deckyStage == null,
|
||||
onChange = a.onDeckyEnabled,
|
||||
)
|
||||
SettingsRow(
|
||||
stringResource(R.string.mode_decky_plugins),
|
||||
stringResource(R.string.mode_decky_plugins_hint),
|
||||
) {
|
||||
SecondaryButton(
|
||||
if (s.deckyStage != null && s.deckyDownloadingBinary) stringResource(R.string.mode_decky_plugin_downloading) else stringResource(R.string.mode_decky_plugin_install_zip),
|
||||
enabled = s.deckyInstalled != null && s.deckyStage == null && !s.deckySessionRunning,
|
||||
onClick = a.onPickDeckyPluginZip,
|
||||
)
|
||||
}
|
||||
if (s.deckyStage != null && s.deckyPercent >= 0) {
|
||||
LinearProgressIndicator(
|
||||
progress = { s.deckyPercent / 100f },
|
||||
modifier = Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 8.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
SettingsGroup(stringResource(R.string.mode_client)) {
|
||||
ToggleRow(
|
||||
host, "mangoapp", stringResource(R.string.mode_mangoapp),
|
||||
@@ -607,7 +546,6 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
|
||||
onPick = a.onSteamClientArch,
|
||||
)
|
||||
}
|
||||
if (s.bootMovie != null) BootMovieGroup(s, a, host)
|
||||
if (s.integration != null) SteamIntegrationGroup(s.integration,
|
||||
onFeature = a.onIntegration, onAppInfo = a.onIntegrationAppInfo, onLocation = a.onIntegrationLocation)
|
||||
}
|
||||
@@ -669,7 +607,7 @@ internal fun DeckyZipWarningDialog(onConfirm: () -> Unit, onCancel: () -> Unit)
|
||||
private const val DECKY_ZIP_WARNING_SECONDS = 5
|
||||
|
||||
@Composable
|
||||
private fun DeckyUninstall(enabled: Boolean, onUninstall: () -> Unit) {
|
||||
internal fun DeckyUninstall(enabled: Boolean, onUninstall: () -> Unit) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val label = stringResource(R.string.common_uninstall)
|
||||
val title = stringResource(R.string.mode_decky_remove_title)
|
||||
|
||||
@@ -26,10 +26,10 @@ internal object DeveloperTools {
|
||||
|
||||
internal object NavTabs {
|
||||
const val MORE = "more"
|
||||
val ALL = listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", "soundtracks", "components", "storage", "sync", "android-apps", "agent")
|
||||
val DEFAULT_SHELVED = setOf("stores", "soundtracks", "components", "storage", "sync", "android-apps", "agent")
|
||||
val ALL = listOf("steam", "desktop", "games", "downloads", "setup", "updates", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "android-apps", "agent")
|
||||
val DEFAULT_SHELVED = setOf("stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "android-apps", "agent")
|
||||
val DEFAULT_HIDDEN = setOf("android-apps", "agent")
|
||||
private val SHELVED_WHEN_NEW = setOf("storage", "sync", "android-apps", "agent")
|
||||
private val SHELVED_WHEN_NEW = setOf("storage", "sync", "decky", "boot-movies", "android-apps", "agent")
|
||||
private val OLD_ORDER = listOf("steam", "games", "soundtracks", "stores", "downloads", "desktop", "agent", "components", "android-apps", "storage", "sync", "setup", "updates")
|
||||
private val OLD_SHELVED = setOf("soundtracks", "agent", "storage", "sync")
|
||||
private const val LAYOUT_VERSION = 2
|
||||
|
||||
@@ -75,6 +75,19 @@ internal fun SyncTabPage(s: FrontEndState, modifier: Modifier) {
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun SteamTabPage(key: String, a: FrontEndActions, modifier: Modifier) {
|
||||
LaunchedEffect(Unit) { a.onSteamSettings() }
|
||||
Column(modifier.verticalScroll(rememberScrollState()).padding(bottom = 24.dp)) {
|
||||
PageHeader(stringResource(if (key == "decky") R.string.rail_decky else R.string.rail_boot_movies))
|
||||
a.modeSheet(
|
||||
com.droiddeck.launcher.session.SessionService.MODE_STEAM,
|
||||
if (key == "decky") SheetTab.DECKY else SheetTab.BOOT_MOVIES,
|
||||
SheetExtras(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ResetTabsRow() {
|
||||
val ctx = androidx.compose.ui.platform.LocalContext.current
|
||||
|
||||
@@ -93,6 +93,8 @@ internal object SettingsIndex {
|
||||
s(SettingsSection.CONTROLLER, R.string.setup_tab_controller, "gamepad", "buttons", "mapping", "profile", "remap"),
|
||||
SettingsEntry(SettingsPlace.TAB, R.string.rail_storage, tab = "storage", words = listOf("sd card", "space", "uninstall", "disk")),
|
||||
SettingsEntry(SettingsPlace.TAB, R.string.rail_sync, tab = "sync", words = listOf("syncthing", "saves")),
|
||||
SettingsEntry(SettingsPlace.TAB, R.string.rail_decky, tab = "decky", words = listOf("plugins", "plugin store", "homebrew", "loader")),
|
||||
SettingsEntry(SettingsPlace.TAB, R.string.rail_boot_movies, tab = "boot-movies", words = listOf("startup movie", "boot video", "animation", "steamdeckrepo")),
|
||||
s(SettingsSection.GLASSES, R.string.setup_tab_glasses, "xreal", "viture", "vr", "ar"),
|
||||
|
||||
s(SettingsSection.LAUNCHER, R.string.setup_theme, "color", "dark"),
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.SystemUpdate
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.PathFillType
|
||||
import androidx.compose.ui.graphics.SolidColor
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.graphics.vector.addPathNodes
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.droiddeck.launcher.update.AppUpdates
|
||||
|
||||
internal enum class BuildKind { STABLE, PREVIEW, TEST, LOCAL }
|
||||
|
||||
internal object RunningBuild {
|
||||
var channel by mutableStateOf(AppUpdates.Channel.STABLE)
|
||||
|
||||
fun kind(me: AppUpdates.Installed = AppUpdates.installed(), channel: AppUpdates.Channel = this.channel): BuildKind = when {
|
||||
me.pr > 0 -> BuildKind.TEST
|
||||
!me.ciBuild -> BuildKind.LOCAL
|
||||
channel == AppUpdates.Channel.NIGHTLY -> BuildKind.PREVIEW
|
||||
else -> BuildKind.STABLE
|
||||
}
|
||||
}
|
||||
|
||||
private const val PHONE = "M17,1.01L7,1c-1.1,0 -2,0.9 -2,2v18c0,1.1 0.9,2 2,2h10c1.1,0 2,-0.9 2,-2V3c0,-1.1 -0.9,-1.99 -2,-1.99zM17,19H7V5h10v14z"
|
||||
private const val LETTER_P = "M9.6,7.6 H12.6 A2.4,2.4 0 0 1 12.6,12.4 H11.4 V16.4 H9.6 Z M11.4,9.2 V10.8 H12.6 A0.8,0.8 0 0 0 12.6,9.2 Z"
|
||||
private const val LETTER_T = "M8.6,7.6 H15.4 V9.3 H12.9 V16.4 H11.1 V9.3 H8.6 Z"
|
||||
private const val LETTER_L = "M9.8,7.6 H11.6 V14.7 H15 V16.4 H9.8 Z"
|
||||
|
||||
private fun phoneWith(name: String, letter: String) =
|
||||
ImageVector.Builder(name, 24.dp, 24.dp, 24f, 24f)
|
||||
.addPath(addPathNodes(PHONE), fill = SolidColor(Color.Black))
|
||||
.addPath(addPathNodes(letter), fill = SolidColor(Color.Black), pathFillType = PathFillType.EvenOdd)
|
||||
.build()
|
||||
|
||||
private val PreviewIcon by lazy { phoneWith("UpdatesPreview", LETTER_P) }
|
||||
private val TestIcon by lazy { phoneWith("UpdatesTest", LETTER_T) }
|
||||
private val LocalIcon by lazy { phoneWith("UpdatesLocal", LETTER_L) }
|
||||
|
||||
internal fun updatesIcon(kind: BuildKind): ImageVector = when (kind) {
|
||||
BuildKind.STABLE -> Icons.Filled.SystemUpdate
|
||||
BuildKind.PREVIEW -> PreviewIcon
|
||||
BuildKind.TEST -> TestIcon
|
||||
BuildKind.LOCAL -> LocalIcon
|
||||
}
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">بدء التشغيل</string>
|
||||
<string name="mode_startup_session">الفتح عند التشغيل</string>
|
||||
<string name="mode_startup_session_hint">يبدأ هذه الجلسة عند تشغيل DroidDeck.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">جارٍ البحث عن إصدارات…</string>
|
||||
<string name="mode_decky_ready">جاهز لتثبيت %1$s.</string>
|
||||
<string name="mode_decky_none">لم يتم العثور على إصدار متوافق. حاول مرة أخرى لاحقًا.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">محدَّث · %1$s</string>
|
||||
<string name="mode_decky_loader">المُحمِّل</string>
|
||||
<string name="mode_decky_install_latest">تثبيت أحدث إصدار</string>
|
||||
<string name="decky_channel">قناة التحديث</string>
|
||||
<string name="decky_channel_hint">إصدارات Decky Loader التي تُثبَّت. يستخدم مُحدِّث Decky نفسه القناة ذاتها.</string>
|
||||
<string name="decky_channel_stable">مستقرة</string>
|
||||
<string name="decky_channel_prerelease">إصدار تجريبي مسبق</string>
|
||||
<string name="decky_channel_testing">اختبار</string>
|
||||
<string name="decky_channel_failed">تعذّر حفظ قناة تحديث Decky</string>
|
||||
<string name="mode_decky_on">يبدأ مع Steam. أثناء تفعيله، قد تتمكن التطبيقات الأخرى على هذا الجهاز من التحكم في Steam.</string>
|
||||
<string name="mode_decky_off">متوقف. يبقى منفذ تصحيح الأخطاء عن بُعد في Steam مغلقًا.</string>
|
||||
<string name="mode_decky_remove_title">هل تريد إلغاء تثبيت Decky Loader؟</string>
|
||||
<string name="mode_decky_remove_text">يزيل المُحمِّل. يتم الاحتفاظ بالمكونات الإضافية والإعدادات.</string>
|
||||
<string name="mode_client">العميل</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Inicio</string>
|
||||
<string name="mode_startup_session">Abrir al iniciar</string>
|
||||
<string name="mode_startup_session_hint">Inicia esta sesión cuando se abre DroidDeck.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Buscando versiones…</string>
|
||||
<string name="mode_decky_ready">Listo para instalar %1$s.</string>
|
||||
<string name="mode_decky_none">No se encontró ninguna versión compatible. Inténtalo más tarde.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Al día · %1$s</string>
|
||||
<string name="mode_decky_loader">Loader</string>
|
||||
<string name="mode_decky_install_latest">Instalar la última</string>
|
||||
<string name="decky_channel">Canal de actualizaciones</string>
|
||||
<string name="decky_channel_hint">Qué versiones de Decky Loader se instalan. El actualizador propio de Decky usa el mismo canal.</string>
|
||||
<string name="decky_channel_stable">Estable</string>
|
||||
<string name="decky_channel_prerelease">Preliminar</string>
|
||||
<string name="decky_channel_testing">Pruebas</string>
|
||||
<string name="decky_channel_failed">No se pudo guardar el canal de actualizaciones de Decky</string>
|
||||
<string name="mode_decky_on">Se inicia con Steam. Mientras esté activado, otras apps de este dispositivo podrían controlar Steam.</string>
|
||||
<string name="mode_decky_off">Desactivado. El puerto de depuración remota de Steam permanece cerrado.</string>
|
||||
<string name="mode_decky_remove_title">¿Desinstalar Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Elimina el loader. Tus plugins y ajustes se conservan.</string>
|
||||
<string name="mode_client">Cliente</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Стартиране</string>
|
||||
<string name="mode_startup_session">Отваряне при стартиране</string>
|
||||
<string name="mode_startup_session_hint">Стартира тази сесия, когато DroidDeck се стартира.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Проверка за издания…</string>
|
||||
<string name="mode_decky_ready">Готово за инсталиране на %1$s.</string>
|
||||
<string name="mode_decky_none">Не е намерена съвместима версия. Опитайте по-късно.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Актуално · %1$s</string>
|
||||
<string name="mode_decky_loader">Зареждач</string>
|
||||
<string name="mode_decky_install_latest">Инсталиране на последната версия</string>
|
||||
<string name="decky_channel">Канал за актуализации</string>
|
||||
<string name="decky_channel_hint">Кои издания на Decky Loader да се инсталират. Собственият актуализатор на Decky използва същия канал.</string>
|
||||
<string name="decky_channel_stable">Стабилен</string>
|
||||
<string name="decky_channel_prerelease">Предварителен</string>
|
||||
<string name="decky_channel_testing">Тестов</string>
|
||||
<string name="decky_channel_failed">Каналът за актуализации на Decky не можа да бъде запазен</string>
|
||||
<string name="mode_decky_on">Стартира заедно със Steam. Докато е включено, други приложения на това устройство може да могат да контролират Steam.</string>
|
||||
<string name="mode_decky_off">Изключено. Портът за отдалечено дебъгване на Steam остава затворен.</string>
|
||||
<string name="mode_decky_remove_title">Деинсталиране на Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Премахва зареждащия модул. Плъгините и настройките ви се запазват.</string>
|
||||
<string name="mode_client">Клиент</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Spouštění</string>
|
||||
<string name="mode_startup_session">Otevřít při spuštění</string>
|
||||
<string name="mode_startup_session_hint">Spustí tuto relaci při spuštění DroidDeck.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Hledání vydání…</string>
|
||||
<string name="mode_decky_ready">Připraveno k instalaci %1$s.</string>
|
||||
<string name="mode_decky_none">Nenalezeno žádné kompatibilní sestavení. Zkuste to později.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Aktuální · %1$s</string>
|
||||
<string name="mode_decky_loader">Loader</string>
|
||||
<string name="mode_decky_install_latest">Nainstalovat nejnovější</string>
|
||||
<string name="decky_channel">Kanál aktualizací</string>
|
||||
<string name="decky_channel_hint">Která vydání Decky Loader instalovat. Vlastní aktualizátor Decky používá stejný kanál.</string>
|
||||
<string name="decky_channel_stable">Stabilní</string>
|
||||
<string name="decky_channel_prerelease">Předběžné vydání</string>
|
||||
<string name="decky_channel_testing">Testovací</string>
|
||||
<string name="decky_channel_failed">Kanál aktualizací Decky se nepodařilo uložit</string>
|
||||
<string name="mode_decky_on">Spouští se se Steamem. Když je zapnuto, jiné aplikace na tomto zařízení mohou mít možnost ovládat Steam.</string>
|
||||
<string name="mode_decky_off">Vypnuto. Port pro vzdálené ladění Steamu zůstává zavřený.</string>
|
||||
<string name="mode_decky_remove_title">Odinstalovat Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Odstraní loader. Vaše pluginy a nastavení zůstanou zachovány.</string>
|
||||
<string name="mode_client">Klient</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Opstart</string>
|
||||
<string name="mode_startup_session">Åbn ved start</string>
|
||||
<string name="mode_startup_session_hint">Starter denne session, når DroidDeck startes.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Søger efter udgivelser…</string>
|
||||
<string name="mode_decky_ready">Klar til at installere %1$s.</string>
|
||||
<string name="mode_decky_none">Ingen kompatibel build fundet. Prøv igen senere.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Opdateret · %1$s</string>
|
||||
<string name="mode_decky_loader">Loader</string>
|
||||
<string name="mode_decky_install_latest">Installer nyeste</string>
|
||||
<string name="decky_channel">Opdateringskanal</string>
|
||||
<string name="decky_channel_hint">Hvilke Decky Loader-udgivelser der installeres. Deckys egen opdatering bruger samme kanal.</string>
|
||||
<string name="decky_channel_stable">Stabil</string>
|
||||
<string name="decky_channel_prerelease">Forhåndsudgivelse</string>
|
||||
<string name="decky_channel_testing">Test</string>
|
||||
<string name="decky_channel_failed">Kunne ikke gemme Decky-opdateringskanalen</string>
|
||||
<string name="mode_decky_on">Starter med Steam. Mens den er til, kan andre apps på denne enhed muligvis styre Steam.</string>
|
||||
<string name="mode_decky_off">Fra. Steams fjerndebugport forbliver lukket.</string>
|
||||
<string name="mode_decky_remove_title">Afinstaller Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Fjerner loaderen. Dine plugins og indstillinger bevares.</string>
|
||||
<string name="mode_client">Klient</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Start</string>
|
||||
<string name="mode_startup_session">Beim Start öffnen</string>
|
||||
<string name="mode_startup_session_hint">Startet diese Sitzung, wenn DroidDeck startet.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Suche nach Releases…</string>
|
||||
<string name="mode_decky_ready">Bereit zur Installation von %1$s.</string>
|
||||
<string name="mode_decky_none">Kein kompatibler Build gefunden. Versuch es später noch einmal.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Aktuell · %1$s</string>
|
||||
<string name="mode_decky_loader">Loader</string>
|
||||
<string name="mode_decky_install_latest">Neueste Version installieren</string>
|
||||
<string name="decky_channel">Update-Kanal</string>
|
||||
<string name="decky_channel_hint">Welche Decky-Loader-Releases installiert werden. Deckys eigener Updater nutzt denselben Kanal.</string>
|
||||
<string name="decky_channel_stable">Stabil</string>
|
||||
<string name="decky_channel_prerelease">Vorabversion</string>
|
||||
<string name="decky_channel_testing">Test</string>
|
||||
<string name="decky_channel_failed">Decky-Update-Kanal konnte nicht gespeichert werden</string>
|
||||
<string name="mode_decky_on">Startet mit Steam. Solange aktiv, können andere Apps auf diesem Gerät Steam möglicherweise steuern.</string>
|
||||
<string name="mode_decky_off">Aus. Der Remote-Debugging-Port von Steam bleibt geschlossen.</string>
|
||||
<string name="mode_decky_remove_title">Decky Loader deinstallieren?</string>
|
||||
<string name="mode_decky_remove_text">Entfernt den Loader. Deine Plugins und Einstellungen bleiben erhalten.</string>
|
||||
<string name="mode_client">Client</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Εκκίνηση</string>
|
||||
<string name="mode_startup_session">Άνοιγμα κατά την εκκίνηση</string>
|
||||
<string name="mode_startup_session_hint">Ξεκινά αυτή τη συνεδρία όταν ανοίγει το DroidDeck.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Έλεγχος για εκδόσεις…</string>
|
||||
<string name="mode_decky_ready">Έτοιμο για εγκατάσταση %1$s.</string>
|
||||
<string name="mode_decky_none">Δεν βρέθηκε συμβατό build. Δοκιμάστε ξανά αργότερα.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Ενημερωμένο · %1$s</string>
|
||||
<string name="mode_decky_loader">Φορτωτής</string>
|
||||
<string name="mode_decky_install_latest">Εγκατάσταση τελευταίας έκδοσης</string>
|
||||
<string name="decky_channel">Κανάλι ενημερώσεων</string>
|
||||
<string name="decky_channel_hint">Ποιες εκδόσεις του Decky Loader θα εγκατασταθούν. Το πρόγραμμα ενημέρωσης του Decky χρησιμοποιεί το ίδιο κανάλι.</string>
|
||||
<string name="decky_channel_stable">Σταθερό</string>
|
||||
<string name="decky_channel_prerelease">Προέκδοση</string>
|
||||
<string name="decky_channel_testing">Δοκιμαστικό</string>
|
||||
<string name="decky_channel_failed">Δεν ήταν δυνατή η αποθήκευση του καναλιού ενημερώσεων του Decky</string>
|
||||
<string name="mode_decky_on">Ξεκινά με το Steam. Όσο είναι ενεργό, άλλες εφαρμογές σε αυτή τη συσκευή μπορεί να είναι σε θέση να ελέγξουν το Steam.</string>
|
||||
<string name="mode_decky_off">Ανενεργό. Η θύρα απομακρυσμένου εντοπισμού σφαλμάτων του Steam παραμένει κλειστή.</string>
|
||||
<string name="mode_decky_remove_title">Κατάργηση εγκατάστασης του Decky Loader;</string>
|
||||
<string name="mode_decky_remove_text">Καταργεί τον loader. Τα plugins και οι ρυθμίσεις σας διατηρούνται.</string>
|
||||
<string name="mode_client">Πελάτης</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Inicio</string>
|
||||
<string name="mode_startup_session">Abrir al iniciar</string>
|
||||
<string name="mode_startup_session_hint">Inicia esta sesión cuando se abre DroidDeck.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Buscando versiones…</string>
|
||||
<string name="mode_decky_ready">Listo para instalar %1$s.</string>
|
||||
<string name="mode_decky_none">No se encontró ninguna versión compatible. Inténtalo más tarde.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Al día · %1$s</string>
|
||||
<string name="mode_decky_loader">Loader</string>
|
||||
<string name="mode_decky_install_latest">Instalar la última</string>
|
||||
<string name="decky_channel">Canal de actualizaciones</string>
|
||||
<string name="decky_channel_hint">Qué versiones de Decky Loader se instalan. El actualizador propio de Decky usa el mismo canal.</string>
|
||||
<string name="decky_channel_stable">Estable</string>
|
||||
<string name="decky_channel_prerelease">Preliminar</string>
|
||||
<string name="decky_channel_testing">Pruebas</string>
|
||||
<string name="decky_channel_failed">No se ha podido guardar el canal de actualizaciones de Decky</string>
|
||||
<string name="mode_decky_on">Se inicia con Steam. Mientras esté activado, otras apps de este dispositivo podrían controlar Steam.</string>
|
||||
<string name="mode_decky_off">Desactivado. El puerto de depuración remota de Steam permanece cerrado.</string>
|
||||
<string name="mode_decky_remove_title">¿Desinstalar Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Elimina el loader. Tus plugins y ajustes se conservan.</string>
|
||||
<string name="mode_client">Cliente</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Käynnistys</string>
|
||||
<string name="mode_startup_session">Avaa käynnistyksessä</string>
|
||||
<string name="mode_startup_session_hint">Käynnistää tämän istunnon, kun DroidDeck avataan.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Tarkistetaan julkaisuja…</string>
|
||||
<string name="mode_decky_ready">Valmiina asentamaan %1$s.</string>
|
||||
<string name="mode_decky_none">Yhteensopivaa versiota ei löytynyt. Yritä myöhemmin uudelleen.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Ajan tasalla · %1$s</string>
|
||||
<string name="mode_decky_loader">Lataaja</string>
|
||||
<string name="mode_decky_install_latest">Asenna uusin</string>
|
||||
<string name="decky_channel">Päivityskanava</string>
|
||||
<string name="decky_channel_hint">Mitkä Decky Loader -julkaisut asennetaan. Deckyn oma päivitysohjelma käyttää samaa kanavaa.</string>
|
||||
<string name="decky_channel_stable">Vakaa</string>
|
||||
<string name="decky_channel_prerelease">Esijulkaisu</string>
|
||||
<string name="decky_channel_testing">Testaus</string>
|
||||
<string name="decky_channel_failed">Deckyn päivityskanavaa ei voitu tallentaa</string>
|
||||
<string name="mode_decky_on">Käynnistyy Steamin kanssa. Päällä ollessaan muut tämän laitteen sovellukset voivat pystyä ohjaamaan Steamia.</string>
|
||||
<string name="mode_decky_off">Pois. Steamin etävianmääritysportti pysyy suljettuna.</string>
|
||||
<string name="mode_decky_remove_title">Poistetaanko Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Poistaa loaderin. Laajennuksesi ja asetuksesi säilyvät.</string>
|
||||
<string name="mode_client">Asiakasohjelma</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Démarrage</string>
|
||||
<string name="mode_startup_session">Ouvrir au démarrage</string>
|
||||
<string name="mode_startup_session_hint">Lance cette session au démarrage de DroidDeck.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Vérification des versions…</string>
|
||||
<string name="mode_decky_ready">Prêt à installer %1$s.</string>
|
||||
<string name="mode_decky_none">Aucune version compatible trouvée. Veuillez réessayer plus tard.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">À jour · %1$s</string>
|
||||
<string name="mode_decky_loader">Chargeur</string>
|
||||
<string name="mode_decky_install_latest">Installer la dernière version</string>
|
||||
<string name="decky_channel">Canal de mise à jour</string>
|
||||
<string name="decky_channel_hint">Les versions de Decky Loader à installer. Le programme de mise à jour de Decky utilise le même canal.</string>
|
||||
<string name="decky_channel_stable">Stable</string>
|
||||
<string name="decky_channel_prerelease">Préversion</string>
|
||||
<string name="decky_channel_testing">Test</string>
|
||||
<string name="decky_channel_failed">Impossible d\'enregistrer le canal de mise à jour de Decky</string>
|
||||
<string name="mode_decky_on">Démarre avec Steam. Une fois activé, d\'autres applications sur cet appareil peuvent contrôler Steam.</string>
|
||||
<string name="mode_decky_off">Désactivé. Le port de débogage distant de Steam reste fermé.</string>
|
||||
<string name="mode_decky_remove_title">Désinstaller Decky Loader ?</string>
|
||||
<string name="mode_decky_remove_text">Supprime le chargeur. Vos plugins et paramètres seront conservés.</string>
|
||||
<string name="mode_client">Client</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">स्टार्टअप</string>
|
||||
<string name="mode_startup_session">लॉन्च पर खोलें</string>
|
||||
<string name="mode_startup_session_hint">DroidDeck खुलने पर यह सेशन शुरू करता है।</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">रिलीज़ देखी जा रही हैं…</string>
|
||||
<string name="mode_decky_ready">%1$s इंस्टॉल करने के लिए तैयार।</string>
|
||||
<string name="mode_decky_none">कोई कम्पैटिबल बिल्ड नहीं मिला। बाद में फिर कोशिश करें।</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">नवीनतम · %1$s</string>
|
||||
<string name="mode_decky_loader">लोडर</string>
|
||||
<string name="mode_decky_install_latest">नवीनतम इंस्टॉल करें</string>
|
||||
<string name="decky_channel">अपडेट चैनल</string>
|
||||
<string name="decky_channel_hint">कौन-सी Decky Loader रिलीज़ इंस्टॉल करनी हैं। Decky का अपना अपडेटर भी यही चैनल इस्तेमाल करता है।</string>
|
||||
<string name="decky_channel_stable">स्टेबल</string>
|
||||
<string name="decky_channel_prerelease">प्री-रिलीज़</string>
|
||||
<string name="decky_channel_testing">टेस्टिंग</string>
|
||||
<string name="decky_channel_failed">Decky अपडेट चैनल सेव नहीं हो सका</string>
|
||||
<string name="mode_decky_on">Steam के साथ शुरू होता है। चालू रहते हुए, इस डिवाइस के दूसरे ऐप Steam को नियंत्रित कर सकते हैं।</string>
|
||||
<string name="mode_decky_off">बंद। Steam का रिमोट डिबगिंग पोर्ट बंद रहता है।</string>
|
||||
<string name="mode_decky_remove_title">Decky Loader अनइंस्टॉल करें?</string>
|
||||
<string name="mode_decky_remove_text">लोडर हटाता है। आपके प्लगइन और सेटिंग बनी रहती हैं।</string>
|
||||
<string name="mode_client">क्लाइंट</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Indítás</string>
|
||||
<string name="mode_startup_session">Megnyitás indításkor</string>
|
||||
<string name="mode_startup_session_hint">A DroidDeck indulásakor elindítja ezt a munkamenetet.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Kiadások keresése…</string>
|
||||
<string name="mode_decky_ready">Készen áll a %1$s telepítésére.</string>
|
||||
<string name="mode_decky_none">Nem található kompatibilis build. Próbálja újra később.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Naprakész · %1$s</string>
|
||||
<string name="mode_decky_loader">Betöltő</string>
|
||||
<string name="mode_decky_install_latest">Legújabb telepítése</string>
|
||||
<string name="decky_channel">Frissítési csatorna</string>
|
||||
<string name="decky_channel_hint">Mely Decky Loader-kiadások települjenek. A Decky saját frissítője ugyanezt a csatornát használja.</string>
|
||||
<string name="decky_channel_stable">Stabil</string>
|
||||
<string name="decky_channel_prerelease">Előzetes kiadás</string>
|
||||
<string name="decky_channel_testing">Tesztelés</string>
|
||||
<string name="decky_channel_failed">Nem sikerült menteni a Decky frissítési csatornáját</string>
|
||||
<string name="mode_decky_on">A Steammel együtt indul. Amíg be van kapcsolva, az eszközön lévő más alkalmazások is irányíthatják a Steamet.</string>
|
||||
<string name="mode_decky_off">Ki. A Steam távoli hibakeresési portja zárva marad.</string>
|
||||
<string name="mode_decky_remove_title">Eltávolítja a Decky Loadert?</string>
|
||||
<string name="mode_decky_remove_text">Eltávolítja a betöltőt. A bővítményei és beállításai megmaradnak.</string>
|
||||
<string name="mode_client">Kliens</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Mulai</string>
|
||||
<string name="mode_startup_session">Buka saat peluncuran</string>
|
||||
<string name="mode_startup_session_hint">Memulai sesi ini saat DroidDeck diluncurkan.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Memeriksa rilis…</string>
|
||||
<string name="mode_decky_ready">Siap menginstal %1$s.</string>
|
||||
<string name="mode_decky_none">Tidak ditemukan build yang kompatibel. Coba lagi nanti.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Terbaru · %1$s</string>
|
||||
<string name="mode_decky_loader">Loader</string>
|
||||
<string name="mode_decky_install_latest">Instal versi terbaru</string>
|
||||
<string name="decky_channel">Saluran Pembaruan</string>
|
||||
<string name="decky_channel_hint">Rilis Decky Loader mana yang akan diinstal. Pembaru bawaan Decky menggunakan saluran yang sama.</string>
|
||||
<string name="decky_channel_stable">Stabil</string>
|
||||
<string name="decky_channel_prerelease">Prarilis</string>
|
||||
<string name="decky_channel_testing">Pengujian</string>
|
||||
<string name="decky_channel_failed">Tidak dapat menyimpan saluran pembaruan Decky</string>
|
||||
<string name="mode_decky_on">Dimulai bersama Steam. Saat aktif, aplikasi lain di perangkat ini mungkin dapat mengendalikan Steam.</string>
|
||||
<string name="mode_decky_off">Nonaktif. Port debugging jarak jauh Steam tetap tertutup.</string>
|
||||
<string name="mode_decky_remove_title">Hapus instalasi Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Menghapus loader. Plugin dan setelan Anda tetap disimpan.</string>
|
||||
<string name="mode_client">Klien</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Avvio</string>
|
||||
<string name="mode_startup_session">Apri all\'avvio</string>
|
||||
<string name="mode_startup_session_hint">Avvia questa sessione all\'avvio di DroidDeck.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Ricerca di release…</string>
|
||||
<string name="mode_decky_ready">Pronto per installare %1$s.</string>
|
||||
<string name="mode_decky_none">Nessuna build compatibile trovata. Riprova più tardi.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Ultima versione · %1$s</string>
|
||||
<string name="mode_decky_loader">Loader</string>
|
||||
<string name="mode_decky_install_latest">Installa l\'ultima versione</string>
|
||||
<string name="decky_channel">Canale di aggiornamento</string>
|
||||
<string name="decky_channel_hint">Quali release di Decky Loader installare. Anche l\'aggiornamento integrato di Decky usa lo stesso canale.</string>
|
||||
<string name="decky_channel_stable">Stabile</string>
|
||||
<string name="decky_channel_prerelease">Pre-release</string>
|
||||
<string name="decky_channel_testing">Test</string>
|
||||
<string name="decky_channel_failed">Impossibile salvare il canale di aggiornamento di Decky</string>
|
||||
<string name="mode_decky_on">Si avvia con Steam. Quando è attivo, altre app su questo dispositivo potrebbero controllare Steam.</string>
|
||||
<string name="mode_decky_off">Disattivato. La porta di debug remoto di Steam resta chiusa.</string>
|
||||
<string name="mode_decky_remove_title">Disinstallare Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Rimuove il loader. I tuoi plugin e le impostazioni vengono mantenuti.</string>
|
||||
<string name="mode_client">Client</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">起動</string>
|
||||
<string name="mode_startup_session">起動時に開く</string>
|
||||
<string name="mode_startup_session_hint">DroidDeck の起動時にこのセッションを開始します。</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">リリースを確認中…</string>
|
||||
<string name="mode_decky_ready">%1$sをインストールする準備ができました。</string>
|
||||
<string name="mode_decky_none">互換性のあるバージョンが見つかりません。後でもう一度お試しください。</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">最新です · %1$s</string>
|
||||
<string name="mode_decky_loader">ローダー</string>
|
||||
<string name="mode_decky_install_latest">最新バージョンをインストール</string>
|
||||
<string name="decky_channel">アップデートチャンネル</string>
|
||||
<string name="decky_channel_hint">インストールするDecky Loaderのリリースです。Decky自身のアップデーターも同じチャンネルを使用します。</string>
|
||||
<string name="decky_channel_stable">安定版</string>
|
||||
<string name="decky_channel_prerelease">プレリリース版</string>
|
||||
<string name="decky_channel_testing">テスト版</string>
|
||||
<string name="decky_channel_failed">Deckyのアップデートチャンネルを保存できませんでした</string>
|
||||
<string name="mode_decky_on">Steamと共に起動します。有効にすると、このデバイス上の他のアプリがSteamを制御できる場合があります。</string>
|
||||
<string name="mode_decky_off">オフ。Steamのリモートデバッグポートは閉じたままになります。</string>
|
||||
<string name="mode_decky_remove_title">Decky Loaderをアンインストールしますか?</string>
|
||||
<string name="mode_decky_remove_text">ローダーを削除します。プラグインと設定は保持されます。</string>
|
||||
<string name="mode_client">クライアント</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">시작</string>
|
||||
<string name="mode_startup_session">실행 시 열기</string>
|
||||
<string name="mode_startup_session_hint">DroidDeck을 실행할 때 이 세션을 시작합니다.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">릴리스 확인 중…</string>
|
||||
<string name="mode_decky_ready">%1$s을(를) 설치할 준비가 되었습니다.</string>
|
||||
<string name="mode_decky_none">호환되는 버전을 찾을 수 없습니다. 나중에 다시 시도하세요.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">최신 버전 · %1$s</string>
|
||||
<string name="mode_decky_loader">로더</string>
|
||||
<string name="mode_decky_install_latest">최신 버전 설치</string>
|
||||
<string name="decky_channel">업데이트 채널</string>
|
||||
<string name="decky_channel_hint">설치할 Decky Loader 릴리스입니다. Decky 자체 업데이터도 같은 채널을 사용합니다.</string>
|
||||
<string name="decky_channel_stable">안정판</string>
|
||||
<string name="decky_channel_prerelease">사전 출시판</string>
|
||||
<string name="decky_channel_testing">테스트판</string>
|
||||
<string name="decky_channel_failed">Decky 업데이트 채널을 저장할 수 없습니다</string>
|
||||
<string name="mode_decky_on">Steam과 함께 시작됩니다. 활성화하면 이 기기의 다른 앱이 Steam을 제어할 수 있습니다.</string>
|
||||
<string name="mode_decky_off">끔. Steam의 원격 디버깅 포트가 닫힌 상태로 유지됩니다.</string>
|
||||
<string name="mode_decky_remove_title">Decky Loader를 제거하시겠습니까?</string>
|
||||
<string name="mode_decky_remove_text">로더를 제거합니다. 플러그인과 설정은 유지됩니다.</string>
|
||||
<string name="mode_client">클라이언트</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Permulaan</string>
|
||||
<string name="mode_startup_session">Buka semasa pelancaran</string>
|
||||
<string name="mode_startup_session_hint">Memulakan sesi ini apabila DroidDeck dilancarkan.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Menyemak keluaran…</string>
|
||||
<string name="mode_decky_ready">Sedia untuk memasang %1$s.</string>
|
||||
<string name="mode_decky_none">Tiada binaan serasi ditemui. Cuba lagi kemudian.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Terkini · %1$s</string>
|
||||
<string name="mode_decky_loader">Loader</string>
|
||||
<string name="mode_decky_install_latest">Pasang yang terbaharu</string>
|
||||
<string name="decky_channel">Saluran Kemas Kini</string>
|
||||
<string name="decky_channel_hint">Keluaran Decky Loader yang hendak dipasang. Pengemas kini Decky sendiri menggunakan saluran yang sama.</string>
|
||||
<string name="decky_channel_stable">Stabil</string>
|
||||
<string name="decky_channel_prerelease">Prakeluaran</string>
|
||||
<string name="decky_channel_testing">Pengujian</string>
|
||||
<string name="decky_channel_failed">Tidak dapat menyimpan saluran kemas kini Decky</string>
|
||||
<string name="mode_decky_on">Bermula bersama Steam. Semasa dihidupkan, apl lain pada peranti ini mungkin boleh mengawal Steam.</string>
|
||||
<string name="mode_decky_off">Mati. Port debug jauh Steam kekal tertutup.</string>
|
||||
<string name="mode_decky_remove_title">Nyahpasang Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Mengalih keluar loader. Plugin dan tetapan anda dikekalkan.</string>
|
||||
<string name="mode_client">Klien</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Oppstart</string>
|
||||
<string name="mode_startup_session">Åpne ved oppstart</string>
|
||||
<string name="mode_startup_session_hint">Starter denne økten når DroidDeck starter.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Ser etter utgivelser…</string>
|
||||
<string name="mode_decky_ready">Klar til å installere %1$s.</string>
|
||||
<string name="mode_decky_none">Ingen kompatibel build funnet. Prøv igjen senere.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Oppdatert · %1$s</string>
|
||||
<string name="mode_decky_loader">Loader</string>
|
||||
<string name="mode_decky_install_latest">Installer nyeste</string>
|
||||
<string name="decky_channel">Oppdateringskanal</string>
|
||||
<string name="decky_channel_hint">Hvilke Decky Loader-utgivelser som installeres. Deckys egen oppdatering bruker samme kanal.</string>
|
||||
<string name="decky_channel_stable">Stabil</string>
|
||||
<string name="decky_channel_prerelease">Forhåndsutgivelse</string>
|
||||
<string name="decky_channel_testing">Testing</string>
|
||||
<string name="decky_channel_failed">Kunne ikke lagre oppdateringskanalen for Decky</string>
|
||||
<string name="mode_decky_on">Starter med Steam. Mens på, kan andre apper på denne enheten kanskje styre Steam.</string>
|
||||
<string name="mode_decky_off">Av. Steams fjernsøkeport for feilsøking forblir stengt.</string>
|
||||
<string name="mode_decky_remove_title">Avinstaller Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Fjerner loaderen. Programtilleggene og innstillingene dine beholdes.</string>
|
||||
<string name="mode_client">Klient</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Opstarten</string>
|
||||
<string name="mode_startup_session">Openen bij start</string>
|
||||
<string name="mode_startup_session_hint">Start deze sessie wanneer DroidDeck start.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Zoeken naar releases…</string>
|
||||
<string name="mode_decky_ready">Klaar om %1$s te installeren.</string>
|
||||
<string name="mode_decky_none">Geen compatibele build gevonden. Probeer het later opnieuw.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Up-to-date · %1$s</string>
|
||||
<string name="mode_decky_loader">Loader</string>
|
||||
<string name="mode_decky_install_latest">Nieuwste installeren</string>
|
||||
<string name="decky_channel">Updatekanaal</string>
|
||||
<string name="decky_channel_hint">Welke Decky Loader-releases worden geïnstalleerd. De eigen updater van Decky gebruikt hetzelfde kanaal.</string>
|
||||
<string name="decky_channel_stable">Stabiel</string>
|
||||
<string name="decky_channel_prerelease">Voorlopige release</string>
|
||||
<string name="decky_channel_testing">Testversie</string>
|
||||
<string name="decky_channel_failed">Kan het Decky-updatekanaal niet opslaan</string>
|
||||
<string name="mode_decky_on">Start met Steam. Zolang dit aan staat, kunnen andere apps op dit apparaat Steam mogelijk bedienen.</string>
|
||||
<string name="mode_decky_off">Uit. De poort voor foutopsporing op afstand van Steam blijft dicht.</string>
|
||||
<string name="mode_decky_remove_title">Decky Loader verwijderen?</string>
|
||||
<string name="mode_decky_remove_text">Verwijdert de loader. Je plug-ins en instellingen blijven behouden.</string>
|
||||
<string name="mode_client">Client</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Uruchamianie</string>
|
||||
<string name="mode_startup_session">Otwórz przy uruchomieniu</string>
|
||||
<string name="mode_startup_session_hint">Uruchamia tę sesję po uruchomieniu DroidDeck.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Sprawdzanie wydań…</string>
|
||||
<string name="mode_decky_ready">Gotowe do instalacji: %1$s.</string>
|
||||
<string name="mode_decky_none">Nie znaleziono zgodnej wersji. Spróbuj ponownie później.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Aktualna · %1$s</string>
|
||||
<string name="mode_decky_loader">Program ładujący</string>
|
||||
<string name="mode_decky_install_latest">Zainstaluj najnowszą</string>
|
||||
<string name="decky_channel">Kanał aktualizacji</string>
|
||||
<string name="decky_channel_hint">Które wydania Decky Loader instalować. Wbudowany aktualizator Decky używa tego samego kanału.</string>
|
||||
<string name="decky_channel_stable">Stabilny</string>
|
||||
<string name="decky_channel_prerelease">Przedpremierowy</string>
|
||||
<string name="decky_channel_testing">Testowy</string>
|
||||
<string name="decky_channel_failed">Nie udało się zapisać kanału aktualizacji Decky</string>
|
||||
<string name="mode_decky_on">Uruchamia się ze Steam. Gdy jest włączony, inne aplikacje na tym urządzeniu mogą sterować Steam.</string>
|
||||
<string name="mode_decky_off">Wyłączony. Port zdalnego debugowania Steam pozostaje zamknięty.</string>
|
||||
<string name="mode_decky_remove_title">Odinstalować Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Usuwa program ładujący. Twoje wtyczki i ustawienia zostaną zachowane.</string>
|
||||
<string name="mode_client">Klient</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Arranque</string>
|
||||
<string name="mode_startup_session">Abrir ao iniciar</string>
|
||||
<string name="mode_startup_session_hint">Inicia esta sessão quando o DroidDeck é aberto.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">A procurar versões…</string>
|
||||
<string name="mode_decky_ready">Pronto para instalar %1$s.</string>
|
||||
<string name="mode_decky_none">Nenhuma versão compatível encontrada. Tente novamente mais tarde.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Atualizado · %1$s</string>
|
||||
<string name="mode_decky_loader">Carregador</string>
|
||||
<string name="mode_decky_install_latest">Instalar a versão mais recente</string>
|
||||
<string name="decky_channel">Canal de atualização</string>
|
||||
<string name="decky_channel_hint">Que versões do Decky Loader instalar. O atualizador do próprio Decky utiliza o mesmo canal.</string>
|
||||
<string name="decky_channel_stable">Estável</string>
|
||||
<string name="decky_channel_prerelease">Pré-lançamento</string>
|
||||
<string name="decky_channel_testing">Testes</string>
|
||||
<string name="decky_channel_failed">Não foi possível guardar o canal de atualização do Decky</string>
|
||||
<string name="mode_decky_on">Inicia com o Steam. Enquanto estiver ligado, outras apps neste dispositivo poderão controlar o Steam.</string>
|
||||
<string name="mode_decky_off">Desligado. A porta de depuração remota do Steam mantém-se fechada.</string>
|
||||
<string name="mode_decky_remove_title">Desinstalar o Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Remove o carregador. Os seus plugins e definições são mantidos.</string>
|
||||
<string name="mode_client">Cliente</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Inicialização</string>
|
||||
<string name="mode_startup_session">Abrir ao iniciar</string>
|
||||
<string name="mode_startup_session_hint">Inicia esta sessão quando o DroidDeck é aberto.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Procurando versões…</string>
|
||||
<string name="mode_decky_ready">Pronto para instalar %1$s.</string>
|
||||
<string name="mode_decky_none">Nenhuma versão compatível encontrada. Tente novamente mais tarde.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Atualizado · %1$s</string>
|
||||
<string name="mode_decky_loader">Loader</string>
|
||||
<string name="mode_decky_install_latest">Instalar a mais recente</string>
|
||||
<string name="decky_channel">Canal de atualização</string>
|
||||
<string name="decky_channel_hint">Quais versões do Decky Loader instalar. O atualizador do próprio Decky usa o mesmo canal.</string>
|
||||
<string name="decky_channel_stable">Estável</string>
|
||||
<string name="decky_channel_prerelease">Pré-lançamento</string>
|
||||
<string name="decky_channel_testing">Testes</string>
|
||||
<string name="decky_channel_failed">Não foi possível salvar o canal de atualização do Decky</string>
|
||||
<string name="mode_decky_on">Inicia com a Steam. Enquanto estiver ativado, outros apps neste dispositivo podem conseguir controlar a Steam.</string>
|
||||
<string name="mode_decky_off">Desativado. A porta de depuração remota da Steam fica fechada.</string>
|
||||
<string name="mode_decky_remove_title">Desinstalar o Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Remove o loader. Seus plugins e configurações são mantidos.</string>
|
||||
<string name="mode_client">Cliente</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Pornire</string>
|
||||
<string name="mode_startup_session">Deschide la pornire</string>
|
||||
<string name="mode_startup_session_hint">Pornește această sesiune când se lansează DroidDeck.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Se verifică versiunile…</string>
|
||||
<string name="mode_decky_ready">Pregătit pentru instalarea %1$s.</string>
|
||||
<string name="mode_decky_none">Nu s-a găsit o versiune compatibilă. Încearcă din nou mai târziu.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Actualizat · %1$s</string>
|
||||
<string name="mode_decky_loader">Loader</string>
|
||||
<string name="mode_decky_install_latest">Instalează cea mai recentă versiune</string>
|
||||
<string name="decky_channel">Canal de actualizare</string>
|
||||
<string name="decky_channel_hint">Ce versiuni Decky Loader se instalează. Actualizatorul propriu al Decky folosește același canal.</string>
|
||||
<string name="decky_channel_stable">Stabil</string>
|
||||
<string name="decky_channel_prerelease">Pre-lansare</string>
|
||||
<string name="decky_channel_testing">Testare</string>
|
||||
<string name="decky_channel_failed">Canalul de actualizare Decky nu a putut fi salvat</string>
|
||||
<string name="mode_decky_on">Pornește odată cu Steam. Cât timp este activ, alte aplicații de pe acest dispozitiv pot fi capabile să controleze Steam.</string>
|
||||
<string name="mode_decky_off">Dezactivat. Portul de depanare la distanță al Steam rămâne închis.</string>
|
||||
<string name="mode_decky_remove_title">Dezinstalezi Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Elimină loader-ul. Pluginurile și setările tale sunt păstrate.</string>
|
||||
<string name="mode_client">Client</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Запуск</string>
|
||||
<string name="mode_startup_session">Открывать при запуске</string>
|
||||
<string name="mode_startup_session_hint">Запускает этот сеанс при запуске DroidDeck.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Проверка выпусков…</string>
|
||||
<string name="mode_decky_ready">Готово к установке %1$s.</string>
|
||||
<string name="mode_decky_none">Совместимая версия не найдена. Повторите попытку позже.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Актуально · %1$s</string>
|
||||
<string name="mode_decky_loader">Загрузчик</string>
|
||||
<string name="mode_decky_install_latest">Установить последнюю</string>
|
||||
<string name="decky_channel">Канал обновлений</string>
|
||||
<string name="decky_channel_hint">Какие выпуски Decky Loader устанавливать. Встроенное средство обновления Decky использует тот же канал.</string>
|
||||
<string name="decky_channel_stable">Стабильный</string>
|
||||
<string name="decky_channel_prerelease">Предварительный</string>
|
||||
<string name="decky_channel_testing">Тестовый</string>
|
||||
<string name="decky_channel_failed">Не удалось сохранить канал обновлений Decky</string>
|
||||
<string name="mode_decky_on">Запускается вместе со Steam. Пока включено, другие приложения на этом устройстве могут управлять Steam.</string>
|
||||
<string name="mode_decky_off">Выкл. Порт удаленной отладки Steam остается закрытым.</string>
|
||||
<string name="mode_decky_remove_title">Удалить Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Удаляет загрузчик. Ваши плагины и настройки сохранятся.</string>
|
||||
<string name="mode_client">Клиент</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Uppstart</string>
|
||||
<string name="mode_startup_session">Öppna vid start</string>
|
||||
<string name="mode_startup_session_hint">Startar den här sessionen när DroidDeck startar.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Söker efter utgåvor…</string>
|
||||
<string name="mode_decky_ready">Redo att installera %1$s.</string>
|
||||
<string name="mode_decky_none">Inget kompatibelt bygge hittades. Försök igen senare.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Senaste versionen · %1$s</string>
|
||||
<string name="mode_decky_loader">Loader</string>
|
||||
<string name="mode_decky_install_latest">Installera senaste</string>
|
||||
<string name="decky_channel">Uppdateringskanal</string>
|
||||
<string name="decky_channel_hint">Vilka Decky Loader-utgåvor som installeras. Deckys egen uppdaterare använder samma kanal.</string>
|
||||
<string name="decky_channel_stable">Stabil</string>
|
||||
<string name="decky_channel_prerelease">Förhandsversion</string>
|
||||
<string name="decky_channel_testing">Test</string>
|
||||
<string name="decky_channel_failed">Det gick inte att spara Deckys uppdateringskanal</string>
|
||||
<string name="mode_decky_on">Startar med Steam. Medan det är på kan andra appar på enheten eventuellt styra Steam.</string>
|
||||
<string name="mode_decky_off">Av. Steams fjärrfelsökningsport förblir stängd.</string>
|
||||
<string name="mode_decky_remove_title">Avinstallera Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Tar bort inläsaren. Dina tillägg och inställningar behålls.</string>
|
||||
<string name="mode_client">Klient</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">การเริ่มทำงาน</string>
|
||||
<string name="mode_startup_session">เปิดเมื่อเริ่มต้น</string>
|
||||
<string name="mode_startup_session_hint">เริ่มเซสชันนี้เมื่อเปิด DroidDeck</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">กำลังค้นหารุ่นที่เผยแพร่…</string>
|
||||
<string name="mode_decky_ready">พร้อมติดตั้ง %1$s</string>
|
||||
<string name="mode_decky_none">ไม่พบบิลด์ที่เข้ากันได้ ลองใหม่อีกครั้งในหลัง</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">เป็นรุ่นล่าสุดแล้ว · %1$s</string>
|
||||
<string name="mode_decky_loader">ตัวโหลด</string>
|
||||
<string name="mode_decky_install_latest">ติดตั้งรุ่นล่าสุด</string>
|
||||
<string name="decky_channel">ช่องทางอัปเดต</string>
|
||||
<string name="decky_channel_hint">รุ่นของ Decky Loader ที่จะติดตั้ง ตัวอัปเดตของ Decky เองก็ใช้ช่องทางเดียวกัน</string>
|
||||
<string name="decky_channel_stable">เสถียร</string>
|
||||
<string name="decky_channel_prerelease">ก่อนเปิดตัว</string>
|
||||
<string name="decky_channel_testing">ทดสอบ</string>
|
||||
<string name="decky_channel_failed">บันทึกช่องทางอัปเดตของ Decky ไม่ได้</string>
|
||||
<string name="mode_decky_on">เริ่มพร้อมกับ Steam เมื่อเปิดใช้งาน แอปอื่นบนอุปกรณ์นี้อาจสามารถควบคุม Steam ได้</string>
|
||||
<string name="mode_decky_off">ปิดอยู่ พอร์ตดีบักระยะไกลของ Steam ยังคงปิดอยู่</string>
|
||||
<string name="mode_decky_remove_title">ถอนการติดตั้ง Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">ลบตัวโหลดออก พลักอินและการตั้งค่าของคุณจะยังคงอยู่</string>
|
||||
<string name="mode_client">ไคลเอนต์</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Başlangıç</string>
|
||||
<string name="mode_startup_session">Açılışta başlat</string>
|
||||
<string name="mode_startup_session_hint">DroidDeck açıldığında bu oturumu başlatır.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Sürümler kontrol ediliyor…</string>
|
||||
<string name="mode_decky_ready">%1$s yüklenmeye hazır.</string>
|
||||
<string name="mode_decky_none">Uyumlu derleme bulunamadı. Daha sonra tekrar deneyin.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Güncel · %1$s</string>
|
||||
<string name="mode_decky_loader">Yükleyici</string>
|
||||
<string name="mode_decky_install_latest">En yenisini yükle</string>
|
||||
<string name="decky_channel">Güncelleme kanalı</string>
|
||||
<string name="decky_channel_hint">Hangi Decky Loader sürümlerinin yükleneceği. Decky\'nin kendi güncelleyicisi de aynı kanalı kullanır.</string>
|
||||
<string name="decky_channel_stable">Kararlı</string>
|
||||
<string name="decky_channel_prerelease">Ön sürüm</string>
|
||||
<string name="decky_channel_testing">Test</string>
|
||||
<string name="decky_channel_failed">Decky güncelleme kanalı kaydedilemedi</string>
|
||||
<string name="mode_decky_on">Steam ile başlar. Açıkken bu cihazdaki diğer uygulamalar Steam\'i kontrol edebilir.</string>
|
||||
<string name="mode_decky_off">Kapalı. Steam\'in uzaktan hata ayıklama bağlantı noktası kapalı kalır.</string>
|
||||
<string name="mode_decky_remove_title">Decky Loader kaldırılsın mı?</string>
|
||||
<string name="mode_decky_remove_text">Yükleyiciyi kaldırır. Eklentileriniz ve ayarlarınız korunur.</string>
|
||||
<string name="mode_client">İstemci</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Запуск</string>
|
||||
<string name="mode_startup_session">Відкривати під час запуску</string>
|
||||
<string name="mode_startup_session_hint">Запускає цей сеанс під час запуску DroidDeck.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Пошук випусків…</string>
|
||||
<string name="mode_decky_ready">Можна встановити %1$s.</string>
|
||||
<string name="mode_decky_none">Сумісну збірку не знайдено. Спробуйте пізніше.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Актуальна версія · %1$s</string>
|
||||
<string name="mode_decky_loader">Завантажувач</string>
|
||||
<string name="mode_decky_install_latest">Установити останню версію</string>
|
||||
<string name="decky_channel">Канал оновлень</string>
|
||||
<string name="decky_channel_hint">Які випуски Decky Loader встановлювати. Власний засіб оновлення Decky використовує той самий канал.</string>
|
||||
<string name="decky_channel_stable">Стабільний</string>
|
||||
<string name="decky_channel_prerelease">Попередній</string>
|
||||
<string name="decky_channel_testing">Тестовий</string>
|
||||
<string name="decky_channel_failed">Не вдалося зберегти канал оновлень Decky</string>
|
||||
<string name="mode_decky_on">Запускається разом зі Steam. Поки його ввімкнено, інші додатки на цьому пристрої можуть керувати Steam.</string>
|
||||
<string name="mode_decky_off">Вимкнено. Порт віддаленого налагодження Steam залишається закритим.</string>
|
||||
<string name="mode_decky_remove_title">Видалити Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Видаляє завантажувач. Ваші плагіни й налаштування зберігаються.</string>
|
||||
<string name="mode_client">Клієнт</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">Khởi động</string>
|
||||
<string name="mode_startup_session">Mở khi khởi chạy</string>
|
||||
<string name="mode_startup_session_hint">Bắt đầu phiên này khi DroidDeck khởi chạy.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Đang kiểm tra bản phát hành…</string>
|
||||
<string name="mode_decky_ready">Sẵn sàng cài %1$s.</string>
|
||||
<string name="mode_decky_none">Không tìm thấy bản build tương thích. Hãy thử lại sau.</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">Đã mới nhất · %1$s</string>
|
||||
<string name="mode_decky_loader">Loader</string>
|
||||
<string name="mode_decky_install_latest">Cài bản mới nhất</string>
|
||||
<string name="decky_channel">Kênh cập nhật</string>
|
||||
<string name="decky_channel_hint">Các bản phát hành Decky Loader sẽ cài. Trình cập nhật riêng của Decky dùng cùng kênh này.</string>
|
||||
<string name="decky_channel_stable">Ổn định</string>
|
||||
<string name="decky_channel_prerelease">Tiền phát hành</string>
|
||||
<string name="decky_channel_testing">Thử nghiệm</string>
|
||||
<string name="decky_channel_failed">Không thể lưu kênh cập nhật Decky</string>
|
||||
<string name="mode_decky_on">Khởi động cùng Steam. Khi đang bật, các ứng dụng khác trên thiết bị này có thể điều khiển được Steam.</string>
|
||||
<string name="mode_decky_off">Tắt. Cổng gỡ lỗi từ xa của Steam luôn đóng.</string>
|
||||
<string name="mode_decky_remove_title">Gỡ cài đặt Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Gỡ bỏ loader. Plugin và thiết lập của bạn được giữ lại.</string>
|
||||
<string name="mode_client">Client</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">启动</string>
|
||||
<string name="mode_startup_session">启动时打开</string>
|
||||
<string name="mode_startup_session_hint">DroidDeck 启动时开始此会话。</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">正在检查发布版本…</string>
|
||||
<string name="mode_decky_ready">已就绪,可安装 %1$s。</string>
|
||||
<string name="mode_decky_none">未找到兼容的构建。请稍后重试。</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">已是最新 · %1$s</string>
|
||||
<string name="mode_decky_loader">加载器</string>
|
||||
<string name="mode_decky_install_latest">安装最新版</string>
|
||||
<string name="decky_channel">更新通道</string>
|
||||
<string name="decky_channel_hint">要安装哪种 Decky Loader 版本。Decky 自带的更新程序也使用相同的通道。</string>
|
||||
<string name="decky_channel_stable">稳定版</string>
|
||||
<string name="decky_channel_prerelease">预发布版</string>
|
||||
<string name="decky_channel_testing">测试版</string>
|
||||
<string name="decky_channel_failed">无法保存 Decky 更新通道</string>
|
||||
<string name="mode_decky_on">随 Steam 启动。开启期间,本设备上的其他应用可能可以控制 Steam。</string>
|
||||
<string name="mode_decky_off">已关闭。Steam 的远程调试端口保持关闭。</string>
|
||||
<string name="mode_decky_remove_title">卸载 Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">移除加载器。你的插件和设置会保留。</string>
|
||||
<string name="mode_client">客户端</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">啟動</string>
|
||||
<string name="mode_startup_session">啟動時開啟</string>
|
||||
<string name="mode_startup_session_hint">DroidDeck 啟動時開始此工作階段。</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">正在檢查發佈版本…</string>
|
||||
<string name="mode_decky_ready">可安裝 %1$s。</string>
|
||||
<string name="mode_decky_none">找不到兼容的版本,請稍後再試。</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">已是最新 · %1$s</string>
|
||||
<string name="mode_decky_loader">載入器</string>
|
||||
<string name="mode_decky_install_latest">安裝最新版本</string>
|
||||
<string name="decky_channel">更新頻道</string>
|
||||
<string name="decky_channel_hint">要安裝哪一種 Decky Loader 版本。Decky 本身的更新程式也會使用相同的頻道。</string>
|
||||
<string name="decky_channel_stable">穩定版</string>
|
||||
<string name="decky_channel_prerelease">預發佈版</string>
|
||||
<string name="decky_channel_testing">測試版</string>
|
||||
<string name="decky_channel_failed">無法儲存 Decky 更新頻道</string>
|
||||
<string name="mode_decky_on">隨 Steam 啟動。啟用時,此裝置上的其他應用程式可能可以控制 Steam。</string>
|
||||
<string name="mode_decky_off">已關閉。Steam 的遠端偵錯連接埠保持關閉。</string>
|
||||
<string name="mode_decky_remove_title">解除安裝 Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">移除載入器,你的插件和設定會保留。</string>
|
||||
<string name="mode_client">用戶端</string>
|
||||
|
||||
@@ -332,7 +332,6 @@
|
||||
<string name="mode_startup">啟動</string>
|
||||
<string name="mode_startup_session">啟動時開啟</string>
|
||||
<string name="mode_startup_session_hint">DroidDeck 啟動時開始此工作階段。</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">正在檢查發行版本…</string>
|
||||
<string name="mode_decky_ready">已準備好安裝 %1$s。</string>
|
||||
<string name="mode_decky_none">未找到相容版本。請稍後再試。</string>
|
||||
@@ -341,14 +340,10 @@
|
||||
<string name="mode_decky_current">已是最新 · %1$s</string>
|
||||
<string name="mode_decky_loader">載入器</string>
|
||||
<string name="mode_decky_install_latest">安裝最新版本</string>
|
||||
<string name="decky_channel">更新頻道</string>
|
||||
<string name="decky_channel_hint">要安裝哪一種 Decky Loader 版本。Decky 本身的更新程式也會使用相同的頻道。</string>
|
||||
<string name="decky_channel_stable">穩定版</string>
|
||||
<string name="decky_channel_prerelease">預先發行版</string>
|
||||
<string name="decky_channel_testing">測試版</string>
|
||||
<string name="decky_channel_failed">無法儲存 Decky 更新頻道</string>
|
||||
<string name="mode_decky_on">隨 Steam 啟動。啟用後,此裝置上的其他應用程式可能可以控制 Steam。</string>
|
||||
<string name="mode_decky_off">關閉。Steam 的遠端偵錯連接埠保持關閉。</string>
|
||||
<string name="mode_decky_remove_title">解除安裝 Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">移除載入器。你的外掛程式和設定會保留。</string>
|
||||
<string name="mode_client">用戶端</string>
|
||||
|
||||
@@ -362,7 +362,6 @@
|
||||
<string name="mode_startup">Startup</string>
|
||||
<string name="mode_startup_session">Open at launch</string>
|
||||
<string name="mode_startup_session_hint">Starts this session when DroidDeck launches.</string>
|
||||
<string name="mode_decky">Decky</string>
|
||||
<string name="mode_decky_checking">Checking for releases…</string>
|
||||
<string name="mode_decky_ready">Ready to install %1$s.</string>
|
||||
<string name="mode_decky_none">No compatible build found. Try again later.</string>
|
||||
@@ -371,14 +370,10 @@
|
||||
<string name="mode_decky_current">Up to date · %1$s</string>
|
||||
<string name="mode_decky_loader">Loader</string>
|
||||
<string name="mode_decky_install_latest">Install latest</string>
|
||||
<string name="decky_channel">Update Channel</string>
|
||||
<string name="decky_channel_hint">Which Decky Loader releases to install. Decky\'s own updater uses the same channel.</string>
|
||||
<string name="decky_channel_stable">Stable</string>
|
||||
<string name="decky_channel_prerelease">Prerelease</string>
|
||||
<string name="decky_channel_testing">Testing</string>
|
||||
<string name="decky_channel_failed">Could not save the Decky update channel</string>
|
||||
<string name="mode_decky_on">Starts with Steam. While on, other apps on this device may be able to control Steam.</string>
|
||||
<string name="mode_decky_off">Off. Steam\'s remote debugging port stays closed.</string>
|
||||
<string name="mode_decky_remove_title">Uninstall Decky Loader?</string>
|
||||
<string name="mode_decky_remove_text">Removes the loader. Your plugins and settings are kept.</string>
|
||||
<string name="mode_client">Client</string>
|
||||
@@ -2221,6 +2216,23 @@
|
||||
<string name="fm_favorite_removed">Removed \"%1$s\" from Favorites</string>
|
||||
<string name="fm_empty_directory">Empty directory</string>
|
||||
<string name="fm_up_one_level">Up one level</string>
|
||||
<string name="fm_edit_open">Open</string>
|
||||
<string name="fm_edit_save">Save</string>
|
||||
<string name="fm_edit_read_only">Read only</string>
|
||||
<string name="fm_edit_binary">Binary</string>
|
||||
<string name="fm_edit_modified">Modified</string>
|
||||
<string name="fm_edit_position">Ln %1$d, Col %2$d</string>
|
||||
<string name="fm_edit_find">Find</string>
|
||||
<string name="fm_edit_find_previous">Find previous</string>
|
||||
<string name="fm_edit_find_next">Find next</string>
|
||||
<string name="fm_edit_replace">Replace</string>
|
||||
<string name="fm_edit_replace_all">All</string>
|
||||
<string name="fm_edit_discard_title">Discard changes?</string>
|
||||
<string name="fm_edit_discard_text">Changes to \"%1$s\" will be lost.</string>
|
||||
<string name="fm_edit_discard">Discard</string>
|
||||
<string name="fm_edit_save_failed">Couldn\'t save \"%1$s\"</string>
|
||||
<string name="fm_edit_open_failed">Couldn\'t open \"%1$s\"</string>
|
||||
<string name="fm_edit_too_large">Too large to open (%1$s)</string>
|
||||
<string name="fm_choose_folder">Choose a folder</string>
|
||||
<string name="fm_choose_file">Choose a file</string>
|
||||
<string name="ctrl_tint_steam_blue">Steam blue</string>
|
||||
@@ -4324,6 +4336,27 @@
|
||||
<string name="dev_preview_drawer">In-game menu</string>
|
||||
<string name="dev_preview_drawer_backdrop">In-game menu preview · Back to close</string>
|
||||
<string name="settings_place_tab">Tabs</string>
|
||||
<string name="decky_status">Status</string>
|
||||
<string name="decky_enable">Enable</string>
|
||||
<string name="decky_release_channel">Release channel</string>
|
||||
<string name="rail_decky">Decky</string>
|
||||
<string name="rail_boot_movies">Boot movies</string>
|
||||
<string name="decky_tab_installed">Installed · %1$d</string>
|
||||
<string name="decky_tab_store">Store</string>
|
||||
<string name="decky_tab_zip">From ZIP</string>
|
||||
<string name="decky_none_installed">No plugins installed. Browse the Store or install a ZIP.</string>
|
||||
<string name="decky_update_to">Update to %1$s</string>
|
||||
<string name="decky_remove">Remove</string>
|
||||
<string name="decky_remove_confirm">Remove %1$s?</string>
|
||||
<string name="decky_remove_confirm_body">Deletes the plugin from Decky. Its settings are kept.</string>
|
||||
<string name="decky_changes_next_session">Plugin changes apply the next time Steam starts.</string>
|
||||
<string name="decky_store_search">Search plugins</string>
|
||||
<string name="decky_store_failed">Could not reach the Decky plugin store</string>
|
||||
<string name="decky_store_empty">No plugins found</string>
|
||||
<string name="decky_store_more">Show %1$d more</string>
|
||||
<string name="decky_store_downloading">Downloading %1$s…</string>
|
||||
<string name="decky_store_download_failed">Could not download %1$s</string>
|
||||
<string name="decky_store_remove_failed">Could not remove the plugin</string>
|
||||
<string name="rail_storage">Storage</string>
|
||||
<string name="rail_sync">Syncthing</string>
|
||||
<string name="downloads_settings">Download settings</string>
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
package com.droiddeck.launcher.files
|
||||
|
||||
import java.io.ByteArrayInputStream
|
||||
import java.io.File
|
||||
import java.nio.charset.Charset
|
||||
import java.nio.file.Files
|
||||
import org.junit.Assert.assertArrayEquals
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class TextEditorLogicTest {
|
||||
|
||||
@Test
|
||||
fun nulByteMarksBinary() {
|
||||
val clean = "hello world".toByteArray()
|
||||
assertFalse(editorIsBinary(clean))
|
||||
val withNul = byteArrayOf(1, 2, 0, 3)
|
||||
assertTrue(editorIsBinary(withNul))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun binaryScanStopsAtSampleLimit() {
|
||||
val bytes = ByteArray(9000) { if (it == 8999) 0 else 65 }
|
||||
assertFalse(editorIsBinary(bytes))
|
||||
assertTrue(editorIsBinary(bytes, sample = 9000))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun utf8TextDecodesAsUtf8() {
|
||||
val decoded = decodeEditorText("你好, world".toByteArray(Charsets.UTF_8))
|
||||
assertEquals(EditorCharset.UTF8, decoded.charset)
|
||||
assertFalse(decoded.lossy)
|
||||
assertEquals("你好, world", decoded.text)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun gbkBytesFallBackToGb18030() {
|
||||
val gbk = "你好".toByteArray(Charset.forName("GBK"))
|
||||
val decoded = decodeEditorText(gbk)
|
||||
assertEquals(EditorCharset.GB18030, decoded.charset)
|
||||
assertFalse(decoded.lossy)
|
||||
assertEquals("你好", decoded.text)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun undecodableBytesStayLossyUtf8() {
|
||||
val decoded = decodeEditorText(byteArrayOf(0xFF.toByte()))
|
||||
assertEquals(EditorCharset.UTF8, decoded.charset)
|
||||
assertTrue(decoded.lossy)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun literalReplacementCharStaysCleanUtf8() {
|
||||
val decoded = decodeEditorText("�A".toByteArray(Charsets.UTF_8))
|
||||
assertEquals(EditorCharset.UTF8, decoded.charset)
|
||||
assertFalse(decoded.lossy)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun readCappedRefusesOverLimit() {
|
||||
val data = ByteArray(100) { 65 }
|
||||
assertArrayEquals(data, readCapped(ByteArrayInputStream(data), 100L))
|
||||
assertNull(readCapped(ByteArrayInputStream(data), 99L))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun tabsExpandToTabStops() {
|
||||
assertEquals("ab c", expandEditorTabs("ab\tc"))
|
||||
assertEquals(" x", expandEditorTabs("\tx"))
|
||||
assertEquals("abcd e", expandEditorTabs("abcd\te"))
|
||||
assertEquals("abc def g", expandEditorTabs("abc\tdef\tg"))
|
||||
assertEquals("a \n b", expandEditorTabs("a\t\n\tb"))
|
||||
assertEquals("plain text", expandEditorTabs("plain text"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun lineCountCountsTrailingEmptyLine() {
|
||||
assertEquals(1, lineCountOf(""))
|
||||
assertEquals(1, lineCountOf("abc"))
|
||||
assertEquals(2, lineCountOf("a\nb"))
|
||||
assertEquals(2, lineCountOf("a\n"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun offsetMapsToZeroBasedLineAndOneBasedColumn() {
|
||||
val text = "ab\ncd"
|
||||
assertEquals(0, lineIndexOfOffset(text, 0))
|
||||
assertEquals(0, lineIndexOfOffset(text, 2))
|
||||
assertEquals(1, lineIndexOfOffset(text, 3))
|
||||
assertEquals(1, lineIndexOfOffset(text, 5))
|
||||
assertEquals(1, columnOfOffset(text, 0))
|
||||
assertEquals(3, columnOfOffset(text, 2))
|
||||
assertEquals(2, columnOfOffset(text, 4))
|
||||
assertEquals(3, columnOfOffset(text, 5))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun findMatchesHonorsCaseAndLimit() {
|
||||
val text = "abcABCabc"
|
||||
val all = findEditorMatches(text, "abc", matchCase = false)
|
||||
assertEquals(listOf(0..2, 3..5, 6..8), all)
|
||||
val exact = findEditorMatches(text, "abc", matchCase = true)
|
||||
assertEquals(listOf(0..2, 6..8), exact)
|
||||
assertEquals(2, findEditorMatches(text, "abc", matchCase = false, limit = 2).size)
|
||||
assertEquals(emptyList<IntRange>(), findEditorMatches(text, ""))
|
||||
assertEquals(listOf(0..1), findEditorMatches("aaa", "aa"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun replaceSpansEveryMatch() {
|
||||
val text = "one two one"
|
||||
val matches = findEditorMatches(text, "one", matchCase = true)
|
||||
assertEquals("1 two 1", replaceEditorMatches(text, matches, "1"))
|
||||
assertEquals(text, replaceEditorMatches(text, emptyList(), "x"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun saveTargetResolvesSymbolicLink() {
|
||||
val dir = Files.createTempDirectory("editor-link").toFile()
|
||||
try {
|
||||
val target = File(dir, "real.txt").apply { writeText("hi") }
|
||||
val link = File(dir, "link.txt")
|
||||
Files.createSymbolicLink(link.toPath(), target.toPath())
|
||||
assertEquals(target.canonicalFile, resolveEditorSaveTarget(link))
|
||||
} finally {
|
||||
dir.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun saveTargetKeepsRegularFile() {
|
||||
val dir = Files.createTempDirectory("editor-plain").toFile()
|
||||
try {
|
||||
val plain = File(dir, "plain.txt").apply { writeText("hi") }
|
||||
assertEquals(plain, resolveEditorSaveTarget(plain))
|
||||
} finally {
|
||||
dir.deleteRecursively()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -354,13 +354,15 @@ class BattleNetTest {
|
||||
assertEquals(codes.distinct(), codes)
|
||||
assertTrue("Fen" in codes && "OSI" in codes && "WTCG" in codes)
|
||||
assertFalse(BattleNet.STORE.any { it.uid == "d3cn" || it.uid == "fen" })
|
||||
assertFalse(BattleNet.STORE.any { it.code == "WoWC" || it.code == "WoWF" })
|
||||
assertFalse(BattleNet.STORE.any { it.code == "WoWC" })
|
||||
assertEquals("wow_forever", BattleNet.STORE.first { it.code == "WoWF" }.uid)
|
||||
assertEquals("fenris", BattleNet.STORE.first { it.code == "Fen" }.uid)
|
||||
assertTrue(BattleNet.STORE.all { it.uid.matches(Regex("[a-z0-9_]{1,32}")) })
|
||||
val installed = listOf("fenris", "diablo3_enus", null)
|
||||
val offered = BattleNet.STORE.filter { BattleNet.notInstalled(it, installed) }.map { it.code }
|
||||
assertFalse("Fen" in offered || "D3" in offered)
|
||||
assertTrue("OSI" in offered)
|
||||
assertTrue("OSI" in offered && "WoWF" in offered)
|
||||
assertFalse("WoWF" in BattleNet.STORE.filter { BattleNet.notInstalled(it, listOf("wow_forever")) }.map { it.code })
|
||||
}
|
||||
|
||||
@Test fun aBattleNetGameStartsWithoutSteamThroughItsShortcutUntilThatIsSwitchedOff() {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.droiddeck.launcher.runtime
|
||||
|
||||
import com.droiddeck.launcher.ui.deckyStoreMatches
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
@org.junit.runner.RunWith(org.robolectric.RobolectricTestRunner::class)
|
||||
@org.robolectric.annotation.Config(sdk = [33], application = android.app.Application::class)
|
||||
class DeckyStoreTest {
|
||||
private val hash = "a".repeat(64)
|
||||
private val listing = """[
|
||||
{"id":1,"name":"Alpha","author":"Ann","description":"Does alpha things","tags":["audio"],"image_url":"https://cdn.example/a.png",
|
||||
"versions":[{"name":"2.0.0","hash":"$hash","downloads":10},{"name":"1.0.0","hash":"${"b".repeat(64)}","downloads":5}]},
|
||||
{"id":2,"name":"Beta","author":"Bob","description":"Themes","tags":["css"],"versions":[{"name":"1.0.0","hash":"${"c".repeat(64)}","downloads":100}]},
|
||||
{"id":3,"name":"NoVersions","author":"X","description":"","tags":[],"versions":[]},
|
||||
{"id":4,"name":"BadHash","author":"X","description":"","tags":[],"versions":[{"name":"1","hash":"nope","downloads":1}]}
|
||||
]"""
|
||||
|
||||
@Test fun listingKeepsOnlyPluginsWithAUsableVersionAndSumsDownloads() {
|
||||
val plugins = DeckyStore.parseListing(listing)
|
||||
assertEquals(listOf("Alpha", "Beta"), plugins.map { it.name })
|
||||
assertEquals("2.0.0", plugins[0].latest?.name)
|
||||
assertEquals(15L, plugins[0].downloads)
|
||||
assertEquals("https://cdn.example/a.png", plugins[0].imageUrl)
|
||||
assertEquals("", plugins[1].imageUrl)
|
||||
}
|
||||
|
||||
@Test fun searchMatchesNameAuthorDescriptionAndTagsAndSortsByDownloads() {
|
||||
val plugins = DeckyStore.parseListing(listing)
|
||||
assertEquals(listOf("Beta", "Alpha"), deckyStoreMatches(plugins, "").map { it.name })
|
||||
assertEquals(listOf("Alpha"), deckyStoreMatches(plugins, "ann audio").map { it.name })
|
||||
assertEquals(listOf("Beta"), deckyStoreMatches(plugins, "THEMES").map { it.name })
|
||||
assertTrue(deckyStoreMatches(plugins, "missing").isEmpty())
|
||||
}
|
||||
|
||||
@Test fun anUpdateNeedsAKnownInstalledVersionThatDiffersFromTheLatest() {
|
||||
val alpha = DeckyStore.parseListing(listing).first()
|
||||
assertTrue(DeckyStore.updateAvailable(DeckyStore.Installed("Alpha", "Alpha", "Ann", "1.0.0"), alpha))
|
||||
assertFalse(DeckyStore.updateAvailable(DeckyStore.Installed("Alpha", "Alpha", "Ann", "2.0.0"), alpha))
|
||||
assertFalse(DeckyStore.updateAvailable(DeckyStore.Installed("Alpha", "Alpha", "Ann", ""), alpha))
|
||||
assertFalse(DeckyStore.updateAvailable(DeckyStore.Installed("Alpha", "Alpha", "Ann", "1.0.0"), null))
|
||||
assertNull(DeckyStore.parseListing("[]").firstOrNull())
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ class NavTabsTest {
|
||||
|
||||
@Test fun aFreshInstallShowsTheDefaultBarMoreAndHiddenTabs() {
|
||||
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", NavTabs.MORE), navigationKeys(state()))
|
||||
assertEquals(listOf("stores", "soundtracks", "components", "storage", "sync"), NavTabs.more(state()))
|
||||
assertEquals(listOf("stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(state()))
|
||||
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "android-apps"))
|
||||
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "agent"))
|
||||
assertFalse(com.droiddeck.launcher.agent.AgentTab.shown)
|
||||
@@ -57,7 +57,7 @@ class NavTabsTest {
|
||||
@Test fun shelvedTabsLeaveTheBarAndAddMoreAtTheEnd() {
|
||||
place("desktop", TabPlace.MORE)
|
||||
val s = state()
|
||||
assertEquals(listOf("desktop", "stores", "soundtracks", "components", "storage", "sync"), NavTabs.more(s))
|
||||
assertEquals(listOf("desktop", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(s))
|
||||
assertEquals(NavTabs.MORE, navigationKeys(s).last())
|
||||
assertFalse("desktop" in navigationKeys(s))
|
||||
}
|
||||
@@ -86,7 +86,7 @@ class NavTabsTest {
|
||||
NavTabs.load(ctx)
|
||||
val s = state()
|
||||
assertEquals(listOf("steam", "games", "desktop", "components", "setup", "updates", NavTabs.MORE), navigationKeys(s))
|
||||
assertEquals(listOf("storage", "sync"), NavTabs.more(s))
|
||||
assertEquals(listOf("storage", "sync", "decky", "boot-movies"), NavTabs.more(s))
|
||||
listOf("stores", "downloads", "soundtracks", "android-apps", "agent").forEach { assertEquals(it, TabPlace.HIDDEN, NavTabs.place(s, it)) }
|
||||
val prefs = ctx.getSharedPreferences("session", Context.MODE_PRIVATE)
|
||||
assertFalse(prefs.contains("gameStoresEnabled"))
|
||||
@@ -108,7 +108,7 @@ class NavTabsTest {
|
||||
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(), "stores"))
|
||||
assertEquals(TabPlace.MORE, NavTabs.place(state(), "components"))
|
||||
assertEquals(TabPlace.BAR, NavTabs.place(state(), "downloads"))
|
||||
assertEquals(listOf("components", "storage", "sync"), NavTabs.more(state()))
|
||||
assertEquals(listOf("components", "storage", "sync", "decky", "boot-movies"), NavTabs.more(state()))
|
||||
}
|
||||
|
||||
@Test fun movingSwapsWithTheNextVisibleTabAndPersists() {
|
||||
@@ -119,9 +119,9 @@ class NavTabsTest {
|
||||
}
|
||||
|
||||
@Test fun tabsMissingFromASavedOrderSlotInAfterTheirDefaultNeighbour() {
|
||||
assertEquals(listOf("updates", "stores", "soundtracks", "components", "storage", "sync", "android-apps", "agent", "steam", "desktop", "games", "downloads", "setup"),
|
||||
assertEquals(listOf("updates", "stores", "soundtracks", "components", "storage", "sync", "decky", "boot-movies", "android-apps", "agent", "steam", "desktop", "games", "downloads", "setup"),
|
||||
NavTabs.arrange(listOf("updates", "steam")))
|
||||
assertEquals(listOf("games", "downloads", "steam", "setup", "stores", "soundtracks", "desktop", "components", "storage", "sync", "android-apps", "agent", "updates"),
|
||||
assertEquals(listOf("games", "downloads", "steam", "setup", "stores", "soundtracks", "desktop", "components", "storage", "sync", "decky", "boot-movies", "android-apps", "agent", "updates"),
|
||||
NavTabs.arrange(listOf("games", "steam", "setup", "stores", "desktop", "components", "android-apps", "updates", "bogus")))
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class NavTabsTest {
|
||||
.putString("navTabOrder", "steam,games,soundtracks,stores,desktop,agent,components,android-apps,setup,updates")
|
||||
.putString("navTabShelved", "soundtracks").commit()
|
||||
NavTabs.load(ctx)
|
||||
assertEquals(listOf("soundtracks", "storage", "sync"), NavTabs.more(state()))
|
||||
assertEquals(listOf("soundtracks", "storage", "sync", "decky", "boot-movies"), NavTabs.more(state()))
|
||||
place("sync", TabPlace.BAR)
|
||||
NavTabs.load(ctx)
|
||||
assertTrue("sync" in navigationKeys(state()))
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import com.droiddeck.launcher.update.AppUpdates
|
||||
import com.droiddeck.launcher.update.AppUpdates.Channel
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class UpdatesRailIconTest {
|
||||
private fun me(pr: Int = 0, ci: Boolean = true) = AppUpdates.Installed("abc", pr, "1.0", 1, ci, ciBuild = ci)
|
||||
|
||||
@Test
|
||||
fun releaseBuildsFollowTheirChannel() {
|
||||
assertEquals(BuildKind.STABLE, RunningBuild.kind(me(), Channel.STABLE))
|
||||
assertEquals(BuildKind.PREVIEW, RunningBuild.kind(me(), Channel.NIGHTLY))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun prBuildsAreTestAndNonCiBuildsAreLocal() {
|
||||
assertEquals(BuildKind.TEST, RunningBuild.kind(me(pr = 12), Channel.TEST))
|
||||
assertEquals(BuildKind.LOCAL, RunningBuild.kind(me(ci = false), Channel.STABLE))
|
||||
}
|
||||
}
|
||||
@@ -291,6 +291,18 @@ alone would then read as an installed client.
|
||||
spins until a `SIGALRM` handler sets a register (R12, or ESI in 32-bit `rt` and legacy frames):
|
||||
FEX-2611.1 with 0001 to 0011 never sees it in any of the three frame types, with this patch all
|
||||
three see it on the first signal, as natively.
|
||||
- `0013-path-syscalls-through-libc`: FEX passes most path system calls of the guest (`mkdirat`,
|
||||
`unlinkat`, `renameat`, `renameat2`, `symlinkat`, `linkat`, `mknodat`, `fchmodat`, `fchmodat2`,
|
||||
`fchownat`, `utimensat`, `truncate`, `chdir`, `chroot`, `inotify_add_watch`) straight to the kernel
|
||||
with an inline `svc`, which the native userland's path hook never sees, so an x86-64 program wrote
|
||||
`/opt/...` or `/root/...` to the Android root instead of the rootfs, and `cd` into a rootfs folder
|
||||
failed. They now go through libc's `syscall()`, which the hook maps like every other path; without
|
||||
the hook it is the same system call. `tools/tests/test_native_hook_path_syscalls.py` checks the hook
|
||||
side, including that an allocator which opens files before the hook has started does not hang.
|
||||
FEX also mirrors each guest signal handler with `syscall(SYS_rt_sigaction, ...)`; for `SIGSYS` the
|
||||
hook records the guest handler as it does for `sigaction()` and keeps its own installed, so a
|
||||
program that sets a crash handler is no longer killed by the next blocked system call
|
||||
(`tools/tests/test_native_hook_sigsys_mask.py`).
|
||||
- **Building and publishing.** Droid-Deck/DroidDeck-Components' `build-fex.yml` builds `tools/fex` from
|
||||
this repository at a chosen ref (default `main`) with host thunks, in the same Arch Linux ARM container
|
||||
with a read-only token, then a separate job replaces `fex.tzst` on Components' single `fex` release,
|
||||
|
||||
@@ -65,6 +65,8 @@ Links of the form `droiddeck://settings/<section>` open a Settings section direc
|
||||
| --- | --- | --- |
|
||||
| Storage | Tabs › Storage | sd card, space, uninstall, disk |
|
||||
| Syncthing | Tabs › Syncthing | syncthing, saves |
|
||||
| Decky | Tabs › Decky | plugins, plugin store, homebrew, loader |
|
||||
| Boot movies | Tabs › Boot movies | startup movie, boot video, animation, steamdeckrepo |
|
||||
| Download speed tier | Tabs › Downloads | download, speed, bandwidth, slow |
|
||||
| Downloads at a time | Tabs › Downloads | download, parallel, queue, at once |
|
||||
| Tabs | Tabs › More | tabs, hide, reorder, agent, stores, edit tabs |
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Passthrough.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Passthrough.cpp
|
||||
index 11ff163..085a621 100644
|
||||
--- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Passthrough.cpp
|
||||
+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Passthrough.cpp
|
||||
@@ -209,6 +209,41 @@ uint64_t SyscallPassthrough7(FEXCore::Core::CpuStateFrame* Frame, uint64_t arg1,
|
||||
}
|
||||
#endif
|
||||
|
||||
+template<int syscall_num>
|
||||
+requires (syscall_num != -1)
|
||||
+uint64_t SyscallPathPassthrough1(FEXCore::Core::CpuStateFrame* Frame, uint64_t arg1) {
|
||||
+ uint64_t Result = ::syscall(syscall_num, arg1);
|
||||
+ SYSCALL_ERRNO();
|
||||
+}
|
||||
+
|
||||
+template<int syscall_num>
|
||||
+requires (syscall_num != -1)
|
||||
+uint64_t SyscallPathPassthrough2(FEXCore::Core::CpuStateFrame* Frame, uint64_t arg1, uint64_t arg2) {
|
||||
+ uint64_t Result = ::syscall(syscall_num, arg1, arg2);
|
||||
+ SYSCALL_ERRNO();
|
||||
+}
|
||||
+
|
||||
+template<int syscall_num>
|
||||
+requires (syscall_num != -1)
|
||||
+uint64_t SyscallPathPassthrough3(FEXCore::Core::CpuStateFrame* Frame, uint64_t arg1, uint64_t arg2, uint64_t arg3) {
|
||||
+ uint64_t Result = ::syscall(syscall_num, arg1, arg2, arg3);
|
||||
+ SYSCALL_ERRNO();
|
||||
+}
|
||||
+
|
||||
+template<int syscall_num>
|
||||
+requires (syscall_num != -1)
|
||||
+uint64_t SyscallPathPassthrough4(FEXCore::Core::CpuStateFrame* Frame, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4) {
|
||||
+ uint64_t Result = ::syscall(syscall_num, arg1, arg2, arg3, arg4);
|
||||
+ SYSCALL_ERRNO();
|
||||
+}
|
||||
+
|
||||
+template<int syscall_num>
|
||||
+requires (syscall_num != -1)
|
||||
+uint64_t SyscallPathPassthrough5(FEXCore::Core::CpuStateFrame* Frame, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5) {
|
||||
+ uint64_t Result = ::syscall(syscall_num, arg1, arg2, arg3, arg4, arg5);
|
||||
+ SYSCALL_ERRNO();
|
||||
+}
|
||||
+
|
||||
static void RegisterCommon(FEX::HLE::SyscallHandler* Handler) {
|
||||
REGISTER_SYSCALL_IMPL(read, SyscallPassthrough3<SYSCALL_DEF(read)>);
|
||||
REGISTER_SYSCALL_IMPL(write, SyscallPassthrough3<SYSCALL_DEF(write)>);
|
||||
@@ -238,9 +273,9 @@ static void RegisterCommon(FEX::HLE::SyscallHandler* Handler) {
|
||||
REGISTER_SYSCALL_IMPL(flock, SyscallPassthrough2<SYSCALL_DEF(flock)>);
|
||||
REGISTER_SYSCALL_IMPL(fsync, SyscallPassthrough1<SYSCALL_DEF(fsync)>);
|
||||
REGISTER_SYSCALL_IMPL(fdatasync, SyscallPassthrough1<SYSCALL_DEF(fdatasync)>);
|
||||
- REGISTER_SYSCALL_IMPL(truncate, SyscallPassthrough2<SYSCALL_DEF(truncate)>);
|
||||
+ REGISTER_SYSCALL_IMPL(truncate, SyscallPathPassthrough2<SYSCALL_DEF(truncate)>);
|
||||
REGISTER_SYSCALL_IMPL(getcwd, SyscallPassthrough2<SYSCALL_DEF(getcwd)>);
|
||||
- REGISTER_SYSCALL_IMPL(chdir, SyscallPassthrough1<SYSCALL_DEF(chdir)>);
|
||||
+ REGISTER_SYSCALL_IMPL(chdir, SyscallPathPassthrough1<SYSCALL_DEF(chdir)>);
|
||||
REGISTER_SYSCALL_IMPL(fchdir, SyscallPassthrough1<SYSCALL_DEF(fchdir)>);
|
||||
REGISTER_SYSCALL_IMPL(fchmod, SyscallPassthrough2<SYSCALL_DEF(fchmod)>);
|
||||
REGISTER_SYSCALL_IMPL(fchown, SyscallPassthrough3<SYSCALL_DEF(fchown)>);
|
||||
@@ -280,7 +315,7 @@ static void RegisterCommon(FEX::HLE::SyscallHandler* Handler) {
|
||||
REGISTER_SYSCALL_IMPL(mlock, SyscallPassthrough2<SYSCALL_DEF(mlock)>);
|
||||
REGISTER_SYSCALL_IMPL(munlock, SyscallPassthrough2<SYSCALL_DEF(munlock)>);
|
||||
REGISTER_SYSCALL_IMPL(pivot_root, SyscallPassthrough2<SYSCALL_DEF(pivot_root)>);
|
||||
- REGISTER_SYSCALL_IMPL(chroot, SyscallPassthrough1<SYSCALL_DEF(chroot)>);
|
||||
+ REGISTER_SYSCALL_IMPL(chroot, SyscallPathPassthrough1<SYSCALL_DEF(chroot)>);
|
||||
REGISTER_SYSCALL_IMPL(sync, SyscallPassthrough0<SYSCALL_DEF(sync)>);
|
||||
REGISTER_SYSCALL_IMPL(acct, SyscallPassthrough1<SYSCALL_DEF(acct)>);
|
||||
REGISTER_SYSCALL_IMPL(mount, SyscallPassthrough5<SYSCALL_DEF(mount)>);
|
||||
@@ -312,17 +347,17 @@ static void RegisterCommon(FEX::HLE::SyscallHandler* Handler) {
|
||||
REGISTER_SYSCALL_IMPL(keyctl, SyscallPassthrough5<SYSCALL_DEF(keyctl)>);
|
||||
REGISTER_SYSCALL_IMPL(ioprio_set, SyscallPassthrough2<SYSCALL_DEF(ioprio_set)>);
|
||||
REGISTER_SYSCALL_IMPL(ioprio_get, SyscallPassthrough3<SYSCALL_DEF(ioprio_get)>);
|
||||
- REGISTER_SYSCALL_IMPL(inotify_add_watch, SyscallPassthrough3<SYSCALL_DEF(inotify_add_watch)>);
|
||||
+ REGISTER_SYSCALL_IMPL(inotify_add_watch, SyscallPathPassthrough3<SYSCALL_DEF(inotify_add_watch)>);
|
||||
REGISTER_SYSCALL_IMPL(inotify_rm_watch, SyscallPassthrough2<SYSCALL_DEF(inotify_rm_watch)>);
|
||||
REGISTER_SYSCALL_IMPL(migrate_pages, SyscallPassthrough4<SYSCALL_DEF(migrate_pages)>);
|
||||
- REGISTER_SYSCALL_IMPL(mkdirat, SyscallPassthrough3<SYSCALL_DEF(mkdirat)>);
|
||||
- REGISTER_SYSCALL_IMPL(mknodat, SyscallPassthrough4<SYSCALL_DEF(mknodat)>);
|
||||
- REGISTER_SYSCALL_IMPL(fchownat, SyscallPassthrough5<SYSCALL_DEF(fchownat)>);
|
||||
- REGISTER_SYSCALL_IMPL(unlinkat, SyscallPassthrough3<SYSCALL_DEF(unlinkat)>);
|
||||
- REGISTER_SYSCALL_IMPL(renameat, SyscallPassthrough4<SYSCALL_DEF(renameat)>);
|
||||
- REGISTER_SYSCALL_IMPL(linkat, SyscallPassthrough5<SYSCALL_DEF(linkat)>);
|
||||
- REGISTER_SYSCALL_IMPL(symlinkat, SyscallPassthrough3<SYSCALL_DEF(symlinkat)>);
|
||||
- REGISTER_SYSCALL_IMPL(fchmodat, SyscallPassthrough3<SYSCALL_DEF(fchmodat)>);
|
||||
+ REGISTER_SYSCALL_IMPL(mkdirat, SyscallPathPassthrough3<SYSCALL_DEF(mkdirat)>);
|
||||
+ REGISTER_SYSCALL_IMPL(mknodat, SyscallPathPassthrough4<SYSCALL_DEF(mknodat)>);
|
||||
+ REGISTER_SYSCALL_IMPL(fchownat, SyscallPathPassthrough5<SYSCALL_DEF(fchownat)>);
|
||||
+ REGISTER_SYSCALL_IMPL(unlinkat, SyscallPathPassthrough3<SYSCALL_DEF(unlinkat)>);
|
||||
+ REGISTER_SYSCALL_IMPL(renameat, SyscallPathPassthrough4<SYSCALL_DEF(renameat)>);
|
||||
+ REGISTER_SYSCALL_IMPL(linkat, SyscallPathPassthrough5<SYSCALL_DEF(linkat)>);
|
||||
+ REGISTER_SYSCALL_IMPL(symlinkat, SyscallPathPassthrough3<SYSCALL_DEF(symlinkat)>);
|
||||
+ REGISTER_SYSCALL_IMPL(fchmodat, SyscallPathPassthrough3<SYSCALL_DEF(fchmodat)>);
|
||||
REGISTER_SYSCALL_IMPL(unshare, SyscallPassthrough1<SYSCALL_DEF(unshare)>);
|
||||
REGISTER_SYSCALL_IMPL(splice, SyscallPassthrough6<SYSCALL_DEF(splice)>);
|
||||
REGISTER_SYSCALL_IMPL(tee, SyscallPassthrough4<SYSCALL_DEF(tee)>);
|
||||
@@ -343,7 +378,7 @@ static void RegisterCommon(FEX::HLE::SyscallHandler* Handler) {
|
||||
REGISTER_SYSCALL_IMPL(kcmp, SyscallPassthrough5<SYSCALL_DEF(kcmp)>);
|
||||
REGISTER_SYSCALL_IMPL(sched_setattr, SyscallPassthrough3<SYSCALL_DEF(sched_setattr)>);
|
||||
REGISTER_SYSCALL_IMPL(sched_getattr, SyscallPassthrough4<SYSCALL_DEF(sched_getattr)>);
|
||||
- REGISTER_SYSCALL_IMPL(renameat2, SyscallPassthrough5<SYSCALL_DEF(renameat2)>);
|
||||
+ REGISTER_SYSCALL_IMPL(renameat2, SyscallPathPassthrough5<SYSCALL_DEF(renameat2)>);
|
||||
REGISTER_SYSCALL_IMPL(getrandom, SyscallPassthrough3<SYSCALL_DEF(getrandom)>);
|
||||
REGISTER_SYSCALL_IMPL(memfd_create, SyscallPassthrough2<SYSCALL_DEF(memfd_create)>);
|
||||
REGISTER_SYSCALL_IMPL(membarrier, SyscallPassthrough2<SYSCALL_DEF(membarrier)>);
|
||||
@@ -468,7 +503,7 @@ namespace x64 {
|
||||
REGISTER_SYSCALL_IMPL_X64(get_robust_list, SyscallPassthrough3<SYSCALL_DEF(get_robust_list)>);
|
||||
REGISTER_SYSCALL_IMPL_X64(sync_file_range, SyscallPassthrough4<SYSCALL_DEF(sync_file_range)>);
|
||||
REGISTER_SYSCALL_IMPL_X64(vmsplice, SyscallPassthrough4<SYSCALL_DEF(vmsplice)>);
|
||||
- REGISTER_SYSCALL_IMPL_X64(utimensat, SyscallPassthrough4<SYSCALL_DEF(utimensat)>);
|
||||
+ REGISTER_SYSCALL_IMPL_X64(utimensat, SyscallPathPassthrough4<SYSCALL_DEF(utimensat)>);
|
||||
REGISTER_SYSCALL_IMPL_X64(fallocate, SyscallPassthrough4<SYSCALL_DEF(fallocate)>);
|
||||
REGISTER_SYSCALL_IMPL_X64(timerfd_settime, SyscallPassthrough4<SYSCALL_DEF(timerfd_settime)>);
|
||||
REGISTER_SYSCALL_IMPL_X64(timerfd_gettime, SyscallPassthrough2<SYSCALL_DEF(timerfd_gettime)>);
|
||||
@@ -492,7 +527,7 @@ namespace x64 {
|
||||
REGISTER_SYSCALL_IMPL_X64(cachestat, UnimplementedSyscallSafe);
|
||||
}
|
||||
if (Handler->IsHostKernelVersionAtLeast(6, 6, 0)) {
|
||||
- REGISTER_SYSCALL_IMPL_X64(fchmodat2, SyscallPassthrough4<SYSCALL_DEF(fchmodat2)>);
|
||||
+ REGISTER_SYSCALL_IMPL_X64(fchmodat2, SyscallPathPassthrough4<SYSCALL_DEF(fchmodat2)>);
|
||||
} else {
|
||||
REGISTER_SYSCALL_IMPL_X64(fchmodat2, UnimplementedSyscallSafe);
|
||||
}
|
||||
@@ -529,7 +564,7 @@ namespace x32 {
|
||||
REGISTER_SYSCALL_IMPL_X32(timer_settime64, SyscallPassthrough4<SYSCALL_DEF(timer_settime)>);
|
||||
REGISTER_SYSCALL_IMPL_X32(timerfd_gettime64, SyscallPassthrough2<SYSCALL_DEF(timerfd_gettime)>);
|
||||
REGISTER_SYSCALL_IMPL_X32(timerfd_settime64, SyscallPassthrough4<SYSCALL_DEF(timerfd_settime)>);
|
||||
- REGISTER_SYSCALL_IMPL_X32(utimensat_time64, SyscallPassthrough4<SYSCALL_DEF(utimensat)>);
|
||||
+ REGISTER_SYSCALL_IMPL_X32(utimensat_time64, SyscallPathPassthrough4<SYSCALL_DEF(utimensat)>);
|
||||
REGISTER_SYSCALL_IMPL_X32(ppoll_time64, SyscallPassthrough5<SYSCALL_DEF(ppoll)>);
|
||||
REGISTER_SYSCALL_IMPL_X32(io_pgetevents_time64, SyscallPassthrough6<SYSCALL_DEF(io_pgetevents)>);
|
||||
REGISTER_SYSCALL_IMPL_X32(mq_timedsend_time64, SyscallPassthrough5<SYSCALL_DEF(mq_timedsend)>);
|
||||
@@ -25,7 +25,6 @@
|
||||
#define CP_FDS 65536
|
||||
|
||||
static const int64_t *cp_shift;
|
||||
static int cp_state;
|
||||
static size_t cp_cond_byte;
|
||||
static unsigned char cp_cond_mask;
|
||||
static unsigned char cp_fds[CP_FDS / 8];
|
||||
@@ -94,25 +93,14 @@ static void cp_init(void) {
|
||||
}
|
||||
|
||||
static int64_t cp_offset(void) {
|
||||
const int64_t *shift;
|
||||
int state = __atomic_load_n(&cp_state, __ATOMIC_ACQUIRE);
|
||||
if (state == 0) {
|
||||
int expected = 0;
|
||||
if (__atomic_compare_exchange_n(&cp_state, &expected, 1, 0, __ATOMIC_ACQ_REL, __ATOMIC_ACQUIRE)) {
|
||||
cp_init();
|
||||
__atomic_store_n(&cp_state, 2, __ATOMIC_RELEASE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (state != 2) return 0;
|
||||
shift = __atomic_load_n(&cp_shift, __ATOMIC_ACQUIRE);
|
||||
const int64_t *shift = __atomic_load_n(&cp_shift, __ATOMIC_ACQUIRE);
|
||||
if (!shift) return 0;
|
||||
int64_t value = __atomic_load_n(shift, __ATOMIC_RELAXED);
|
||||
return value > 0 ? value : 0;
|
||||
}
|
||||
|
||||
__attribute__((constructor)) static void cp_start(void) {
|
||||
cp_offset();
|
||||
cp_init();
|
||||
}
|
||||
|
||||
static int cp_mono(clockid_t clock) {
|
||||
|
||||
@@ -72,7 +72,7 @@ static char *map_preload_paths(const char *value) {
|
||||
return out;
|
||||
}
|
||||
|
||||
static char **prepare_ddnatv_env(char *const envp[], const char *real_exe) {
|
||||
static char **prepare_ddnatv_env(char *const envp[], const char *real_exe, const char *lib_path) {
|
||||
init_ddnatv_hook();
|
||||
int count = 0;
|
||||
int has_preload = 0;
|
||||
@@ -164,6 +164,9 @@ static char **prepare_ddnatv_env(char *const envp[], const char *real_exe) {
|
||||
if (chosen_real_exe && envp[i][0] == 'D' && strncmp(envp[i], "DDNATV_REAL_EXE=", 16) == 0) {
|
||||
continue;
|
||||
}
|
||||
if (chosen_real_exe && envp[i][0] == 'D' && strncmp(envp[i], "DDNATV_LIBRARY_PATH=", 20) == 0) {
|
||||
continue;
|
||||
}
|
||||
new_env[dst++] = envp[i];
|
||||
}
|
||||
|
||||
@@ -178,6 +181,15 @@ static char **prepare_ddnatv_env(char *const envp[], const char *real_exe) {
|
||||
new_env[dst++] = str;
|
||||
}
|
||||
}
|
||||
if (chosen_real_exe && lib_path && lib_path[0] != '\0') {
|
||||
size_t len = strlen(lib_path);
|
||||
char *str = malloc(20 + len + 1);
|
||||
if (str) {
|
||||
memcpy(str, "DDNATV_LIBRARY_PATH=", 20);
|
||||
memcpy(str + 20, lib_path, len + 1);
|
||||
new_env[dst++] = str;
|
||||
}
|
||||
}
|
||||
|
||||
char hook_buf[PATH_MAX];
|
||||
const char *hook = (!has_preload && g_ddnatv_root[0] != '\0') ? ddnatv_hook_library(hook_buf, sizeof(hook_buf)) : NULL;
|
||||
|
||||
@@ -44,8 +44,8 @@ static void resolve_symlinks(const char *path, char *out, size_t out_size, int d
|
||||
resolve_symlinks(next_path, out, out_size, depth + 1);
|
||||
}
|
||||
|
||||
static char **ensure_hook_in_envp(char *const envp[], const char *real_exe) {
|
||||
return prepare_ddnatv_env(envp, real_exe);
|
||||
static char **ensure_hook_in_envp(char *const envp[], const char *real_exe, const char *lib_path) {
|
||||
return prepare_ddnatv_env(envp, real_exe, lib_path);
|
||||
}
|
||||
|
||||
// The file whose header decides how to start `target`: the symlink-resolved ELF (so ld.so and
|
||||
@@ -162,7 +162,7 @@ static int exec_interp_missing(int fd) {
|
||||
syscall(SYS_pread64, fd, interp, ph.p_filesz, (long)ph.p_offset) != (long)ph.p_filesz)
|
||||
return ENOEXEC;
|
||||
interp[ph.p_filesz] = 0;
|
||||
int ifd = (int)syscall(SYS_openat, AT_FDCWD, interp, O_RDONLY | O_CLOEXEC | O_NONBLOCK);
|
||||
int ifd = (int)call_orig_syscall(SYS_openat, AT_FDCWD, (unsigned long)interp, O_RDONLY | O_CLOEXEC | O_NONBLOCK, 0, 0, 0);
|
||||
if (ifd < 0) return errno;
|
||||
syscall(SYS_close, ifd);
|
||||
return 0;
|
||||
@@ -174,7 +174,7 @@ static int exec_interp_missing(int fd) {
|
||||
// a shell walking $PATH moves on at ENOENT and EACCES, and runs a file without "#!" as a script at
|
||||
// ENOEXEC.
|
||||
static int exec_preflight(const char *path) {
|
||||
int fd = (int)syscall(SYS_openat, AT_FDCWD, path, O_RDONLY | O_CLOEXEC | O_NONBLOCK);
|
||||
int fd = (int)call_orig_syscall(SYS_openat, AT_FDCWD, (unsigned long)path, O_RDONLY | O_CLOEXEC | O_NONBLOCK, 0, 0, 0);
|
||||
if (fd < 0) return errno;
|
||||
struct stat st;
|
||||
int err = 0;
|
||||
@@ -263,6 +263,60 @@ static int is_ldconfig_name(const char *name) {
|
||||
return strcmp(name, "ldconfig") == 0 || strcmp(name, "ldconfig.real") == 0;
|
||||
}
|
||||
|
||||
struct ldso_direct {
|
||||
char prog[PATH_MAX];
|
||||
char lib_path[PATH_MAX * 6];
|
||||
};
|
||||
|
||||
// ld.so started directly (ldd, "ld.so --list PROGRAM", "ld.so PROGRAM"): the program it loads
|
||||
// gets the --library-path a start of its own gets, or ldd reports its libraries as not found,
|
||||
// and its path mapped into the rootfs, since ld.so opens it without the hook
|
||||
static char **ldso_direct_argv(char *const argv[], char *const envp[], struct ldso_direct *buf, int *err) {
|
||||
*err = 0;
|
||||
int caller_lib_path = 0;
|
||||
int pi = ldso_program_index(argv, &caller_lib_path);
|
||||
if (pi <= 0) return NULL;
|
||||
int argc = 0;
|
||||
while (argv[argc]) argc++;
|
||||
const char *prog = argv[pi];
|
||||
if (caller_lib_path) {
|
||||
// the caller's own --library-path stays as it is; only the program is mapped (when it is
|
||||
// in the rootfs: a caller can also name a file by its real path)
|
||||
if (prog[0] == '/') {
|
||||
const char *mapped = rewrite_path(prog, buf->prog, sizeof(buf->prog));
|
||||
int fd = mapped != prog ? (int)syscall(SYS_openat, AT_FDCWD, mapped, O_PATH | O_CLOEXEC) : -1;
|
||||
if (fd >= 0) {
|
||||
syscall(SYS_close, fd);
|
||||
prog = mapped;
|
||||
}
|
||||
}
|
||||
char **out = (char **)malloc(sizeof(char *) * (size_t)(argc + 1));
|
||||
if (!out) {
|
||||
*err = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
for (int i = 0; i <= argc; i++) out[i] = argv[i];
|
||||
out[pi] = (char *)prog;
|
||||
return out;
|
||||
}
|
||||
if (prog[0] == '/') prog = rewrite_path(prog, buf->prog, sizeof(buf->prog));
|
||||
struct exec_probe prog_probe;
|
||||
probe_exec_file(prog, &prog_probe);
|
||||
build_ld_library_path(envp, prog_probe.runpath, prog_probe.runpath_is_rpath,
|
||||
prog[0] == '/' ? prog : NULL, buf->lib_path, sizeof(buf->lib_path));
|
||||
char **out = (char **)malloc(sizeof(char *) * (size_t)(argc + 3));
|
||||
if (!out) {
|
||||
*err = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
out[0] = argv[0];
|
||||
out[1] = (char *)"--library-path";
|
||||
out[2] = buf->lib_path;
|
||||
for (int i = 1; i <= argc; i++) out[i + 2] = argv[i];
|
||||
out[pi + 2] = (char *)prog; // ld.so opens it itself: "ldd /usr/bin/adb" as well
|
||||
return out;
|
||||
}
|
||||
|
||||
static int ddnatv_execve(const char *filename, char *const argv[], char *const envp[], int depth) {
|
||||
orig_execve_f_type orig_execve = real_execve();
|
||||
if (!orig_execve) {
|
||||
@@ -374,7 +428,7 @@ static int ddnatv_execve(const char *filename, char *const argv[], char *const e
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
char **new_env = ensure_hook_in_envp(envp, elf_target);
|
||||
char **new_env = ensure_hook_in_envp(envp, elf_target, ld_lib_path);
|
||||
int ret = run_execve(orig_execve, ld_so, new_argv, new_env);
|
||||
if (errno == EACCES && chmod(ld_so, 0755) == 0) {
|
||||
// ld.so without its exec bit (an unusual restore): fix it once and retry
|
||||
@@ -388,65 +442,17 @@ static int ddnatv_execve(const char *filename, char *const argv[], char *const e
|
||||
}
|
||||
}
|
||||
|
||||
// ld.so started directly (ldd, "ld.so --list PROGRAM", "ld.so PROGRAM"): the program it loads
|
||||
// gets the --library-path a start of its own gets, or ldd reports its libraries as not found,
|
||||
// and its path mapped into the rootfs, since ld.so opens it without the hook
|
||||
if (probe.is_elf && !probe.is_dynamic && is_ld_linux(elf_target)) {
|
||||
int caller_lib_path = 0;
|
||||
int pi = ldso_program_index(argv, &caller_lib_path);
|
||||
if (pi > 0 && caller_lib_path) {
|
||||
// the caller's own --library-path stays as it is; only the program is mapped (when it is
|
||||
// in the rootfs: a caller can also name a file by its real path)
|
||||
char prog_buf[PATH_MAX];
|
||||
const char *prog = argv[pi];
|
||||
if (prog[0] == '/') {
|
||||
const char *mapped = rewrite_path(prog, prog_buf, sizeof(prog_buf));
|
||||
int fd = mapped != prog ? (int)syscall(SYS_openat, AT_FDCWD, mapped, O_PATH | O_CLOEXEC) : -1;
|
||||
if (fd >= 0) {
|
||||
syscall(SYS_close, fd);
|
||||
prog = mapped;
|
||||
}
|
||||
}
|
||||
int argc = 0;
|
||||
while (argv[argc]) argc++;
|
||||
char **new_argv = (char **)malloc(sizeof(char *) * (size_t)(argc + 1));
|
||||
if (!new_argv) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
for (int i = 0; i <= argc; i++) new_argv[i] = argv[i];
|
||||
new_argv[pi] = (char *)prog;
|
||||
prepare_static_program(static_elf); // ld.so is a static program itself
|
||||
char **ddnatv_env = prepare_ddnatv_env(envp, target);
|
||||
int ret = run_execve(orig_execve, target, new_argv, ddnatv_env);
|
||||
int saved_errno = errno;
|
||||
free_modified_env(ddnatv_env, envp);
|
||||
free(new_argv);
|
||||
errno = saved_errno;
|
||||
return ret;
|
||||
struct ldso_direct direct;
|
||||
int err;
|
||||
char **new_argv = ldso_direct_argv(argv, envp, &direct, &err);
|
||||
if (err) {
|
||||
errno = err;
|
||||
return -1;
|
||||
}
|
||||
if (pi > 0) {
|
||||
char prog_buf[PATH_MAX];
|
||||
const char *prog = argv[pi][0] == '/' ? rewrite_path(argv[pi], prog_buf, sizeof(prog_buf)) : argv[pi];
|
||||
struct exec_probe prog_probe;
|
||||
probe_exec_file(prog, &prog_probe);
|
||||
char ld_lib_path[PATH_MAX * 6];
|
||||
build_ld_library_path(envp, prog_probe.runpath, prog_probe.runpath_is_rpath,
|
||||
prog[0] == '/' ? prog : NULL, ld_lib_path, sizeof(ld_lib_path));
|
||||
int argc = 0;
|
||||
while (argv[argc]) argc++;
|
||||
char **new_argv = (char **)malloc(sizeof(char *) * (size_t)(argc + 3));
|
||||
if (!new_argv) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
new_argv[0] = argv[0];
|
||||
new_argv[1] = (char *)"--library-path";
|
||||
new_argv[2] = ld_lib_path;
|
||||
for (int i = 1; i <= argc; i++) new_argv[i + 2] = argv[i];
|
||||
new_argv[pi + 2] = (char *)prog; // ld.so opens it itself: "ldd /usr/bin/adb" as well
|
||||
if (new_argv) {
|
||||
prepare_static_program(static_elf); // ld.so is a static program itself
|
||||
char **ddnatv_env = prepare_ddnatv_env(envp, target);
|
||||
char **ddnatv_env = prepare_ddnatv_env(envp, target, NULL);
|
||||
int ret = run_execve(orig_execve, target, new_argv, ddnatv_env);
|
||||
int saved_errno = errno;
|
||||
free_modified_env(ddnatv_env, envp);
|
||||
@@ -480,7 +486,7 @@ static int ddnatv_execve(const char *filename, char *const argv[], char *const e
|
||||
errno = ELOOP;
|
||||
ret = -1;
|
||||
} else {
|
||||
char **ddnatv_env = prepare_ddnatv_env(envp, NULL);
|
||||
char **ddnatv_env = prepare_ddnatv_env(envp, NULL, NULL);
|
||||
ret = ddnatv_execve(rewritten_interp, new_argv, ddnatv_env, depth + 1);
|
||||
int saved_errno = errno;
|
||||
free_modified_env(ddnatv_env, envp);
|
||||
@@ -500,7 +506,7 @@ static int ddnatv_execve(const char *filename, char *const argv[], char *const e
|
||||
}
|
||||
|
||||
if (static_elf) prepare_static_program(static_elf);
|
||||
char **ddnatv_env = prepare_ddnatv_env(envp, target);
|
||||
char **ddnatv_env = prepare_ddnatv_env(envp, target, NULL);
|
||||
int ret = run_execve(orig_execve, target, argv, ddnatv_env);
|
||||
int saved_errno = errno;
|
||||
free_modified_env(ddnatv_env, envp);
|
||||
@@ -942,17 +948,21 @@ static int ddnatv_posix_spawn(pid_t *pid, const char *path,
|
||||
|
||||
// Android programs get Android's environment, as execve() gives them: the glibc hook in
|
||||
// LD_PRELOAD crashes them.
|
||||
char **new_envp = in_root ? ensure_hook_in_envp(orig_ep, elf_target) : clean_env_for_system(orig_ep);
|
||||
int via_ld_so = has_ld_so && strcmp(elf_target, ld_so) != 0;
|
||||
char ld_lib_path[PATH_MAX * 6];
|
||||
ld_lib_path[0] = '\0';
|
||||
if (via_ld_so)
|
||||
build_ld_library_path(orig_ep, probe.runpath, probe.runpath_is_rpath, elf_target, ld_lib_path, sizeof(ld_lib_path));
|
||||
char **new_envp = in_root ? ensure_hook_in_envp(orig_ep, elf_target, via_ld_so ? ld_lib_path : NULL)
|
||||
: clean_env_for_system(orig_ep);
|
||||
|
||||
int ret = -1;
|
||||
if (has_ld_so && strcmp(elf_target, ld_so) != 0) {
|
||||
if (via_ld_so) {
|
||||
ensure_exec_bit(elf_target, probe.mode);
|
||||
if (probe.android_interp) prepare_static_program_ex(elf_target, 1); // a Go program built for Android (#42)
|
||||
|
||||
char hook_buf[PATH_MAX];
|
||||
const char *hook_so = ddnatv_hook_library(hook_buf, sizeof(hook_buf));
|
||||
char ld_lib_path[PATH_MAX * 6];
|
||||
build_ld_library_path(orig_ep, probe.runpath, probe.runpath_is_rpath, elf_target, ld_lib_path, sizeof(ld_lib_path));
|
||||
char **new_argv = build_ldso_argv(ld_so, hook_so, ld_lib_path, elf_target, prog_name, argv);
|
||||
if (!new_argv) {
|
||||
ret = ENOMEM;
|
||||
@@ -968,9 +978,19 @@ static int ddnatv_posix_spawn(pid_t *pid, const char *path,
|
||||
}
|
||||
} else {
|
||||
if (in_root && probe.is_elf && !probe.is_dynamic) prepare_static_program(elf_target);
|
||||
if (orig_posix_spawn) {
|
||||
ret = run_spawn(orig_posix_spawn, pid, target, file_actions, attrp, argv, new_envp);
|
||||
char **spawn_argv = (char **)argv;
|
||||
int err = 0;
|
||||
struct ldso_direct direct;
|
||||
if (in_root && probe.is_elf && !probe.is_dynamic && is_ld_linux(elf_target)) {
|
||||
char **direct_argv = ldso_direct_argv(argv, orig_ep, &direct, &err);
|
||||
if (direct_argv) spawn_argv = direct_argv;
|
||||
}
|
||||
if (err) {
|
||||
ret = err;
|
||||
} else if (orig_posix_spawn) {
|
||||
ret = run_spawn(orig_posix_spawn, pid, target, file_actions, attrp, spawn_argv, new_envp);
|
||||
}
|
||||
if (spawn_argv != argv) free(spawn_argv);
|
||||
}
|
||||
|
||||
if (!orig_posix_spawn) {
|
||||
|
||||
@@ -519,6 +519,13 @@ static int close_range_all(unsigned int first, unsigned int last, int flags) {
|
||||
|
||||
static __thread int t_syscall_redirect = 0;
|
||||
|
||||
static long nested_path_syscall(long number, unsigned long dirfd, unsigned long pathname, unsigned long arg3, unsigned long arg4) {
|
||||
char nested_buf[PATH_MAX];
|
||||
const char *path = (const char *)pathname;
|
||||
if (path && path[0] == '/') path = rewrite_path(path, nested_buf, sizeof(nested_buf));
|
||||
return call_orig_syscall(number, dirfd, (unsigned long)path, arg3, arg4, 0, 0);
|
||||
}
|
||||
|
||||
long syscall(long number, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, number);
|
||||
@@ -563,6 +570,38 @@ long syscall(long number, ...) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __NR_rt_sigprocmask
|
||||
if (number == __NR_rt_sigprocmask && arg2 && (arg1 == SIG_BLOCK || arg1 == SIG_SETMASK) && arg4 == sizeof(uint64_t)) {
|
||||
uint64_t mask;
|
||||
memcpy(&mask, (const void *)arg2, sizeof(mask));
|
||||
mask &= ~(1ULL << (SIGSYS - 1));
|
||||
return call_orig_syscall(number, arg1, (unsigned long)&mask, arg3, arg4, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __NR_rt_sigaction
|
||||
if (number == __NR_rt_sigaction && arg1 == SIGSYS && arg4 == sizeof(uint64_t)) {
|
||||
struct { void *handler; unsigned long flags; void *restorer; uint64_t mask; } kact, kold;
|
||||
struct sigaction act, old;
|
||||
memset(&act, 0, sizeof(act));
|
||||
if (arg2) {
|
||||
memcpy(&kact, (const void *)arg2, sizeof(kact));
|
||||
act.sa_sigaction = (void (*)(int, siginfo_t *, void *))kact.handler;
|
||||
act.sa_flags = (int)kact.flags;
|
||||
memcpy(&act.sa_mask, &kact.mask, sizeof(kact.mask));
|
||||
}
|
||||
remember_app_sigsys(arg2 ? &act : NULL, arg3 ? &old : NULL);
|
||||
if (arg3) {
|
||||
memset(&kold, 0, sizeof(kold));
|
||||
kold.handler = (void *)old.sa_sigaction;
|
||||
kold.flags = (unsigned long)(unsigned int)old.sa_flags;
|
||||
memcpy(&kold.mask, &old.sa_mask, sizeof(kold.mask));
|
||||
memcpy((void *)arg3, &kold, sizeof(kold));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __NR_seccomp
|
||||
if (number == __NR_seccomp) {
|
||||
return (long)seccomp((unsigned int)arg1, (unsigned int)arg2, (void *)arg3);
|
||||
@@ -618,16 +657,84 @@ long syscall(long number, ...) {
|
||||
}
|
||||
#endif
|
||||
|
||||
if (g_initialized) {
|
||||
#ifdef __NR_openat
|
||||
if (number == __NR_openat) {
|
||||
if (t_syscall_redirect) return nested_path_syscall(number, arg1, arg2, arg3, arg4);
|
||||
t_syscall_redirect++;
|
||||
long ret = (long)openat((int)arg1, (const char *)arg2, (int)arg3, (mode_t)arg4);
|
||||
t_syscall_redirect--;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
#if defined(__NR_mkdirat)
|
||||
if (number == __NR_mkdirat) {
|
||||
return (long)mkdirat((int)arg1, (const char *)arg2, (mode_t)arg3);
|
||||
}
|
||||
#endif
|
||||
#if defined(__NR_unlinkat)
|
||||
if (number == __NR_unlinkat) {
|
||||
return (long)unlinkat((int)arg1, (const char *)arg2, (int)arg3);
|
||||
}
|
||||
#endif
|
||||
#if defined(__NR_renameat)
|
||||
if (number == __NR_renameat) {
|
||||
return (long)renameat((int)arg1, (const char *)arg2, (int)arg3, (const char *)arg4);
|
||||
}
|
||||
#endif
|
||||
#if defined(__NR_renameat2)
|
||||
if (number == __NR_renameat2) {
|
||||
return (long)renameat2((int)arg1, (const char *)arg2, (int)arg3, (const char *)arg4, (unsigned int)arg5);
|
||||
}
|
||||
#endif
|
||||
#if defined(__NR_symlinkat)
|
||||
if (number == __NR_symlinkat) {
|
||||
return (long)symlinkat((const char *)arg1, (int)arg2, (const char *)arg3);
|
||||
}
|
||||
#endif
|
||||
#if defined(__NR_fchmodat)
|
||||
if (number == __NR_fchmodat) {
|
||||
return (long)fchmodat((int)arg1, (const char *)arg2, (mode_t)arg3, 0);
|
||||
}
|
||||
#endif
|
||||
#if defined(__NR_fchownat)
|
||||
if (number == __NR_fchownat) {
|
||||
return (long)fchownat((int)arg1, (const char *)arg2, (uid_t)arg3, (gid_t)arg4, (int)arg5);
|
||||
}
|
||||
#endif
|
||||
#if defined(__NR_utimensat)
|
||||
if (number == __NR_utimensat) {
|
||||
if (!arg2) return call_orig_syscall(number, arg1, arg2, arg3, arg4, 0, 0);
|
||||
return (long)utimensat((int)arg1, (const char *)arg2, (const struct timespec *)arg3, (int)arg4);
|
||||
}
|
||||
#endif
|
||||
#if defined(__NR_truncate)
|
||||
if (number == __NR_truncate) {
|
||||
return (long)truncate((const char *)arg1, (off_t)arg2);
|
||||
}
|
||||
#endif
|
||||
#if defined(__NR_chdir)
|
||||
if (number == __NR_chdir) {
|
||||
return (long)chdir((const char *)arg1);
|
||||
}
|
||||
#endif
|
||||
#if defined(__NR_chroot)
|
||||
if (number == __NR_chroot) {
|
||||
return (long)chroot((const char *)arg1);
|
||||
}
|
||||
#endif
|
||||
#if defined(__NR_inotify_add_watch)
|
||||
if (number == __NR_inotify_add_watch) {
|
||||
return (long)inotify_add_watch((int)arg1, (const char *)arg2, (uint32_t)arg3);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __NR_openat2
|
||||
if (number == __NR_openat2) {
|
||||
// libddsession's openat2() calls syscall() again (an endless loop until the stack ran out): the nested
|
||||
// call maps the path and goes straight to the kernel
|
||||
if (t_syscall_redirect) {
|
||||
char nested_buf[PATH_MAX];
|
||||
const char *path = (const char *)arg2;
|
||||
if (path && path[0] == '/') path = rewrite_path(path, nested_buf, sizeof(nested_buf));
|
||||
return call_orig_syscall(number, arg1, (unsigned long)path, arg3, arg4, 0, 0);
|
||||
}
|
||||
if (t_syscall_redirect) return nested_path_syscall(number, arg1, arg2, arg3, arg4);
|
||||
t_syscall_redirect++;
|
||||
long ret = (long)openat2((int)arg1, (const char *)arg2, (struct ddnatv_open_how *)arg3, (size_t)arg4);
|
||||
t_syscall_redirect--;
|
||||
@@ -649,12 +756,7 @@ long syscall(long number, ...) {
|
||||
|
||||
#if defined(__NR_faccessat)
|
||||
if (number == __NR_faccessat) {
|
||||
if (t_syscall_redirect) {
|
||||
char nested_buf[PATH_MAX];
|
||||
const char *path = (const char *)arg2;
|
||||
if (path && path[0] == '/') path = rewrite_path(path, nested_buf, sizeof(nested_buf));
|
||||
return call_orig_syscall(number, arg1, (unsigned long)path, arg3, 0, 0, 0);
|
||||
}
|
||||
if (t_syscall_redirect) return nested_path_syscall(number, arg1, arg2, arg3, 0);
|
||||
t_syscall_redirect++;
|
||||
long ret = (long)faccessat((int)arg1, (const char *)arg2, (int)arg3, 0);
|
||||
t_syscall_redirect--;
|
||||
|
||||
@@ -107,6 +107,51 @@ int main(void) {
|
||||
}
|
||||
"""
|
||||
|
||||
EARLY_LIBRARY = r"""
|
||||
#include <pthread.h>
|
||||
#include <time.h>
|
||||
|
||||
pthread_mutex_t early_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
__attribute__((constructor)) static void early_start(void) {
|
||||
struct timespec ts;
|
||||
pthread_mutex_lock(&early_lock);
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
pthread_mutex_unlock(&early_lock);
|
||||
}
|
||||
"""
|
||||
|
||||
EARLY_PROGRAM = r"""
|
||||
#define _GNU_SOURCE
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern pthread_mutex_t early_lock;
|
||||
|
||||
int open(const char *path, int flags, ...) {
|
||||
va_list args;
|
||||
va_start(args, flags);
|
||||
mode_t mode = (mode_t)va_arg(args, int);
|
||||
va_end(args);
|
||||
pthread_mutex_lock(&early_lock);
|
||||
pthread_mutex_unlock(&early_lock);
|
||||
return (int)syscall(SYS_openat, AT_FDCWD, path, flags, mode);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
struct timespec mono, boot;
|
||||
clock_gettime(CLOCK_MONOTONIC, &mono);
|
||||
clock_gettime(CLOCK_BOOTTIME, &boot);
|
||||
printf("gap %lld\n", (long long)(((boot.tv_sec - mono.tv_sec) * 1000000000LL + boot.tv_nsec - mono.tv_nsec) / 1000000LL));
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
SHIFT_MS = 10000
|
||||
|
||||
|
||||
@@ -128,6 +173,13 @@ class ClockPausePreloadTest(unittest.TestCase):
|
||||
subprocess.run(["cc", "-O2", "-pthread", "-o", str(cls.shell), str(build / "program.c")], check=True)
|
||||
cls.other = build / "kwin_wayland"
|
||||
shutil.copy(cls.shell, cls.other)
|
||||
(build / "early.c").write_text(EARLY_LIBRARY)
|
||||
(build / "early_program.c").write_text(EARLY_PROGRAM)
|
||||
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-pthread", "-o", str(build / "libearly.so"),
|
||||
str(build / "early.c")], check=True)
|
||||
cls.early = build / "early_program"
|
||||
subprocess.run(["cc", "-O2", "-pthread", "-o", str(cls.early), str(build / "early_program.c"),
|
||||
"-L", str(build), "-learly", "-Wl,-rpath," + str(build)], check=True)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
@@ -153,6 +205,11 @@ class ClockPausePreloadTest(unittest.TestCase):
|
||||
self.assertGreaterEqual(paused[name], 50, name)
|
||||
self.assertLess(paused[name], 1000, name)
|
||||
|
||||
def test_clock_read_inside_a_library_constructor_does_not_reenter_the_program(self):
|
||||
plain = self.run_program(self.early, 0)
|
||||
paused = self.run_program(self.early, SHIFT_MS)
|
||||
self.assertAlmostEqual(paused["gap"] - plain["gap"], SHIFT_MS, delta=50)
|
||||
|
||||
def test_program_without_preload_keeps_the_real_clock(self):
|
||||
plain = self.run_program(self.other, 0, preload=False)
|
||||
paused = self.run_program(self.other, SHIFT_MS, preload=False)
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from tools.tests.test_usr2_preload import runner
|
||||
|
||||
REPO = Path(__file__).resolve().parents[2]
|
||||
SOURCE = REPO / "app/src/main/cpp/ddexec/ddexec.c"
|
||||
SYSROOT = Path("/usr/aarch64-linux-gnu")
|
||||
|
||||
LIBRARY = r"""
|
||||
int dd_probe_value(void) { return 7; }
|
||||
"""
|
||||
|
||||
HOOK = r"""
|
||||
#include <unistd.h>
|
||||
|
||||
__attribute__((constructor)) static void hooked(void) { write(1, "hooked\n", 7); }
|
||||
"""
|
||||
|
||||
PROGRAM = r"""
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/auxv.h>
|
||||
#include <sys/syscall.h>
|
||||
|
||||
int dd_probe_value(void);
|
||||
|
||||
int main(int argc, char **argv, char **envp) {
|
||||
if (dd_probe_value() != 7) return 4;
|
||||
if (argc > 1 && strcmp(argv[1], "again") == 0) {
|
||||
for (int i = 0; i < argc; i++) printf("%s%s", i ? "|" : "", argv[i]);
|
||||
printf("\n%s\n", (char *)getauxval(AT_EXECFN));
|
||||
return 0;
|
||||
}
|
||||
char *next[] = {"first", "again", "x y", NULL};
|
||||
syscall(SYS_execveat, -100, "/proc/self/exe", next, envp, 0);
|
||||
return 3;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def ndk_clang():
|
||||
sdk = Path(os.environ.get("ANDROID_HOME") or os.environ.get("ANDROID_SDK_ROOT") or Path.home() / "Android/Sdk")
|
||||
for ndk in sorted((sdk / "ndk").glob("*"), reverse=True):
|
||||
clang = ndk / "toolchains/llvm/prebuilt/linux-x86_64/bin/clang"
|
||||
if clang.exists():
|
||||
return str(clang)
|
||||
return shutil.which("clang")
|
||||
|
||||
|
||||
class DdexecReexecTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cc, prefix = runner()
|
||||
clang = ndk_clang()
|
||||
if cc is None or clang is None or not shutil.which("bwrap") or not SYSROOT.is_dir():
|
||||
raise unittest.SkipTest("no aarch64 toolchain, runner or bwrap")
|
||||
cls.qemu = list(prefix[:3]) if prefix else []
|
||||
cls.tmp = tempfile.TemporaryDirectory()
|
||||
tmp = Path(cls.tmp.name)
|
||||
cls.loader = tmp / "libddexec.so"
|
||||
subprocess.run([clang, "--target=aarch64-linux-android29", "-shared", "-fPIC", "-O2", "-ffreestanding",
|
||||
"-fno-builtin", "-fno-stack-protector", "-fno-asynchronous-unwind-tables", "-nostdlib",
|
||||
"-Wl,-e,_start", "-Wl,-z,noexecstack", "-Wl,--no-undefined", "-Wl,-Bsymbolic",
|
||||
"-Wl,-z,max-page-size=16384", "-o", str(cls.loader), str(SOURCE)], check=True)
|
||||
cls.libdir = tmp / "own-lib"
|
||||
cls.libdir.mkdir()
|
||||
(tmp / "lib.c").write_text(LIBRARY)
|
||||
subprocess.run([cc, "-shared", "-fPIC", "-O1", "-o", str(cls.libdir / "libddprobe.so"), str(tmp / "lib.c")],
|
||||
check=True)
|
||||
(tmp / "prog.c").write_text(PROGRAM)
|
||||
cls.program = tmp / "prog"
|
||||
subprocess.run([cc, "-O1", "-o", str(cls.program), str(tmp / "prog.c"), "-L", str(cls.libdir), "-lddprobe"],
|
||||
check=True)
|
||||
cls.root = tmp / "root"
|
||||
(cls.root / "usr/lib").mkdir(parents=True)
|
||||
(cls.root / "lib").mkdir()
|
||||
shutil.copy2(SYSROOT / "lib/ld-linux-aarch64.so.1", cls.root / "lib/ld-linux-aarch64.so.1")
|
||||
(tmp / "hook.c").write_text(HOOK)
|
||||
subprocess.run([cc, "-shared", "-fPIC", "-O1", "-o", str(cls.root / "usr/lib/libddnatv-hook.so"), str(tmp / "hook.c")],
|
||||
check=True)
|
||||
probe = subprocess.run(["bwrap", "--dev-bind", "/", "/", "true"], capture_output=True)
|
||||
if probe.returncode != 0:
|
||||
raise unittest.SkipTest("bwrap cannot create a namespace here")
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.tmp.cleanup()
|
||||
|
||||
def env(self, real_exe, library_path=None, root=SYSROOT):
|
||||
env = {k: v for k, v in os.environ.items() if not k.startswith(("DDNATV_", "LD_", "QEMU_"))}
|
||||
env["DDNATV_ROOT"] = str(root)
|
||||
env["LD_LIBRARY_PATH"] = f"{SYSROOT / 'lib'}:{self.libdir}" if library_path is None else str(SYSROOT / "lib")
|
||||
if real_exe:
|
||||
env["DDNATV_REAL_EXE"] = str(real_exe)
|
||||
if library_path:
|
||||
env["DDNATV_LIBRARY_PATH"] = library_path
|
||||
return env
|
||||
|
||||
def reexec(self, execfn, real_exe, library_path=None, root=SYSROOT):
|
||||
jail = ["bwrap", "--dev-bind", "/", "/", "--tmpfs", "/proc"]
|
||||
parent = str(Path(execfn).parent)
|
||||
jail += ["--dir", parent, "--ro-bind", str(self.loader), execfn]
|
||||
start = self.qemu + ["-0", "first", execfn] if self.qemu else ["bash", "-c", 'exec -a first "$0" "$@"', execfn]
|
||||
cmd = jail + start + ["again", "x y"]
|
||||
return subprocess.run(cmd, env=self.env(real_exe, library_path, root), capture_output=True, text=True, timeout=120)
|
||||
|
||||
def test_reexec_through_proc_self_exe_runs_the_guest_program(self):
|
||||
out = self.reexec("/proc/self/exe", self.program)
|
||||
self.assertEqual(out.returncode, 0, out.stderr)
|
||||
self.assertEqual(["first|again|x y", str(self.program)], out.stdout.splitlines())
|
||||
|
||||
def test_reexec_through_thread_self_exe_runs_the_guest_program(self):
|
||||
out = self.reexec("/proc/thread-self/exe", self.program)
|
||||
self.assertEqual(out.returncode, 0, out.stderr)
|
||||
self.assertEqual(["first|again|x y", str(self.program)], out.stdout.splitlines())
|
||||
|
||||
def test_reexec_finds_libraries_through_the_recorded_library_path(self):
|
||||
out = self.reexec("/proc/self/exe", self.program, f"{self.libdir}:{SYSROOT / 'lib'}")
|
||||
self.assertEqual(out.returncode, 0, out.stderr)
|
||||
self.assertEqual(["first|again|x y", str(self.program)], out.stdout.splitlines())
|
||||
|
||||
def test_reexec_through_ld_so_preloads_the_hook_of_the_root(self):
|
||||
out = self.reexec("/proc/self/exe", self.program, f"{self.libdir}:{SYSROOT / 'lib'}", self.root)
|
||||
self.assertEqual(out.returncode, 0, out.stderr)
|
||||
self.assertEqual(["hooked", "first|again|x y", str(self.program)], out.stdout.splitlines())
|
||||
|
||||
def test_reexec_without_a_known_program_fails_cleanly(self):
|
||||
out = self.reexec("/proc/self/exe", None)
|
||||
self.assertEqual(127, out.returncode)
|
||||
self.assertIn("DDNATV_REAL_EXE", out.stderr)
|
||||
|
||||
def test_a_started_program_keeps_its_own_arguments(self):
|
||||
ldso = SYSROOT / "lib/ld-linux-aarch64.so.1"
|
||||
cmd = self.qemu + [str(self.loader), str(ldso), "ld.so", "--library-path", f"{SYSROOT / 'lib'}:{self.libdir}",
|
||||
str(self.program), "again", "a"]
|
||||
out = subprocess.run(cmd, env=self.env(self.program), capture_output=True, text=True, timeout=120)
|
||||
self.assertEqual(out.returncode, 0, out.stderr)
|
||||
self.assertEqual([f"{self.program}|again|a", str(self.program)], out.stdout.splitlines())
|
||||
|
||||
def test_the_usage_check_still_applies_outside_a_reexec(self):
|
||||
out = subprocess.run(self.qemu + [str(self.loader), str(self.program)], env=self.env(self.program),
|
||||
capture_output=True, text=True, timeout=120)
|
||||
self.assertEqual(127, out.returncode)
|
||||
self.assertIn("usage", out.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,49 @@
|
||||
import re
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
REPO = Path(__file__).resolve().parents[2]
|
||||
PATCH = REPO / "tools/fex/patches/0013-path-syscalls-through-libc.patch"
|
||||
HOOK = REPO / "tools/nativeguest/hook/privileged.c"
|
||||
PASSTHROUGH = "Source/Tools/LinuxEmulation/LinuxSyscalls/Syscalls/Passthrough.cpp"
|
||||
REGISTER = re.compile(r"REGISTER_SYSCALL_IMPL(?:_X64|_X32)?\((\w+), (\w+?)(\d)<SYSCALL_DEF\((\w+)\)>\);")
|
||||
|
||||
|
||||
def changed():
|
||||
removed, added = {}, {}
|
||||
for line in PATCH.read_text().splitlines():
|
||||
found = REGISTER.search(line)
|
||||
if found and line[:1] in "+-":
|
||||
(added if line[0] == "+" else removed)[found.group(1)] = found.groups()[1:]
|
||||
return removed, added
|
||||
|
||||
|
||||
class FexPathSyscallsTest(unittest.TestCase):
|
||||
def test_only_the_passthrough_table_changes(self):
|
||||
self.assertEqual(re.findall(r"^diff --git a/(\S+) ", PATCH.read_text(), re.M), [PASSTHROUGH])
|
||||
|
||||
def test_each_path_syscall_keeps_its_arity_and_goes_through_libc(self):
|
||||
removed, added = changed()
|
||||
self.assertEqual(sorted(removed), sorted(added))
|
||||
self.assertGreater(len(added), 10)
|
||||
for name, (template, arity, number) in added.items():
|
||||
with self.subTest(name=name):
|
||||
self.assertEqual(("SyscallPassthrough", arity, number), removed[name])
|
||||
self.assertEqual("SyscallPathPassthrough", template)
|
||||
|
||||
def test_the_new_templates_call_the_libc_syscall(self):
|
||||
added = [line[1:] for line in PATCH.read_text().splitlines() if line.startswith("+") and not line.startswith("+++")]
|
||||
calls = [line for line in added if "syscall(" in line and "Result" in line]
|
||||
self.assertEqual(5, len(calls))
|
||||
self.assertTrue(all("::syscall(syscall_num" in line for line in calls))
|
||||
self.assertFalse([line for line in added if line.strip().startswith(("//", "/*"))])
|
||||
|
||||
def test_every_routed_syscall_is_rewritten_by_the_hook(self):
|
||||
hook = HOOK.read_text()
|
||||
for name, (_, _, number) in changed()[1].items():
|
||||
with self.subTest(name=name):
|
||||
self.assertIn(f"number == __NR_{number})", hook)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,163 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from tools.tests.test_usr2_preload import runner
|
||||
|
||||
HOOK_BUILD = Path(__file__).resolve().parents[1] / "nativeguest/build.sh"
|
||||
GUEST_LDSO = "/usr/lib/ld-linux-aarch64.so.1"
|
||||
GUEST_TOOL = "/usr/local/bin/tool"
|
||||
|
||||
RECORDER = r"""
|
||||
#define _GNU_SOURCE
|
||||
#include <spawn.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void show(const char *path, char *const argv[], char *const envp[]) {
|
||||
printf("call\t%s", path);
|
||||
for (int i = 0; argv[i]; i++) printf("\t%s", argv[i]);
|
||||
printf("\n");
|
||||
for (int i = 0; envp && envp[i]; i++)
|
||||
if (strncmp(envp[i], "DDNATV_LIBRARY_PATH=", 20) == 0) printf("libpath\t%s\n", envp[i] + 20);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
int posix_spawn(pid_t *pid, const char *path, const posix_spawn_file_actions_t *actions,
|
||||
const posix_spawnattr_t *attr, char *const argv[], char *const envp[]) {
|
||||
show(path, argv, envp);
|
||||
if (pid) *pid = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int execve(const char *path, char *const argv[], char *const envp[]) {
|
||||
show(path, argv, envp);
|
||||
_exit(0);
|
||||
}
|
||||
"""
|
||||
|
||||
PROBE = r"""
|
||||
#include <spawn.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern char **environ;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
if (argc < 3) return 2;
|
||||
if (strcmp(argv[1], "spawn") == 0) {
|
||||
pid_t pid;
|
||||
posix_spawn_file_actions_t actions;
|
||||
posix_spawn_file_actions_init(&actions);
|
||||
posix_spawn_file_actions_adddup2(&actions, 1, 1);
|
||||
int ret = posix_spawn(&pid, argv[2], &actions, NULL, argv + 2, environ);
|
||||
posix_spawn_file_actions_destroy(&actions);
|
||||
printf("ret\t%d\n", ret);
|
||||
return 0;
|
||||
}
|
||||
execve(argv[2], argv + 2, environ);
|
||||
printf("ret\t-1\n");
|
||||
return 1;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def guest_loader(prefix):
|
||||
roots = [Path(prefix[prefix.index("-L") + 1])] if prefix and "-L" in prefix else [Path("/")]
|
||||
for root in roots:
|
||||
for name in ("lib/ld-linux-aarch64.so.1", "lib64/ld-linux-aarch64.so.1", "usr/lib/ld-linux-aarch64.so.1"):
|
||||
if (root / name).exists():
|
||||
return root / name
|
||||
return None
|
||||
|
||||
|
||||
class NativeHookLdsoSpawnTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.cc, cls.prefix = runner()
|
||||
if cls.cc is None:
|
||||
raise unittest.SkipTest("no aarch64 compiler and runner")
|
||||
loader = guest_loader(cls.prefix)
|
||||
if loader is None:
|
||||
raise unittest.SkipTest("no aarch64 glibc loader to put in the rootfs")
|
||||
cls.tmp = tempfile.TemporaryDirectory()
|
||||
tmp = Path(cls.tmp.name)
|
||||
cls.hook = tmp / "hook.so"
|
||||
subprocess.run(["bash", str(HOOK_BUILD), str(cls.hook), cls.cc], check=True, capture_output=True)
|
||||
(tmp / "recorder.c").write_text(RECORDER)
|
||||
cls.recorder = tmp / "recorder.so"
|
||||
subprocess.run([cls.cc, "-shared", "-fPIC", "-O1", "-o", str(cls.recorder), str(tmp / "recorder.c")], check=True)
|
||||
(tmp / "probe.c").write_text(PROBE)
|
||||
cls.probe = tmp / "probe"
|
||||
subprocess.run([cls.cc, "-O1", "-o", str(cls.probe), str(tmp / "probe.c")], check=True)
|
||||
cls.root = tmp / "root"
|
||||
for guest, source in ((GUEST_LDSO, loader), (GUEST_TOOL, cls.probe)):
|
||||
host = cls.root / guest.lstrip("/")
|
||||
host.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy(source, host)
|
||||
host.chmod(0o755)
|
||||
(cls.root / "usr/lib/aarch64-linux-gnu").mkdir(parents=True, exist_ok=True)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.tmp.cleanup()
|
||||
|
||||
def call(self, how, *argv):
|
||||
hook_env = {"DDNATV_ROOT": str(self.root), "LD_PRELOAD": f"{self.hook}:{self.recorder}"}
|
||||
env = {k: v for k, v in os.environ.items() if k not in ("LD_PRELOAD", "DDNATV_EXEC", "LD_LIBRARY_PATH")}
|
||||
if self.prefix:
|
||||
cmd = list(self.prefix) + [arg for key, value in hook_env.items() for arg in ("-E", f"{key}={value}")]
|
||||
else:
|
||||
cmd = []
|
||||
env.update(hook_env)
|
||||
out = subprocess.run(cmd + [str(self.probe), how, *argv], env=env, capture_output=True, text=True, timeout=120)
|
||||
calls = [line.split("\t")[1:] for line in out.stdout.splitlines() if line.startswith("call\t")]
|
||||
self.library_paths = [line.split("\t", 1)[1] for line in out.stdout.splitlines() if line.startswith("libpath\t")]
|
||||
self.assertEqual(1, len(calls), out.stdout + out.stderr)
|
||||
if how == "spawn":
|
||||
self.assertIn("ret\t0", out.stdout.splitlines(), out.stdout + out.stderr)
|
||||
return calls[0]
|
||||
|
||||
def test_spawned_ldso_list_loads_the_program_from_the_rootfs(self):
|
||||
call = self.call("spawn", GUEST_LDSO, "--list", GUEST_TOOL)
|
||||
argv = call[1:]
|
||||
self.assertEqual(str(self.root / GUEST_TOOL.lstrip("/")), argv[-1])
|
||||
self.assertEqual("--list", argv[-2])
|
||||
self.assertIn("--library-path", argv[:-2])
|
||||
|
||||
def test_spawn_and_exec_start_ldso_with_the_same_arguments(self):
|
||||
for args in (("--list", GUEST_TOOL), (GUEST_TOOL, "x"), ("--library-path", "/opt/own", "--list", GUEST_TOOL)):
|
||||
with self.subTest(args=args):
|
||||
self.assertEqual(self.call("exec", GUEST_LDSO, *args), self.call("spawn", GUEST_LDSO, *args))
|
||||
|
||||
def test_a_callers_own_library_path_is_kept(self):
|
||||
call = self.call("spawn", GUEST_LDSO, "--library-path", "/opt/own", "--list", GUEST_TOOL)
|
||||
self.assertEqual([GUEST_LDSO, "--library-path", "/opt/own", "--list", str(self.root / GUEST_TOOL.lstrip("/"))], call[1:])
|
||||
|
||||
def test_ldso_without_a_program_is_spawned_unchanged(self):
|
||||
call = self.call("spawn", GUEST_LDSO, "--version")
|
||||
self.assertEqual([GUEST_LDSO, "--version"], call[1:])
|
||||
|
||||
def test_spawn_and_exec_start_a_dynamic_program_the_same_way(self):
|
||||
self.assertEqual(self.call("exec", GUEST_TOOL, "x"), self.call("spawn", GUEST_TOOL, "x"))
|
||||
|
||||
def test_a_program_started_through_ldso_records_its_library_path(self):
|
||||
for how in ("exec", "spawn"):
|
||||
with self.subTest(how=how):
|
||||
argv = self.call(how, GUEST_TOOL, "x")[1:]
|
||||
self.assertEqual([argv[argv.index("--library-path") + 1]], self.library_paths)
|
||||
|
||||
def test_ldso_started_by_name_records_no_library_path(self):
|
||||
for how in ("exec", "spawn"):
|
||||
with self.subTest(how=how):
|
||||
self.call(how, GUEST_LDSO, "--list", GUEST_TOOL)
|
||||
self.assertEqual([], self.library_paths)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,163 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from tools.tests.test_usr2_preload import runner
|
||||
|
||||
HOOK_BUILD = Path(__file__).resolve().parents[1] / "nativeguest/build.sh"
|
||||
|
||||
PROBE = r"""
|
||||
#define _GNU_SOURCE
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void show(const char *name, long ret) { printf("%s\t%d\n", name, ret >= 0); }
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
const char *dir = argv[1];
|
||||
char p[PATH_MAX], q[PATH_MAX], cwd[PATH_MAX];
|
||||
snprintf(p, sizeof(p), "%s/made", dir);
|
||||
show("mkdirat", syscall(SYS_mkdirat, AT_FDCWD, p, 0755));
|
||||
snprintf(p, sizeof(p), "%s/made/file", dir);
|
||||
long fd = syscall(SYS_openat, AT_FDCWD, p, O_WRONLY | O_CREAT | O_CLOEXEC, 0644);
|
||||
show("openat", fd);
|
||||
if (fd >= 0) close((int)fd);
|
||||
show("truncate", syscall(SYS_truncate, p, 4));
|
||||
show("fchmodat", syscall(SYS_fchmodat, AT_FDCWD, p, 0600));
|
||||
show("utimensat", syscall(SYS_utimensat, AT_FDCWD, p, NULL, 0));
|
||||
fd = syscall(SYS_openat, AT_FDCWD, p, O_RDONLY | O_CLOEXEC);
|
||||
show("futimens", fd >= 0 ? syscall(SYS_utimensat, (int)fd, NULL, NULL, 0) : -1);
|
||||
if (fd >= 0) close((int)fd);
|
||||
snprintf(q, sizeof(q), "%s/made/moved", dir);
|
||||
show("renameat", syscall(SYS_renameat, AT_FDCWD, p, AT_FDCWD, q));
|
||||
show("renameat2", syscall(SYS_renameat2, AT_FDCWD, q, AT_FDCWD, p, 0));
|
||||
snprintf(q, sizeof(q), "%s/made/link", dir);
|
||||
show("symlinkat", syscall(SYS_symlinkat, "file", AT_FDCWD, q));
|
||||
show("unlinkat", syscall(SYS_unlinkat, AT_FDCWD, q, 0));
|
||||
snprintf(q, sizeof(q), "%s/made", dir);
|
||||
show("chdir", syscall(SYS_chdir, q));
|
||||
show("cwd", getcwd(cwd, sizeof(cwd)) && strstr(cwd, "/made") ? 0 : -1);
|
||||
show("unlinkat-file", syscall(SYS_unlinkat, AT_FDCWD, p, 0));
|
||||
show("unlinkat-dir", syscall(SYS_unlinkat, AT_FDCWD, q, AT_REMOVEDIR));
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
ALLOCATOR = r"""
|
||||
#define _GNU_SOURCE
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern void *__libc_malloc(size_t);
|
||||
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static int ready;
|
||||
|
||||
void *malloc(size_t size) {
|
||||
if (!ready) {
|
||||
pthread_mutex_lock(&lock);
|
||||
if (!ready) {
|
||||
long fd = syscall(SYS_openat, AT_FDCWD, "/proc/self/stat", O_RDONLY | O_CLOEXEC);
|
||||
if (fd >= 0) close((int)fd);
|
||||
ready = 1;
|
||||
}
|
||||
pthread_mutex_unlock(&lock);
|
||||
}
|
||||
return __libc_malloc(size);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
puts("ready");
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
EARLY = r"""
|
||||
#include <stdlib.h>
|
||||
|
||||
__attribute__((constructor)) static void early(void) { free(malloc(1)); }
|
||||
"""
|
||||
|
||||
CALLS = ("mkdirat", "openat", "truncate", "fchmodat", "utimensat", "futimens", "renameat", "renameat2", "symlinkat", "unlinkat",
|
||||
"chdir", "cwd", "unlinkat-file", "unlinkat-dir")
|
||||
|
||||
|
||||
class NativeHookPathSyscallsTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.cc, cls.prefix = runner()
|
||||
if cls.cc is None:
|
||||
raise unittest.SkipTest("no aarch64 compiler and runner")
|
||||
cls.tmp = tempfile.TemporaryDirectory()
|
||||
tmp = Path(cls.tmp.name)
|
||||
cls.hook = tmp / "hook.so"
|
||||
subprocess.run(["bash", str(HOOK_BUILD), str(cls.hook), cls.cc], check=True, capture_output=True)
|
||||
(tmp / "probe.c").write_text(PROBE)
|
||||
cls.probe = tmp / "probe"
|
||||
subprocess.run([cls.cc, "-O1", "-o", str(cls.probe), str(tmp / "probe.c")], check=True)
|
||||
cls.root = tmp / "root"
|
||||
(cls.root / "opt").mkdir(parents=True)
|
||||
(tmp / "allocator.c").write_text(ALLOCATOR)
|
||||
cls.allocator = tmp / "allocator"
|
||||
subprocess.run([cls.cc, "-O1", "-rdynamic", "-pthread", "-o", str(cls.allocator), str(tmp / "allocator.c")], check=True)
|
||||
(tmp / "early.c").write_text(EARLY)
|
||||
cls.early = tmp / "early.so"
|
||||
subprocess.run([cls.cc, "-shared", "-fPIC", "-O1", "-o", str(cls.early), str(tmp / "early.c")], check=True)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.tmp.cleanup()
|
||||
|
||||
def run_program(self, argv, hook_env):
|
||||
env = {k: v for k, v in os.environ.items() if k not in ("LD_PRELOAD", "DDNATV_ROOT")}
|
||||
if self.prefix:
|
||||
cmd = list(self.prefix) + [arg for key, value in hook_env.items() for arg in ("-E", f"{key}={value}")]
|
||||
else:
|
||||
cmd = []
|
||||
env.update(hook_env)
|
||||
return subprocess.run(cmd + argv, env=env, capture_output=True, text=True, timeout=120)
|
||||
|
||||
def run_probe(self, guest_dir, hook=True):
|
||||
hook_env = {"DDNATV_ROOT": str(self.root), "LD_PRELOAD": str(self.hook)} if hook else {}
|
||||
out = self.run_program([str(self.probe), guest_dir], hook_env)
|
||||
self.assertEqual(out.returncode, 0, out.stderr)
|
||||
return {line.split("\t")[0]: int(line.split("\t")[1]) for line in out.stdout.splitlines()}
|
||||
|
||||
def test_guest_paths_through_syscall_land_in_the_root(self):
|
||||
results = self.run_probe("/opt")
|
||||
for call in CALLS:
|
||||
with self.subTest(call=call):
|
||||
self.assertEqual(1, results[call])
|
||||
self.assertEqual([], list((self.root / "opt").iterdir()))
|
||||
|
||||
def test_paths_already_in_the_root_are_kept(self):
|
||||
results = self.run_probe(str(self.root / "opt"))
|
||||
for call in CALLS:
|
||||
with self.subTest(call=call):
|
||||
self.assertEqual(1, results[call])
|
||||
|
||||
def test_without_the_hook_guest_paths_reach_the_host(self):
|
||||
results = self.run_probe("/opt/droiddeck-hook-probe-missing", hook=False)
|
||||
self.assertEqual(0, results["mkdirat"])
|
||||
self.assertEqual(0, results["openat"])
|
||||
self.assertEqual(0, results["chdir"])
|
||||
|
||||
def test_an_allocator_opening_files_before_the_hook_starts_does_not_hang(self):
|
||||
hook_env = {"DDNATV_ROOT": str(self.root), "DDNATV_BINDS": "/proc:/proc",
|
||||
"LD_PRELOAD": f"{self.hook}:{self.early}"}
|
||||
out = self.run_program([str(self.allocator)], hook_env)
|
||||
self.assertEqual(out.returncode, 0, out.stderr)
|
||||
self.assertEqual("ready", out.stdout.strip())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,144 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from tools.tests.test_usr2_preload import runner
|
||||
|
||||
HOOK_BUILD = Path(__file__).resolve().parents[1] / "nativeguest/build.sh"
|
||||
|
||||
PROBE = r"""
|
||||
#define _GNU_SOURCE
|
||||
#include <pthread.h>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static uint64_t current(void) {
|
||||
uint64_t mask = 0;
|
||||
syscall(SYS_rt_sigprocmask, SIG_SETMASK, NULL, &mask, sizeof(mask));
|
||||
return mask;
|
||||
}
|
||||
|
||||
struct kact { void *handler; unsigned long flags; void *restorer; uint64_t mask; };
|
||||
|
||||
static void own(int sig, siginfo_t *info, void *ctx) { (void)sig; (void)info; (void)ctx; }
|
||||
|
||||
static long raw_sigaction(int sig, const struct kact *act, struct kact *old) {
|
||||
register long x8 __asm__("x8") = SYS_rt_sigaction;
|
||||
register long x0 __asm__("x0") = sig;
|
||||
register long x1 __asm__("x1") = (long)act;
|
||||
register long x2 __asm__("x2") = (long)old;
|
||||
register long x3 __asm__("x3") = 8;
|
||||
__asm__ volatile("svc #0" : "+r"(x0) : "r"(x8), "r"(x1), "r"(x2), "r"(x3) : "memory");
|
||||
return x0;
|
||||
}
|
||||
|
||||
static void handlers(void) {
|
||||
struct kact act = { (void *)own, SA_SIGINFO, NULL, 0 }, seen, kernel;
|
||||
syscall(SYS_rt_sigaction, SIGSYS, &act, NULL, 8);
|
||||
syscall(SYS_rt_sigaction, SIGSYS, NULL, &seen, 8);
|
||||
raw_sigaction(SIGSYS, NULL, &kernel);
|
||||
printf("sigaction\t%d\t%d\n", seen.handler == (void *)own, kernel.handler == (void *)own);
|
||||
struct kact usr1 = { (void *)own, SA_SIGINFO, NULL, 0 };
|
||||
syscall(SYS_rt_sigaction, SIGUSR1, &usr1, NULL, 8);
|
||||
raw_sigaction(SIGUSR1, NULL, &kernel);
|
||||
printf("sigaction-usr1\t%d\n", kernel.handler == (void *)own);
|
||||
}
|
||||
|
||||
static void show(const char *how) {
|
||||
uint64_t mask = current();
|
||||
printf("%s\t%d\t%d\n", how, !!(mask & (1ULL << (SIGSYS - 1))), !!(mask & (1ULL << (SIGUSR1 - 1))));
|
||||
uint64_t none = 0;
|
||||
syscall(SYS_rt_sigprocmask, SIG_SETMASK, &none, NULL, sizeof(none));
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
uint64_t all = ~0ULL;
|
||||
sigset_t set;
|
||||
sigfillset(&set);
|
||||
for (int i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "syscall-setmask") == 0) syscall(SYS_rt_sigprocmask, SIG_SETMASK, &all, NULL, sizeof(all));
|
||||
else if (strcmp(argv[i], "syscall-block") == 0) syscall(SYS_rt_sigprocmask, SIG_BLOCK, &all, NULL, sizeof(all));
|
||||
else if (strcmp(argv[i], "syscall-unblock") == 0) {
|
||||
syscall(SYS_rt_sigprocmask, SIG_BLOCK, &all, NULL, sizeof(all));
|
||||
uint64_t usr1 = 1ULL << (SIGUSR1 - 1);
|
||||
syscall(SYS_rt_sigprocmask, SIG_UNBLOCK, &usr1, NULL, sizeof(usr1));
|
||||
}
|
||||
else if (strcmp(argv[i], "sigprocmask") == 0) sigprocmask(SIG_SETMASK, &set, NULL);
|
||||
else if (strcmp(argv[i], "pthread_sigmask") == 0) pthread_sigmask(SIG_SETMASK, &set, NULL);
|
||||
else if (strcmp(argv[i], "sigaction") == 0) {
|
||||
handlers();
|
||||
continue;
|
||||
}
|
||||
show(argv[i]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
WAYS = ("syscall-setmask", "syscall-block", "sigprocmask", "pthread_sigmask")
|
||||
|
||||
|
||||
class NativeHookSigsysMaskTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.cc, cls.prefix = runner()
|
||||
if cls.cc is None:
|
||||
raise unittest.SkipTest("no aarch64 compiler and runner")
|
||||
cls.tmp = tempfile.TemporaryDirectory()
|
||||
tmp = Path(cls.tmp.name)
|
||||
cls.hook = tmp / "hook.so"
|
||||
subprocess.run(["bash", str(HOOK_BUILD), str(cls.hook), cls.cc], check=True, capture_output=True)
|
||||
(tmp / "probe.c").write_text(PROBE)
|
||||
cls.probe = tmp / "probe"
|
||||
subprocess.run([cls.cc, "-O1", "-pthread", "-o", str(cls.probe), str(tmp / "probe.c")], check=True)
|
||||
cls.root = tmp / "root"
|
||||
cls.root.mkdir()
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.tmp.cleanup()
|
||||
|
||||
def masks(self, *ways, hook=True):
|
||||
hook_env = {"DDNATV_ROOT": str(self.root), "LD_PRELOAD": str(self.hook)} if hook else {}
|
||||
env = {k: v for k, v in os.environ.items() if k not in ("LD_PRELOAD", "DDNATV_ROOT")}
|
||||
if self.prefix:
|
||||
cmd = list(self.prefix) + [arg for key, value in hook_env.items() for arg in ("-E", f"{key}={value}")]
|
||||
else:
|
||||
cmd = []
|
||||
env.update(hook_env)
|
||||
out = subprocess.run(cmd + [str(self.probe), *ways], env=env, capture_output=True, text=True, timeout=120)
|
||||
self.assertEqual(out.returncode, 0, out.stderr)
|
||||
return {line.split("\t")[0]: tuple(int(v) for v in line.split("\t")[1:]) for line in out.stdout.splitlines()}
|
||||
|
||||
def test_blocking_every_signal_leaves_sigsys_open(self):
|
||||
masks = self.masks(*WAYS)
|
||||
for way in WAYS:
|
||||
with self.subTest(way=way):
|
||||
self.assertEqual((0, 1), masks[way])
|
||||
|
||||
def test_unblocking_is_unchanged(self):
|
||||
self.assertEqual((0, 0), self.masks("syscall-unblock")["syscall-unblock"])
|
||||
|
||||
def test_a_sigsys_handler_set_through_syscall_keeps_the_hooks(self):
|
||||
seen = self.masks("sigaction")
|
||||
self.assertEqual((1, 0), seen["sigaction"])
|
||||
self.assertEqual((1,), seen["sigaction-usr1"])
|
||||
|
||||
def test_without_the_hook_a_sigsys_handler_reaches_the_kernel(self):
|
||||
self.assertEqual((1, 1), self.masks("sigaction", hook=False)["sigaction"])
|
||||
|
||||
def test_without_the_hook_every_signal_is_blocked(self):
|
||||
masks = self.masks(*WAYS, hook=False)
|
||||
for way in WAYS:
|
||||
with self.subTest(way=way):
|
||||
self.assertEqual((1, 1), masks[way])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user