chore: merge main into feat/bt-controller-trinket

This commit is contained in:
Kurt Himebauch committed 2026-11-17 23:59:27 -05:00
commit 81d2643a88
278 files changed
+3203 -2656

No files matched your search

+1 -1
View File
@@ -2312,7 +2312,7 @@ __attribute__((visibility("hidden"))) static int inject_uevent(const char *actio
const char *subsystem, const char *devname,
unsigned major, unsigned minor) {
using inject_fn = int (*)(const char *, const char *, const char *, const char *, unsigned, unsigned);
static auto inject = reinterpret_cast<inject_fn>(dlsym(RTLD_DEFAULT, "bl_udevmon_inject"));
static auto inject = reinterpret_cast<inject_fn>(dlsym(RTLD_DEFAULT, "dd_udevmon_inject"));
return inject ? inject(action, devpath, subsystem, devname, major, minor) : -1;
}
+1 -1
View File
@@ -26,7 +26,7 @@ add_library(droiddeckwayland SHARED
generated/linux-dmabuf-v1-protocol.c
generated/wayland-android-protocol.c
generated/viewporter-protocol.c
generated/banner-desktop-v1-protocol.c
generated/droiddeck-desktop-v1-protocol.c
generated/presentation-time-protocol.c
generated/pointer-constraints-unstable-v1-protocol.c
generated/relative-pointer-unstable-v1-protocol.c
@@ -38,7 +38,7 @@
extern const struct wl_interface wl_surface_interface;
static const struct wl_interface *banner_desktop_v1_types[] = {
static const struct wl_interface *droiddeck_desktop_v1_types[] = {
NULL,
&wl_surface_interface,
&wl_surface_interface,
@@ -47,16 +47,16 @@ static const struct wl_interface *banner_desktop_v1_types[] = {
NULL,
};
static const struct wl_message banner_desktop_v1_requests[] = {
{ "destroy", "", banner_desktop_v1_types + 0 },
{ "set_desktop", "o", banner_desktop_v1_types + 1 },
{ "set_window", "ouii", banner_desktop_v1_types + 2 },
{ "set_zorder", "a", banner_desktop_v1_types + 0 },
static const struct wl_message droiddeck_desktop_v1_requests[] = {
{ "destroy", "", droiddeck_desktop_v1_types + 0 },
{ "set_desktop", "o", droiddeck_desktop_v1_types + 1 },
{ "set_window", "ouii", droiddeck_desktop_v1_types + 2 },
{ "set_zorder", "a", droiddeck_desktop_v1_types + 0 },
};
WL_PRIVATE const struct wl_interface banner_desktop_v1_interface = {
"banner_desktop_v1", 1,
4, banner_desktop_v1_requests,
WL_PRIVATE const struct wl_interface droiddeck_desktop_v1_interface = {
"droiddeck_desktop_v1", 1,
4, droiddeck_desktop_v1_requests,
0, NULL,
};
@@ -1,6 +1,6 @@
#ifndef BANNER_DESKTOP_V1_SERVER_PROTOCOL_H
#define BANNER_DESKTOP_V1_SERVER_PROTOCOL_H
#ifndef DROIDDECK_DESKTOP_V1_SERVER_PROTOCOL_H
#define DROIDDECK_DESKTOP_V1_SERVER_PROTOCOL_H
#include <stdint.h>
#include <stddef.h>
@@ -14,7 +14,7 @@ struct wl_client;
struct wl_resource;
/*
* @section page_copyright_banner_desktop_v1 Copyright
* @section page_copyright_droiddeck_desktop_v1 Copyright
*
* Copyright 2026 The412Banner
*
@@ -42,15 +42,15 @@ struct wl_resource;
struct banner_desktop_v1;
struct droiddeck_desktop_v1;
struct wl_surface;
#ifndef BANNER_DESKTOP_V1_INTERFACE
#define BANNER_DESKTOP_V1_INTERFACE
extern const struct wl_interface banner_desktop_v1_interface;
#ifndef DROIDDECK_DESKTOP_V1_INTERFACE
#define DROIDDECK_DESKTOP_V1_INTERFACE
extern const struct wl_interface droiddeck_desktop_v1_interface;
#endif
struct banner_desktop_v1_interface {
struct droiddeck_desktop_v1_interface {
void (*destroy)(struct wl_client *client,
struct wl_resource *resource);
void (*set_desktop)(struct wl_client *client,
@@ -68,10 +68,10 @@ struct banner_desktop_v1_interface {
};
#define BANNER_DESKTOP_V1_DESTROY_SINCE_VERSION 1
#define BANNER_DESKTOP_V1_SET_DESKTOP_SINCE_VERSION 1
#define BANNER_DESKTOP_V1_SET_WINDOW_SINCE_VERSION 1
#define BANNER_DESKTOP_V1_SET_ZORDER_SINCE_VERSION 1
#define DROIDDECK_DESKTOP_V1_DESTROY_SINCE_VERSION 1
#define DROIDDECK_DESKTOP_V1_SET_DESKTOP_SINCE_VERSION 1
#define DROIDDECK_DESKTOP_V1_SET_WINDOW_SINCE_VERSION 1
#define DROIDDECK_DESKTOP_V1_SET_ZORDER_SINCE_VERSION 1
#ifdef __cplusplus
}
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="banner_desktop_v1">
<protocol name="droiddeck_desktop_v1">
<copyright>
Copyright 2026 The412Banner
@@ -23,7 +23,7 @@
DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="banner_desktop_v1" version="1">
<interface name="droiddeck_desktop_v1" version="1">
<description summary="Windows virtual desktop layout">
Each Wine process is a separate Wayland client, so a Windows virtual
desktop can't be built from subsurfaces. Instead the process that owns
@@ -24,7 +24,7 @@
#include "sc_layer.h"
#include "ahb_swapchain.h"
#include "viewporter-server-protocol.h"
#include "banner-desktop-v1-server-protocol.h"
#include "droiddeck-desktop-v1-server-protocol.h"
#include "presentation-time-server-protocol.h"
#include "pointer-constraints-unstable-v1-server-protocol.h"
#include "relative-pointer-unstable-v1-server-protocol.h"
@@ -79,7 +79,7 @@ static void open_session_log(void) {
localtime_r(&now, &tm);
strftime(stamp, sizeof(stamp), "%Y-%m-%d_%H-%M-%S", &tm);
const char *given = getenv("BL_WAYLAND_LOG");
const char *given = getenv("DD_WAYLAND_LOG");
if (given && *given) {
snprintf(path, sizeof(path), "%s", given);
} else {
@@ -1796,14 +1796,14 @@ static void desktop_set_zorder(struct wl_client *c, struct wl_resource *r, struc
apply_zorder();
schedule_render();
}
static const struct banner_desktop_v1_interface desktop_impl = {
static const struct droiddeck_desktop_v1_interface desktop_impl = {
.destroy = desktop_destroy_req,
.set_desktop = desktop_set_desktop,
.set_window = desktop_set_window,
.set_zorder = desktop_set_zorder,
};
static void bind_desktop(struct wl_client *c, void *data, uint32_t ver, uint32_t id) {
struct wl_resource *r = wl_resource_create(c, &banner_desktop_v1_interface, ver, id);
struct wl_resource *r = wl_resource_create(c, &droiddeck_desktop_v1_interface, ver, id);
wl_resource_set_implementation(r, &desktop_impl, NULL, NULL);
}
@@ -4083,7 +4083,7 @@ int droiddeck_wayland_run(void) {
wl_global_create(display, &zwp_linux_dmabuf_v1_interface, 4, NULL, bind_dmabuf);
droiddeck_android_wlegl_init(display);
wl_global_create(display, &wl_seat_interface, 9, NULL, bind_seat);
wl_global_create(display, &banner_desktop_v1_interface, 1, NULL, bind_desktop);
wl_global_create(display, &droiddeck_desktop_v1_interface, 1, NULL, bind_desktop);
wl_global_create(display, &wp_presentation_interface, 2, NULL, bind_presentation);
wl_global_create(display, &zwp_pointer_constraints_v1_interface, 1, NULL, bind_pointer_constraints);
wl_global_create(display, &zwp_relative_pointer_manager_v1_interface, 1, NULL, bind_relative_pointer_manager);
@@ -45,7 +45,6 @@ class App : Application() {
CrashHandler.install(this)
com.droiddeck.launcher.input.ShortcutsRelay.Holder.install(this)
com.droiddeck.launcher.agent.AgentHost.refresh(this)
com.droiddeck.launcher.agent.AgentTab.load(this)
com.droiddeck.launcher.ui.DeveloperTools.load(this)
com.droiddeck.launcher.ui.NavTabs.load(this)
com.droiddeck.launcher.ui.AgentPet.install(this)
@@ -208,8 +208,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
private var animationsEnabled by mutableStateOf(true)
private var lowStorageWarning by mutableStateOf(true)
private var launcherIcon by mutableStateOf(LauncherIcon.DARK)
private var gameStoresEnabled by mutableStateOf(true)
private var soundtracksEnabled by mutableStateOf(true)
private var soundtracksIngame by mutableStateOf(false)
private var soundtracks by mutableStateOf<List<Library.SteamGame>>(emptyList())
private var soundtracksLoaded by mutableStateOf(false)
@@ -937,7 +935,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
val soundtrackId = com.droiddeck.launcher.frontend.SoundtrackShortcuts.read(request)
if (soundtrackId != null) {
soundtrackLaunch = true
navRequest = if (SessionPrefs.soundtracksEnabled(this)) "sound:$soundtrackId" else "app:$soundtrackId"
navRequest = if ("soundtracks" !in com.droiddeck.launcher.ui.NavTabs.hidden) "sound:$soundtrackId" else "app:$soundtrackId"
request.data = null
request.action = Intent.ACTION_MAIN
return
@@ -1245,8 +1243,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
lowStorageWarning = SessionPrefs.lowStorageWarning(this)
LauncherIcon.repair(this, intent?.component)
launcherIcon = LauncherIcon.current(this)
gameStoresEnabled = SessionPrefs.gameStoresEnabled(this)
soundtracksEnabled = SessionPrefs.soundtracksEnabled(this)
soundtracksIngame = SessionPrefs.soundtracksIngame(this)
gameStoresSpeedTier = SessionPrefs.gameStoresSpeedTier(this)
storesShowMature = SessionPrefs.storesShowMature(this)
@@ -1259,6 +1255,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
androidx.compose.runtime.LaunchedEffect(prootPack) {
if (prootPack == com.droiddeck.launcher.core.AddonPack.State.Ready && installed == null) refresh()
}
val appsTabShown = "android-apps" !in com.droiddeck.launcher.ui.NavTabs.hidden
androidx.compose.runtime.LaunchedEffect(appsTabShown) { if (appsTabShown && androidApps.isEmpty()) refreshAndroidApps() }
DroidDeckTheme(theme, appScale = appScale) {
com.droiddeck.launcher.ui.FocusGlideHost(androidx.compose.ui.Modifier.fillMaxSize().exposeTestTags()) {
if (decky.deckyPendingZip != null) com.droiddeck.launcher.ui.DeckyZipWarningDialog(
@@ -1342,8 +1340,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
animationsEnabled = animationsEnabled,
lowStorageWarning = lowStorageWarning,
launcherIcon = launcherIcon,
gameStoresEnabled = gameStoresEnabled,
soundtracksEnabled = soundtracksEnabled,
soundtracksEnabled = "soundtracks" !in com.droiddeck.launcher.ui.NavTabs.hidden,
soundtracksIngame = soundtracksIngame,
soundtracks = soundtracks,
soundtracksLoaded = soundtracksLoaded,
@@ -1619,8 +1616,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
offline = OfflineMode.enabled(this)
},
onPageBack = { showPerformance = false; showComponents = false; showMapping = false },
onGameStoresEnabled = { on -> SessionPrefs.setGameStoresEnabled(this, on); gameStoresEnabled = on },
onSoundtracksEnabled = { on -> SessionPrefs.setSoundtracksEnabled(this, on); soundtracksEnabled = on },
onSoundtracksIngame = { on ->
SessionPrefs.setSoundtracksIngame(this, on)
soundtracksIngame = on
@@ -2211,13 +2206,13 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
}
private fun refreshAndroidApps() {
if (!homeAppSelected) {
if (!homeAppSelected && "android-apps" in com.droiddeck.launcher.ui.NavTabs.hidden) {
++androidAppsListing
androidApps = emptyList()
return
}
val seq = ++androidAppsListing
HomePins.refresh(this)
if (homeAppSelected) HomePins.refresh(this)
Thread({
val apps = runCatching { HomeApp.launchableApps(this) }.getOrDefault(emptyList())
ui.post { if (seq == androidAppsListing) androidApps = apps }
@@ -3312,7 +3307,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
com.droiddeck.launcher.core.AppLanguage.setChosen(this, com.droiddeck.launcher.core.AppLanguage.SYSTEM)
if (!ok) android.widget.Toast.makeText(this, R.string.setup_reset_settings_partial, android.widget.Toast.LENGTH_LONG).show()
com.droiddeck.launcher.ui.Motion.refresh(this)
com.droiddeck.launcher.agent.AgentTab.load(this)
com.droiddeck.launcher.ui.DeveloperTools.load(this)
com.droiddeck.launcher.ui.NavTabs.load(this)
if (!switchLauncherIcon(LauncherIcon.DARK)) recreate()
@@ -2745,7 +2745,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
val waylandLog = File(SessionPaths.beginOrCurrent(this), "wayland.log")
WaylandCompositor.setSessionLogFile(waylandLog)
try {
android.system.Os.setenv("BL_WAYLAND_LOG", waylandLog.path, true)
android.system.Os.setenv("DD_WAYLAND_LOG", waylandLog.path, true)
} catch (e: Exception) {
Log.w(TAG, "could not point the compositor's log at $waylandLog", e)
}
@@ -58,7 +58,8 @@ object AgentEnv {
fun override(context: Context, name: String): JSONObject = synchronized(lock) {
AgentAccess.requireCommands(context)
if (NAME.matchEntire(name) == null || name in setOf(".", "..")) throw AgentException("INVALID_NAME", "Override names are letters, digits, '.', '_' and '-'")
if (name == "libblfastpath.so" && (SessionState.running || SessionState.guestPid > 0 || SessionState.phase == SessionPhase.STOPPING)) {
if (name == LEGACY_FAST_PATH) throw AgentException("INVALID_NAME", "The fast-path library is now $FAST_PATH")
if (name == "libddfastpath.so" && (SessionState.running || SessionState.guestPid > 0 || SessionState.phase == SessionPhase.STOPPING)) {
throw AgentException("SESSION_ACTIVE", "Stop the session before installing a fast-path library")
}
val source = File(inbox(context), name)
@@ -73,7 +74,7 @@ object AgentEnv {
staged.delete()
throw AgentException("OVERRIDE_FAILED", "Could not stage the override")
}
if (name == "libblfastpath.so" && !arm64SharedLibrary(staged)) {
if (name == "libddfastpath.so" && !arm64SharedLibrary(staged)) {
staged.delete()
throw AgentException("INVALID_LIBRARY", "The fast path must be a 64-bit little-endian ARM64 ELF shared library")
}
@@ -86,7 +87,7 @@ object AgentEnv {
state.put("pendingOverrides", JSONArray(merge(strings(state.optJSONArray("pendingOverrides")), listOf(name))))
save(context, state)
state.put("installed", "$GUEST_BIN/$name")
if (name == "libblfastpath.so") {
if (name == "libddfastpath.so") {
val digest = MessageDigest.getInstance("SHA-256")
target.inputStream().use { input ->
val buffer = ByteArray(65536)
@@ -103,10 +104,10 @@ object AgentEnv {
fun fastPathLibrary(context: Context): String = synchronized(lock) {
if (!AgentAccess.commandsAllowed(context)) return@synchronized ProotFastPath.LIBRARY
if ("libblfastpath.so" !in strings(load(context).optJSONArray("activeOverrides"))) return@synchronized ProotFastPath.LIBRARY
val file = File(bin(context), "libblfastpath.so")
if ("libddfastpath.so" !in strings(load(context).optJSONArray("activeOverrides"))) return@synchronized ProotFastPath.LIBRARY
val file = File(bin(context), "libddfastpath.so")
if (!file.isFile || Files.isSymbolicLink(file.toPath())) return@synchronized ProotFastPath.LIBRARY
"$GUEST_BIN/libblfastpath.so"
"$GUEST_BIN/libddfastpath.so"
}
private fun arm64SharedLibrary(file: File): Boolean = file.inputStream().use { input ->
@@ -129,13 +130,18 @@ object AgentEnv {
}
val state = load(context)
val active = strings(state.optJSONArray("pending"))
val overrides = strings(state.optJSONArray("pendingOverrides"))
val queued = strings(state.optJSONArray("pendingOverrides"))
val legacy = File(bin(context), LEGACY_FAST_PATH)
val stranded = FAST_PATH in queued && legacy.isFile && !File(bin(context), FAST_PATH).exists() &&
!legacy.renameTo(File(bin(context), FAST_PATH))
if (stranded) Log.w(TAG, "could not rename the queued $LEGACY_FAST_PATH; it stays queued for the next session")
val overrides = if (stranded) queued - FAST_PATH else queued
bin(context).listFiles()
?.filter { it.name !in overrides }?.forEach { it.delete() }
?.filter { it.name !in overrides && !(stranded && it.name == LEGACY_FAST_PATH) }?.forEach { it.delete() }
val lines = strings(state.optJSONArray("persistent")) + active
val withPath = if (overrides.none { it != "libblfastpath.so" }) lines else lines + "PATH=$GUEST_BIN:${pathOf(lines)}"
val withPath = if (overrides.none { it != "libddfastpath.so" }) lines else lines + "PATH=$GUEST_BIN:${pathOf(lines)}"
state.put("active", JSONArray(active)).put("pending", JSONArray())
state.put("activeOverrides", JSONArray(overrides)).put("pendingOverrides", JSONArray())
state.put("activeOverrides", JSONArray(overrides)).put("pendingOverrides", JSONArray(if (stranded) listOf(FAST_PATH) else emptyList()))
save(context, state)
if (withPath.isNotEmpty()) Log.i(TAG, "agent environment keys for this session: ${withPath.map { it.substringBefore('=') }}")
withPath
@@ -158,6 +164,9 @@ object AgentEnv {
save(context, state)
}
private const val FAST_PATH = "libddfastpath.so"
private const val LEGACY_FAST_PATH = "libblfastpath.so"
private fun pathOf(lines: List<String>) =
lines.lastOrNull { it.startsWith("PATH=") }?.substringAfter('=')?.takeIf { it.isNotBlank() } ?: LinuxRuntime.GUEST_PATH
@@ -186,6 +195,9 @@ object AgentEnv {
for (key in listOf("pending", "active", "persistent", "pendingOverrides", "activeOverrides")) {
if (!state.has(key)) state.put(key, JSONArray())
}
for (key in listOf("pendingOverrides", "activeOverrides")) {
state.put(key, JSONArray(strings(state.optJSONArray(key)).map { if (it == LEGACY_FAST_PATH) FAST_PATH else it }.distinct()))
}
return state
}
@@ -1,23 +1,9 @@
package com.droiddeck.launcher.agent
import android.content.Context
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.droiddeck.launcher.session.SessionPrefs
import com.droiddeck.launcher.ui.NavTabs
object AgentTab {
var shown by mutableStateOf(false)
private set
val shown: Boolean get() = "agent" !in NavTabs.hidden
val visible: Boolean get() = shown && AgentHost.available
fun load(context: Context) {
shown = SessionPrefs.agentTab(context)
}
fun set(context: Context, show: Boolean) {
shown = show
SessionPrefs.setAgentTab(context, show)
}
}
@@ -23,6 +23,7 @@ object GameEnvironment {
)
fun validName(name: String) = namePattern.matches(name)
fun currentName(name: String) = if (name.startsWith("BL_")) "DD_" + name.removePrefix("BL_") else name
fun supported(name: String) = name !in unused && !name.startsWith("BOX64_") && !name.startsWith("BOX86_")
fun validValue(value: String) = '\u0000' !in value && value.length <= 8192
fun validScope(scope: String) = scope.isEmpty() || (Regex("[1-9][0-9]*").matches(scope) && scope.toLongOrNull()?.let { it in 1..4294967295L } == true)
@@ -97,14 +98,14 @@ object GameEnvironment {
val syncBackends = listOf(SessionPrefs.SYNC_NTSYNC, SessionPrefs.SYNC_FSYNC, SessionPrefs.SYNC_ESYNC, SessionPrefs.SYNC_WINESERVER)
val syncKeys = listOf("BL_SYNC", "BL_FSYNC_FIRST", "BL_SYNC_FALLBACK", "PROTON_NO_ESYNC", "PROTON_NO_FSYNC", "PROTON_NO_NTSYNC", "WINEESYNC")
val syncKeys = listOf("DD_SYNC", "DD_FSYNC_FIRST", "DD_SYNC_FALLBACK", "PROTON_NO_ESYNC", "PROTON_NO_FSYNC", "PROTON_NO_NTSYNC", "WINEESYNC")
fun syncEnvironment(backend: String): Map<String, String> {
require(backend in syncBackends) { "unknown sync $backend" }
return buildMap {
put("BL_SYNC", if (backend == SessionPrefs.SYNC_NTSYNC) "1" else "0")
put("BL_FSYNC_FIRST", if (backend == SessionPrefs.SYNC_FSYNC) "1" else "0")
put("BL_SYNC_FALLBACK", if (backend == SessionPrefs.SYNC_WINESERVER) "0" else "1")
put("DD_SYNC", if (backend == SessionPrefs.SYNC_NTSYNC) "1" else "0")
put("DD_FSYNC_FIRST", if (backend == SessionPrefs.SYNC_FSYNC) "1" else "0")
put("DD_SYNC_FALLBACK", if (backend == SessionPrefs.SYNC_WINESERVER) "0" else "1")
if (backend == SessionPrefs.SYNC_FSYNC) put("PROTON_NO_ESYNC", "1")
}
}
@@ -20,7 +20,7 @@ object GameEnvironmentOptions {
Option("PROTON_NO_NTSYNC", "1", R.string.game_env_no_ntsync, Type.TOGGLE, listOf("0", "1")),
Option("PROTON_NO_ESYNC", "1", R.string.game_env_no_esync, Type.TOGGLE, listOf("0", "1")),
Option("PROTON_NO_FSYNC", "1", R.string.game_env_no_fsync, Type.TOGGLE, listOf("0", "1")),
Option("BL_FSYNC_FIRST", "1", R.string.game_env_fsync_first, Type.TOGGLE, listOf("0", "1")),
Option("DD_FSYNC_FIRST", "1", R.string.game_env_fsync_first, Type.TOGGLE, listOf("0", "1")),
Option("DXVK_HUD", "fps", R.string.game_env_hud, Type.MULTIPLE, listOf("scale=0.5", "scale=0.7", "opacity=0.5", "opacity=0.7", "devinfo", "fps", "frametimes", "submissions", "drawcalls", "pipelines", "descriptors", "memory", "gpuload", "version", "api", "cs", "compiler", "samplers")),
Option("DXVK_CONFIG", "dxvk.maxFrameRate = 60", R.string.game_env_dxvk_config, Type.TEXT),
Option("VKD3D_FRAME_RATE", "60", R.string.game_env_vkd3d_limit, Type.NUMBER),
@@ -12,7 +12,7 @@ import java.util.function.Supplier;
public final class LinuxVulkanDriver {
private static final String TAG = "LinuxVulkanDriver";
public static final String ENV = "BL_VK_DRIVER";
public static final String ENV = "DD_VK_DRIVER";
public static final String HELP_TEXT =
"The driver the Steam client, the games it launches and the desktop's programs render on, "
@@ -256,12 +256,12 @@ public final class SystemVulkanDriver {
if (xclipse) environment.add("DROIDDECK_HYBRIS_DXVK=dxvk-2.6.2");
// The Android driver has a render node, but no KMS primary node. SDL presents
// through the wrapper's Wayland Vulkan swapchain instead of a KMS-style path.
environment.add("BL_GAMESCOPE_BACKEND=sdl");
environment.add("DD_GAMESCOPE_BACKEND=sdl");
// The Android pvr kernel accepts Vulkan DMA-BUF imports but rejects PRIME GEM handles.
environment.add("BL_POWERVR_DRM_HANDLES=1");
environment.add("BL_POWERVR_RENDER_NODE=" + node);
environment.add("DD_POWERVR_DRM_HANDLES=1");
environment.add("DD_POWERVR_RENDER_NODE=" + node);
// Inner Gamescope/Xwayland lacks the bridge's Android-buffer WSI protocols.
environment.add("BL_STEAM_GL_PRESENT=1");
environment.add("DD_STEAM_GL_PRESENT=1");
// Only actual Proton game launches use the bundled DXVK and X11 WSI layer.
environment.add("DROIDDECK_POWERVR_RUNTIME=" + directory.getPath());
}
@@ -275,7 +275,7 @@ internal class GameFrameFeed(
private const val INFO_NS = 500_000_000L
private const val SHIFT_NS = 1_000_000_000L
private const val SHIFT_RECHECK_NS = 100_000_000L
private const val CLOCK_CONTROL_PATH = "tmp/.bl-clock"
private const val CLOCK_CONTROL_PATH = "tmp/.dd-clock"
fun forRoot(root: File) = GameFrameFeed(File(root, HudFrames.PATH), clockControl = File(root, CLOCK_CONTROL_PATH))
@@ -21,6 +21,10 @@ object LegacyNames {
"etc/bannerlator-network.json" to "etc/droiddeck-network.json",
"etc/bannerlator-wifi-scan-request" to "etc/droiddeck-wifi-scan-request",
)
private val RETIRED_FILES = listOf("libblsession.so", "libblfastpath.so", "libblaudit.so").map { "usr/local/lib/$it" } +
listOf("x86_64", "i386").map { "usr/local/lib/droiddeck-fex/$it/libblsession.so" }
private const val LEGACY_MARKER = ".bl-"
private val QUEUED_MARKERS = setOf(".bl-proton-extra", ".bl-steam-urls")
private val MENU_REWRITES = listOf(
Triple("usr/local/share/applications", "/usr/local/bin/bannerlator-", "/usr/local/bin/droiddeck-"),
Triple("usr/share/applications", "Exec=env APPIMAGE_EXTRACT_AND_RUN=1 /opt/appimages/",
@@ -38,6 +42,20 @@ object LegacyNames {
fun migrateRootfs(root: File) {
migrateEtc(root)
for ((old, new) in MOVED_FILES) move(File(root, old), File(root, new))
for (path in RETIRED_FILES) File(root, path).delete()
File(root, "root").listFiles { f -> f.name.startsWith(LEGACY_MARKER) }?.forEach {
val target = File(it.parentFile, ".dd-" + it.name.removePrefix(LEGACY_MARKER))
if (it.name in QUEUED_MARKERS && it.isFile && !isLink(it) && target.isFile && !isLink(target)) {
val queued = it.readText()
if (queued.isNotBlank()) {
val separator = if (target.length() > 0 && !target.readText().endsWith("\n")) "\n" else ""
target.appendText(separator + if (queued.endsWith("\n")) queued else queued + "\n")
}
FileUtils.delete(it)
} else {
move(it, target)
}
}
linkScripts(root)
rewriteMenuEntries(root)
}
@@ -9,7 +9,7 @@ import java.security.MessageDigest
object ProotFastPath {
private const val TAG = "ProotFastPath"
const val LIBRARY = "/usr/local/lib/libblfastpath.so"
const val LIBRARY = "/usr/local/lib/libddfastpath.so"
const val MAX_BINDS = 256
fun allows(preference: Boolean, noSeccomp: Boolean, source: String, nativeUserland: Boolean = false): Boolean =
@@ -315,11 +315,11 @@ object BottomDesktop {
main.post { if (generation == guestGeneration) watchIme(imeDir) }
val binds = LinuxRuntime.binds(context, current.sessionRoot, runtime, Environment.getExternalStorageDirectory(), current.binds)
val guest = ArrayList(current.guest).apply {
add("BL_WIDTH=$width")
add("BL_HEIGHT=$height")
add("BL_DEBUG_DIR=" + dir.path)
add("BL_TOP_SESSION=" + SessionState.mode)
add("BL_IME_DIR=" + imeDir.path)
add("DD_WIDTH=$width")
add("DD_HEIGHT=$height")
add("DD_DEBUG_DIR=" + dir.path)
add("DD_TOP_SESSION=" + SessionState.mode)
add("DD_IME_DIR=" + imeDir.path)
add(SCRIPT)
}
val command = if (current.nativeUserland) {
@@ -440,7 +440,7 @@ object EsyncPacks {
fun enabled(context: Context): Boolean = SessionPrefs.syncFallback(context) || try {
GameEnvironmentStore.read(context).let { config ->
(listOf(config.shared) + config.games.values).any { it["BL_SYNC_FALLBACK"] == "1" }
(listOf(config.shared) + config.games.values).any { it["DD_SYNC_FALLBACK"] == "1" }
}
} catch (t: Throwable) {
false
@@ -57,8 +57,8 @@ object FexCatalog {
}
fun environment(build: Build, sources: List<String> = DownloadSource.candidates(build.url)): List<String> = listOf(
"BL_FEX_TAG=${build.tag}",
"BL_FEX_SHA256=${build.sha256}",
"BL_FEX_URLS=" + sources.joinToString(" "),
"DD_FEX_TAG=${build.tag}",
"DD_FEX_SHA256=${build.sha256}",
"DD_FEX_URLS=" + sources.joinToString(" "),
)
}
@@ -29,7 +29,8 @@ object GameEnvironmentStore {
require(GameEnvironment.validName(name))
val entry = value.get(name)
require(entry == JSONObject.NULL || entry is String && GameEnvironment.validValue(entry))
put(name, if (entry == JSONObject.NULL) null else entry as String)
val current = GameEnvironment.currentName(name)
if (current == name || !value.has(current)) put(current, if (entry == JSONObject.NULL) null else entry as String)
}
}
val games = json.optJSONObject("games")
@@ -52,10 +53,9 @@ object GameEnvironmentStore {
@Synchronized
fun save(context: Context, config: GameEnvironment.Config) {
val json = encode(config)
decode(json)
write(File(context.filesDir, SETTINGS), json.toString())
publish(context, config)
val normalized = decode(encode(config))
write(File(context.filesDir, SETTINGS), encode(normalized).toString())
publish(context, normalized)
}
@Synchronized
@@ -34,8 +34,8 @@ object GraphicsReport {
/** The guest keys the report repeats: everything that decides which Vulkan driver loads. */
private val ENV_PREFIXES = listOf(
"VK_", "BL_VK", "BL_DRM", "BL_VKBRIDGE", "VKBRIDGE", "MESA_", "GALLIUM_", "ZINK", "TU_", "PANVK",
"DROIDDECK_POWERVR", "DROIDDECK_HYBRIS", "BL_GAME_LOGS", "LIBGL_", "GAMESCOPE_DISABLE", "XWAYLAND",
"VK_", "DD_VK", "DD_DRM", "DD_VKBRIDGE", "VKBRIDGE", "MESA_", "GALLIUM_", "ZINK", "TU_", "PANVK",
"DROIDDECK_POWERVR", "DROIDDECK_HYBRIS", "DD_GAME_LOGS", "LIBGL_", "GAMESCOPE_DISABLE", "XWAYLAND",
)
/** Per-game graphics logs and the guest's Vulkan summary: on for a non-Adreno GPU, or by Setup's switch. */
@@ -37,7 +37,7 @@ object ProtonExtras {
)
private fun home(context: Context) = File(LinuxRuntime.rootDir(context), "root")
private fun requests(context: Context) = File(home(context), ".bl-proton-extra")
private fun requests(context: Context) = File(home(context), ".dd-proton-extra")
private fun toolsDir(context: Context) = File(home(context), ".local/share/Steam/compatibilitytools.d")
private fun releasesFile(context: Context) = File(context.filesDir, "proton-extras.json")
private fun latestFile(context: Context) = File(context.filesDir, "proton-latest.json")
@@ -68,7 +68,7 @@ object QuestExperimental {
appendLine("driverMode=${SessionPrefs.gpuDriverMode(context)}")
appendLine("androidDriver=${SessionPrefs.androidDriver(context)}")
appendLine("steamSurfaceControlWorkaround=${SessionPrefs.hdr(context, "steam")}")
appendLine("GPUOBJ fallback installed in Android driver and ARM64 libblsession")
appendLine("GPUOBJ fallback installed in Android driver and ARM64 libddsession")
appendLine("Experimental Quest 2/3/3S compatibility; 2D panel application")
}
Log.i(TAG, report)
@@ -109,11 +109,11 @@ object SessionFiles {
"usr/local/bin/droiddeck-steam-compat" to "usr/local/bin/droiddeck-steam-compat",
"usr/local/bin/droiddeck-steam-taskset" to "usr/local/libexec/droiddeck-steam/taskset",
"usr/local/bin/droiddeck-fex" to "usr/local/bin/droiddeck-fex",
"libblsession.so" to "usr/local/lib/libblsession.so",
"libddsession.so" to "usr/local/lib/libddsession.so",
"libfakeinput.so" to "usr/local/lib/libfakeinput.so",
"libblfastpath.so" to "usr/local/lib/libblfastpath.so",
"libddfastpath.so" to "usr/local/lib/libddfastpath.so",
"libddnatv-hook.so" to "usr/lib/libddnatv-hook.so",
"libblaudit.so" to "usr/local/lib/libblaudit.so",
"libddaudit.so" to "usr/local/lib/libddaudit.so",
"libssbs.so" to "usr/local/lib/libssbs.so",
"usr/local/bin/droiddeck-session" to "usr/local/bin/droiddeck-session",
"usr/local/bin/droiddeck-fonts" to "usr/local/bin/droiddeck-fonts",
@@ -238,7 +238,7 @@ object SessionFiles {
"usr/local/lib/droiddeck-gpuload/VK_LAYER_DROIDDECK_vram_cap.json" to "usr/share/vulkan/implicit_layer.d/droiddeck_vram_cap.json",
)
val fexPreloads = listOf("x86_64", "i386").flatMap { arch ->
listOf("libblsession.so", "libfakeinput.so", "libfaultreport.so").map { "$arch/$it" to "usr/local/lib/droiddeck-fex/$arch/$it" }
listOf("libddsession.so", "libfakeinput.so", "libfaultreport.so").map { "$arch/$it" to "usr/local/lib/droiddeck-fex/$arch/$it" }
} + listOf("libvulkan-thunk.so", "libwebkitinput.so").map { "x86_64/$it" to "usr/local/lib/droiddeck-fex/x86_64/$it" }
// The Mali compatibility layer (tools/venus/layer, David Cimo): an implicit Vulkan layer that
// fills in the features DXVK requires and Mali lacks. Idle outside Wine and on GPUs that have them.
@@ -315,7 +315,7 @@ object SessionFiles {
for (pack in SERVICE_PACKS.keys) stageStoreService(context, root, pack, ledger)
ledger.save()
for (old in arrayOf("aarch64-unix", "aarch64-windows", "i386-windows")) File(root, "$DIRECTAUDIO_DIR/lib/wine/$old").deleteRecursively()
val preload = StringBuilder("/usr/local/lib/libblsession.so\n")
val preload = StringBuilder("/usr/local/lib/libddsession.so\n")
if (!File(Environment.getExternalStorageDirectory(), NO_PAD_SWITCH).exists()) {
preload.append("/usr/local/lib/libfakeinput.so\n")
}
@@ -203,18 +203,6 @@ object SessionPrefs {
prefs(context).edit().putBoolean("androidTextFieldKeyboard", on).apply()
}
fun gameStoresEnabled(context: Context): Boolean = prefs(context).getBoolean("gameStoresEnabled", true)
fun setGameStoresEnabled(context: Context, on: Boolean) {
prefs(context).edit().putBoolean("gameStoresEnabled", on).apply()
}
fun soundtracksEnabled(context: Context): Boolean = prefs(context).getBoolean("soundtracksEnabled", true)
fun setSoundtracksEnabled(context: Context, on: Boolean) {
prefs(context).edit().putBoolean("soundtracksEnabled", on).apply()
}
fun soundtracksIngame(context: Context): Boolean = prefs(context).getBoolean("soundtracksIngame", false)
fun setSoundtracksIngame(context: Context, on: Boolean) {
@@ -273,14 +261,8 @@ object SessionPrefs {
prefs(context).edit().putBoolean("railLabels", show).apply()
}
fun agentTab(context: Context): Boolean = prefs(context).getBoolean("agentTab", false)
fun setAgentTab(context: Context, show: Boolean) {
prefs(context).edit().putBoolean("agentTab", show).apply()
}
fun developerTools(context: Context): Boolean =
prefs(context).getBoolean("developerTools", agentTab(context) || com.droiddeck.launcher.agent.AgentAccess.commandsEnabled(context))
prefs(context).getBoolean("developerTools", com.droiddeck.launcher.agent.AgentAccess.commandsEnabled(context))
fun setDeveloperTools(context: Context, on: Boolean) {
prefs(context).edit().putBoolean("developerTools", on).apply()
@@ -342,13 +324,35 @@ object SessionPrefs {
prefs(context).edit().putString("navTabOrder", order.joinToString(",")).apply()
}
fun navTabShelved(context: Context): Set<String> = idList(prefs(context).getString("navTabShelved", "soundtracks,agent,storage,sync")).toSet()
fun navTabShelved(context: Context): Set<String>? = prefs(context).getString("navTabShelved", null)?.let { idList(it).toSet() }
fun setNavTabShelved(context: Context, keys: Set<String>) {
prefs(context).edit().putString("navTabShelved", keys.joinToString(",")).apply()
}
fun navTabHidden(context: Context): Set<String> = idList(prefs(context).getString("navTabHidden", null)).toSet()
fun navTabHidden(context: Context): Set<String>? = prefs(context).getString("navTabHidden", null)?.let { idList(it).toSet() }
fun navTabLayoutVersion(context: Context): Int = prefs(context).getInt("navTabLayout", 0)
class LegacyTabSwitches(val touched: Boolean, val stores: Boolean, val soundtracks: Boolean, val agent: Boolean)
fun legacyTabSwitches(context: Context): LegacyTabSwitches {
val p = prefs(context)
val keys = listOf("navTabOrder", "navTabShelved", "navTabHidden", "gameStoresEnabled", "soundtracksEnabled", "agentTab")
return LegacyTabSwitches(
touched = keys.any { p.contains(it) },
stores = p.getBoolean("gameStoresEnabled", true),
soundtracks = p.getBoolean("soundtracksEnabled", true),
agent = p.getBoolean("agentTab", false) && p.getBoolean("developerTools", true),
)
}
fun finishTabSwitchMigration(context: Context, version: Int) {
val p = prefs(context)
val e = p.edit()
if (!p.contains("developerTools") && p.getBoolean("agentTab", false)) e.putBoolean("developerTools", true)
e.remove("gameStoresEnabled").remove("soundtracksEnabled").remove("agentTab").putInt("navTabLayout", version).apply()
}
fun setNavTabHidden(context: Context, keys: Set<String>) {
prefs(context).edit().putString("navTabHidden", keys.joinToString(",")).apply()
@@ -694,7 +698,7 @@ object SessionPrefs {
}
private fun shaderPrecacheApplied(context: Context) =
java.io.File(com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context), "root/.bl-shader-precache-applied")
java.io.File(com.droiddeck.launcher.runtime.LinuxRuntime.rootDir(context), "root/.dd-shader-precache-applied")
fun pendingShaderPrecache(context: Context): Boolean? {
val prefs = prefs(context)
@@ -612,7 +612,7 @@ class SessionService : Service() {
stopSession(-1, gen)
return
}
if (steamHere) guest.add("BL_EPIC_APP_ID=" + com.droiddeck.launcher.stores.epic.EpicClient.shortcutAppId)
if (steamHere) guest.add("DD_EPIC_APP_ID=" + com.droiddeck.launcher.stores.epic.EpicClient.shortcutAppId)
val fastPathAt = guest.size
val pulse = SessionEvents.step("audio") { startAudio(guest, sessionDir, directAudioPack) }
@@ -624,36 +624,36 @@ class SessionService : Service() {
val encoder = VideoEncodeBridge(File(filesDir, "venc/venc.sock"))
encoder.attach(this)
components.add(encoder)
guest.add("BL_VENC_SOCKET=" + encoder.socket.absolutePath)
guest.add("DD_VENC_SOCKET=" + encoder.socket.absolutePath)
}
com.droiddeck.launcher.gpu.ClockLogComponent(File(sessionDir, "clocks.log")).let {
it.attach(this)
components.add(it)
}
guest.add("BL_WIDTH=" + size.first)
guest.add("BL_HEIGHT=" + size.second)
guest.add("DD_WIDTH=" + size.first)
guest.add("DD_HEIGHT=" + size.second)
if (noSteamGame()) runCatching {
val scope = NoSteamLaunch.scopeOf(SessionState.program, SessionState.programArgs) { NoSteamLaunch.battleNetTitleScope(this, it) }
NoSteamLaunch.resolution(GameEnvironmentStore.read(this), scope, size)
}.onFailure { Log.w(TAG, "game resolution", it) }.getOrNull()?.let { (w, h) ->
guest.add("BL_GAME_WIDTH=$w")
guest.add("BL_GAME_HEIGHT=$h")
guest.add("DD_GAME_WIDTH=$w")
guest.add("DD_GAME_HEIGHT=$h")
Log.i(TAG, "game resolution: ${w}x$h on a ${size.first}x${size.second} output")
}
if (SessionState.followScreen || size.first < size.second ||
SessionPrefs.orientation(this) == android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER)
guest.add("BL_FOLLOW_OUTPUT=1")
guest.add("DD_FOLLOW_OUTPUT=1")
if (SessionState.hdr) {
guest.add("BL_HDR=1")
guest.add("DD_HDR=1")
guest.add("DXVK_HDR=1")
Log.i(TAG, "hdr: gamescope --hdr-enabled, DXVK_HDR=1")
}
guest.add("DROIDDECK_WSI_BYPASS_CHECK_MS=100")
guest.add("WINE_OFFSCREEN_CHECK_MS=100")
guest.add("BL_REFRESH=" + Math.round(SessionState.refreshHz))
guest.add("BL_LOG=" + sessionLog.path)
guest.add("BL_DEBUG_DIR=" + sessionDir.path)
guest.add("DD_REFRESH=" + Math.round(SessionState.refreshHz))
guest.add("DD_LOG=" + sessionLog.path)
guest.add("DD_DEBUG_DIR=" + sessionDir.path)
if (EnhancedDiagnostics.isActive(this, sessionDir)) guest.add("DROIDDECK_ENHANCED_DIAGNOSTICS=1")
val fakeInputDir = File(sessionRoot, "dev/input").apply { mkdirs() }
@@ -666,7 +666,7 @@ class SessionService : Service() {
SessionEvents.step("controller-sync") { SessionState.padBridge?.syncConnectedControllers() }
}
val noSteamGame = noSteamGame()
if (noSteamGame) guest.add("BL_PIN_CORES=0")
if (noSteamGame) guest.add("DD_PIN_CORES=0")
if ((steamHere || SessionState.program == NoSteamLaunch.EPIC) && com.droiddeck.launcher.stores.epic.EpicClient.read(this).installed) {
runCatching { SessionEvents.step("epic-library") { com.droiddeck.launcher.stores.epic.EpicClientLibrary.sync(this) } }
.onFailure { Log.w(TAG, "Epic library sync failed", it) }
@@ -676,17 +676,19 @@ class SessionService : Service() {
if (steamHere || noSteamGame) {
val added = SessionEvents.step("added-games-scan") { com.droiddeck.launcher.frontend.AddedGames.scan(this) }
val listing = SessionEvents.step("added-games-listing") { com.droiddeck.launcher.frontend.AddedGames.writeListing(this, added) }
guest.add("BL_ADDED_GAMES=" + listing.path)
if (OfflineMode.enabled(this)) guest.add("BL_STEAM_OFFLINE=1")
if (com.droiddeck.launcher.gpu.Lossless.owned(this)) guest.add("BL_LOSSLESS_OWNED=1")
guest.add("DD_ADDED_GAMES=" + listing.path)
if (OfflineMode.enabled(this)) guest.add("DD_STEAM_OFFLINE=1")
if (com.droiddeck.launcher.gpu.Lossless.owned(this)) guest.add("DD_LOSSLESS_OWNED=1")
if (added.isNotEmpty()) Log.i(TAG, "added games: " + added.joinToString { "${it.name} (${it.exe.name})" })
}
guest.add("DD_LAUNCH_DIR=" + sessionRoot.path)
// Proton builds up to 11.12 report X11 text fields under this name.
guest.add("BL_LAUNCH_DIR=" + sessionRoot.path)
GameStorage.effective(this)?.let { guest.add("BL_LIBRARY_LABEL=" + it.label.replace('"', ' ')) }
if (SessionState.mode == MODE_STEAM && SessionState.steamUi == "desktop") guest.add("BL_STEAM_UI=desktop")
GameStorage.effective(this)?.let { guest.add("DD_LIBRARY_LABEL=" + it.label.replace('"', ' ')) }
if (SessionState.mode == MODE_STEAM && SessionState.steamUi == "desktop") guest.add("DD_STEAM_UI=desktop")
// Detailed graphics logs: per-game logs and the guest's Vulkan summary (a GPU that is not
// an Adreno, or Setup's switch), and graphics-report.txt for every session.
if (GraphicsReport.detailed(this)) guest.add("BL_GAME_LOGS=1")
if (GraphicsReport.detailed(this)) guest.add("DD_GAME_LOGS=1")
SessionEvents.step("graphics-report") { GraphicsReport.begin(this, sessionDir, guest) }
val shellGuest = ArrayList(guest).apply {
add("SHELL=/bin/bash")
@@ -873,8 +875,8 @@ class SessionService : Service() {
if (!pulse.setSinkSuspended(false)) Log.w(TAG, "could not resume audio sink")
if (!pulse.setMicSuspended(false)) Log.w(TAG, "could not resume microphone source")
},
zramControl = File(filesDir, "${LinuxRuntime.DIR}/tmp/.bl-zram"),
clockControl = File(filesDir, "${LinuxRuntime.DIR}/tmp/.bl-clock"),
zramControl = File(filesDir, "${LinuxRuntime.DIR}/tmp/.dd-zram"),
clockControl = File(filesDir, "${LinuxRuntime.DIR}/tmp/.dd-clock"),
mapClockControl = { WaylandCompositor.nativeSetClockControl(it.path) },
pagedOut = { processes, unacknowledged, residentKb, swapKb, swapBeforeKb, millis ->
Log.i(TAG, "paged out $processes processes ($unacknowledged unacknowledged) in $millis ms: " +
@@ -943,16 +945,16 @@ class SessionService : Service() {
} else {
guest.add("LANG=C.UTF-8")
}
guest.add("BL_STEAM_LANGUAGE=" + SteamLanguage.forLocale(
guest.add("DD_STEAM_LANGUAGE=" + SteamLanguage.forLocale(
com.droiddeck.launcher.core.AppLanguage.effective(this),
com.droiddeck.launcher.core.AppLanguage.system(this).country,
))
guest.add("TZ=" + java.util.TimeZone.getDefault().id)
if (SessionState.mode == MODE_STEAM) SessionPrefs.pendingShaderPrecache(this)?.let { guest.add("BL_SHADER_PRECACHE=" + if (it) "1" else "0") }
if (SessionState.mode == MODE_STEAM) SessionPrefs.pendingShaderPrecache(this)?.let { guest.add("DD_SHADER_PRECACHE=" + if (it) "1" else "0") }
guest.add("XDG_RUNTIME_DIR=" + LinuxRuntime.GUEST_RUNTIME_DIR)
guest.add("XDG_SESSION_TYPE=wayland")
guest.add("WAYLAND_DISPLAY=wayland-0")
guest.add("BL_ANDROID_CLIPBOARD=" + File(filesDir, "session/android-clipboard").path)
guest.add("DD_ANDROID_CLIPBOARD=" + File(filesDir, "session/android-clipboard").path)
guest.add("GAMESCOPE_FORCE_GENERAL_QUEUE=1")
guest.add("MESA_LOADER_DRIVER_OVERRIDE=zink")
guest.add("GALLIUM_DRIVER=zink")
@@ -981,7 +983,7 @@ class SessionService : Service() {
guest.add("XWAYLAND_NO_GLAMOR=1")
Log.w(TAG, "xwayland: the last session's Xwayland crashed; glamor off for this one (XWAYLAND_NO_GLAMOR=1)")
}
if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) guest.add("BL_RAISE_NOFILE=1")
if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) guest.add("DD_RAISE_NOFILE=1")
if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) {
val kernel = System.getProperty("os.version").orEmpty()
val old = kernelBefore(kernel, 6, 6)
@@ -995,11 +997,11 @@ class SessionService : Service() {
if (SessionPrefs.steamGpuCompositing(this)) {
Log.i(TAG, "steam: GPU web compositing (Setup's \"Steam interface: GPU drawing\")")
} else {
guest.add("BL_STEAM_SOFT_COMPOSITING=1")
guest.add("DD_STEAM_SOFT_COMPOSITING=1")
Log.i(TAG, "steam: software web compositing for the open driver pair (GPU raster kept)")
}
guest.add("BL_OPEN_DRIVER=1")
LinuxRuntime.gpuStandIn(this)?.takeIf { it == LinuxRuntime.MALI_DEVICE }?.let { guest.add("BL_DRM_STANDIN=$it") }
guest.add("DD_OPEN_DRIVER=1")
LinuxRuntime.gpuStandIn(this)?.takeIf { it == LinuxRuntime.MALI_DEVICE }?.let { guest.add("DD_DRM_STANDIN=$it") }
}
val tuOverride = tuDebugOverride()
val tuDriver = sysmemDriver(linuxDriverId)
@@ -1013,10 +1015,10 @@ class SessionService : Service() {
guest.add("MESA_DISK_CACHE_DATABASE=1")
guest.addAll(GpuStatsComponent.guestEnv(LinuxRuntime.rootDir(this)))
guest.add("GLIBC_TUNABLES=glibc.pthread.rseq=0:glibc.malloc.top_pad=16777216")
if (SessionState.mode == MODE_STEAM) guest.add("BL_MANGOAPP=" + (if (SessionPrefs.mangoapp(this)) "1" else "0"))
if (SessionState.mode == MODE_STEAM) guest.add("DD_MANGOAPP=" + (if (SessionPrefs.mangoapp(this)) "1" else "0"))
SessionState.steamClientArch = if (steamHere) SessionPrefs.steamClientArch(this) else null
SessionState.steamClientArch?.let { arch ->
guest.add("BL_STEAM_CLIENT_ARCH=$arch")
guest.add("DD_STEAM_CLIENT_ARCH=$arch")
SessionPaths.current()?.let {
SessionArtifacts.recordClient(it, arch)
SessionArtifacts.markSteamLogs(it, File(SessionPrefs.steamRoot(this, arch), "logs"))
@@ -1024,23 +1026,23 @@ class SessionService : Service() {
}
FexCatalog.cached(this)?.let { guest.addAll(FexCatalog.environment(it)) }
if (SessionState.mode == MODE_STEAM) {
guest.add("BL_GAMESCOPE_STRETCH_16X9=" + (if (SessionPrefs.stretch16x9(this)) "1" else "0"))
guest.add("DD_GAMESCOPE_STRETCH_16X9=" + (if (SessionPrefs.stretch16x9(this)) "1" else "0"))
}
if (SessionPrefs.noXalia(this)) guest.add("PROTON_USE_XALIA=0")
guest.add("BL_SYNC=" + (if (SessionPrefs.fastSync(this)) "1" else "0"))
guest.add("BL_SYNC_FALLBACK=" + (if (SessionPrefs.syncFallback(this)) "1" else "0"))
guest.add("BL_FSYNC_FIRST=" + (if (SessionPrefs.fsyncFirst(this)) "1" else "0"))
guest.add("BL_PACE_CORES=" + (if (SessionPrefs.paceCores(this)) "1" else "0"))
guest.add("BL_GAMESCOPE_REALTIME=" + (if (SessionPrefs.gamescopeRealtime(this)) "1" else "0"))
if (SessionPrefs.cursorComposite(this)) guest.add("BL_CURSOR_COMPOSITE=1")
guest.add("DD_SYNC=" + (if (SessionPrefs.fastSync(this)) "1" else "0"))
guest.add("DD_SYNC_FALLBACK=" + (if (SessionPrefs.syncFallback(this)) "1" else "0"))
guest.add("DD_FSYNC_FIRST=" + (if (SessionPrefs.fsyncFirst(this)) "1" else "0"))
guest.add("DD_PACE_CORES=" + (if (SessionPrefs.paceCores(this)) "1" else "0"))
guest.add("DD_GAMESCOPE_REALTIME=" + (if (SessionPrefs.gamescopeRealtime(this)) "1" else "0"))
if (SessionPrefs.cursorComposite(this)) guest.add("DD_CURSOR_COMPOSITE=1")
relativeMouseForSession().takeIf { it != 0 }?.let { guest.add("gamescope_relative_mouse=$it") }
if (com.droiddeck.launcher.core.ZramSupport.supported()) {
guest.add("BL_ZRAM=1")
if (steamHere) SessionPrefs.ramCapMb(this).takeIf { it > 0 }?.let { guest.add("BL_RAM_CAP_MB=$it") }
if (!SessionPrefs.zramClient(this)) guest.add("BL_ZRAM_CLIENT=0")
if (!SessionPrefs.zramIdle(this)) guest.add("BL_ZRAM_IDLE=0")
guest.add("DD_ZRAM=1")
if (steamHere) SessionPrefs.ramCapMb(this).takeIf { it > 0 }?.let { guest.add("DD_RAM_CAP_MB=$it") }
if (!SessionPrefs.zramClient(this)) guest.add("DD_ZRAM_CLIENT=0")
if (!SessionPrefs.zramIdle(this)) guest.add("DD_ZRAM_IDLE=0")
}
SessionPrefs.vramCapMb(this).takeIf { it > 0 }?.let { guest.add("BL_VRAM_MB=$it") }
SessionPrefs.vramCapMb(this).takeIf { it > 0 }?.let { guest.add("DD_VRAM_MB=$it") }
guest.add("AUDIO_DIRECT_DECAY=0")
val extra = extraEnv() + agentEnvironment
guest.addAll(TurnipEnvironment.gameEnvironment(tuOverride, tuDriver, SessionPrefs.tuSysmem(this), extra))
@@ -1049,10 +1051,10 @@ class SessionService : Service() {
com.droiddeck.launcher.gpu.TpUbwcHint.forThisDevice(this)?.let { guest.add("${com.droiddeck.launcher.gpu.TpUbwcHint.ENV}=$it") }
val clientPinned = steamHere && SessionPrefs.clientCpusOverride(this)
if (clientPinned) {
guest.add("BL_CLIENT_CPUS=" + CpuCores.listOrAll(SessionPrefs.clientCpus(this)))
guest.add("DD_CLIENT_CPUS=" + CpuCores.listOrAll(SessionPrefs.clientCpus(this)))
}
CpuCores.gameLaunchList(SessionPrefs.gameCpus(this), clientPinned)
.takeIf { it.isNotEmpty() }?.let { guest.add("BL_GAME_CPUS=$it") }
.takeIf { it.isNotEmpty() }?.let { guest.add("DD_GAME_CPUS=$it") }
}
private fun startVkBridge(guest: MutableList<String>, sessionDir: File) {
@@ -1061,16 +1063,16 @@ class SessionService : Service() {
val bridge = com.droiddeck.launcher.gpu.VkBridgeComponent(socket, File(sessionDir, "vkbridge-server.log"))
bridge.attach(this)
components.add(bridge)
guest.add("BL_VKBRIDGE=1")
if (SessionPrefs.steamGpuCompositing(this)) guest.add("BL_STEAM_GPU_COMPOSITING=1")
guest.add("DD_VKBRIDGE=1")
if (SessionPrefs.steamGpuCompositing(this)) guest.add("DD_STEAM_GPU_COMPOSITING=1")
SessionPrefs.linuxDriver(this).takeIf { it.isNotEmpty() }
?.let { runCatching { LinuxVulkanDriver.resolveIcdPath(this, it) }.getOrNull() }
?.let { guest.add("BL_VKBRIDGE_FALLBACK_ICD=$it") }
?.let { guest.add("DD_VKBRIDGE_FALLBACK_ICD=$it") }
guest.add("VKBRIDGE_SOCKET=" + socket.path)
guest.add("VKBRIDGE_CLIENT_LOG=" + File(sessionDir, "vkbridge-client.log").path)
guest.add("VKBRIDGE_MODE=" + SessionPrefs.vkBridgeMode(this))
LinuxRuntime.gpuStandIn(this)?.let { node ->
guest.add("BL_DRM_STANDIN=$node")
guest.add("DD_DRM_STANDIN=$node")
LinuxRuntime.deviceNumbers(node)?.let { guest.add("VKBRIDGE_DRM_RENDER=$it") }
}
Log.i(TAG, "vkbridge: on (${com.droiddeck.launcher.core.DeviceSupport.gpuName(this)}, ${SessionPrefs.vkBridgeMode(this)} mode), socket $socket")
@@ -1084,7 +1086,7 @@ class SessionService : Service() {
SessionPrefs.directAudio(this)
val wantsMic = SessionPrefs.micEnabled(this) &&
checkSelfPermission(android.Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED
guest.add("BL_MIC_ENABLED=" + if (wantsMic) "1" else "0")
guest.add("DD_MIC_ENABLED=" + if (wantsMic) "1" else "0")
guest.add("AUDIO_DIRECT_MIC=" + if (wantsMic) "1" else "0")
val audioDir = File(filesDir, "directaudio").apply { mkdirs() }
val relaySocket = File(audioDir, "relay.sock")
@@ -1112,7 +1114,7 @@ class SessionService : Service() {
components.add(relay)
}
if (wantsDirectAudio) {
guest.add("BL_DIRECTAUDIO=/" + SessionFiles.DIRECTAUDIO_DIR)
guest.add("DD_DIRECTAUDIO=/" + SessionFiles.DIRECTAUDIO_DIR)
guest.add("AUDIO_DIRECT_RELAY=" + relaySocket.absolutePath)
val lowLatency = com.droiddeck.launcher.audio.DirectAudioTiming.lowLatencyOutput()
val timing = com.droiddeck.launcher.audio.DirectAudioTiming.environment(lowLatency)
@@ -1268,9 +1270,9 @@ class SessionService : Service() {
)
if (device != null) {
val envAt = guest.indexOf(LinuxRuntime.SESSION_SCRIPT).takeIf { it >= 0 } ?: guest.size
guest.add(envAt, "BL_STORAGE_DIAGNOSTICS=1")
guest.add(envAt + 1, "BL_STORAGE_DEVICE=$device")
guest.add(envAt + 2, "BL_STORAGE_LOG=${File(sessionDir, "storage.log").absolutePath}")
guest.add(envAt, "DD_STORAGE_DIAGNOSTICS=1")
guest.add(envAt + 1, "DD_STORAGE_DEVICE=$device")
guest.add(envAt + 2, "DD_STORAGE_LOG=${File(sessionDir, "storage.log").absolutePath}")
} else {
Log.w(TAG, "storage diagnostics: selected library could not be identified; metadata snapshot only")
}
@@ -1415,7 +1417,7 @@ class SessionService : Service() {
val listing = File(filesDir, "session/steam-libraries-x64.json").apply { parentFile?.mkdirs() }
listing.writeText(x64Libraries.toString())
val envAt = guest.indexOf(LinuxRuntime.SESSION_SCRIPT).takeIf { it >= 0 } ?: guest.size
guest.add(envAt, "BL_X64_STEAM_LIBRARIES=" + listing.path)
guest.add(envAt, "DD_X64_STEAM_LIBRARIES=" + listing.path)
} catch (e: Exception) {
Log.w(TAG, "x86-64 steam library: the list could not be written; internal storage alone this session", e)
}
@@ -1425,7 +1427,7 @@ class SessionService : Service() {
for ((path, label) in libraries) json.put(org.json.JSONObject().put("path", path).put("label", label.replace('"', ' ').replace('\\', ' ')))
listing.writeText(json.toString())
val envAt = guest.indexOf(LinuxRuntime.SESSION_SCRIPT).takeIf { it >= 0 } ?: guest.size
guest.add(envAt, "BL_STEAM_LIBRARIES=" + listing.path)
guest.add(envAt, "DD_STEAM_LIBRARIES=" + listing.path)
} catch (e: Exception) {
Log.w(TAG, "steam library: the list could not be written; the card alone this session", e)
}
@@ -1446,7 +1448,7 @@ class SessionService : Service() {
}
listing.writeText(volumes.toString())
val envAt = guest.indexOf(LinuxRuntime.SESSION_SCRIPT).takeIf { it >= 0 } ?: guest.size
guest.add(envAt, "BL_DESKTOP_VOLUMES=" + listing.path)
guest.add(envAt, "DD_DESKTOP_VOLUMES=" + listing.path)
} catch (e: Exception) {
Log.w(TAG, "desktop volumes: the list could not be written", e)
}
@@ -286,7 +286,7 @@ internal class SessionSuspendController(
}
val targets = records.values.filter { record ->
try {
File(procRoot, "${record.pid}/maps").useLines { lines -> lines.any { it.endsWith("/libblsession.so") } }
File(procRoot, "${record.pid}/maps").useLines { lines -> lines.any { it.endsWith("/libddsession.so") } }
} catch (_: IOException) {
false
}
@@ -14,11 +14,11 @@ object SettingsReset {
internal val SESSION_KEYS = setOf(
"orientation", "launcherFullscreen", "animations", "lowStorageWarning", "theme", "runSteamAtStartup", "startupSession", "addedGamesArt",
"dualScreenMode", "dualScreenSessionMode", "dualScreenLauncher", "dualScreenSessionControls", "androidTextFieldKeyboard",
"gameStoresEnabled", "soundtracksEnabled", "soundtracksIngame", "gameStoresSpeedTier", "gameStoresParallel", "storesOpenTab", "storesShowMature",
"soundtracksIngame", "gameStoresSpeedTier", "gameStoresParallel", "storesOpenTab", "storesShowMature",
"storesInstallLanguage",
"hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "__KEEP_droidDeckHud__", "__KEEP_droidDeckHudPos__", "backHold", "backActionsInverted", "backDoubleTapMs", "touch", "pen", "penButton", "osc", "shape", "steamController",
"gamepadLeft", "gamepadRight", "pipAutoEnter", "unfoldedControls", "unfoldedControlsWithController",
"stretch16x9", "picturePosition", "integerScaling", "railLabels", "agentTab", "navTabOrder", "navTabShelved", "navTabHidden", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
"stretch16x9", "picturePosition", "integerScaling", "railLabels", "navTabOrder", "navTabShelved", "navTabHidden", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
"gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop",
"tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "paceCores", "ramCapMb", "vramCapMb", "zramClient", "zramIdle",
"directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus",
@@ -115,7 +115,7 @@ internal class SteamDownloadMonitor {
val steam = File(home, ".local/share/Steam")
val stamped = File(steam, "package/droiddeck-installed").isFile ||
File(steam, "package/bannerlator-installed").isFile
return !(stamped && File(steam, "steamrtarm64/steam").isFile) || File(home, ".bl-steam-repair").exists()
return !(stamped && File(steam, "steamrtarm64/steam").isFile) || File(home, ".dd-steam-repair").exists()
}
internal fun manifests(runtimeRoot: File, mounts: Map<String, File>): List<File> {
@@ -6,7 +6,7 @@ import java.io.File
object SteamRepair {
private fun home(context: Context) = File(LinuxRuntime.rootDir(context), "root")
private fun request(context: Context) = File(home(context), ".bl-steam-repair")
private fun request(context: Context) = File(home(context), ".dd-steam-repair")
private fun unconfirmed(context: Context) = File(home(context), ".local/share/Steam/package/droiddeck-unconfirmed")
private fun x64Unconfirmed(context: Context) = File(home(context), ".droiddeck-x64/.local/share/Steam/package/droiddeck-unconfirmed")
@@ -102,7 +102,7 @@ class VenusComponent(private val logFile: File?) : SessionPart() {
// (Steam's GL, Xwayland's glamor) requires robustness2's nullDescriptor, which the
// layer stands in for. The session script checks it and falls back to llvmpipe.
"DROIDDECK_MALI_COMPAT=1",
"BL_VENUS=1",
"DD_VENUS=1",
// gamescope's composite layout without immutable YCbCr samplers from the start
// (patch 0930): a Mali-G615 refused every composite pipeline with them, and testing
// that through Venus took the render server down.
@@ -27,13 +27,20 @@ object StoreSizes {
fun size(item: CatalogItem): Long = known[item.key] ?: item.sizeBytes
private val NO_REMOTE_SIZE = setOf(Store.GOG, Store.XBOX, Store.BATTLENET, Store.UBISOFT, Store.ROCKSTAR)
private val settled = mutableStateMapOf<String, Boolean>()
// A size that can still arrive this session: not known yet, the store can report one, and no lookup came back empty.
fun coming(item: CatalogItem): Boolean =
item.accessible && item.sizeBytes <= 0 && item.store !in NO_REMOTE_SIZE && !known.containsKey(item.key) && settled[item.key] != true
private val caches = ConcurrentHashMap<Store, SizeCache>()
private fun cache(context: Context, store: Store) = caches.getOrPut(store) { SizeCache.forStore(context.applicationContext.filesDir, store) }
fun request(context: Context, item: CatalogItem) {
if (!item.accessible || item.sizeBytes > 0 || item.store == Store.GOG || known.containsKey(item.key)) return
resolve(context, item).thenAccept { bytes ->
if (bytes != null) StoresState.post { known[item.key] = bytes }
resolve(context, item).whenComplete { bytes, _ ->
StoresState.post { if (bytes != null && bytes > 0) known[item.key] = bytes else settled[item.key] = true }
}
}
@@ -26,6 +26,7 @@ import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Brush
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.luminance
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.input.pointer.pointerInput
import androidx.compose.ui.layout.onGloballyPositioned
@@ -76,6 +77,7 @@ internal fun CardDetailHost(
var leaving by remember { mutableStateOf(false) }
var from by remember { mutableStateOf<Origin?>(null) }
var art by remember { mutableStateOf<String?>(null) }
var hero by remember { mutableStateOf<String?>(null) }
var viewportAt by remember { mutableStateOf(Offset.Zero) }
var viewportH by remember { mutableStateOf(0) }
LaunchedEffect(open) {
@@ -83,6 +85,7 @@ internal fun CardDetailHost(
val mark = StoresMotion.takeCard(open)
from = mark?.let { Origin(it.bounds.translate(-viewportAt), it.corner) }
art = mark?.art
hero = mark?.hero
StoresMotion.heroLands = mark != null
leaving = false
shown = open
@@ -152,7 +155,12 @@ internal fun CardDetailHost(
},
)
}
PageFlood(origin, leaving, painter, onto = { StoresMotion.heroAt }, ontoCorner = 16.dp) { body() }
val light = androidx.compose.material3.MaterialTheme.colorScheme.background.luminance() > 0.5f
val heroPainter = hero?.takeIf { it != art }?.let { url ->
coil.compose.rememberAsyncImagePainter(remember(url) { coil.request.ImageRequest.Builder(ctx).data(url).size(1280, 720).placeholderMemoryCacheKey(url).build() })
} ?: painter
val look = HeroLook(rememberArtBrightness(hero ?: art), light, androidx.compose.material3.MaterialTheme.colorScheme.background)
PageFlood(origin, leaving, painter, onto = { StoresMotion.heroAt }, ontoCorner = 0.dp, ontoLook = look, ontoArt = heroPainter) { body() }
}
}
}
@@ -1,5 +1,7 @@
package com.droiddeck.launcher.ui
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material.icons.Icons
import android.app.ActivityOptions
import android.content.Context
import android.content.Intent
@@ -363,7 +365,8 @@ internal fun DualPanelContent(model: DualPanelModel) {
private fun PanelTile(key: String, current: Boolean, badge: Boolean, count: Int, modifier: Modifier, onClick: () -> Unit) {
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
val (label, icon) = railLabelIcon(key)
val (label, base) = railLabelIcon(key)
val icon = if (key == NavTabs.MORE && MoreTabs.inside) Icons.AutoMirrored.Outlined.ArrowBack else base
val shape = RoundedCornerShape(18.dp)
Box(
modifier.fillMaxSize().clip(shape)
@@ -373,7 +376,7 @@ private fun PanelTile(key: String, current: Boolean, badge: Boolean, count: Int,
contentAlignment = Alignment.Center,
) {
Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(8.dp)) {
Icon(icon, contentDescription = null, tint = if (current) pal.signal else colors.onSurfaceVariant, modifier = Modifier.size(34.dp))
androidx.compose.animation.Crossfade(icon, animationSpec = Motion.tw(220), label = "panelIcon") { Icon(it, contentDescription = null, tint = if (current) pal.signal else colors.onSurfaceVariant, modifier = Modifier.size(34.dp)) }
Text(stringResource(label), fontSize = 15.sp, fontWeight = FontWeight.SemiBold,
color = if (current) pal.signal else colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis,
modifier = Modifier.padding(horizontal = 6.dp))
@@ -302,7 +302,7 @@ private fun Content(
AgentPage(modifier.padding(horizontal = padH).padding(top = padV))
return
}
if (selected == "android-apps" && s.isHomeApp) {
if (selected == "android-apps") {
AndroidAppsPage(s, a, modifier, onAndroidAppClick)
return
}
@@ -1,5 +1,6 @@
package com.droiddeck.launcher.ui
import androidx.compose.material.icons.outlined.Sync
import androidx.compose.ui.platform.testTag
import com.droiddeck.launcher.R
import androidx.compose.ui.res.stringResource
@@ -41,11 +42,12 @@ import androidx.compose.runtime.getValue
@Composable
internal fun GameFileFolderActions(s: FrontEndState, a: FrontEndActions) {
internal fun GameFileFolderActions(s: FrontEndState, a: FrontEndActions, labeled: Boolean = false) {
if (s.shortcutPicker) return
var open by remember { androidx.compose.runtime.mutableStateOf(false) }
Box {
SecondaryButton(stringResource(R.string.game_frontend_files), compact = true) { open = !open }
if (labeled) SecondaryButton(stringResource(R.string.game_frontend_files), compact = true) { open = !open }
else HeaderIconButton(stringResource(R.string.game_frontend_files), androidx.compose.material.icons.Icons.Outlined.Sync, "frontend-files") { open = !open }
AnchoredMenu(open, onDismiss = { open = false }, title = s.gameSyncFolder ?: stringResource(R.string.game_frontend_files)) { first ->
MenuItem(stringResource(R.string.game_file_sync), checked = false, focusRequester = first) {
open = false; a.onSyncGameFiles()
@@ -55,6 +55,7 @@ import androidx.compose.material.icons.outlined.DesktopWindows
import androidx.compose.material.icons.outlined.Layers
import androidx.compose.material.icons.outlined.LocalMall
import androidx.compose.material.icons.outlined.MoreHoriz
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
import androidx.compose.material.icons.outlined.SportsEsports
import androidx.compose.material.icons.outlined.Storefront
import androidx.compose.material.icons.outlined.SystemUpdate
@@ -237,7 +238,8 @@ private fun NavigationItems(
val setupNeedsAttention = setupNeedsAttention(s)
val downloadsAt = if ("downloads" in NavTabs.more(s)) NavTabs.MORE else "downloads"
for (key in navigationKeys(s)) {
val (label, icon) = railLabelIcon(key)
val (label, base) = railLabelIcon(key)
val icon = if (key == NavTabs.MORE && MoreTabs.inside) Icons.AutoMirrored.Outlined.ArrowBack else base
key(key) {
RailItem(stringResource(label), icon, key, shown == key, compact, iconOnly, height, width,
badge = railBadge(s, key, setupNeedsAttention),
@@ -299,9 +301,9 @@ private fun RailItem(
.selectable(selected = current, interactionSource = src, indication = LocalIndication.current, role = Role.Tab, onClick = onClick)
.then(if (iconOnly) Modifier.semantics { contentDescription = label } else Modifier),
) {
if (iconOnly) Icon(icon, contentDescription = null, tint = fg, modifier = Modifier.size(22.dp))
if (iconOnly) androidx.compose.animation.Crossfade(icon, animationSpec = Motion.tw(220), label = "railIcon") { Icon(it, contentDescription = null, tint = fg, modifier = Modifier.size(22.dp)) }
else Column(horizontalAlignment = Alignment.CenterHorizontally, verticalArrangement = Arrangement.spacedBy(3.dp)) {
Icon(icon, contentDescription = null, tint = fg, modifier = Modifier.size(if (height < 56.dp) 20.dp else 22.dp))
androidx.compose.animation.Crossfade(icon, animationSpec = Motion.tw(220), label = "railIcon") { Icon(it, contentDescription = null, tint = fg, modifier = Modifier.size(if (height < 56.dp) 20.dp else 22.dp)) }
FitText(label, maxSize = 12.sp, modifier = Modifier.padding(horizontal = 4.dp), fontWeight = FontWeight.SemiBold, color = fg)
}
if (badge) Box(
@@ -181,7 +181,6 @@ class FrontEndState(
val animationsEnabled: Boolean = true,
val lowStorageWarning: Boolean = true,
val launcherIcon: String = com.droiddeck.launcher.LauncherIcon.DARK,
val gameStoresEnabled: Boolean = true,
val soundtracksEnabled: Boolean = true,
val soundtracksIngame: Boolean = false,
val soundtracks: List<Library.SteamGame> = emptyList(),
@@ -290,8 +289,6 @@ class FrontEndActions(
val onDownloadMirror: (String) -> Unit = {},
val onDownloadPrefix: (String) -> Unit = {},
val onDownloadProxy: (String) -> Unit = {},
val onGameStoresEnabled: (Boolean) -> Unit = {},
val onSoundtracksEnabled: (Boolean) -> Unit = {},
val onSoundtracksIngame: (Boolean) -> Unit = {},
val onSoundtrackAdded: (java.io.File) -> Unit = {},
val onSoundtracksChanged: () -> Unit = {},
@@ -594,7 +591,6 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com
BackHandler(enabled = !processSettingsPageVisible && backToMore) {
selected = NavTabs.MORE
}
LaunchedEffect(s.isHomeApp) { if (!s.isHomeApp && selected == "android-apps") selected = "steam" }
LaunchedEffect(s.soundtracksEnabled) {
if (!s.soundtracksEnabled && (selected == "soundtracks" || selected.startsWith("sound:"))) selected = "games"
}
@@ -616,6 +612,7 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com
else -> s.pageKey ?: selected
}
val railSelection = if (openTab in NavTabs.more(s)) NavTabs.MORE else openTab
androidx.compose.runtime.SideEffect { MoreTabs.inside = railSelection == NavTabs.MORE && openTab != NavTabs.MORE }
val railSelectionNow = androidx.compose.runtime.rememberUpdatedState(railSelection)
var railPicks by remember { mutableStateOf(0) }
val showRailPage: (String, Boolean) -> Unit = { key, focusContent ->
@@ -236,12 +236,10 @@ internal fun SetupPanel(
),
) {
PageHeader(stringResource(R.string.setup_title)) {
Box(Modifier.weight(1f)) { SheetChips(tabs, tab, chipFocus, onPick = pick) }
if (!searching) SearchIcon(stringResource(R.string.settings_search)) { searching = true }
}
if (searching) {
androidx.activity.compose.BackHandler { searching = false; query = "" }
SettingsSearchField(query, { query = it }) { searching = false; query = "" }
SettingsPillSearch(
Modifier.weight(1f), searching, query, { query = it },
onOpen = { searching = true }, onClose = { searching = false; query = "" },
) { SheetChips(tabs, tab, chipFocus, onPick = pick) }
}
val listing = searching && query.isNotBlank()
val fixed = tab == CONTROLLER_TAB && !listing
@@ -1,5 +1,6 @@
package com.droiddeck.launcher.ui
import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.LocalIndication
import androidx.compose.ui.semantics.Role
import androidx.compose.runtime.CompositionLocalProvider
@@ -216,7 +217,6 @@ internal fun GameDetail(
}
val art: Any? = game?.hero ?: item?.imageUrl ?: installed?.sidecar?.hero ?: installed?.sidecar?.cover
val artModel: Any? = if (art is String) cardArtRequest(art, item?.tallImageUrl) else art
val inSteam = !s.shortcutPicker && source != Library.SOURCE_STEAM && (game != null || installed != null) && !(game?.library == Library.XBOX_CLOUD && installed == null)
val inset = LocalDetailInset.current
GameBackdrop(artModel, art ?: game?.art, hueOf(title), fadeTop = inset.top < 8.dp, onArtPlaced = { StoresMotion.heroAt = it }) {
Column(Modifier.fillMaxWidth().padding(horizontal = inset.horizontal).padding(top = inset.top).onFocusChanged { inPage = it.hasFocus }.bumpers(onPrevious = { cycle(-1) }, onNext = { cycle(1) })) {
@@ -236,8 +236,9 @@ internal fun GameDetail(
}
val header: @Composable () -> Unit = {
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
GameStatusLine(source, game, item, installed, download?.location ?: failed?.location, inSteam)
Spacer(Modifier.height(if (narrow) 8.dp else 20.dp))
GameTitle(title, game?.logo ?: item?.logoUrl, if (narrow) 30.sp else 40.sp)
GameStatusLine(source, game, item, installed, download?.location ?: failed?.location)
if (!failed?.error.isNullOrBlank()) Text(
failed!!.error!!, fontSize = 13.sp, lineHeight = 17.sp, fontWeight = FontWeight.Medium,
color = MaterialTheme.colorScheme.error, maxLines = 3, overflow = TextOverflow.Ellipsis,
@@ -296,16 +297,16 @@ internal fun SourceBadge(source: String) {
}
@Composable
private fun GameStatusLine(source: String, game: Library.SteamGame?, item: CatalogItem?, installed: InstalledStoreGame?, downloadAt: String?, inSteam: Boolean) {
private fun GameStatusLine(source: String, game: Library.SteamGame?, item: CatalogItem?, installed: InstalledStoreGame?, downloadAt: String?) {
val ctx = LocalContext.current
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
val folder = installed?.folder ?: game?.gameFiles
val passName = item?.includedWith.orEmpty()
val state = when {
installed != null -> listOf(stringResource(R.string.stores_eyebrow_installed), StoreInstallRoot.labelFor(ctx, installed.folder))
installed != null -> listOf(StoreInstallRoot.labelFor(ctx, installed.folder))
game?.library == Library.XBOX_CLOUD -> listOf(libraryLabel(game))
game != null -> listOf(stringResource(R.string.stores_eyebrow_installed), libraryLabel(game))
game != null -> listOf(libraryLabel(game))
!downloadAt.isNullOrBlank() -> listOf(stringResource(R.string.stores_eyebrow_library), downloadAt)
item?.owned == true -> listOf(stringResource(R.string.stores_eyebrow_library))
item?.subscription == true -> listOf(passName.ifBlank { stringResource(R.string.stores_game_pass) })
@@ -314,19 +315,26 @@ private fun GameStatusLine(source: String, game: Library.SteamGame?, item: Catal
else -> listOf(stringResource(R.string.stores_eyebrow_store))
}
val size = if (folder != null && (installed != null || game != null)) diskSize(installed, folder) else catalogSize(item).takeIf { it > 0 }
val line = (state + listOfNotNull(size?.let { formatBytes(it) })).filter { it.isNotBlank() }.joinToString(" · ").replaceFirstChar { it.uppercase() }
val muted = colors.onBackground.copy(alpha = 0.78f)
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(10.dp)) {
val where = state.filter { it.isNotBlank() }.joinToString(" · ").replaceFirstChar { it.uppercase() }
Row(
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp),
modifier = Modifier.horizontalScroll(androidx.compose.foundation.rememberScrollState()),
) {
SourceBadge(source)
Text(line, fontSize = 12.sp, color = muted, maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f, fill = false))
if (inSteam) {
Text("·", fontSize = 12.sp, color = muted.copy(alpha = 0.5f))
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(5.dp)) {
Icon(Icons.Outlined.VideogameAsset, contentDescription = null, tint = muted, modifier = Modifier.size(15.dp))
Text(stringResource(R.string.stores_in_steam_label), fontSize = 12.sp, color = muted, maxLines = 1)
Icon(Icons.Filled.Check, contentDescription = null, tint = pal.good, modifier = Modifier.size(14.dp))
}
}
if (where.isNotBlank()) StatusChip(where)
if (size != null) StatusChip(formatBytes(size))
}
}
@Composable
private fun StatusChip(text: String, icon: androidx.compose.ui.graphics.vector.ImageVector? = null, tint: Color? = null) {
val colors = MaterialTheme.colorScheme
Row(
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp),
modifier = Modifier.glass(CircleShape, 0.06f).padding(horizontal = 10.dp, vertical = 4.dp),
) {
if (icon != null) Icon(icon, contentDescription = null, tint = tint ?: colors.onBackground.copy(alpha = 0.85f), modifier = Modifier.size(13.dp))
Text(text, fontSize = 11.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground.copy(alpha = 0.9f), maxLines = 1)
}
}
@@ -384,7 +392,7 @@ private fun GameTitle(title: String, logo: Any?, titleSize: TextUnit) {
if (logo != null && !failed) AsyncImage(
model = logo, contentDescription = title, contentScale = ContentScale.Fit, alignment = Alignment.CenterStart,
onError = { failed = true },
modifier = Modifier.padding(vertical = 4.dp).height((titleSize.value * 1.5f).dp).widthIn(max = (titleSize.value * 7f).dp).clip(RoundedCornerShape(10.dp)).testTag("game-logo"),
modifier = Modifier.padding(vertical = 4.dp).height((titleSize.value * 2.3f).dp).widthIn(max = (titleSize.value * 10f).dp).clip(RoundedCornerShape(10.dp)).testTag("game-logo"),
) else Text(
title, fontSize = titleSize, lineHeight = titleSize * 1.12f, fontWeight = FontWeight.Black,
color = MaterialTheme.colorScheme.onBackground, maxLines = 2, overflow = TextOverflow.Ellipsis,
@@ -1055,6 +1063,15 @@ internal fun diskSize(installed: InstalledStoreGame?, folder: File): Long? {
internal object FolderSizes {
val known = androidx.compose.runtime.mutableStateMapOf<String, Long>()
private val asked = java.util.Collections.synchronizedSet(HashSet<String>())
private var saved: android.content.SharedPreferences? = null
// The last walk of each folder shows at once after a restart; a fresh walk still replaces it.
fun load(context: android.content.Context) {
if (saved != null) return
val p = context.applicationContext.getSharedPreferences("folder_sizes", android.content.Context.MODE_PRIVATE)
saved = p
p.all.forEach { (path, bytes) -> if (bytes is Long && path !in known) known[path] = bytes }
}
fun request(folder: File) {
if (!asked.add(folder.path)) return
@@ -1069,7 +1086,10 @@ internal object FolderSizes {
override fun visitFileFailed(file: java.nio.file.Path, exc: java.io.IOException): java.nio.file.FileVisitResult = java.nio.file.FileVisitResult.CONTINUE
})
}.isSuccess
if (walked) StoresState.post { known[folder.path] = total } else asked.remove(folder.path)
if (walked) {
saved?.edit()?.putLong(folder.path, total)?.apply()
StoresState.post { known[folder.path] = total }
} else asked.remove(folder.path)
}, "folder-size").start()
}
}
@@ -1,5 +1,6 @@
package com.droiddeck.launcher.ui
import androidx.compose.animation.core.animateFloat
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Box
@@ -117,7 +118,7 @@ private fun ambientRequest(ctx: android.content.Context, model: Any?): ImageRequ
private const val AmbientPixels = 6
@Composable
private fun rememberArtBrightness(model: Any?): Float {
internal fun rememberArtBrightness(model: Any?): Float {
val ctx = LocalContext.current
val data = (model as? ImageRequest)?.data ?: model
val brightness by produceState(0.3f, data) {
@@ -189,8 +190,9 @@ internal fun GameBackdrop(
private fun ArtLayer(model: Any?, sample: Any?, fadeTop: Boolean, blur: androidx.compose.ui.unit.Dp, onPlaced: (androidx.compose.ui.geometry.Rect?) -> Unit) {
val colors = MaterialTheme.colorScheme
val light = colors.background.luminance() > 0.5f
val pale = ((rememberArtBrightness(sample) - 0.28f) / 0.5f).coerceIn(0f, 1f)
val dim = if (light) 1f else 1f - 0.4f * pale
val look = HeroLook(rememberArtBrightness(sample), light, colors.background)
val dim = look.dim
val pale = look.pale
val artFilter = remember(dim) { ColorFilter.colorMatrix(ColorMatrix(floatArrayOf(dim, 0f, 0f, 0f, 0f, 0f, dim, 0f, 0f, 0f, 0f, 0f, dim, 0f, 0f, 0f, 0f, 0f, 1f, 0f))) }
BoxWithConstraints(Modifier.fillMaxWidth()) {
val height = (maxWidth * 0.4f).coerceIn(ArtMin, ArtMax)
@@ -206,24 +208,33 @@ private fun ArtLayer(model: Any?, sample: Any?, fadeTop: Boolean, blur: androidx
if (fadeTop) drawRect(Brush.verticalGradient(0f to Color.Transparent, (24.dp.toPx() / size.height) to Color.Black), blendMode = BlendMode.DstIn)
},
) {
// A slow push-in and drift, centred where the crop leans, that starts from rest so a card flight lands on the same frame.
val drift = if (Motion.scale == 0f) null else androidx.compose.animation.core.rememberInfiniteTransition(label = "heroDrift").animateFloat(
0f, 1f,
androidx.compose.animation.core.infiniteRepeatable(
androidx.compose.animation.core.tween(18_000, easing = androidx.compose.animation.core.EaseInOutSine),
androidx.compose.animation.core.RepeatMode.Reverse,
),
label = "heroDriftT",
)
AsyncImage(
model = model, contentDescription = null, contentScale = ContentScale.Crop,
alignment = BiasAlignment(0.45f, -0.35f),
colorFilter = artFilter,
modifier = Modifier.matchParentSize().then(if (blur > 0.dp) Modifier.blur(blur) else Modifier),
modifier = Modifier.matchParentSize()
.graphicsLayer {
val t = drift?.value ?: 0f
val zoom = 1f + 0.16f * t
scaleX = zoom
scaleY = zoom
translationX = -size.width * 0.05f * t
translationY = size.height * 0.03f * t
transformOrigin = androidx.compose.ui.graphics.TransformOrigin(0.72f, 0.33f)
}
.then(if (blur > 0.dp) Modifier.blur(blur) else Modifier),
)
Box(
Modifier.matchParentSize().drawBehind {
drawRect(colors.background.copy(alpha = if (light) 0.1f else 0.12f + 0.3f * pale))
drawRect(
Brush.radialGradient(
0f to colors.background.copy(alpha = if (light) 0.5f else 0.66f),
0.55f to colors.background.copy(alpha = if (light) 0.2f else 0.3f),
1f to Color.Transparent,
center = Offset(size.width * 0.22f, size.height * 0.55f), radius = size.width * 0.55f,
),
)
},
Modifier.matchParentSize().drawBehind { with(look) { shade(size, 1f) } },
)
}
}
@@ -265,3 +276,21 @@ internal fun Modifier.glass(shape: Shape, lift: Float = 0f): Modifier {
}
.border(1.dp, rim, shape)
}
internal class HeroLook(brightness: Float, val light: Boolean, val background: Color) {
val pale = ((brightness - 0.28f) / 0.5f).coerceIn(0f, 1f)
val dim = if (light) 1f else 1f - 0.4f * pale
fun androidx.compose.ui.graphics.drawscope.DrawScope.shade(size: androidx.compose.ui.geometry.Size, strength: Float) {
drawRect(background.copy(alpha = (if (light) 0.1f else 0.12f + 0.3f * pale) * strength), size = size)
drawRect(
Brush.radialGradient(
0f to background.copy(alpha = (if (light) 0.5f else 0.66f) * strength),
0.55f to background.copy(alpha = (if (light) 0.2f else 0.3f) * strength),
1f to Color.Transparent,
center = Offset(size.width * 0.22f, size.height * 0.55f), radius = size.width * 0.55f,
),
size = size,
)
}
}
@@ -0,0 +1,171 @@
package com.droiddeck.launcher.ui
import androidx.compose.foundation.LocalIndication
import androidx.compose.foundation.background
import androidx.compose.foundation.basicMarquee
import androidx.compose.foundation.clickable
import androidx.compose.foundation.hoverable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material3.Icon
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.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.layout.LayoutCoordinates
import androidx.compose.ui.layout.boundsInRoot
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.text.font.FontWeight
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.stores.Store
import com.droiddeck.launcher.stores.StoresState
@Composable
internal fun StoreAccountsButton() {
val ctx = LocalContext.current
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
val placed = remember { arrayOfNulls<LayoutCoordinates>(1) }
var itchKey by remember { mutableStateOf(false) }
val home = { placed[0]?.takeIf { it.isAttached }?.boundsInRoot() }
if (itchKey) ItchKeyDialog { itchKey = false }
val src = remember { MutableInteractionSource() }
val hot = rememberHot(src)
val label = stringResource(R.string.library_accounts)
val open = {
placed[0]?.takeIf { it.isAttached }?.boundsInRoot()?.let { at ->
Steps.ask(StepAsk(
anchor = at, side = StepSide.Left, accent = pal.signal, items = storesWithSignIn().size + 1, pillCorner = 20.dp, maxWidth = 380.dp,
handle = { Icon(Icons.Filled.Add, null, tint = pal.signal, modifier = Modifier.size(20.dp)) },
) {
StoreAccountsStep(onSignIn = { store, row ->
Steps.fold()
when {
store == Store.ITCH -> itchKey = true
row == null || Motion.scale == 0f || StoresMotion.signIn != null -> StoresState.signIn(ctx, store)
else -> {
val accent = storePalette(pal, store).signal
StoresMotion.signIn = SignInFlood(store, row, accent, sourceColours(store.id).dot, home = home())
}
}
})
})
}
Unit
}
Box(Modifier.onGloballyPositioned { placed[0] = it }) {
Box(
contentAlignment = Alignment.Center,
modifier = Modifier.paneItem("libchip:accounts").testTag("library-accounts").size(40.dp).clip(CircleShape)
.background(colors.surface)
.glideBorder(hot, CircleShape, pal.signal, pal.line)
.hoverable(src)
.clickable(interactionSource = src, indication = LocalIndication.current, role = Role.Button, onClickLabel = label, onClick = open)
.controllerConfirm(onClick = open),
) { Icon(Icons.Filled.Add, label, tint = if (hot) colors.onBackground else colors.onSurfaceVariant, modifier = Modifier.size(20.dp)) }
}
}
private fun storesWithSignIn(): List<Store> = Store.entries.filter { StoresState.backend(it) != null }
@Composable
private fun StepOutScope.StoreAccountsStep(onSignIn: (Store, androidx.compose.ui.geometry.Rect?) -> Unit) {
val ctx = LocalContext.current
val colors = MaterialTheme.colorScheme
var leaving by remember { mutableStateOf<Store?>(null) }
LaunchedEffect(leaving) { if (leaving != null) focusSoon { first } }
val out = leaving
if (out == null) {
StepTitle(stringResource(R.string.library_accounts))
Column(Modifier.fillMaxWidth().heightIn(max = (maxHeight - 72.dp).coerceAtLeast(120.dp)).verticalScroll(rememberScrollState())) {
storesWithSignIn().forEachIndexed { i, store ->
val name = StoresState.accounts[store]
val at = remember { arrayOfNulls<LayoutCoordinates>(1) }
StoreTheme(store) {
AccountRow(
store, name,
modifier = Modifier.stepItem(1 + i).then(if (i == 0) Modifier.focusRequester(first) else Modifier)
.onGloballyPositioned { at[0] = it },
enabled = open,
) { if (name != null) leaving = store else onSignIn(store, at[0]?.takeIf { it.isAttached }?.boundsInRoot()) }
}
}
}
} else {
StepTitle(stringResource(R.string.stores_signout_title, out.label))
Text(stringResource(R.string.stores_signout_note), fontSize = 13.sp, color = colors.onSurfaceVariant, modifier = Modifier.stepItem(1).padding(start = 4.dp, bottom = 12.dp))
Row(horizontalArrangement = Arrangement.spacedBy(8.dp, Alignment.End), modifier = Modifier.fillMaxWidth().stepItem(2)) {
StepChoice(stringResource(R.string.stores_signout_stay), enabled = open, modifier = Modifier.focusRequester(first)) { leaving = null }
StepChoice(stringResource(R.string.stores_signout_go), danger = true, enabled = open) {
Steps.fold()
StoresState.signOut(ctx, out)
}
}
}
}
@OptIn(androidx.compose.foundation.ExperimentalFoundationApi::class)
@Composable
private fun AccountRow(store: Store, account: String?, modifier: Modifier, enabled: Boolean, onClick: () -> Unit) {
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
val src = remember { MutableInteractionSource() }
val hot = rememberHot(src)
val shape = RoundedCornerShape(20.dp)
val signedIn = account != null
val accent = pal.signal
Row(
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp),
modifier = modifier.fillMaxWidth().heightIn(min = 44.dp).clip(shape)
.background(if (hot) accent.copy(alpha = 0.16f) else Color.Transparent)
.glideBorder(hot, shape, accent, Color.Transparent)
.hoverable(src)
.clickable(interactionSource = src, indication = LocalIndication.current, enabled = enabled, role = Role.Button, onClick = onClick)
.controllerConfirm(enabled = enabled, onClick = onClick)
.testTag("account-${store.id}")
.padding(horizontal = 16.dp),
) {
Box(Modifier.size(10.dp).background(sourceColours(store.id).dot.copy(alpha = if (signedIn) 1f else 0.45f), CircleShape))
Row(Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
Text(store.label, fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground, maxLines = 1, softWrap = false)
if (account != null) Text(
account, fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = 1, softWrap = false,
modifier = Modifier.weight(1f, fill = false).basicMarquee(iterations = Int.MAX_VALUE, initialDelayMillis = 1_200),
)
}
Text(
stringResource(if (signedIn) R.string.library_account_sign_out else R.string.library_account_sign_in),
fontSize = 13.sp, fontWeight = FontWeight.SemiBold, color = if (signedIn) (if (hot) colors.error else colors.onSurfaceVariant) else if (hot) accent else colors.onBackground, maxLines = 1,
)
}
}
@@ -226,10 +226,11 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
val inputMode = androidx.compose.ui.platform.LocalInputModeManager.current
LaunchedEffect(Unit) { StoresState.refresh(ctx) }
remember { LibraryDisplay.load(ctx) }
remember { FolderSizes.load(ctx) }
remember { LibraryFavorites.load(ctx) }
val soundMode = selected == "soundtracks" || selected.startsWith("sound:")
val favorites = if (soundMode) emptySet() else LibraryFavorites.keys
val stores = s.gameStoresEnabled && !s.shortcutPicker && !soundMode
val stores = !s.shortcutPicker && !soundMode
val signedIn = Store.entries.filter { StoresState.isSignedIn(it) }
LaunchedEffect(stores, signedIn) { if (stores) signedIn.forEach { StoresState.loadLibrary(ctx, it) } }
val owned = if (stores) signedIn.associateWith { StoresState.library[it].orEmpty() } else emptyMap()
@@ -345,7 +346,13 @@ internal fun LibraryPage(s: FrontEndState, a: FrontEndActions, selected: String,
}
var sizesWaited by remember(sizeSort) { mutableStateOf(false) }
LaunchedEffect(sizeSort) { if (sizeSort) { kotlinx.coroutines.delay(8_000); sizesWaited = true } }
val sizesPending = sizeSort && !sizesWaited && candidates.any { sizeOf(it) == null }
fun sizeComing(e: LibraryEntry): Boolean = when {
e.storeKey != null && e.storeKey in installedStore -> true
e.game?.gameFiles != null -> true
e.item != null -> StoreSizes.coming(e.item)
else -> false
}
val sizesPending = sizeSort && !sizesWaited && candidates.any { sizeOf(it) == null && sizeComing(it) }
val sorted = sortGames(
candidates, sort, title = { it.title }, releaseDate = { it.item?.releaseDate.orEmpty() },
lastPlayed = { e -> entryTime(e.game?.lastPlayed, e.storeKey?.let { lastPlayed[it] }) },
@@ -476,7 +483,7 @@ private fun LibraryEmpty(s: FrontEndState, a: FrontEndActions, modifier: Modifie
PrimaryButton(stringResource(R.string.games_play_steam), enabled = !s.busy, main = true, icon = Icons.Filled.PlayArrow, modifier = Modifier.padding(top = 12.dp).testTag("play-steam"), onClick = a.onPlay)
}
}
Box(Modifier.padding(top = 12.dp)) { GameFileFolderActions(s, a) }
Box(Modifier.padding(top = 12.dp)) { GameFileFolderActions(s, a, labeled = true) }
}
}
@@ -545,7 +552,7 @@ private fun LibraryGrid(
Rise(0) { LibraryHeader(s, a, total, searchCleared, source == Store.XBOX.id, showUninstalled, onShowUninstalled, collections = Store.byId(source)?.takeIf { it == Store.ITCH || it == Store.GAMEJOLT }, soundMode = soundMode, onAddSoundtrack = onAddSoundtrack, onCollections = onCollections) }
}
item(key = "filters", span = { GridItemSpan(maxLineSpan) }) {
Rise(1) { LibraryFilters(sources, source, onSource) }
Rise(1) { LibraryFilters(sources, source, onSource, accounts = !soundMode && !s.shortcutPicker) }
}
for ((store, line) in syncing) item(key = "sync-${store.id}", span = { GridItemSpan(maxLineSpan) }) {
Column(verticalArrangement = Arrangement.spacedBy(4.dp), modifier = Modifier.fillMaxWidth()) {
@@ -668,14 +675,14 @@ private fun LibraryHeader(
}
@Composable
private fun LibraryFilters(sources: List<String>, source: String, onSource: (String) -> Unit) {
if (sources.size < 2) return
private fun LibraryFilters(sources: List<String>, source: String, onSource: (String) -> Unit, accounts: Boolean) {
if (sources.size < 2 && !accounts) return
Row(
horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically,
modifier = Modifier.fillMaxWidth().padding(top = 4.dp, bottom = 2.dp).horizontalScroll(rememberScrollState()),
) {
SourceFilterChip(LIBRARY_ALL, stringResource(R.string.stores_tab_all), source == LIBRARY_ALL, dot = null) { onSource(LIBRARY_ALL) }
for (src in sources) {
if (sources.size >= 2) SourceFilterChip(LIBRARY_ALL, stringResource(R.string.stores_tab_all), source == LIBRARY_ALL, dot = null) { onSource(LIBRARY_ALL) }
if (sources.size >= 2) for (src in sources) {
val store = Store.byId(src)
val dot = when {
store != null -> sourceColours(src).dot.copy(alpha = if (StoresState.isSignedIn(store) && StoresState.expired[store] != true) 1f else 0.35f)
@@ -693,6 +700,7 @@ private fun LibraryFilters(sources: List<String>, source: String, onSource: (Str
source == src, dot,
) { onSource(src) }
}
if (accounts) StoreAccountsButton()
}
}
@@ -739,7 +747,9 @@ private fun LibraryTile(e: LibraryEntry, capsule: Boolean, first: Boolean, navig
RequestSize(e)
val open = {
val art = if (capsule) tall else wide
placed[0]?.takeIf { it.isAttached }?.let { StoresMotion.markCard(CardMark(e.key, it.boundsInRoot(), corner, (art as? java.io.File)?.path ?: art as? String)) }
placed[0]?.takeIf { it.isAttached }?.let {
StoresMotion.markCard(CardMark(e.key, it.boundsInRoot(), corner, (art as? java.io.File)?.path ?: art as? String, (wide as? java.io.File)?.path ?: wide as? String))
}
onOpen(e.key)
}
Column(
@@ -5,7 +5,6 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.droiddeck.launcher.agent.AgentHost
import com.droiddeck.launcher.agent.AgentTab
import com.droiddeck.launcher.session.SessionPrefs
internal enum class TabPlace { BAR, MORE, HIDDEN }
@@ -26,9 +25,13 @@ internal object DeveloperTools {
internal object NavTabs {
const val MORE = "more"
val FEATURES = setOf("stores", "soundtracks", "agent")
val ALL = listOf("steam", "games", "soundtracks", "stores", "downloads", "desktop", "agent", "components", "android-apps", "storage", "sync", "setup", "updates", "trinkets")
private val SHELVED_WHEN_NEW = setOf("storage", "sync")
val ALL = listOf("steam", "desktop", "games", "downloads", "setup", "updates", "trinkets", "stores", "soundtracks", "components", "storage", "sync", "android-apps", "agent")
val DEFAULT_SHELVED = setOf("stores", "soundtracks", "components", "storage", "sync", "android-apps", "agent")
val DEFAULT_HIDDEN = setOf("android-apps", "agent")
private val SHELVED_WHEN_NEW = setOf("storage", "sync", "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
var order by mutableStateOf(ALL)
private set
@@ -38,11 +41,41 @@ internal object NavTabs {
private set
fun load(context: Context) {
migrate(context)
val saved = SessionPrefs.navTabOrder(context)
order = arrange(saved)
shelved = SessionPrefs.navTabShelved(context).intersect(ALL.toSet()) +
shelved = (SessionPrefs.navTabShelved(context) ?: DEFAULT_SHELVED).intersect(ALL.toSet()) +
if (saved.isEmpty()) emptySet() else SHELVED_WHEN_NEW - saved.toSet()
hidden = SessionPrefs.navTabHidden(context).intersect(ALL.toSet()) - FEATURES - "setup"
hidden = (SessionPrefs.navTabHidden(context) ?: DEFAULT_HIDDEN).intersect(ALL.toSet()) - "setup"
}
fun reset(context: Context) {
order = ALL
shelved = DEFAULT_SHELVED
hidden = DEFAULT_HIDDEN
SessionPrefs.setNavTabOrder(context, order)
SessionPrefs.setNavTabShelved(context, shelved)
SessionPrefs.setNavTabHidden(context, hidden)
}
fun isDefault(): Boolean = order == ALL && shelved == DEFAULT_SHELVED && hidden == DEFAULT_HIDDEN
// Before layout 2, switches for game stores, soundtracks and the agent tab, and the home-screen requirement for Apps,
// decided which tabs existed. A layout someone had already touched keeps showing what it showed then.
private fun migrate(context: Context) {
if (SessionPrefs.navTabLayoutVersion(context) >= LAYOUT_VERSION) return
val legacy = SessionPrefs.legacyTabSwitches(context)
if (legacy.touched) {
if (SessionPrefs.navTabOrder(context).isEmpty()) SessionPrefs.setNavTabOrder(context, OLD_ORDER)
if (SessionPrefs.navTabShelved(context) == null) SessionPrefs.setNavTabShelved(context, OLD_SHELVED)
val hide = (SessionPrefs.navTabHidden(context) ?: emptySet()).toMutableSet()
if (!legacy.stores) hide += setOf("stores", "downloads")
if (!legacy.soundtracks) hide += "soundtracks"
if (!legacy.agent) hide += "agent"
if (!com.droiddeck.launcher.HomeApp.isHomeScreenEnabled(context) || !com.droiddeck.launcher.HomeApp.isDefault(context)) hide += "android-apps"
SessionPrefs.setNavTabHidden(context, hide)
}
SessionPrefs.finishTabSwitchMigration(context, LAYOUT_VERSION)
}
fun arrange(saved: List<String>): List<String> {
@@ -57,26 +90,18 @@ internal object NavTabs {
}
fun available(s: FrontEndState, key: String): Boolean = when (key) {
"android-apps" -> s.isHomeApp
"agent" -> AgentHost.available && DeveloperTools.on
"agent" -> AgentHost.available
else -> true
}
fun hideable(key: String) = key != "setup"
fun place(s: FrontEndState, key: String): TabPlace = when {
featureOff(s, key) || key in hidden -> TabPlace.HIDDEN
key in hidden -> TabPlace.HIDDEN
key in shelved -> TabPlace.MORE
else -> TabPlace.BAR
}
private fun featureOff(s: FrontEndState, key: String) = when (key) {
"stores", "downloads" -> !s.gameStoresEnabled
"soundtracks" -> !s.soundtracksEnabled
"agent" -> !AgentTab.shown
else -> false
}
fun listed(s: FrontEndState) = order.filter { available(s, it) }
fun more(s: FrontEndState) = listed(s).filter { place(s, it) == TabPlace.MORE }
@@ -87,7 +112,7 @@ internal object NavTabs {
}
fun setHidden(context: Context, key: String, hide: Boolean) {
hidden = if (hide && hideable(key) && key !in FEATURES) hidden + key else hidden - key
hidden = if (hide && hideable(key)) hidden + key else hidden - key
SessionPrefs.setNavTabHidden(context, hidden)
}
@@ -84,6 +84,8 @@ internal fun PageFlood(
sinks: Boolean = false,
onto: (() -> Rect?)? = null,
ontoCorner: androidx.compose.ui.unit.Dp = 0.dp,
ontoLook: HeroLook? = null,
ontoArt: Painter? = null,
content: @Composable () -> Unit,
) {
val pal = LocalPalette.current
@@ -108,12 +110,16 @@ internal fun PageFlood(
kotlinx.coroutines.withTimeoutOrNull(300) { snapshotFlow { get() }.first { it != null } }
}?.translate(-at)?.takeIf { it.height > 1f && it.overlaps(Rect(Offset.Zero, size)) }
if (target != null) {
// A tile with no picture yet would cover the card with a blank box, so wait briefly for the art.
if (!leaving) kotlinx.coroutines.withTimeoutOrNull(250) {
snapshotFlow { art.ready() && (ontoArt == null || ontoArt.ready()) }.first { it }
}
coroutineScope {
if (!leaving) {
val runs = edges.map { launch { it.animateTo(1f, Motion.sp(0.85f, 320f)) } }
snapshotFlow { edges.all { it.value >= 0.9f } }.first { it }
launch { shown.animateTo(1f, Motion.tw(240)) }
launch { delay(Motion.ms(140).toLong()); tile.animateTo(0f, Motion.tw(220)) }
snapshotFlow { edges.all { it.value >= 0.985f } }.first { it }
launch { shown.animateTo(1f, Motion.tw(220)) }
launch { delay(Motion.ms(120).toLong()); tile.animateTo(0f, Motion.tw(200)) }
runs.forEach { it.join() }
} else {
launch { shown.animateTo(0f, Motion.tw(160)) }
@@ -164,15 +170,16 @@ internal fun PageFlood(
val rise = if (onto != null) 0f else 1f
Box(Modifier.fillMaxSize().graphicsLayer { alpha = shown.value; translationY = (1f - shown.value) * 14.dp.toPx() * rise }) { content() }
val onCorner = with(density) { ontoCorner.toPx() }
Canvas(Modifier.fillMaxSize()) {
if (tile.value > 0.01f) drawTile(from, edges.map { it.value }, pal.surface, pal.line2, tile.value, art, target, onCorner)
Canvas(Modifier.fillMaxSize().graphicsLayer { compositingStrategy = androidx.compose.ui.graphics.CompositingStrategy.Offscreen }) {
val live = target?.let { landed -> onto?.invoke()?.translate(-at)?.takeIf { it.height > 1f } ?: landed }
if (tile.value > 0.01f && (live == null || art.ready())) drawTile(from, edges.map { it.value }, pal.surface, pal.line2, tile.value, art, live, onCorner, ontoLook, ontoArt)
}
}
}
private fun DrawScope.drawTile(
from: Origin, v: List<Float>, fill: Color, line: Color, alpha: Float, art: Painter? = null,
to: Rect? = null, toCorner: Float = 0f,
to: Rect? = null, toCorner: Float = 0f, look: HeroLook? = null, toArt: Painter? = null,
) {
val (l, t, r, b) = v
val mean = v.sumOf { it.coerceIn(0f, 1f).toDouble() }.toFloat() / 4f
@@ -194,8 +201,12 @@ private fun DrawScope.drawTile(
val h = (bottom - top).coerceAtLeast(0f)
val corner = if (to != null) lerp(from.corner, toCorner, mean).coerceAtMost(minOf(w, h) / 2f)
else lerp(from.corner * (1f - mean), minOf(w, h) * 0.42f, sin(PI * mean).toFloat().coerceAtLeast(0f))
drawRoundRect(fill, Offset(left, top), Size(w, h), CornerRadius(corner), alpha = alpha)
val pic = art?.intrinsicSize?.takeIf { it.isSpecified && it.width > 0f && it.height > 0f }
if (to != null && art != null && pic != null && w > 0f && h > 0f) {
drawHeroTile(art, toArt ?: art, left, top, w, h, corner, mean, alpha, fill, look)
return
}
drawRoundRect(fill, Offset(left, top), Size(w, h), CornerRadius(corner), alpha = alpha)
if (art != null && pic != null && w > 0f && h > 0f) {
val k = maxOf(w / pic.width, h / pic.height)
val dw = pic.width * k
@@ -207,3 +218,44 @@ private fun DrawScope.drawTile(
val edge = (1f - mean * 3f).coerceIn(0f, 1f)
if (edge > 0f) drawRoundRect(line, Offset(left, top), Size(w, h), CornerRadius(corner), alpha = alpha * edge, style = Stroke(1.dp.toPx()))
}
// Morphs the card's fitted art into the detail hero as GameBackdrop's ArtLayer draws it: cropped toward the upper right,
// dimmed, faded in from the left and out at the bottom, so the hand-off to the real hero has nothing to jump.
private fun DrawScope.drawHeroTile(
card: Painter, hero: Painter, left: Float, top: Float, w: Float, h: Float, corner: Float, t: Float, alpha: Float, fill: Color, look: HeroLook?,
) {
val shape = Path().apply { addRoundRect(RoundRect(left, top, left + w, top + h, CornerRadius(corner))) }
drawContext.canvas.saveLayer(Rect(left, top, left + w, top + h), androidx.compose.ui.graphics.Paint())
clipPath(shape) {
drawRect(fill, Offset(left, top), Size(w, h), alpha = alpha * (1f - t))
val swap = ((t - 0.15f) / 0.6f).coerceIn(0f, 1f)
if (hero !== card) drawCropped(card, left, top, w, h, 0f, 0f, alpha * (1f - swap))
drawCropped(hero, left, top, w, h, lerp(0f, 0.45f, t), lerp(0f, -0.35f, t), alpha * if (hero !== card) swap else 1f)
if (look != null) {
if (look.dim < 1f) drawRect(Color.Black, Offset(left, top), Size(w, h), alpha = alpha * (1f - look.dim) * t)
translate(left, top) { with(look) { shade(Size(w, h), t * alpha) } }
}
val keep = Color.Black
val gone = Color.Black.copy(alpha = 1f - t)
drawRect(
androidx.compose.ui.graphics.Brush.horizontalGradient(0.08f to gone, 0.55f to keep, startX = left, endX = left + w),
Offset(left, top), Size(w, h), blendMode = androidx.compose.ui.graphics.BlendMode.DstIn,
)
drawRect(
androidx.compose.ui.graphics.Brush.verticalGradient(0.55f to keep, 1f to gone, startY = top, endY = top + h),
Offset(left, top), Size(w, h), blendMode = androidx.compose.ui.graphics.BlendMode.DstIn,
)
}
drawContext.canvas.restore()
}
private fun DrawScope.drawCropped(art: Painter, left: Float, top: Float, w: Float, h: Float, bx: Float, by: Float, alpha: Float) {
if (alpha <= 0.001f) return
val pic = art.intrinsicSize.takeIf { it.isSpecified && it.width > 0f && it.height > 0f } ?: return
val k = maxOf(w / pic.width, h / pic.height)
val dw = pic.width * k
val dh = pic.height * k
translate(left + (w - dw) / 2f * (1f + bx), top + (h - dh) / 2f * (1f + by)) { with(art) { draw(Size(dw, dh), alpha = alpha) } }
}
private fun Painter?.ready(): Boolean = this == null || intrinsicSize.let { it.isSpecified && it.width > 0f && it.height > 0f }
@@ -39,12 +39,16 @@ import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.foundation.focusGroup
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.boundsInRoot
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.droiddeck.launcher.R
internal object MoreTabs {
var editing by mutableStateOf(false)
var inside by mutableStateOf(false)
val button = FocusRequester()
}
@@ -71,6 +75,36 @@ internal fun SyncTabPage(s: FrontEndState, modifier: Modifier) {
}
}
@Composable
private fun ResetTabsRow() {
val ctx = androidx.compose.ui.platform.LocalContext.current
val colors = MaterialTheme.colorScheme
val pal = LocalPalette.current
val title = stringResource(R.string.tabs_reset_title)
val body = stringResource(R.string.tabs_reset_body)
val keep = stringResource(R.string.common_cancel)
val reset = stringResource(R.string.tabs_reset)
var at by remember { mutableStateOf<androidx.compose.ui.geometry.Rect?>(null) }
Box(Modifier.padding(top = 12.dp)) { SettingsRow(stringResource(R.string.tabs_reset_title), stringResource(R.string.tabs_reset_hint)) {
Box(Modifier.onGloballyPositioned { at = it.boundsInRoot() }) {
SecondaryButton(reset, modifier = Modifier.testTag("tabs-reset")) {
val from = at ?: run { NavTabs.reset(ctx); return@SecondaryButton }
Steps.ask(StepAsk(
anchor = from, side = StepSide.Left, accent = pal.signal, items = 3, pillCorner = 20.dp, maxWidth = 360.dp,
handle = { androidx.compose.material3.Text(reset, fontSize = 13.sp, color = pal.signal) },
) {
StepTitle(title)
androidx.compose.material3.Text(body, fontSize = 13.sp, color = colors.onSurfaceVariant, modifier = Modifier.stepItem(1).padding(start = 4.dp, bottom = 12.dp))
androidx.compose.foundation.layout.Row(horizontalArrangement = androidx.compose.foundation.layout.Arrangement.spacedBy(8.dp, Alignment.End), modifier = Modifier.stepItem(2)) {
StepChoice(keep, enabled = open, modifier = Modifier.focusRequester(first)) { Steps.fold() }
StepChoice(reset, enabled = open) { Steps.fold(); NavTabs.reset(ctx) }
}
})
}
}
} }
}
@OptIn(androidx.compose.ui.ExperimentalComposeUiApi::class)
@Composable
internal fun EditTabsSheet(s: FrontEndState, a: FrontEndActions) {
@@ -123,6 +157,7 @@ internal fun EditTabsSheet(s: FrontEndState, a: FrontEndActions) {
}
Column(Modifier.weight(1f).verticalScroll(rememberScrollState())) {
TabsSettingsGroup(rememberMenuHost(), s, a)
if (!NavTabs.isDefault()) ResetTabsRow()
}
}
}
@@ -14,7 +14,7 @@ internal enum class SessionDrawerPage(val firstControl: String) {
}
internal fun sessionDrawerPages(
hasSecondScreen: Boolean, hasGlasses: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentHost.installed && com.droiddeck.launcher.agent.AgentTab.shown && DeveloperTools.on,
hasSecondScreen: Boolean, hasGlasses: Boolean = false, hasAgent: Boolean = com.droiddeck.launcher.agent.AgentHost.installed && com.droiddeck.launcher.agent.AgentTab.shown,
): List<SessionDrawerPage> =
SessionDrawerPage.entries.filter {
(hasSecondScreen || it != SessionDrawerPage.SECOND_SCREEN) && (hasGlasses || it != SessionDrawerPage.GLASSES) &&
@@ -1,5 +1,20 @@
package com.droiddeck.launcher.ui
import androidx.compose.ui.unit.lerp
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.runtime.setValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.focusGroup
import androidx.compose.animation.core.animateFloatAsState
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@@ -19,18 +34,48 @@ import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
import com.droiddeck.launcher.R
// Grows out of the search button over the section pills, with the same spring as the other page searches.
@OptIn(androidx.compose.ui.ExperimentalComposeUiApi::class)
@Composable
internal fun SettingsSearchField(query: String, onQuery: (String) -> Unit, onClose: () -> Unit) {
Row(
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp),
modifier = Modifier.fillMaxWidth().padding(bottom = 8.dp),
) {
AdbTextField(
value = query, onValueChange = onQuery, label = "", keyboardType = KeyboardType.Text, imeAction = ImeAction.Search,
placeholder = stringResource(R.string.settings_search), compact = true, showLabel = false, focusOnShow = true,
modifier = Modifier.weight(1f),
)
SmallIconButton(Icons.Filled.Close, stringResource(R.string.settings_search_clear), tint = MaterialTheme.colorScheme.onSurfaceVariant, onClick = onClose)
internal fun SettingsPillSearch(
modifier: Modifier, searching: Boolean, query: String, onQuery: (String) -> Unit,
onOpen: () -> Unit, onClose: () -> Unit, pills: @Composable () -> Unit,
) {
val colors = MaterialTheme.colorScheme
val open by animateFloatAsState(if (searching) 1f else 0f, Motion.sp(0.75f, 420f), label = "settingsSearch")
val icon = remember { FocusRequester() }
var toIcon by remember { mutableStateOf(false) }
var focusOnOpen by remember { mutableStateOf(false) }
val close = { toIcon = true; focusOnOpen = false; onClose() }
BackHandler(enabled = searching) { close() }
LaunchedEffect(toIcon, searching, open <= 0.01f) {
if (searching) toIcon = false
else if (toIcon && open <= 0.01f) { focusSoon { icon }; toIcon = false }
}
BoxWithConstraints(modifier, contentAlignment = Alignment.CenterEnd) {
val full = maxWidth
Box(
Modifier.fillMaxWidth().padding(end = 52.dp)
.graphicsLayer { alpha = 1f - open; translationX = -24.dp.toPx() * open }
.focusProperties { enter = { if (searching) FocusRequester.Cancel else FocusRequester.Default } }
.focusGroup(),
) { pills() }
if (searching || open > 0.01f) {
val w = lerp(44.dp, (full - 40.dp).coerceIn(44.dp, 640.dp), open)
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp)) {
Box(Modifier.width(w).graphicsLayer { alpha = (open * 1.6f).coerceAtMost(1f) }) {
AdbTextField(
value = query, onValueChange = onQuery, label = "", keyboardType = KeyboardType.Text, imeAction = ImeAction.Search,
placeholder = stringResource(R.string.settings_search), compact = true, showLabel = false, focusOnShow = focusOnOpen,
clearFocus = !searching,
onFocusChange = { focused -> if (!focused && query.isEmpty() && searching) { focusOnOpen = false; onClose() } },
)
}
SmallIconButton(Icons.Filled.Close, stringResource(R.string.settings_search_clear), tint = colors.onSurfaceVariant) { close() }
}
} else {
Box(Modifier.focusRequester(icon)) { SearchIcon(stringResource(R.string.settings_search)) { focusOnOpen = true; onOpen() } }
}
}
}
@@ -143,7 +143,7 @@ internal object StoresMotion {
fun takeCard(key: String): CardMark? = card?.takeIf { it.key == key && SystemClock.uptimeMillis() - cardAt < 1_000 }.also { card = null }
}
internal class CardMark(val key: String, val bounds: Rect, val corner: Float, val art: String?)
internal class CardMark(val key: String, val bounds: Rect, val corner: Float, val art: String?, val hero: String? = art)
internal class StepAsk(
val anchor: Rect,
@@ -157,7 +157,7 @@ internal class StepAsk(
val content: @Composable StepOutScope.() -> Unit,
)
internal class SignInFlood(val store: Store, val from: Rect, val start: Color, val color: Color) {
internal class SignInFlood(val store: Store, val from: Rect, val start: Color, val color: Color, val home: Rect? = null) {
var away by mutableStateOf(false)
var drainTo by mutableStateOf<Rect?>(null)
}
@@ -335,7 +335,10 @@ internal fun DownloadFlights() {
val from = StoresMotion.takeInstall() ?: focusAnchor(glide, origin)
if (from != null) StoresMotion.fly(from) else StoresMotion.landed++
}
Box(Modifier.fillMaxSize().onGloballyPositioned { origin = it.positionInRoot() }) { FlightLayer(origin) }
Box(Modifier.fillMaxSize().onGloballyPositioned { origin = it.positionInRoot() }) {
FlightLayer(origin)
SignInFloodLayer(origin)
}
}
internal fun focusAnchor(glide: FocusGlide?, origin: Offset): Rect? {
@@ -398,7 +398,6 @@ internal fun StoresPage(s: FrontEndState, a: FrontEndActions, modifier: Modifier
)
}
}
SignInFloodLayer(hostAt)
}
androidx.compose.runtime.DisposableEffect(Unit) { val page = Any(); StoresMotion.hosting(page); onDispose { StoresMotion.release(page) } }
}
@@ -458,14 +457,14 @@ internal fun InstallWhere(item: CatalogItem) {
}
@Composable
private fun SignInFloodLayer(hostAt: Offset) {
internal fun SignInFloodLayer(hostAt: Offset) {
val f = StoresMotion.signIn ?: return
val ctx = LocalContext.current
val lifecycle = androidx.compose.ui.platform.LocalLifecycleOwner.current.lifecycle
val density = androidx.compose.ui.platform.LocalDensity.current
key(f) {
var paused by remember { mutableStateOf(false) }
fun back() { if (f.drainTo == null) f.drainTo = if (StoresState.isSignedIn(f.store)) StoresMotion.dots[f.store] ?: f.from else f.from }
fun back() { if (f.drainTo == null) f.drainTo = f.home ?: if (StoresState.isSignedIn(f.store)) StoresMotion.dots[f.store] ?: f.from else f.from }
androidx.compose.runtime.DisposableEffect(lifecycle) {
val obs = androidx.lifecycle.LifecycleEventObserver { _, e ->
if (e == androidx.lifecycle.Lifecycle.Event.ON_PAUSE && f.away) paused = true
@@ -1278,7 +1277,7 @@ private fun GameCard(
val placed = remember { arrayOfNulls<androidx.compose.ui.layout.LayoutCoordinates>(1) }
val corner = with(androidx.compose.ui.platform.LocalDensity.current) { 10.dp.toPx() }
val open = {
placed[0]?.takeIf { it.isAttached }?.let { StoresMotion.markCard(CardMark(item.key, it.boundsInRoot(), corner, item.imageUrl ?: item.tallImageUrl)) }
placed[0]?.takeIf { it.isAttached }?.let { StoresMotion.markCard(CardMark(item.key, it.boundsInRoot(), corner, item.imageUrl ?: item.tallImageUrl, item.imageUrl ?: item.tallImageUrl)) }
onOpen(item.key)
}
val screen = with(androidx.compose.ui.platform.LocalDensity.current) { androidx.compose.ui.platform.LocalConfiguration.current.screenHeightDp.dp.toPx() }
@@ -55,7 +55,6 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.zIndex
import com.droiddeck.launcher.R
import com.droiddeck.launcher.agent.AgentTab
import kotlin.math.roundToInt
private const val MORE_LINE = "|more|"
@@ -93,11 +92,6 @@ internal fun TabsSettingsGroup(host: MenuHost, s: FrontEndState, a: FrontEndActi
NavTabs.rearrange(ctx, state, next.subList(0, split), next.subList(split + 1, next.size))
}
fun setShown(key: String, show: Boolean) {
when (key) {
"stores" -> if (show != s.gameStoresEnabled) a.onGameStoresEnabled(show)
"soundtracks" -> if (show != s.soundtracksEnabled) a.onSoundtracksEnabled(show)
"agent" -> if (show != AgentTab.shown) AgentTab.set(ctx, show)
}
NavTabs.setHidden(ctx, key, !show)
}
@@ -70,7 +70,7 @@ class BottomDesktopCompositorService : Service() {
FileUtils.copyAsset(this, "wayland/keymap.xkb", File(runtimeDir, "keymap.xkb"))
data.getString(KEY_LOG)?.let { path ->
WaylandCompositor.setSessionLogFile(File(path))
runCatching { android.system.Os.setenv("BL_WAYLAND_LOG", path, true) }
runCatching { android.system.Os.setenv("DD_WAYLAND_LOG", path, true) }
.onFailure { Log.w(TAG, "could not point the compositor's log at $path", it) }
}
WaylandCompositor.setFirstFrameListener { reply(MSG_FIRST_FRAME) }
@@ -50,7 +50,7 @@ object CompositorHost {
refreshHz: Float,
fpsLimit: Int,
): Boolean {
WaylandCompositor.nativeSetClockControl(java.io.File(context.filesDir, "${com.droiddeck.launcher.runtime.LinuxRuntime.DIR}/tmp/.bl-clock").path)
WaylandCompositor.nativeSetClockControl(java.io.File(context.filesDir, "${com.droiddeck.launcher.runtime.LinuxRuntime.DIR}/tmp/.dd-clock").path)
ownVsyncThread = SessionPrefs.vsyncThread(context)
WaylandCompositor.nativeSetRenderOnCommit(SessionPrefs.renderOnCommit(context))
blackFrameInsertion = SessionPrefs.blackFrameInsertion(context)
@@ -84,7 +84,7 @@ public class DroidDeckLowLatencyDecoderFactory implements VideoDecoderFactory {
private Surface standInSurface() {
if (standIn == null) {
standInThread = new HandlerThread("bl-decoder-standin");
standInThread = new HandlerThread("dd-decoder-standin");
standInThread.start();
standIn = ImageReader.newInstance(Math.max(width, 16), Math.max(height, 16), ImageFormat.PRIVATE, 3);
standIn.setOnImageAvailableListener(reader -> {
+7
View File
@@ -4280,4 +4280,11 @@
<string name="drawer_corner_tap_hint">Double-tap the top-right corner, for devices without a Back button</string>
<string name="drawer_handle">Open the session menu</string>
<string name="play_needs_you">Settings need you</string>
<string name="library_accounts">Store accounts</string>
<string name="library_account_sign_in">Sign in</string>
<string name="library_account_sign_out">Sign out</string>
<string name="tabs_reset">Reset</string>
<string name="tabs_reset_title">Reset tabs</string>
<string name="tabs_reset_hint">Steam, Desktop, Library, Downloads, Settings and Updates on the bar, the rest under More.</string>
<string name="tabs_reset_body">Your tab order and what sits under More or is hidden go back to the defaults.</string>
</resources>
@@ -209,7 +209,7 @@ class AgentSecurityTest {
@Test fun fastPathLibraryIsValidatedAndSelectedForOneSession() {
AgentAccess.setCommandsEnabled(context, true)
val source = File(AgentEnv.inbox(context).apply { mkdirs() }, "libblfastpath.so")
val source = File(AgentEnv.inbox(context).apply { mkdirs() }, "libddfastpath.so")
source.writeText("wrong architecture")
refused("INVALID_LIBRARY") { AgentEnv.override(context, source.name) }
val header = ByteArray(64)
@@ -227,11 +227,43 @@ class AgentSecurityTest {
assertEquals(64, response.getString("sha256").length)
assertEquals(ProotFastPath.LIBRARY, AgentEnv.fastPathLibrary(context))
AgentEnv.beginSession(context)
assertEquals("/opt/droiddeck-agent/bin/libblfastpath.so", AgentEnv.fastPathLibrary(context))
assertEquals("/opt/droiddeck-agent/bin/libddfastpath.so", AgentEnv.fastPathLibrary(context))
AgentEnv.endSession(context)
assertEquals(ProotFastPath.LIBRARY, AgentEnv.fastPathLibrary(context))
}
@Test fun aFastPathOverrideQueuedUnderTheOldNameStillApplies() {
AgentAccess.setCommandsEnabled(context, true)
File(AgentEnv.inbox(context).apply { mkdirs() }, "libblfastpath.so").writeText("old")
refused("INVALID_NAME") { AgentEnv.override(context, "libblfastpath.so") }
val bin = File(LinuxRuntime.rootDir(context), "opt/droiddeck-agent/bin").apply { mkdirs() }
File(bin, "libblfastpath.so").writeText("queued")
File(context.filesDir, "agent-env.json").writeText("""{"pendingOverrides":["libblfastpath.so"]}""")
AgentEnv.beginSession(context)
assertEquals("/opt/droiddeck-agent/bin/libddfastpath.so", AgentEnv.fastPathLibrary(context))
assertEquals("queued", File(bin, "libddfastpath.so").readText())
assertFalse(File(bin, "libblfastpath.so").exists())
AgentEnv.endSession(context)
}
@Test fun aQueuedOldNameOverrideThatCannotBeRenamedWaits() {
AgentAccess.setCommandsEnabled(context, true)
val bin = File(LinuxRuntime.rootDir(context), "opt/droiddeck-agent/bin").apply { mkdirs() }
File(bin, "libblfastpath.so").writeText("queued")
File(context.filesDir, "agent-env.json").writeText("""{"pendingOverrides":["libblfastpath.so"]}""")
bin.setWritable(false)
try {
org.junit.Assume.assumeFalse(bin.canWrite())
AgentEnv.beginSession(context)
assertEquals(ProotFastPath.LIBRARY, AgentEnv.fastPathLibrary(context))
assertTrue(File(bin, "libblfastpath.so").isFile)
val state = JSONObject(File(context.filesDir, "agent-env.json").readText())
assertEquals("libddfastpath.so", state.getJSONArray("pendingOverrides").getString(0))
} finally {
bin.setWritable(true)
}
}
@Test fun environmentValuesAreNotLogged() {
AgentAccess.setCommandsEnabled(context, true)
AgentEnv.set(context, listOf("CUSTOM=synthetic-private-value"), false)
@@ -134,12 +134,12 @@ class GameEnvironmentTest {
assertEquals("1", chosen.games["42"]!!["FEX_TSOENABLED"])
}
val ntsync = GameEnvironment.withGameSync(base, "42", "ntsync").games["42"]!!
assertEquals(listOf("1", "0", "1"), listOf(ntsync["BL_SYNC"], ntsync["BL_FSYNC_FIRST"], ntsync["BL_SYNC_FALLBACK"]))
assertEquals(listOf("1", "0", "1"), listOf(ntsync["DD_SYNC"], ntsync["DD_FSYNC_FIRST"], ntsync["DD_SYNC_FALLBACK"]))
assertFalse(ntsync.containsKey("PROTON_NO_ESYNC"))
val fsync = GameEnvironment.withGameSync(base, "42", "fsync").games["42"]!!
assertEquals(listOf("0", "1", "1", "1"), listOf(fsync["BL_SYNC"], fsync["BL_FSYNC_FIRST"], fsync["BL_SYNC_FALLBACK"], fsync["PROTON_NO_ESYNC"]))
assertEquals(listOf("0", "1", "1", "1"), listOf(fsync["DD_SYNC"], fsync["DD_FSYNC_FIRST"], fsync["DD_SYNC_FALLBACK"], fsync["PROTON_NO_ESYNC"]))
val wineserver = GameEnvironment.withGameSync(base, "42", "wineserver").games["42"]!!
assertEquals(listOf("0", "0", "0"), listOf(wineserver["BL_SYNC"], wineserver["BL_FSYNC_FIRST"], wineserver["BL_SYNC_FALLBACK"]))
assertEquals(listOf("0", "0", "0"), listOf(wineserver["DD_SYNC"], wineserver["DD_FSYNC_FIRST"], wineserver["DD_SYNC_FALLBACK"]))
val inherited = GameEnvironment.withGameSync(base, "42", null)
assertNull(GameEnvironment.gameSync(inherited, "42"))
assertEquals(mapOf("FEX_TSOENABLED" to "1"), inherited.games["42"])
@@ -35,7 +35,7 @@ class ModeSettingsLoadingTest {
@Test fun desktopDoesNotConsumeSteamsAppliedShaderChoice() {
val activity = Robolectric.buildActivity(FrontEndActivity::class.java).get()
SessionPrefs.setShaderPrecache(activity, false)
val applied = File(LinuxRuntime.rootDir(activity), "root/.bl-shader-precache-applied")
val applied = File(LinuxRuntime.rootDir(activity), "root/.dd-shader-precache-applied")
applied.parentFile!!.mkdirs()
applied.writeText("0")
load(activity, SessionService.MODE_DESKTOP)
@@ -82,7 +82,7 @@ class FrameStatsTest {
}
@Test fun guestFrameTimesMoveByThePausedSessionsClockShift() {
val control = java.io.File.createTempFile("bl-clock", null)
val control = java.io.File.createTempFile("dd-clock", null)
try {
control.writeBytes(java.nio.ByteBuffer.allocate(8).order(java.nio.ByteOrder.LITTLE_ENDIAN).putLong(62_283_930_706L).array())
val feed = GameFrameFeed(java.io.File("/nonexistent/droiddeck-hud/frames"), clockControl = control)
@@ -60,10 +60,10 @@ class BwrapSpawnerTest {
val env = mutableMapOf(
"DDNATV_ROOT" to rootfs, "DDNATV_BINDS" to "/dev:/dev", "HOME" to "/root",
"SPA_PLUGIN_DIR" to "/usr/local/lib/droiddeck-pipewire/lib/spa-0.2",
"LD_PRELOAD" to "/run/droiddeck-preload/libblsession.so:$rootfs/usr/local/lib/libblsession.so:$rootfs/usr/lib/libddnatv-hook.so",
"LD_PRELOAD" to "/run/droiddeck-preload/libddsession.so:$rootfs/usr/local/lib/libddsession.so:$rootfs/usr/lib/libddnatv-hook.so",
)
BwrapSpawner.withoutRootfsSettings(env, rootfs)
assertEquals(mapOf("HOME" to "/root", "LD_PRELOAD" to "/run/droiddeck-preload/libblsession.so"), env)
assertEquals(mapOf("HOME" to "/root", "LD_PRELOAD" to "/run/droiddeck-preload/libddsession.so"), env)
val onlySession = mutableMapOf("LD_PRELOAD" to "$rootfs/usr/lib/libddnatv-hook.so")
BwrapSpawner.withoutRootfsSettings(onlySession, rootfs)
assertTrue(onlySession.isEmpty())
@@ -117,33 +117,33 @@ class BwrapSpawnerPlanTest {
lib.parentFile!!.mkdirs()
lib.writeText("")
val root = File(dir, "root").apply { mkdirs() }
for (session in listOf(emptyMap(), mapOf("BL_DESKTOP" to "1"),
mapOf("BL_DESKTOP" to "1", "GALLIUM_DRIVER" to "zink", "MESA_LOADER_DRIVER_OVERRIDE" to "zink"))) {
for (session in listOf(emptyMap(), mapOf("DD_DESKTOP" to "1"),
mapOf("DD_DESKTOP" to "1", "GALLIUM_DRIVER" to "zink", "MESA_LOADER_DRIVER_OVERRIDE" to "zink"))) {
val env = session.toMutableMap()
val binds = BwrapSpawner.gpu(runtime.path, root, env, true)!!
assertTrue(binds.any { it.host == lib.canonicalPath && it.guest == "/run/droiddeck-gpu/libvulkan_freedreno.so" })
assertEquals("/run/droiddeck-gpu/freedreno_icd.json", env["VK_DRIVER_FILES"])
assertEquals("zink", env["GALLIUM_DRIVER"])
assertEquals(session["BL_DESKTOP"], env["BL_DESKTOP"])
assertEquals(session["DD_DESKTOP"], env["DD_DESKTOP"])
}
for (choice in listOf(mapOf("VK_DRIVER_FILES" to "/custom/icd.json"),
mapOf("VK_ICD_FILENAMES" to ""), mapOf("LIBGL_ALWAYS_SOFTWARE" to "1"))) {
val env = (choice + ("BL_DESKTOP" to "1")).toMutableMap()
val env = (choice + ("DD_DESKTOP" to "1")).toMutableMap()
val original = env.toMap()
assertEquals(null, BwrapSpawner.gpu(runtime.path, root, env, true))
assertEquals(original, env)
}
val env = mutableMapOf("BL_DESKTOP" to "1", "GALLIUM_DRIVER" to "llvmpipe")
val env = mutableMapOf("DD_DESKTOP" to "1", "GALLIUM_DRIVER" to "llvmpipe")
assertTrue(BwrapSpawner.gpu(runtime.path, root, env, true)!!.isNotEmpty())
assertEquals("llvmpipe", env["GALLIUM_DRIVER"])
val gamescope = mutableMapOf("BL_DESKTOP" to "1", "LIBGL_ALWAYS_SOFTWARE" to "1", "GAMESCOPE_WAYLAND_DISPLAY" to "gamescope-0")
val gamescope = mutableMapOf("DD_DESKTOP" to "1", "LIBGL_ALWAYS_SOFTWARE" to "1", "GAMESCOPE_WAYLAND_DISPLAY" to "gamescope-0")
assertTrue(BwrapSpawner.gpu(runtime.path, root, gamescope, true)!!.isNotEmpty())
val unavailable = mutableMapOf("BL_DESKTOP" to "1")
val unavailable = mutableMapOf("DD_DESKTOP" to "1")
assertEquals(null, BwrapSpawner.gpu(runtime.path, root, unavailable, false))
assertEquals(mapOf("BL_DESKTOP" to "1"), unavailable)
assertEquals(mapOf("DD_DESKTOP" to "1"), unavailable)
assertTrue(lib.delete())
assertEquals(null, BwrapSpawner.gpu(runtime.path, root, unavailable, true))
assertEquals(mapOf("BL_DESKTOP" to "1"), unavailable)
assertEquals(mapOf("DD_DESKTOP" to "1"), unavailable)
}
@Test fun buildsTheTreeFlatpakAsksFor() {
@@ -181,8 +181,8 @@ class BwrapSpawnerPlanTest {
@Test fun fexSandboxesStartThroughTheEnvTheyBringAndSkipArmPreloads() {
val context = RuntimeEnvironment.getApplication()
val rootfs = LinuxRuntime.rootDir(context)
val lib = File(rootfs, "usr/local/lib/libblsession.so").apply { parentFile?.mkdirs(); writeText("") }
val preload = File(rootfs, "etc/ld.so.preload").apply { parentFile?.mkdirs(); writeText("/usr/local/lib/libblsession.so\n") }
val lib = File(rootfs, "usr/local/lib/libddsession.so").apply { parentFile?.mkdirs(); writeText("") }
val preload = File(rootfs, "etc/ld.so.preload").apply { parentFile?.mkdirs(); writeText("/usr/local/lib/libddsession.so\n") }
try {
val plan = BwrapSpawner.plan(context, request(op("t" to "dir", "dest" to "/tmp"))
.put("envTool", "/run/droiddeck-fex/bin/env"), dir)
@@ -197,12 +197,12 @@ class BwrapSpawnerPlanTest {
@Test fun sandboxedAppsSeeTheSessionsNetworkLink() {
val context = RuntimeEnvironment.getApplication()
val rootfs = LinuxRuntime.rootDir(context)
val lib = File(rootfs, "usr/local/lib/libblsession.so").apply { parentFile?.mkdirs(); writeText("") }
val preload = File(rootfs, "etc/ld.so.preload").apply { parentFile?.mkdirs(); writeText("/usr/local/lib/libblsession.so\n") }
val lib = File(rootfs, "usr/local/lib/libddsession.so").apply { parentFile?.mkdirs(); writeText("") }
val preload = File(rootfs, "etc/ld.so.preload").apply { parentFile?.mkdirs(); writeText("/usr/local/lib/libddsession.so\n") }
val link = File(rootfs, "etc/droiddeck-net").apply { writeText("if wlan0 2 1500\n") }
try {
val plan = BwrapSpawner.plan(context, request(op("t" to "dir", "dest" to "/tmp")), dir)
assertEquals("/run/droiddeck-preload/libblsession.so", plan.env["LD_PRELOAD"])
assertEquals("/run/droiddeck-preload/libddsession.so", plan.env["LD_PRELOAD"])
assertEquals(link.path, plan.binds.single { it.guest == "/etc/droiddeck-net" }.host)
} finally {
listOf(lib, preload, link).forEach { it.delete() }
@@ -93,4 +93,41 @@ class LegacyNamesTest {
assertEquals("Exec=env APPIMAGE_EXTRACT_AND_RUN=1 /opt/appimages/other.AppImage\n",
File(root, "usr/share/applications/other.desktop").readText())
}
@Test fun homeMarkersKeepTheirStateAndRetiredLibrariesGo() {
write("root/.bl-lossless-asked", "1")
write("root/.bl-compat-pending", "550\n")
write("root/.dd-seed-beat", "new")
write("root/.bl-seed-beat", "old")
write("usr/local/lib/libblsession.so", "old")
write("usr/local/lib/droiddeck-fex/x86_64/libblsession.so", "old")
write("usr/local/lib/libddsession.so", "new")
LegacyNames.migrateRootfs(root)
assertEquals("1", File(root, "root/.dd-lossless-asked").readText())
assertEquals("550\n", File(root, "root/.dd-compat-pending").readText())
assertEquals("new", File(root, "root/.dd-seed-beat").readText())
assertFalse(File(root, "root/.bl-lossless-asked").exists())
assertFalse(File(root, "root/.bl-seed-beat").exists())
assertFalse(File(root, "usr/local/lib/libblsession.so").exists())
assertFalse(File(root, "usr/local/lib/droiddeck-fex/x86_64/libblsession.so").exists())
assertEquals("new", File(root, "usr/local/lib/libddsession.so").readText())
}
@Test fun queuedRequestsUnderBothNamesAreAllKept() {
write("root/.bl-proton-extra", "ge")
write("root/.dd-proton-extra", "em\n")
LegacyNames.migrateRootfs(root)
assertEquals("em\nge\n", File(root, "root/.dd-proton-extra").readText())
assertFalse(File(root, "root/.bl-proton-extra").exists())
}
@Test fun queuedRequestsStaySeparateWhenTheNewQueueIsUnterminated() {
write("root/.bl-proton-extra", "ge\n")
write("root/.dd-proton-extra", "cachyos")
write("root/.bl-steam-urls", "steam://run/440")
write("root/.dd-steam-urls", "steam://run/570")
LegacyNames.migrateRootfs(root)
assertEquals("cachyos\nge\n", File(root, "root/.dd-proton-extra").readText())
assertEquals("steam://run/570\nsteam://run/440\n", File(root, "root/.dd-steam-urls").readText())
}
}
@@ -679,11 +679,11 @@ class EsyncPacksTest {
val root = temp.newFolder("rootfs")
EsyncPacks.store(root).mkdirs()
assertEquals(0, EsyncPacks.fetchWanted(context, root))
GameEnvironmentStore.save(context, GameEnvironment.Config(games = mapOf("42" to mapOf("BL_SYNC_FALLBACK" to "1"))))
GameEnvironmentStore.save(context, GameEnvironment.Config(games = mapOf("42" to mapOf("DD_SYNC_FALLBACK" to "1"))))
assertTrue(EsyncPacks.enabled(context))
GameEnvironmentStore.save(context, GameEnvironment.Config(shared = mapOf("BL_SYNC_FALLBACK" to "1")))
GameEnvironmentStore.save(context, GameEnvironment.Config(shared = mapOf("DD_SYNC_FALLBACK" to "1")))
assertTrue(EsyncPacks.enabled(context))
GameEnvironmentStore.save(context, GameEnvironment.Config(games = mapOf("42" to mapOf("BL_SYNC_FALLBACK" to "0"))))
GameEnvironmentStore.save(context, GameEnvironment.Config(games = mapOf("42" to mapOf("DD_SYNC_FALLBACK" to "0"))))
assertFalse(EsyncPacks.enabled(context))
SessionPrefs.setSyncFallback(context, true)
assertTrue(EsyncPacks.enabled(context))
@@ -41,6 +41,6 @@ class FexCatalogTest {
@Test fun theSessionGetsTheBuildAndEverySource() {
val env = FexCatalog.environment(FexCatalog.Build("fex-2610-r5", url, sha), listOf(url, "https://ghfast.top/$url"))
assertEquals(listOf("BL_FEX_TAG=fex-2610-r5", "BL_FEX_SHA256=$sha", "BL_FEX_URLS=$url https://ghfast.top/$url"), env)
assertEquals(listOf("DD_FEX_TAG=fex-2610-r5", "DD_FEX_SHA256=$sha", "DD_FEX_URLS=$url https://ghfast.top/$url"), env)
}
}
@@ -315,4 +315,12 @@ class GameEnvironmentStoreTest {
GameEnvironmentStore.save(context, config)
assertEquals(config, GameEnvironmentStore.read(context))
}
@Test fun savedSettingsFromBeforeTheRenameKeepTheirValues() {
val json = JSONObject("""{"version":1,"shared":{"BL_SYNC":"1","DXVK_HUD":"fps"},
"games":{"440":{"BL_FSYNC_FIRST":"1","BL_SYNC_FALLBACK":"0","DD_SYNC_FALLBACK":"1"}}}""")
val config = GameEnvironmentStore.decode(json)
assertEquals(mapOf("DD_SYNC" to "1", "DXVK_HUD" to "fps"), config.shared)
assertEquals(mapOf("DD_FSYNC_FIRST" to "1", "DD_SYNC_FALLBACK" to "1"), config.games["440"])
}
}
@@ -39,7 +39,7 @@ class SessionSuspendControllerTest {
assertEquals(listOf(Triple(1, 1_000_000L, 3_000_000L)), fixture.pagedOut)
assertEquals(0, fixture.unacknowledged)
assertTrue(fixture.game.threads.all { it.state == 't' })
assertFalse(File(fixture.control.parentFile, ".bl-zram.ack.$GAME").exists())
assertFalse(File(fixture.control.parentFile, ".dd-zram.ack.$GAME").exists())
}
@Test fun unchangedSwapIsNotTakenForAFinishedPageOut() {
@@ -478,8 +478,8 @@ class SessionSuspendControllerTest {
var emptyGameTasks = false
var rootGone = false
var afterSleep: (() -> Unit)? = null
val control = File(tmp, ".bl-zram")
val clock = File(tmp, ".bl-clock")
val control = File(tmp, ".dd-zram")
val clock = File(tmp, ".dd-clock")
var clockAtContinue: Long? = null
var clockAtMapping: Long? = null
val pagedOut = mutableListOf<Triple<Int, Long, Long>>()
@@ -582,7 +582,7 @@ class SessionSuspendControllerTest {
"TracerPid: ${group.tracer}\n" +
if (group == game) "VmRSS:\t$gameResidentKb kB\nVmSwap:\t$gameSwapKb kB\n" else "",
)
if (group == game) File(dir, "maps").writeText("7f00000000-7f00001000 r-xp 00000000 fe:05 42 /usr/local/lib/libblsession.so\n")
if (group == game) File(dir, "maps").writeText("7f00000000-7f00001000 r-xp 00000000 fe:05 42 /usr/local/lib/libddsession.so\n")
val taskDir = File(dir, "task")
if (group == game && missingGameTasks) { taskDir.deleteRecursively(); continue }
taskDir.mkdirs()
@@ -250,7 +250,7 @@ class SteamDownloadMonitorTest {
File(steam, "package").mkdirs()
File(steam, "package/bannerlator-installed").writeText("1\n")
assertFalse(SteamDownloadMonitor.clientInstallPending(root))
File(root, "root/.bl-steam-repair").writeText("1\n")
File(root, "root/.dd-steam-repair").writeText("1\n")
assertTrue(SteamDownloadMonitor.clientInstallPending(root))
} finally {
root.deleteRecursively()
@@ -37,29 +37,60 @@ class NavTabsTest {
@Before @After fun reset() {
ctx.getSharedPreferences("session", Context.MODE_PRIVATE).edit().clear().commit()
NavTabs.load(ctx)
com.droiddeck.launcher.agent.AgentTab.load(ctx)
}
@Test fun musicStartsInMore() {
assertEquals(listOf("steam", "games", "stores", "downloads", "desktop", "components", "setup", "updates", "trinkets", NavTabs.MORE), navigationKeys(state()))
assertEquals(listOf("soundtracks", "storage", "sync"), NavTabs.more(state()))
assertEquals(setOf("soundtracks", "agent", "storage", "sync"), NavTabs.shelved)
@Test fun aFreshInstallShowsTheDefaultBarMoreAndHiddenTabs() {
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "trinkets", NavTabs.MORE), navigationKeys(state()))
assertEquals(listOf("stores", "soundtracks", "components", "storage", "sync"), 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)
assertTrue(NavTabs.isDefault())
}
@Test fun showingMusicOnceKeepsItShownAfterReload() {
place("soundtracks", TabPlace.BAR)
NavTabs.load(ctx)
assertEquals(listOf("steam", "games", "soundtracks", "stores", "downloads", "desktop", "components", "setup", "updates", "trinkets", NavTabs.MORE), navigationKeys(state()))
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "trinkets", "soundtracks", NavTabs.MORE), navigationKeys(state()))
}
@Test fun shelvedTabsLeaveTheBarAndAddMoreAtTheEnd() {
place("stores", TabPlace.MORE)
place("components", TabPlace.MORE)
place("desktop", TabPlace.MORE)
val s = state()
assertEquals(listOf("components", "soundtracks", "stores", "storage", "sync"), NavTabs.more(s))
assertEquals(listOf("desktop", "stores", "soundtracks", "components", "storage", "sync"), NavTabs.more(s))
assertEquals(NavTabs.MORE, navigationKeys(s).last())
assertFalse("stores" in navigationKeys(s))
assertFalse("desktop" in navigationKeys(s))
}
@Test fun appsAndTheDevHarnessCanBeShownWithoutHomeScreenOrDeveloperTools() {
place("android-apps", TabPlace.MORE)
assertTrue("android-apps" in NavTabs.more(state()))
place("agent", TabPlace.BAR)
assertTrue(com.droiddeck.launcher.agent.AgentTab.shown)
}
@Test fun resettingPutsBackTheDefaultLayout() {
place("stores", TabPlace.BAR)
place("updates", TabPlace.HIDDEN)
moveTab("downloads", -1)
assertFalse(NavTabs.isDefault())
NavTabs.reset(ctx)
NavTabs.load(ctx)
assertTrue(NavTabs.isDefault())
assertEquals(listOf("steam", "desktop", "games", "downloads", "setup", "updates", "trinkets", NavTabs.MORE), navigationKeys(state()))
}
@Test fun anOldLayoutKeepsWhatItsSwitchesShowed() {
ctx.getSharedPreferences("session", Context.MODE_PRIVATE).edit().clear()
.putBoolean("gameStoresEnabled", false).putBoolean("soundtracksEnabled", false).commit()
NavTabs.load(ctx)
val s = state()
assertEquals(listOf("steam", "games", "desktop", "components", "setup", "updates", "trinkets", NavTabs.MORE), navigationKeys(s))
assertEquals(listOf("storage", "sync"), 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"))
assertFalse(prefs.contains("soundtracksEnabled"))
}
@Test fun hiddenTabsAreNowhereAndSetupCannotBeHidden() {
@@ -71,23 +102,26 @@ class NavTabsTest {
assertTrue("setup" in navigationKeys(s))
}
@Test fun disabledStoresFeatureReadsAsHidden() {
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(storesOn = false), "stores"))
assertEquals(TabPlace.HIDDEN, NavTabs.place(state(storesOn = false), "downloads"))
@Test fun storesAndMusicHideLikeAnyOtherTab() {
place("stores", TabPlace.HIDDEN)
place("soundtracks", TabPlace.HIDDEN)
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()))
}
@Test fun movingSwapsWithTheNextVisibleTabAndPersists() {
place("soundtracks", TabPlace.BAR)
moveTab("stores", -1)
assertEquals(listOf("steam", "games", "stores", "soundtracks"), navigationKeys(state()).take(4))
moveTab("games", -1)
assertEquals(listOf("steam", "games", "desktop", "downloads"), navigationKeys(state()).take(4))
NavTabs.load(ctx)
assertEquals(listOf("steam", "games", "stores", "soundtracks"), navigationKeys(state()).take(4))
assertEquals(listOf("steam", "games", "desktop", "downloads"), navigationKeys(state()).take(4))
}
@Test fun tabsMissingFromASavedOrderSlotInAfterTheirDefaultNeighbour() {
assertEquals(listOf("updates", "trinkets", "steam", "games", "soundtracks", "stores", "downloads", "desktop", "agent", "components", "android-apps", "storage", "sync", "setup"),
assertEquals(listOf("updates", "trinkets", "stores", "soundtracks", "components", "storage", "sync", "android-apps", "agent", "steam", "desktop", "games", "downloads", "setup"),
NavTabs.arrange(listOf("updates", "steam")))
assertEquals(listOf("games", "soundtracks", "steam", "setup", "stores", "downloads", "desktop", "agent", "components", "android-apps", "storage", "sync", "updates", "trinkets"),
assertEquals(listOf("games", "downloads", "steam", "setup", "stores", "soundtracks", "desktop", "components", "storage", "sync", "android-apps", "agent", "updates", "trinkets"),
NavTabs.arrange(listOf("games", "steam", "setup", "stores", "desktop", "components", "android-apps", "updates", "bogus")))
}
@@ -172,7 +206,7 @@ class NavTabsTest {
compose.setContent { DroidDeckTheme { FrontEndScreen(state(), actions(), page = null) } }
compose.mainClock.advanceTimeBy(2_000)
compose.onNode(hasText(ctx.getString(com.droiddeck.launcher.R.string.content_page_gone))).assertDoesNotExist()
compose.onNode(hasTestTag("rail-games") and androidx.compose.ui.test.isSelected()).assertExists()
compose.onNode(hasTestTag("rail-desktop") and androidx.compose.ui.test.isSelected()).assertExists()
}
@Test fun setupListMovesATabAcrossTheMoreLineWithTheControllerAndHidesWithItsSwitch() {
@@ -216,11 +250,11 @@ class NavTabsTest {
private fun hasParentTag(tag: String) = androidx.compose.ui.test.hasAnyAncestor(hasTestTag(tag))
private fun state(storesOn: Boolean = true, downloads: Int = 0, setupReady: Boolean = true) = FrontEndState(
private fun state(downloads: Int = 0, setupReady: Boolean = true) = FrontEndState(
installed = "r9", ready = setupReady, available = null, busy = false, stage = "", percent = -1,
desktopInstalled = true, offlineAccount = null, offline = false, frameGenLabel = "", romsDir = null, logsEnabled = false,
steamGames = emptyList(), emulators = emptyList(), running = null,
gameStoresEnabled = storesOn, storeDownloadsActive = downloads,
storeDownloadsActive = downloads,
)
private fun actions() = FrontEndActions(
@@ -75,6 +75,11 @@ class PortraitLayoutTest {
}
@Test fun narrowBottomBarScrollsToEveryDestinationWithAppsAndResumeVisible() {
val ctx = androidx.test.core.app.ApplicationProvider.getApplicationContext<android.content.Context>()
NavTabs.reset(ctx)
NavTabs.setHidden(ctx, "android-apps", false)
val all = NavTabs.listed(stateWithAppsAndSession).filter { NavTabs.place(stateWithAppsAndSession, it) != TabPlace.HIDDEN }
NavTabs.rearrange(ctx, stateWithAppsAndSession, all, emptyList())
val selected = mutableStateOf("steam")
compose.setContent {
DroidDeckTheme {
@@ -82,7 +87,7 @@ class PortraitLayoutTest {
}
}
compose.mainClock.advanceTimeBy(1_000)
for (key in listOf("games", "stores", "desktop", "components", "android-apps", "setup", "updates", "steam")) {
for (key in all.drop(1) + all.first()) {
compose.onNodeWithTag("rail-$key").performScrollTo()
compose.mainClock.advanceTimeBy(1_000)
compose.onNodeWithTag("rail-$key").assertIsDisplayed().performClick()
@@ -91,6 +96,7 @@ class PortraitLayoutTest {
compose.onNodeWithTag("rail-$key").assertIsSelected().assertHeightIsAtLeast(48.dp).assertWidthIsAtLeast(48.dp)
}
compose.onNodeWithContentDescription("Resume Steam").assertIsDisplayed()
NavTabs.reset(ctx)
}
@Test fun bottomBarFollowsSidebarLabelsSetting() {