diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e4229729de..40ae60df71 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -307,6 +307,9 @@ jobs: aarch64-linux-gnu-gcc -O2 -Wall -o "$D/usr/local/bin/droiddeck-glprobe" tools/venus/glprobe.c -ldl aarch64-linux-gnu-strip --strip-unneeded "$D/usr/local/bin/droiddeck-glprobe" + - name: Build the LSE atomics emulator for ARMv8.0 CPUs + run: bash tools/linuxfs/lse-emu/build.sh app/src/main/assets/linuxfs + - name: Check the preloads run: | set -euo pipefail diff --git a/README.md b/README.md index 021fed17b3..d6616b1ab7 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,13 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V +
+Setup and tools + +- The wireless debugging pairing keypad was inspired by Ryan Retro’s Handheld Toolkit. + +
+ ## Star history diff --git a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt index 8c9657f1f5..900823e0f4 100644 --- a/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/FrontEndActivity.kt @@ -52,6 +52,7 @@ import com.droiddeck.launcher.ui.ComponentsPage import com.droiddeck.launcher.session.GameSaves import com.droiddeck.launcher.session.SessionLogShare import com.droiddeck.launcher.session.SessionPaths +import com.droiddeck.launcher.session.FullscreenMode import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.session.SteamRepair import com.droiddeck.launcher.session.LaunchCoordinator @@ -190,9 +191,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet private var gamescopeRealtime by mutableStateOf(false) private var paceCores by mutableStateOf(true) private var gpuClockPin by mutableStateOf(false) - private var prootNoSeccomp by mutableStateOf(false) - private var prootFastPath by mutableStateOf(true) - private var nativeUserland by mutableStateOf(true) private var desktopAsUser by mutableStateOf(false) private var cursorComposite by mutableStateOf(true) private var guestHostname by mutableStateOf(SessionPrefs.DEFAULT_GUEST_HOSTNAME) @@ -208,7 +206,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet private var orientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) private var launcherOrientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER) private var homePage by mutableStateOf(com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_STEAM) - private var launcherFullscreen by mutableStateOf(true) + private var launcherFullscreenMode by mutableStateOf(FullscreenMode.ALWAYS) + private var sessionFullscreenMode by mutableStateOf(FullscreenMode.ALWAYS) private var launcherFrost by mutableStateOf(false) private var frostWallpaper by mutableStateOf(true) private var frostCards by mutableStateOf(true) @@ -1366,8 +1365,12 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet orientation = SessionPrefs.orientation(this) launcherOrientation = com.droiddeck.launcher.core.AppUiPrefs.orientation(this) requestedOrientation = launcherOrientation + launcherFullscreenMode = SessionPrefs.launcherFullscreenMode(this) + sessionFullscreenMode = SessionPrefs.sessionFullscreenMode(this) + applyLauncherFullscreen() homePage = com.droiddeck.launcher.core.AppUiPrefs.homePage(this) - launcherFullscreen = SessionPrefs.launcherFullscreen(this) + launcherFullscreenMode = SessionPrefs.launcherFullscreenMode(this) + sessionFullscreenMode = SessionPrefs.sessionFullscreenMode(this) launcherFrost = SessionPrefs.launcherFrost(this) frostWallpaper = SessionPrefs.frostWallpaper(this) frostCards = SessionPrefs.frostCards(this) @@ -1482,7 +1485,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet orientation = orientation, launcherOrientation = launcherOrientation, homePage = homePage, - launcherFullscreen = launcherFullscreen, + launcherFullscreenMode = launcherFullscreenMode, + sessionFullscreenMode = sessionFullscreenMode, launcherFrost = launcherFrost, frostWallpaper = frostWallpaper, frostCards = frostCards, @@ -1758,13 +1762,14 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet } }, "delete-session-logs").start() }, - onClearLogs = { + onClearLogs = { done -> Thread({ val cleared = runCatching { SessionArtifacts.clearAll(this) }.getOrDefault(0) ui.post { android.widget.Toast.makeText(this, if (cleared == 0) getString(R.string.main_no_logs_to_clear) else resources.getQuantityString(R.plurals.main_logs_cleared, cleared, cleared), android.widget.Toast.LENGTH_SHORT).show() + done() } }, "clear-logs").start() }, @@ -1816,11 +1821,15 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet homePage = value }, onControllerHaptics = { on -> SessionPrefs.setControllerHaptics(this, on); controllerHaptics = on }, - onLauncherFullscreen = { on -> - SessionPrefs.setLauncherFullscreen(this, on) - launcherFullscreen = on + onLauncherFullscreenMode = { mode -> + SessionPrefs.setLauncherFullscreenMode(this, mode) + launcherFullscreenMode = mode applyLauncherFullscreen() }, + onSessionFullscreenMode = { mode -> + SessionPrefs.setSessionFullscreenMode(this, mode) + sessionFullscreenMode = mode + }, onLauncherFrost = { on -> SessionPrefs.setLauncherFrost(this, on) launcherFrost = on @@ -2152,7 +2161,13 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet private fun frostShown(): Boolean = launcherFrost && frostWallpaper && frost.prepared && frost.available && theme != com.droiddeck.launcher.ui.Themes.TRUE_BLACK - private fun applyLauncherFullscreen() { + override fun onConfigurationChanged(newConfig: android.content.res.Configuration) { + super.onConfigurationChanged(newConfig) + applyLauncherFullscreen(newConfig) + } + + private fun applyLauncherFullscreen(config: android.content.res.Configuration = resources.configuration) { + val launcherFullscreen = launcherFullscreenMode.hidesSystemBars(config.orientation) @Suppress("DEPRECATION") window.decorView.systemUiVisibility = if (launcherFullscreen) { (View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY @@ -3107,7 +3122,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet fsyncFirst = fsyncFirst, gamescopeRealtime = gamescopeRealtime, gpuClockPin = gpuClockPin, - prootNoSeccomp = prootNoSeccomp, prootFastPath = prootFastPath, nativeUserland = nativeUserland, desktopAsUser = desktopAsUser, cursorComposite = cursorComposite, + nativeDesktopAvailable = com.droiddeck.launcher.runtime.NativeGuest.nextSession(this), desktopAsUser = desktopAsUser, cursorComposite = cursorComposite, guestHostname = guestHostname, phantomWarning = phantomWarning, onClientOverride = { on -> SessionPrefs.setClientCpusOverride(this, on); clientOverride = on }, onPaceCores = { on -> SessionPrefs.setPaceCores(this, on); paceCores = on }, @@ -3121,9 +3136,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet onFsyncFirst = { on -> SessionPrefs.setFsyncFirst(this, on); fsyncFirst = on }, onGamescopeRealtime = { on -> SessionPrefs.setGamescopeRealtime(this, on); gamescopeRealtime = on }, onGpuClockPin = { on -> SessionPrefs.setGpuClockPin(this, on); gpuClockPin = on }, - onProotNoSeccomp = { on -> SessionPrefs.setProotNoSeccomp(this, on); prootNoSeccomp = on }, - onProotFastPath = { on -> SessionPrefs.setProotFastPath(this, on); prootFastPath = on }, - onNativeUserland = { on -> SessionPrefs.setNativeUserland(this, on); nativeUserland = on }, onDesktopAsUser = { on -> SessionPrefs.setDesktopAsUser(this, on); desktopAsUser = on }, onCursorComposite = { on -> SessionPrefs.setCursorComposite(this, on); cursorComposite = on }, onGuestHostname = { name -> SessionPrefs.setGuestHostname(this, name) }, @@ -3446,9 +3458,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet gamescopeRealtime = SessionPrefs.gamescopeRealtime(this) paceCores = SessionPrefs.paceCores(this) gpuClockPin = SessionPrefs.gpuClockPin(this) - prootNoSeccomp = SessionPrefs.prootNoSeccomp(this) - prootFastPath = SessionPrefs.prootFastPath(this) - nativeUserland = SessionPrefs.nativeUserland(this) desktopAsUser = SessionPrefs.desktopAsUser(this) cursorComposite = SessionPrefs.cursorComposite(this) guestHostname = SessionPrefs.guestHostname(this) diff --git a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt index 61c633d16f..bce76a9b63 100644 --- a/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt +++ b/app/src/main/java/com/droiddeck/launcher/SessionActivity.kt @@ -129,6 +129,7 @@ import com.droiddeck.launcher.session.GpuClockPin import com.droiddeck.launcher.session.GameProfileFollowState import com.droiddeck.launcher.session.GameProfileInventoryCache import com.droiddeck.launcher.session.GameProfileRefreshState +import com.droiddeck.launcher.session.FullscreenMode import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.session.SessionEvents import com.droiddeck.launcher.session.SessionArtifacts @@ -646,6 +647,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde private var drawerControllerActive by mutableStateOf(false) private var backHold by mutableStateOf(true) private var dockedMenuController by mutableStateOf(false) + private var sessionFullscreenMode by mutableStateOf(FullscreenMode.ALWAYS) private var sessionOrientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE) private var dualScreenSessionMode by mutableStateOf(com.droiddeck.launcher.input.DualScreen.MODE_AUTO) private var backActionsInverted by mutableStateOf(false) @@ -944,7 +946,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } applyFollowChoice() applyFollowOrientation(resources.configuration) - goFullscreen() + sessionFullscreenMode = SessionPrefs.sessionFullscreenMode(this) + applySessionFullscreen() volumeControlStream = android.media.AudioManager.STREAM_MUSIC displayManager = getSystemService(DISPLAY_SERVICE) as DisplayManager refreshSecondScreenDisplays() @@ -2119,6 +2122,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde onPause = ::pauseNow, paused = SessionState.suspended || SessionState.manualPause, onResume = { SessionService.resume(this@SessionActivity) }, + fullscreenMode = sessionFullscreenMode, + onFullscreenMode = { mode -> + SessionPrefs.setSessionFullscreenMode(this@SessionActivity, mode) + sessionFullscreenMode = mode + applySessionFullscreen() + }, orientation = sessionOrientation, onOrientation = { value -> when (SessionState.mode) { @@ -3325,6 +3334,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde override fun onConfigurationChanged(newConfig: android.content.res.Configuration) { super.onConfigurationChanged(newConfig) + if (!pipUi && !isInPictureInPictureMode) applySessionFullscreen(newConfig) picturePosition = SessionPrefs.picturePosition(this, picturePortrait(newConfig)) if (refreshActivityDisplayId() && started) { SessionService.setActivityDisplay(this, sessionActivityDisplayId) @@ -3868,7 +3878,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde presentationFaultHint()?.let { return it } if (log == null || !log.isFile) return null return try { - var enosys = 0 var fexMissing = false val size = log.length() val text = java.io.RandomAccessFile(log, "r").use { f -> @@ -3879,7 +3888,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde String(bytes, Charsets.ISO_8859_1) } text.lineSequence().forEach { line -> - if (line.contains("Function not implemented")) enosys++ if (line.contains(FEX_MISSING)) fexMissing = true } val steamSetup = com.droiddeck.launcher.session.SteamClientSetupFailure.find(text.lineSequence()) @@ -3901,9 +3909,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde } else if (fexMissing) { val what = com.droiddeck.launcher.frontend.Library.nameForProgram(SessionState.program) ?: getString(R.string.session_end_program) EndHint(getString(R.string.session_end_fex_missing, what), evenOnSuccess = true) - } else if (enosys >= 8) { - EndHint(resources.getQuantityString(R.plurals.session_hint_enosys, enosys, enosys, - getString(R.string.perf_title), getString(R.string.perf_seccomp), getString(R.string.perf_xalia))) } else null } catch (e: Exception) { null @@ -6734,6 +6739,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde uiHandler.removeCallbacks(questSteamVrRequest) if (com.droiddeck.launcher.session.QuestExperimental.isSupported()) uiHandler.post(questSteamVrRequest) if (runtimeRemovalBlocked) return + sessionFullscreenMode = SessionPrefs.sessionFullscreenMode(this) + if (!pipUi && !isInPictureInPictureMode) applySessionFullscreen() if (!SessionState.suspended) pausedFrame = null com.droiddeck.launcher.ui.Motion.refresh(this) refreshHomeApp() @@ -7447,7 +7454,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (hasFocus && airTriggersOpen) RedMagicAirTriggers.open(this) if (hasFocus && !pipUi) { retryFieldKeyboard(true) - goFullscreen() + applySessionFullscreen() refreshClipboard() } updatePointerCapture() @@ -7457,19 +7464,24 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde if (resumed) sessionClipboard.refresh() } - private fun goFullscreen() { + private fun applySessionFullscreen(config: android.content.res.Configuration = resources.configuration) { + val fullscreen = sessionFullscreenMode.hidesSystemBars(config.orientation) + if (fullscreen) window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN) + else window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN) @Suppress("DEPRECATION") - window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + window.decorView.systemUiVisibility = if (fullscreen) (View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY or View.SYSTEM_UI_FLAG_FULLSCREEN or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION or View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) + or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) else View.SYSTEM_UI_FLAG_LAYOUT_STABLE if (Build.VERSION.SDK_INT >= 28) { window.attributes = window.attributes.apply { - layoutInDisplayCutoutMode = if (Build.VERSION.SDK_INT >= 30) - WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS - else WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES + layoutInDisplayCutoutMode = when { + !fullscreen -> WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT + Build.VERSION.SDK_INT >= 30 -> WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS + else -> WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES + } } } } diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentAccess.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentAccess.kt index 2113161467..9c4659a550 100644 --- a/app/src/main/java/com/droiddeck/launcher/agent/AgentAccess.kt +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentAccess.kt @@ -23,7 +23,7 @@ object AgentAccess { fun requireCommands(context: Context) { if (!commandsAllowed(context)) throw AgentException( "AGENT_COMMANDS_DISABLED", - "Debugging tools are off: turn on Setup > Developer > Debugging tools on the device", + "droiddeckctl is off: turn on Setup > Developer > droiddeckctl on the device", ) } diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt index 87188e34d7..22c30a994e 100644 --- a/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentHost.kt @@ -571,7 +571,6 @@ object AgentHost { remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH") put("PROOT_LOADER", LinuxRuntime.prootLoader(app).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(app).path) - if (SessionPrefs.prootNoSeccomp(app)) put("PROOT_NO_SECCOMP", "1") LinuxRuntime.prootLibraryPath(app).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/agent/AgentNative.kt b/app/src/main/java/com/droiddeck/launcher/agent/AgentNative.kt index 613cbe2c39..0d2fffc73e 100644 --- a/app/src/main/java/com/droiddeck/launcher/agent/AgentNative.kt +++ b/app/src/main/java/com/droiddeck/launcher/agent/AgentNative.kt @@ -14,8 +14,6 @@ object AgentNative { fun run(context: Context, request: JSONObject, timeoutMs: Long): JSONObject { val root = LinuxRuntime.rootDir(context) com.droiddeck.launcher.session.SessionFiles.stage(context, root) - // with the setting off, staging leaves the rootfs as proot wants it - if (!com.droiddeck.launcher.session.SessionPrefs.nativeUserland(context)) NativeGuest.prepare(context, root) if (!NativeGuest.available(root)) throw AgentException("NATIVE_UNAVAILABLE", "The rootfs has no native hook or glibc loader yet; start a session once") val argvJson = request.optJSONArray("argv") ?: throw AgentException("INVALID_REQUEST", "argv is required") val argv = (0 until argvJson.length()).map { argvJson.getString(it) } diff --git a/app/src/main/java/com/droiddeck/launcher/core/CpuFeatures.kt b/app/src/main/java/com/droiddeck/launcher/core/CpuFeatures.kt new file mode 100644 index 0000000000..e8cd318bc2 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/core/CpuFeatures.kt @@ -0,0 +1,17 @@ +package com.droiddeck.launcher.core + +import java.io.File + +object CpuFeatures { + internal fun lacksAtomics(cpuInfo: String): Boolean { + val cores = cpuInfo.lineSequence() + .filter { it.substringBefore(':').trim() == "Features" } + .map { it.substringAfter(':').trim().split(Regex("\\s+")) } + .toList() + return cores.isNotEmpty() && cores.any { "atomics" !in it } + } + + val lacksAtomics: Boolean by lazy { + runCatching { lacksAtomics(File("/proc/cpuinfo").readText()) }.getOrDefault(false) + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt index d94fbbb587..46b74fbafa 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/DeviceReport.kt @@ -192,6 +192,7 @@ object DeviceReport { val fs = StatFs(Environment.getExternalStorageDirectory().path) k("Shared storage free", FileUtils.sizeToString(fs.availableBlocksLong * fs.blockSizeLong)) } + k("All files access", runCatching { com.droiddeck.launcher.files.AllFilesAccess.state() }.getOrNull()) h("GPU") k("KGSL gpu_model", readSys("/sys/class/kgsl/kgsl-3d0/gpu_model")) @@ -290,9 +291,12 @@ object DeviceReport { k("Linux x86 (FEX)", if (com.droiddeck.launcher.runtime.LinuxFex.ready(context)) "ready" else "not set up") k("gamescope realtime", SessionPrefs.gamescopeRealtime(context)) k("pace cores", SessionPrefs.paceCores(context)) - k("proot without seccomp", SessionPrefs.prootNoSeccomp(context)) - k("native userland (no proot)", SessionPrefs.nativeUserland(context)) - k("proot fast path", SessionPrefs.prootFastPath(context)) + k("guest runtime policy", "native preferred with PRoot fallback") + k("guest runtime", when (com.droiddeck.launcher.runtime.NativeGuest.sessionMode) { + true -> "native" + false -> "PRoot" + null -> if (com.droiddeck.launcher.runtime.NativeGuest.enabled(context)) "native available" else "native unavailable" + }) k("proot binary", LinuxRuntime.prootSource(context) + " " + LinuxRuntime.prootBinary(context).path) k("proot fast path (eligible)", com.droiddeck.launcher.runtime.ProotFastPath.enabled(context)) k("Guest host name", SessionPrefs.guestHostname(context)) diff --git a/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbFix.kt b/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbFix.kt index 64087a24f3..e9f8bbdfaa 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbFix.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbFix.kt @@ -119,7 +119,7 @@ object WirelessAdbFix { * socket table, and mDNS often advertises nothing, so the ephemeral range Linux gives adbd is * scanned on loopback (closed ports refuse at once) and the open ports are tried with our key. */ - private fun loopbackAdbPort(app: Context): Int? { + private fun loopbackAdbPort(app: Context, exclude: Int? = null): Int? { val open = java.util.concurrent.ConcurrentLinkedQueue() val workers = 32 val range = EPHEMERAL_PORTS @@ -127,7 +127,7 @@ object WirelessAdbFix { Thread { var port = range.first + worker while (port <= range.last) { - if (answers(LOOPBACK, port, 150)) open += port + if (port != exclude && answers(LOOPBACK, port, 150)) open += port port += workers } }.apply { start() } @@ -162,8 +162,28 @@ object WirelessAdbFix { }.getOrDefault(address is Inet4Address) fun localConnectPort(context: Context): Int? = - tlsPortProperty() - ?: findConnectPort(context, LOOPBACK) + discoverConnectPort(context, LOOPBACK) + + private fun discoverConnectPort(context: Context, host: String, exclude: Int? = null): Int? = + chooseConnectPort(host, exclude, + property = ::tlsPortProperty, + advertised = { acceptable -> findConnectPort(context, host, accept = acceptable) }, + answers = { port -> answers(host, port) }, + // Some local devices never advertise their connect port. Try only + // loopback and require the app's existing paired key to authenticate. + authenticatedLocal = { loopbackAdbPort(context.applicationContext, exclude) }, + ) + + internal fun chooseConnectPort( + host: String, exclude: Int?, + property: () -> Int?, advertised: ((Int) -> Boolean) -> Int?, + answers: (Int) -> Boolean, authenticatedLocal: () -> Int?, + ): Int? { + val local = host == LOOPBACK + val acceptable: (Int) -> Boolean = { port -> port != exclude && (!local || answers(port)) } + val propertyPort = if (local) property()?.takeIf(acceptable) else null + return propertyPort ?: advertised(acceptable) ?: if (local) authenticatedLocal() else null + } private fun tlsPortProperty(): Int? = runCatching { Class.forName("android.os.SystemProperties").getMethod("get", String::class.java) @@ -301,14 +321,14 @@ object WirelessAdbFix { if (cachedPort != null) { val cachedResult = runCatching { action(appContext, saved.host, cachedPort) } if (cachedResult.isSuccess) return - val discoveredPort = findConnectPort(appContext, saved.host) + val discoveredPort = discoverConnectPort(appContext, saved.host, exclude = cachedPort) if (discoveredPort != null && discoveredPort != cachedPort) { action(appContext, saved.host, discoveredPort) } else { cachedResult.getOrThrow() } } else { - val discoveredPort = findConnectPort(appContext, saved.host) + val discoveredPort = discoverConnectPort(appContext, saved.host) ?: error(appContext.getString(R.string.adbfix_enter_address)) action(appContext, saved.host, discoveredPort) } diff --git a/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbPairingService.kt b/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbPairingService.kt index f7097dce7c..d1e2d911e8 100644 --- a/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbPairingService.kt +++ b/app/src/main/java/com/droiddeck/launcher/core/WirelessAdbPairingService.kt @@ -4,20 +4,23 @@ import android.app.Notification import android.app.NotificationChannel import android.app.NotificationManager import android.app.PendingIntent -import android.app.RemoteInput import android.app.Service import android.content.Context import android.content.Intent +import android.net.Uri import android.net.nsd.NsdManager import android.net.nsd.NsdServiceInfo import android.os.Build import android.os.Handler import android.os.IBinder import android.os.Looper +import android.util.TypedValue +import android.widget.RemoteViews import com.droiddeck.launcher.FrontEndActivity import com.droiddeck.launcher.R import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow +import java.util.UUID class WirelessAdbPairingService : Service() { override fun attachBaseContext(newBase: android.content.Context) = @@ -37,6 +40,8 @@ class WirelessAdbPairingService : Service() { private var discovery: NsdManager.DiscoveryListener? = null private var pairingHost: String? = null private var pairingPort: Int? = null + private val keypad = WirelessPairingKeypad() + private var keypadToken = UUID.randomUUID().toString() @Volatile private var working = false @Volatile private var limitEnabled = false @Volatile private var session = 0 @@ -46,13 +51,21 @@ class WirelessAdbPairingService : Service() { override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int { when (intent?.action) { - ACTION_CODE -> { - val code = RemoteInput.getResultsFromIntent(intent)?.getCharSequence(KEY_CODE) - ?.filter(Char::isDigit)?.toString().orEmpty() - onCode(code) + ACTION_KEYPAD -> { + if (intent.data?.host == keypadToken && current.value is Stage.CodeNeeded && !working) { + val key = intent.data?.lastPathSegment?.toIntOrNull() + if (key == WirelessPairingKeypad.SUBMIT) { + if (keypad.ready && pairingPort != null) onCode(keypad.digits) + } else if (key != null && keypad.press(key)) { + show(current.value, quietUpdate = true) + } + } else if (current.value == Stage.Idle) { + stopSelf(startId) + } } ACTION_CANCEL -> finish(Stage.Idle) - else -> begin(intent?.getBooleanExtra(EXTRA_ENABLE_LIMIT, false) == true) + null -> begin(intent?.getBooleanExtra(EXTRA_ENABLE_LIMIT, false) == true) + else -> if (discovery == null && !working) stopSelf(startId) } return START_NOT_STICKY } @@ -60,11 +73,13 @@ class WirelessAdbPairingService : Service() { private fun begin(enableLimit: Boolean) { if (working) return session++ + resetKeypad() limitEnabled = enableLimit pairingHost = null pairingPort = null working = false publish(Stage.Waiting) + getSystemService(NotificationManager::class.java)?.cancel(KEYPAD_NOTIFICATION_ID) startForeground(NOTIFICATION_ID, notification(Stage.Waiting)) startDiscovery() main.removeCallbacks(timeout) @@ -101,9 +116,13 @@ class WirelessAdbPairingService : Service() { if (!WirelessAdbFix.isLocalAddress(address)) return main.post { if (owner != session || working || current.value == Stage.Done) return@post + val endpointChanged = pairingHost != address.hostAddress || pairingPort != serviceInfo.port pairingHost = address.hostAddress pairingPort = serviceInfo.port - if (current.value !is Stage.CodeNeeded) show(Stage.CodeNeeded()) + if (endpointChanged) { + resetKeypad() + show(Stage.CodeNeeded()) + } } } } @@ -117,11 +136,12 @@ class WirelessAdbPairingService : Service() { show(Stage.Waiting) return } - if (code.length != 6) { + if (code.length != WirelessPairingKeypad.LENGTH) { show(Stage.CodeNeeded(getString(R.string.adbpair_six_digits))) return } working = true + resetKeypad() val owner = session val enable = limitEnabled show(Stage.Working(getString(R.string.adbpair_pairing))) @@ -155,17 +175,34 @@ class WirelessAdbPairingService : Service() { }, "wireless-adb-pairing").start() } - private fun show(stage: Stage) { + private fun show(stage: Stage, quietUpdate: Boolean = false) { publish(stage) - getSystemService(NotificationManager::class.java)?.notify(NOTIFICATION_ID, notification(stage)) + val manager = getSystemService(NotificationManager::class.java) ?: return + if (stage is Stage.CodeNeeded) { + // A new high-priority notification can pop over Settings. Updating the + // quiet foreground-service notification can leave the keypad in the shade. + // End any previous indeterminate progress even if this is a code retry. + if (!quietUpdate) manager.notify(NOTIFICATION_ID, notification(stage, foregroundCodeEntry = true)) + manager.notify(KEYPAD_NOTIFICATION_ID, notification(stage, quietUpdate)) + } else { + manager.cancel(KEYPAD_NOTIFICATION_ID) + manager.notify(NOTIFICATION_ID, notification(stage, quietUpdate)) + } + } + + private fun resetKeypad() { + keypad.clear() + keypadToken = UUID.randomUUID().toString() } private fun finish(stage: Stage) { session++ + resetKeypad() main.removeCallbacks(timeout) stopDiscovery() publish(stage) val manager = getSystemService(NotificationManager::class.java) + manager?.cancel(KEYPAD_NOTIFICATION_ID) if (stage is Stage.Done || stage is Stage.Failed) { manager?.notify(NOTIFICATION_ID, notification(stage)) stopForeground(STOP_FOREGROUND_DETACH) @@ -183,13 +220,16 @@ class WirelessAdbPairingService : Service() { } override fun onDestroy() { + getSystemService(NotificationManager::class.java)?.cancel(KEYPAD_NOTIFICATION_ID) main.removeCallbacks(timeout) stopDiscovery() if (current.value.let { it is Stage.Waiting || it is Stage.CodeNeeded || it is Stage.Working }) publish(Stage.Idle) super.onDestroy() } - private fun notification(stage: Stage): Notification { + private fun notification( + stage: Stage, quietUpdate: Boolean = false, foregroundCodeEntry: Boolean = false, + ): Notification { val manager = getSystemService(NotificationManager::class.java) manager?.createNotificationChannel(NotificationChannel(CHANNEL_ID, getString(R.string.adbpair_channel_name), NotificationManager.IMPORTANCE_HIGH).apply { @@ -205,7 +245,7 @@ class WirelessAdbPairingService : Service() { PendingIntent.FLAG_IMMUTABLE) val cancel = PendingIntent.getService(this, 1, Intent(this, WirelessAdbPairingService::class.java).setAction(ACTION_CANCEL), PendingIntent.FLAG_IMMUTABLE) - val quiet = stage == Stage.Waiting || stage == Stage.Idle || stage is Stage.Working + val quiet = foregroundCodeEntry || stage == Stage.Waiting || stage == Stage.Idle || stage is Stage.Working val builder = Notification.Builder(this, if (quiet) PROGRESS_CHANNEL_ID else CHANNEL_ID) .setSmallIcon(R.drawable.ic_stat_session) .setContentIntent(open) @@ -220,19 +260,31 @@ class WirelessAdbPairingService : Service() { .setOnlyAlertOnce(true) .addAction(Notification.Action.Builder(null, getString(R.string.common_cancel), cancel).build()) is Stage.CodeNeeded -> { - val reply = PendingIntent.getService(this, 2, - Intent(this, WirelessAdbPairingService::class.java).setAction(ACTION_CODE), - if (Build.VERSION.SDK_INT >= 31) PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT - else PendingIntent.FLAG_UPDATE_CURRENT) - val input = RemoteInput.Builder(KEY_CODE).setLabel(getString(R.string.adbpair_code_label)).build() - val text = stage.error ?: getString(R.string.adbpair_code_hint) builder - .setContentTitle(getString(if (stage.error == null) R.string.adbpair_title_code else R.string.adbpair_title_retry)) - .setContentText(text) - .setStyle(Notification.BigTextStyle().bigText(text)) + .setContentTitle(getString(if (foregroundCodeEntry) R.string.adbpair_title_pair + else if (stage.error == null) R.string.adbpair_title_code else R.string.adbpair_title_retry)) + .setContentIntent(null) + .setVisibility(Notification.VISIBILITY_SECRET) + .setLocalOnly(true) .setOngoing(true) - .addAction(Notification.Action.Builder(null, getString(R.string.adbpair_enter_code), reply).addRemoteInput(input).build()) - .addAction(Notification.Action.Builder(null, getString(R.string.common_cancel), cancel).build()) + .setOnlyAlertOnce(foregroundCodeEntry || quietUpdate) + if (!foregroundCodeEntry) { + // Keep the keypad separate from status/install notifications. Android owns + // the heads-up timeout; the drawer remains usable without expanding a group. + builder.setGroup(KEYPAD_GROUP) + .addAction(Notification.Action.Builder(null, getString(R.string.common_cancel), cancel).build()) + if (stage.error != null && pairingPort == null) { + builder.setContentText(stage.error) + .setStyle(Notification.BigTextStyle().bigText(stage.error)) + } else { + builder.setStyle(Notification.DecoratedCustomViewStyle()) + .setCustomBigContentView(pairingKeypad()) + .setCustomHeadsUpContentView(pairingKeypad(keyHeightDp = 24)) + if (Build.VERSION.SDK_INT >= 31) { + builder.setCustomContentView(pairingKeypad(keyHeightDp = 21)) + } + } + } } is Stage.Working -> builder .setContentTitle(getString(R.string.adbpair_title_working)) @@ -254,14 +306,39 @@ class WirelessAdbPairingService : Service() { return builder.build() } + private fun pairingKeypad(keyHeightDp: Int? = null): RemoteViews = RemoteViews(packageName, R.layout.wireless_pairing_keypad).apply { + val ids = intArrayOf(R.id.pair_key_0, R.id.pair_key_1, R.id.pair_key_2, R.id.pair_key_3, R.id.pair_key_4, + R.id.pair_key_5, R.id.pair_key_6, R.id.pair_key_7, R.id.pair_key_8, R.id.pair_key_9, + R.id.pair_key_delete, R.id.pair_key_submit) + ids.forEachIndexed { key, id -> + if (keyHeightDp != null && Build.VERSION.SDK_INT >= 31) { + // Fit both rows inside the system template's heads-up or collapsed height. + setViewLayoutHeight(id, keyHeightDp.toFloat(), TypedValue.COMPLEX_UNIT_DIP) + setViewLayoutMargin(id, RemoteViews.MARGIN_TOP, 1f, TypedValue.COMPLEX_UNIT_DIP) + setViewLayoutMargin(id, RemoteViews.MARGIN_BOTTOM, 1f, TypedValue.COMPLEX_UNIT_DIP) + setTextViewTextSize(id, TypedValue.COMPLEX_UNIT_SP, if (keyHeightDp < 24) 14f else 15f) + } + val intent = Intent(this@WirelessAdbPairingService, WirelessAdbPairingService::class.java) + .setAction(ACTION_KEYPAD) + .setData(Uri.Builder().scheme("droiddeck-pairing").authority(keypadToken).appendPath(key.toString()).build()) + val press = PendingIntent.getService(this@WirelessAdbPairingService, key, intent, PendingIntent.FLAG_IMMUTABLE) + setOnClickPendingIntent(id, press) + } + setTextViewText(R.id.pair_key_code, keypad.display) + setContentDescription(R.id.pair_key_code, getString(R.string.adbpair_keypad_entered, keypad.digits.length)) + setBoolean(R.id.pair_key_delete, "setEnabled", keypad.digits.isNotEmpty()) + setBoolean(R.id.pair_key_submit, "setEnabled", keypad.ready && pairingPort != null) + } + companion object { private const val CHANNEL_ID = "wireless-adb-pairing" private const val PROGRESS_CHANNEL_ID = "wireless-adb-pairing-progress" private const val NOTIFICATION_ID = 3 + private const val KEYPAD_NOTIFICATION_ID = 3403 + private const val KEYPAD_GROUP = "wireless-adb-keypad" private const val PAIRING_TYPE = "_adb-tls-pairing._tcp" - private const val ACTION_CODE = "com.droiddeck.launcher.action.WIRELESS_ADB_CODE" + private const val ACTION_KEYPAD = "com.droiddeck.launcher.action.WIRELESS_ADB_KEYPAD" private const val ACTION_CANCEL = "com.droiddeck.launcher.action.WIRELESS_ADB_CANCEL" - private const val KEY_CODE = "code" private const val EXTRA_ENABLE_LIMIT = "enable_limit" private const val TIMEOUT_MS = 5 * 60_000L @@ -288,7 +365,7 @@ class WirelessAdbPairingService : Service() { fun notificationsEnabled(context: Context): Boolean = context.getSystemService(NotificationManager::class.java)?.areNotificationsEnabled() != false && !channelBlocked(context) - /** The code is typed into a notification on this channel; a channel the user switched off leaves pairing with nothing to type into. */ + /** Pairing needs this notification channel to show the keypad over Android Settings. */ fun channelBlocked(context: Context): Boolean = context.getSystemService(NotificationManager::class.java)?.getNotificationChannel(CHANNEL_ID)?.importance == NotificationManager.IMPORTANCE_NONE diff --git a/app/src/main/java/com/droiddeck/launcher/core/WirelessPairingKeypad.kt b/app/src/main/java/com/droiddeck/launcher/core/WirelessPairingKeypad.kt new file mode 100644 index 0000000000..942911a78d --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/core/WirelessPairingKeypad.kt @@ -0,0 +1,29 @@ +package com.droiddeck.launcher.core + +internal class WirelessPairingKeypad { + var digits = "" + private set + val ready: Boolean get() = digits.length == LENGTH + val display: String get() = digits.padEnd(LENGTH, '–') + + fun press(key: Int): Boolean { + val next = when { + key == DELETE -> digits.dropLast(1) + key in 0..9 && !ready -> digits + key + else -> digits + } + if (next == digits) return false + digits = next + return true + } + + fun clear() { + digits = "" + } + + companion object { + const val LENGTH = 6 + const val DELETE = 10 + const val SUBMIT = 11 + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/files/AllFilesAccess.kt b/app/src/main/java/com/droiddeck/launcher/files/AllFilesAccess.kt index 2c9529f4ed..94ea2e33f9 100644 --- a/app/src/main/java/com/droiddeck/launcher/files/AllFilesAccess.kt +++ b/app/src/main/java/com/droiddeck/launcher/files/AllFilesAccess.kt @@ -14,6 +14,15 @@ object AllFilesAccess { fun missing(sdk: Int = Build.VERSION.SDK_INT, granted: () -> Boolean = { Environment.isExternalStorageManager() }): Boolean = sdk >= Build.VERSION_CODES.R && !granted() + fun state(sdk: Int = Build.VERSION.SDK_INT, granted: () -> Boolean = { Environment.isExternalStorageManager() }): String = when { + sdk < Build.VERSION_CODES.R -> "not needed" + granted() -> "granted" + else -> "missing" + } + + fun mayHideFilesIn(path: String, sdk: Int = Build.VERSION.SDK_INT, granted: () -> Boolean = { Environment.isExternalStorageManager() }): Boolean = + covers(path) && missing(sdk, granted) + /** Whether reading [path] takes all-files access: shared storage, outside the per-app folders directly under a volume's root, which Android always lets the app use. */ fun covers(path: String): Boolean { val inside = VOLUME.matchEntire(path)?.groupValues?.get(2) ?: return false diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/BwrapSpawner.kt b/app/src/main/java/com/droiddeck/launcher/runtime/BwrapSpawner.kt index 0e42e770e3..d72274443b 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/BwrapSpawner.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/BwrapSpawner.kt @@ -288,12 +288,26 @@ object BwrapSpawner { } private fun preload(session: List, rootfs: String, env: MutableMap): List { - val libs = FileUtils.readString(File(rootfs, "etc/ld.so.preload"))?.lines() - ?.map { it.trim() }?.filter { it.startsWith("/") && File(rootfs + it).isFile } ?: return emptyList() - if (libs.isEmpty()) return emptyList() + val configured = FileUtils.readString(File(rootfs, "etc/ld.so.preload"))?.lines() + ?.map { it.trim() }?.filter { it.startsWith("/") && File(rootfs + it).isFile } ?: emptyList() + val lseDisabled = env["LSE_EMU"] == "0" + val libs = configured.filterNot { lseDisabled && it.endsWith("/liblse_emu.so") } + val inherited = env["LD_PRELOAD"]?.split(Regex("[\\s:]+")) + ?.filter { it.isNotEmpty() && !(lseDisabled && it.substringAfterLast('/') == "liblse_emu.so") } + ?: emptyList() + if (libs.isEmpty()) { + if (lseDisabled) { + if (inherited.isEmpty()) env.remove("LD_PRELOAD") + else env["LD_PRELOAD"] = inherited.joinToString(":") + } + return emptyList() + } val binds = ArrayList() val paths = libs.map { lib -> "$PRELOAD_DIR/${lib.substringAfterLast('/')}".also { binds.add(Bind(rootfs + lib, it)) } } - env["LD_PRELOAD"] = (paths + listOfNotNull(env["LD_PRELOAD"]?.takeIf { it.isNotBlank() })).joinToString(":") + env["LD_PRELOAD"] = (paths + inherited).joinToString(":") + if (libs.any { it.endsWith("/liblse_emu.so") }) { + env.putIfAbsent("LSE_EMU", "1") + } File(rootfs, NET_LINK).takeIf { it.isFile }?.let { binds.add(Bind(it.path, "/$NET_LINK")) } env["FAKE_EVDEV_DIR"]?.let { File(it).parent }?.let { dev -> binds.addAll(bindsFor(session, rootfs, dev, dev)) @@ -563,12 +577,15 @@ object BwrapSpawner { private fun run(context: Context, plan: Plan, client: LocalSocket, out: DataOutputStream, id: Int) { val verbose = plan.env["DROIDDECK_PROOT_VERBOSE"]?.toIntOrNull() - val native = if (NativeGuest.forSession(context)) nativeLaunch(context, plan) else null + val nativeSession = NativeGuest.forSession(context) + val native = if (nativeSession) nativeLaunch(context, plan) else null val builder = if (native != null) { ProcessBuilder(native.first).redirectErrorStream(true) .directory(File(hostPath(plan.binds, plan.root.path, plan.cwd)).takeIf { it.isDirectory } ?: plan.root) .also { b -> b.environment().apply { clear(); putAll(native.second) } } } else { + val reason = if (nativeSession) "sandbox native launch unavailable" else "parent guest uses PRoot" + Log.i(TAG, "Flatpak: using PRoot ($reason)") val cmd = LinuxRuntime.prootPrefix(context, plan.root, plan.cwd) if (verbose != null) { cmd.add("-v"); cmd.add(verbose.toString()) } plan.binds.forEach { cmd.add("-b"); cmd.add(it.spec) } @@ -585,7 +602,6 @@ object BwrapSpawner { putAll(prootEnvironment(plan, envTool)) put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(context).path) - if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1") LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt b/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt index 6c0936e679..50a190c1ba 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/GuestCommand.kt @@ -6,7 +6,6 @@ import com.droiddeck.launcher.core.HostProcess import com.droiddeck.launcher.session.OrphanReaper import com.droiddeck.launcher.session.SessionFiles import com.droiddeck.launcher.session.SessionPaths -import com.droiddeck.launcher.session.SessionPrefs import java.io.File import java.util.concurrent.atomic.AtomicBoolean @@ -67,7 +66,6 @@ object GuestCommand { put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(context).path) if (linkDir != null) put("PROOT_L2S_DIR", linkDir.path) - if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1") fastPathKey?.let { ProotFastPath.hostEnv(it).let { (k, v) -> put(k, v) } } LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/NativeGuest.kt b/app/src/main/java/com/droiddeck/launcher/runtime/NativeGuest.kt index 95a660eaf4..6e69ffe376 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/NativeGuest.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/NativeGuest.kt @@ -22,15 +22,15 @@ object NativeGuest { } fun enabled(context: Context): Boolean = - SessionPrefs.nativeUserland(context) && available(LinuxRuntime.rootDir(context)) + available(LinuxRuntime.rootDir(context)) /** * Whether the next session will start natively. The session stages the hook from the APK before - * it starts, so only the setting and the rootfs's loader decide, and a runtime still to be + * it starts, so the rootfs's loader decides, and a runtime still to be * installed will have one. */ fun nextSession(context: Context): Boolean = - SessionPrefs.nativeUserland(context) && willRun(LinuxRuntime.rootDir(context), LinuxRuntime.isInstalled(context)) + willRun(LinuxRuntime.rootDir(context), LinuxRuntime.isInstalled(context)) internal fun willRun(root: File, installed: Boolean): Boolean = !installed || loader(root) != null @@ -39,7 +39,7 @@ object NativeGuest { /** * Whether a session's helpers (root commands, Flatpak sandboxes, installers) run natively: the - * session's own mode while one runs, as the setting can change under it and the rootfs is only + * session's own mode while one runs, as the rootfs is only * prepared for native programs at a session's start. */ fun forSession(context: Context): Boolean = sessionMode ?: enabled(context) @@ -104,8 +104,11 @@ object NativeGuest { private fun hostProgram(root: File, program: String): File = File(root, program.removePrefix("/")) /** The environment of the session process: the hook's root, the mounts proot used to make, the preload list. */ - fun sessionEnvironment(root: File, binds: List, program: String, hostname: String? = null): Map { - val preload = preloadList(root) + fun sessionEnvironment( + root: File, binds: List, program: String, hostname: String? = null, lseEmu: String? = null, + ): Map { + val preload = preloadList(root).filterNot { lseEmu == "0" && it.substringAfterLast('/') == "liblse_emu.so" } + val lse = lseEmu ?: "1".takeIf { preload.any { it.substringAfterLast('/') == "liblse_emu.so" } } return linkedMapOf( "DDNATV_ROOT" to root.path, "DDNATV_EXEC" to execLoader.orEmpty(), @@ -113,6 +116,7 @@ object NativeGuest { "DDNATV_HOSTNAME" to hostname.orEmpty(), "DDNATV_BINDS" to binds.joinToString("|") { if (it.contains(':')) it else "$it:$it" }, "DDNATV_PRELOAD" to preload.joinToString(":"), + "LSE_EMU" to lse.orEmpty(), "LD_PRELOAD" to (preload.map { File(root, it.removePrefix("/")).path } + hook(root).path).joinToString(":"), ).filterValues { it.isNotEmpty() } } diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/ProotFastPath.kt b/app/src/main/java/com/droiddeck/launcher/runtime/ProotFastPath.kt index 27ef86f086..33fa897237 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/ProotFastPath.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/ProotFastPath.kt @@ -3,7 +3,6 @@ package com.droiddeck.launcher.runtime import android.content.Context import android.os.Build import android.util.Log -import com.droiddeck.launcher.session.SessionPrefs import java.io.File import java.security.MessageDigest @@ -12,17 +11,14 @@ object ProotFastPath { 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 = - preference && !noSeccomp && !nativeUserland && source == LinuxRuntime.PROOT_PACK + internal fun allows(source: String, native: Boolean): Boolean = + !native && source == LinuxRuntime.PROOT_PACK - fun enabled(context: Context): Boolean { - val preference = SessionPrefs.prootFastPath(context) - val noSeccomp = SessionPrefs.prootNoSeccomp(context) - val nativeUserland = SessionPrefs.nativeUserland(context) + fun enabled(context: Context, native: Boolean = NativeGuest.forSession(context)): Boolean { + if (native) return false val source = LinuxRuntime.prootSource(context) - val on = allows(preference, noSeccomp, source, nativeUserland) - if (preference && !noSeccomp && !nativeUserland && !on) - Log.i(TAG, "proot: fast path off - binary is $source, not the patched proot") + val on = allows(source, native) + if (!on) Log.i(TAG, "proot: fast path off - binary is $source, not the patched proot") return on } diff --git a/app/src/main/java/com/droiddeck/launcher/runtime/RootSpawner.kt b/app/src/main/java/com/droiddeck/launcher/runtime/RootSpawner.kt index 16228be728..1791df54b0 100644 --- a/app/src/main/java/com/droiddeck/launcher/runtime/RootSpawner.kt +++ b/app/src/main/java/com/droiddeck/launcher/runtime/RootSpawner.kt @@ -8,7 +8,6 @@ import android.os.Process import android.util.Log import com.droiddeck.launcher.core.HostProcess import com.droiddeck.launcher.session.OrphanReaper -import com.droiddeck.launcher.session.SessionPrefs import org.json.JSONObject import java.io.DataInputStream import java.io.DataOutputStream @@ -128,7 +127,6 @@ object RootSpawner { clear() put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(context).path) - if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1") LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/session/BottomDesktop.kt b/app/src/main/java/com/droiddeck/launcher/session/BottomDesktop.kt index ffccd3e237..b815d29fdd 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/BottomDesktop.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/BottomDesktop.kt @@ -343,7 +343,8 @@ object BottomDesktop { LinuxRuntime.commandWithBinds(context, current.root, binds, guest) } val environment = if (current.nativeUserland) { - com.droiddeck.launcher.runtime.NativeGuest.sessionEnvironment(current.root, binds, guest.first(), SessionPrefs.guestHostname(context)) + val lseEmu = current.guest.lastOrNull { it.startsWith("LSE_EMU=") }?.substringAfter('=') + com.droiddeck.launcher.runtime.NativeGuest.sessionEnvironment(current.root, binds, guest.first(), SessionPrefs.guestHostname(context), lseEmu) .map { (k, v) -> "$k=$v" }.toTypedArray() } else current.hostEnvironment val line = command.joinToString(" ") { it.replace("\\", "\\\\").replace(" ", "\\ ") } diff --git a/app/src/main/java/com/droiddeck/launcher/session/FullscreenMode.kt b/app/src/main/java/com/droiddeck/launcher/session/FullscreenMode.kt new file mode 100644 index 0000000000..9d3cdd2e21 --- /dev/null +++ b/app/src/main/java/com/droiddeck/launcher/session/FullscreenMode.kt @@ -0,0 +1,18 @@ +package com.droiddeck.launcher.session + +import android.content.res.Configuration +import androidx.annotation.StringRes +import com.droiddeck.launcher.R + +enum class FullscreenMode(@StringRes val label: Int) { + ALWAYS(R.string.widgets_on), + LANDSCAPE_ONLY(R.string.setup_fullscreen_landscape_only), + OFF(R.string.widgets_off); + + fun hidesSystemBars(orientation: Int): Boolean = + this == ALWAYS || (this == LANDSCAPE_ONLY && orientation == Configuration.ORIENTATION_LANDSCAPE) + + companion object { + fun fromStored(value: String?): FullscreenMode? = entries.firstOrNull { it.name == value } + } +} diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt index d28ae192db..dc708cb51d 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionFiles.kt @@ -5,6 +5,7 @@ import android.content.Context import android.os.Environment import android.util.Log import com.droiddeck.launcher.R +import com.droiddeck.launcher.core.CpuFeatures import com.droiddeck.launcher.core.FileUtils import com.droiddeck.launcher.runtime.BwrapSpawner import com.droiddeck.launcher.runtime.DesktopCatalog @@ -22,6 +23,10 @@ object SessionFiles { private const val NO_PAD_SWITCH = "Download/droiddeck-no-pad" const val DIRECTAUDIO_DIR = "usr/local/lib/directaudio" private const val STAGED_LEDGER = "usr/local/.droiddeck-staged" + internal const val LSE_EMU = "usr/local/lib/droiddeck-lse/liblse_emu.so" + + internal fun lsePreload(lacksAtomics: Boolean, staged: Boolean, lseEmu: String? = null): String = + if (lacksAtomics && staged && lseEmu != "0") "/$LSE_EMU\n" else "" private const val IME_MANIFEST = "usr/local/share/droiddeck/ime-files.json" private const val IME_DEFAULT_MODE = 420 val DIRECTAUDIO_SETS = arrayOf("linux-wine11", "linux-wine11-systhread") @@ -102,10 +107,23 @@ object SessionFiles { } private val STAGE_LOCK = Any() + @Volatile private var activeSessionLseEmu: String? = null - fun stage(context: Context, root: File, startsSession: Boolean = false) = synchronized(STAGE_LOCK) { stageNow(context, root, startsSession) } + fun stage(context: Context, root: File, startsSession: Boolean = false) = + stage(context, root, startsSession, lseEmu = null) - private fun stageNow(context: Context, root: File, startsSession: Boolean) { + fun stage(context: Context, root: File, startsSession: Boolean, lseEmu: String?) = + synchronized(STAGE_LOCK) { + val selection = if (startsSession) { + activeSessionLseEmu = lseEmu + lseEmu + } else { + lseEmu ?: activeSessionLseEmu + } + stageNow(context, root, startsSession, selection) + } + + private fun stageNow(context: Context, root: File, startsSession: Boolean, lseEmu: String?) { if (DesktopCatalog.desktopInstalled(root) && !DesktopCatalog.desktopFromPack(root)) try { DesktopCatalog.cleanLegacy(context) } catch (e: Exception) { Log.w(TAG, "LXQt cleanup will retry next session", e) } GameEnvironmentStore.publish(context) @@ -281,6 +299,7 @@ object SessionFiles { "usr/local/lib/droiddeck-pipewire.tzst" to "usr/local/lib/droiddeck-pipewire.tzst", "usr/local/share/licenses/dwarfs/LICENSE" to "usr/local/share/licenses/dwarfs/LICENSE", "usr/local/share/licenses/uruntime/LICENSE" to "usr/local/share/licenses/uruntime/LICENSE", + LSE_EMU to LSE_EMU, ) + mangoapp + xclipse.map { it to it } + maliCompat + msitools.map { it to it } + vr + gpuLoad + fexPreloads).filter { (asset, _) -> val dir = asset.substringBeforeLast('/') runCatching { context.assets.list("linuxfs/$dir")?.contains(asset.substringAfterLast('/')) == true }.getOrDefault(false) @@ -343,20 +362,22 @@ object SessionFiles { stageImeFiles(context, root, 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/libddsession.so\n") + val preload = StringBuilder(lsePreload(CpuFeatures.lacksAtomics, File(root, LSE_EMU).isFile, lseEmu)) + preload.append("/usr/local/lib/libddsession.so\n") if (!File(Environment.getExternalStorageDirectory(), NO_PAD_SWITCH).exists()) { preload.append("/usr/local/lib/libfakeinput.so\n") } - val nativeUserland = SessionPrefs.nativeUserland(context) - if (nativeUserland) com.droiddeck.launcher.runtime.NativeGuest.prepare(context, root) - if (ProotFastPath.enabled(context)) { + com.droiddeck.launcher.runtime.NativeGuest.prepare(context, root) + val native = com.droiddeck.launcher.runtime.NativeGuest.available(root) + val nativePreload = preload.toString() + if (ProotFastPath.enabled(context, native)) { val library = com.droiddeck.launcher.agent.AgentEnv.fastPathLibrary(context) preload.append(library + "\n") if (startsSession && library != ProotFastPath.LIBRARY) Log.i(TAG, "fast path preload: $library (debugging override)") } val etc = File(root, "etc").apply { mkdirs() } File(etc, "droiddeck").mkdirs() - FileUtils.writeString(File(etc, "droiddeck/native-preload"), preload.toString()) + FileUtils.writeString(File(etc, "droiddeck/native-preload"), nativePreload) val staged = File(etc, "ld.so.preload.staged") if (!FileUtils.writeString(staged, preload.toString()) || !staged.renameTo(File(etc, "ld.so.preload"))) { diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt index e274182222..efbb31afbc 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionPrefs.kt @@ -112,10 +112,21 @@ object SessionPrefs { else -> false } - fun launcherFullscreen(context: Context): Boolean = prefs(context).getBoolean("launcherFullscreen", true) + fun launcherFullscreenMode(context: Context): FullscreenMode { + val preferences = prefs(context) + return FullscreenMode.fromStored(preferences.getString("launcherFullscreenMode", null)) + ?: if (preferences.getBoolean("launcherFullscreen", true)) FullscreenMode.ALWAYS else FullscreenMode.OFF + } - fun setLauncherFullscreen(context: Context, on: Boolean) { - prefs(context).edit().putBoolean("launcherFullscreen", on).apply() + fun setLauncherFullscreenMode(context: Context, mode: FullscreenMode) { + prefs(context).edit().putString("launcherFullscreenMode", mode.name).apply() + } + + fun sessionFullscreenMode(context: Context): FullscreenMode = + FullscreenMode.fromStored(prefs(context).getString("sessionFullscreenMode", null)) ?: FullscreenMode.ALWAYS + + fun setSessionFullscreenMode(context: Context, mode: FullscreenMode) { + prefs(context).edit().putString("sessionFullscreenMode", mode.name).apply() } fun launcherFrost(context: Context): Boolean = prefs(context).getBoolean("launcherFrost", false) @@ -1171,21 +1182,9 @@ object SessionPrefs { prefs(context).edit().putBoolean("mountSharedStorage", on).apply() } - fun prootNoSeccomp(context: Context): Boolean = prefs(context).getBoolean("prootNoSeccomp", false) - - fun setProotNoSeccomp(context: Context, on: Boolean) { - prefs(context).edit().putBoolean("prootNoSeccomp", on).apply() - } - - fun nativeUserland(context: Context): Boolean = prefs(context).getBoolean("nativeUserland", true) - /** The session's long-lived programs run in worker processes Android does not count (GuestWorkers). */ fun childProcessHandoff(context: Context): Boolean = prefs(context).getBoolean("childProcessHandoff", true) - fun setNativeUserland(context: Context, on: Boolean) { - prefs(context).edit().putBoolean("nativeUserland", on).apply() - } - /** Whether the Plasma desktop, and so its apps and shells, runs as an ordinary user instead of root (native userland only). */ fun desktopAsUser(context: Context): Boolean = prefs(context).getBoolean("desktopAsUser", false) @@ -1193,12 +1192,6 @@ object SessionPrefs { prefs(context).edit().putBoolean("desktopAsUser", on).apply() } - fun prootFastPath(context: Context): Boolean = prefs(context).getBoolean("prootFastPath", true) - - fun setProotFastPath(context: Context, on: Boolean) { - prefs(context).edit().putBoolean("prootFastPath", on).apply() - } - fun cursorComposite(context: Context): Boolean = prefs(context).getBoolean("cursorComposite", true) fun setCursorComposite(context: Context, on: Boolean) { diff --git a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt index 67992024db..fb6d3503f8 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SessionService.kt @@ -47,6 +47,7 @@ import com.droiddeck.launcher.input.SteamControllerBle import com.droiddeck.launcher.runtime.BwrapSpawner import com.droiddeck.launcher.runtime.LinuxNetworkLinkComponent import com.droiddeck.launcher.runtime.LinuxRuntime +import com.droiddeck.launcher.runtime.NativeGuest import com.droiddeck.launcher.runtime.ProotFastPath import com.droiddeck.launcher.runtime.UserApps import com.droiddeck.launcher.wayland.WaylandCompositor @@ -566,6 +567,7 @@ class SessionService : Service() { .onFailure { Log.w(TAG, "agent environment skipped", it) } val agentEnvironment = nextAgentEnvironment.getOrDefault(emptyList()) val customEnvironment = extraEnv() + val lseEmu = (customEnvironment + agentEnvironment).lastOrNull { it.startsWith("LSE_EMU=") }?.substringAfter('=') try { if (systemVulkan) { SystemVulkanDriver.prepare(this) @@ -575,7 +577,7 @@ class SessionService : Service() { } pruneSystemVulkanRuntime() } - SessionFiles.stage(this, root, startsSession = true) + SessionFiles.stage(this, root, startsSession = true, lseEmu = lseEmu) } catch (error: Exception) { Log.e(TAG, "Could not prepare the session graphics runtime", error) failSession(gen, "GRAPHICS_RUNTIME_FAILED", getString(R.string.session_graphics_runtime_failed), -1) @@ -783,12 +785,13 @@ class SessionService : Service() { SessionEvents.step("shm-clear") { FileUtils.clear(File(LinuxRuntime.liveDir(this), "shm")) } val sharedStorage = LinuxRuntime.sharedStorage(this) - val binds = sessionBinds(controllersOn, fakeInputDir, sessionDir, guest, sessionRoot, runtimeDir, sharedStorage) - val nativeUserland = com.droiddeck.launcher.runtime.NativeGuest.enabled(this) + val nativeUserland = NativeGuest.enabled(this) + val fastPath = ProotFastPath.enabled(this, nativeUserland) + val binds = sessionBinds(controllersOn, fakeInputDir, sessionDir, guest, sessionRoot, runtimeDir, sharedStorage, fastPath) synchronized(stopLock) { if (gen == sessionGen && SessionState.running) com.droiddeck.launcher.runtime.NativeGuest.sessionMode = nativeUserland } - val fastPathKey = if (ProotFastPath.enabled(this)) { + val fastPathKey = if (fastPath) { val prootBinds = LinuxRuntime.binds( this, sessionRoot, runtimeDir, sharedStorage, binds, ) @@ -809,16 +812,14 @@ class SessionService : Service() { LinuxRuntime.rememberSessionBinds(sessionBindSpecs) com.droiddeck.launcher.runtime.NativeGuest.command(root, guest.first(), guest.drop(1)) } else { + val reason = if (NativeGuest.loader(root) == null) "missing glibc loader" else "missing native hook" + Log.i(TAG, "guest runtime: using PRoot ($reason)") LinuxRuntime.command(this, sessionRoot, runtimeDir, sharedStorage, binds, guest) } val prootEnv = HostEnvironment() prootEnv["PROOT_LOADER"] = LinuxRuntime.prootLoader(this).path prootEnv["PROOT_TMP_DIR"] = LinuxRuntime.prootTempDir(this).path - if (SessionPrefs.prootNoSeccomp(this)) { - prootEnv["PROOT_NO_SECCOMP"] = "1" - if (!nativeUserland) Log.i(TAG, "proot: seccomp acceleration off by request") - } fastPathKey?.let { ProotFastPath.hostEnv(it).let { (k, v) -> prootEnv[k] = v } } for (key in listOf("PROOT_PROFILE", "PROOT_PROFILE_SLOW_US")) { guest.lastOrNull { it.startsWith("$key=") }?.substringAfter('=')?.let { prootEnv[key] = it } @@ -830,7 +831,7 @@ class SessionService : Service() { if (drives > 0) Log.i(TAG, "$drives Wine drive links given their guest paths back") val hostEnv = if (nativeUserland) HostEnvironment().also { env -> Log.i(TAG, "native userland: no proot (${sessionBindSpecs.size} mounts)") - com.droiddeck.launcher.runtime.NativeGuest.sessionEnvironment(root, sessionBindSpecs, guest.first(), SessionPrefs.guestHostname(this)) + com.droiddeck.launcher.runtime.NativeGuest.sessionEnvironment(root, sessionBindSpecs, guest.first(), SessionPrefs.guestHostname(this), lseEmu) .forEach { (k, v) -> env[k] = v } } else prootEnv @@ -1312,6 +1313,7 @@ class SessionService : Service() { sessionRoot: File, runtimeDir: File, sharedStorage: File?, + fastPath: Boolean, ): ArrayList { val binds = ArrayList() if (controllersOn) binds.add(fakeInputDir.path + ":/dev/input") @@ -1355,10 +1357,17 @@ class SessionService : Service() { if (controllersOn) components.add(RumbleComponent().also { it.attach(this) }) val home = File(LinuxRuntime.rootDir(this), "root") File(home, "Storage").mkdirs() + val addedExeFolders = com.droiddeck.launcher.frontend.AddedExes.list(this).map { File(it.folder) }.distinctBy { it.path } + val addedGameRoots = com.droiddeck.launcher.frontend.AddedGames.roots(this) + val addedFolders = (addedExeFolders + addedGameRoots.map { it.host }).distinctBy { it.path } + for (folder in addedFolders) { + if (com.droiddeck.launcher.files.AllFilesAccess.mayHideFilesIn(folder.path)) + Log.w(TAG, "added games: Android may hide .exe files in $folder because All files access is missing") + } if (sharedStorage != null) { binds.add(sharedStorage.path + ":/root/Storage") } else { - for (folder in com.droiddeck.launcher.frontend.AddedExes.list(this).map { File(it.folder) }.distinctBy { it.path }) { + for (folder in addedExeFolders) { val guest = com.droiddeck.launcher.frontend.AddedGames.guestPath(this, folder) ?: continue if (!guest.startsWith("/root/Storage/") || !folder.isDirectory) continue File(LinuxRuntime.rootDir(this), guest.removePrefix("/")).mkdirs() @@ -1409,7 +1418,7 @@ class SessionService : Service() { Log.w(TAG, "storage diagnostics: selected library could not be identified; metadata snapshot only") } } - for (root in com.droiddeck.launcher.frontend.AddedGames.roots(this)) { + for (root in addedGameRoots) { if (root.host.isDirectory && root.host.canRead()) { File(LinuxRuntime.rootDir(this), root.guest.removePrefix("/")).mkdirs() binds.add(root.host.path + ":" + root.guest) @@ -1438,7 +1447,7 @@ class SessionService : Service() { if (storageDiagnosticLibrary != null && library != null) libraries.add(SecondaryLibrary.CARD_GUESTS[0] to library.label) val gamesLibraries = GameStorage.gamesFolderLibraries(this) if (gamesLibraries.isNotEmpty()) { - var room = if (ProotFastPath.enabled(this)) { + var room = if (fastPath) { ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE for (games in gamesLibraries) { @@ -1480,7 +1489,7 @@ class SessionService : Service() { continue } try { - val room = if (ProotFastPath.enabled(this)) { + val room = if (fastPath) { ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE val content = SecondaryLibrary.contentPath(entry.host) @@ -1509,7 +1518,7 @@ class SessionService : Service() { if (problem != null) { Log.w(TAG, "x86-64 steam library: $problem") } else try { - val room = if (ProotFastPath.enabled(this)) { + val room = if (fastPath) { ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE val extra = SecondaryLibrary.binds(filesDir, x64, listOf(GameStorage.X64_CARD_GUEST)).drop(1) @@ -1531,7 +1540,7 @@ class SessionService : Service() { continue } try { - val room = if (ProotFastPath.enabled(this)) { + val room = if (fastPath) { ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE val extra = SecondaryLibrary.binds(filesDir, entry.x64Host, listOf(entry.x64Guest)).drop(1) @@ -1567,7 +1576,7 @@ class SessionService : Service() { try { val listing = File(filesDir, "session/desktop-volumes.json").apply { parentFile?.mkdirs() } val volumes = org.json.JSONArray() - var room = if (ProotFastPath.enabled(this)) { + var room = if (fastPath) { ProotFastPath.MAX_BINDS - LinuxRuntime.binds(this, sessionRoot, runtimeDir, sharedStorage, binds).size } else Int.MAX_VALUE for (root in com.droiddeck.launcher.files.StorageRoots.list(this)) { diff --git a/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt b/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt index e4fb6ed9c3..c9852d4b8b 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SettingsReset.kt @@ -12,7 +12,7 @@ object SettingsReset { private const val TAG = "SettingsReset" internal val SESSION_KEYS = setOf( - "orientation", "launcherFullscreen", "launcherFrost", "frostWallpaper", "frostCards", "frostTransparency", "frostCardTransparency", "controllerHaptics", "animations", "lowStorageWarning", "theme", "runSteamAtStartup", "startupSession", "addedGamesArt", + "orientation", "launcherFullscreen", "launcherFullscreenMode", "sessionFullscreenMode", "launcherFrost", "frostWallpaper", "frostCards", "frostTransparency", "frostCardTransparency", "controllerHaptics", "animations", "lowStorageWarning", "theme", "runSteamAtStartup", "startupSession", "addedGamesArt", "drawerWidthDp", "dualScreenMode", "dualScreenSessionMode", "dualScreenLauncher", "dualScreenSessionControls", "androidTextFieldKeyboard", "soundtracksIngame", "gameStoresSpeedTier", "gameStoresParallel", "storesOpenTab", "storesShowMature", "storesInstallLanguage", diff --git a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogComet.kt b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogComet.kt index 6f77df7990..56e8d6e128 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/gog/GogComet.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/gog/GogComet.kt @@ -8,7 +8,6 @@ import androidx.compose.runtime.setValue import com.droiddeck.launcher.core.AddonPack import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.session.SessionEvents -import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.session.SessionState import com.droiddeck.launcher.stores.Store import com.droiddeck.launcher.stores.AchievementNotifications @@ -149,7 +148,6 @@ object GogComet { remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH") put("PROOT_LOADER", LinuxRuntime.prootLoader(context).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(context).path) - if (SessionPrefs.prootNoSeccomp(context)) put("PROOT_NO_SECCOMP", "1") LinuxRuntime.prootLibraryPath(context).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } } diff --git a/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt b/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt index 07d47c78cd..6be4ddb14e 100644 --- a/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt +++ b/app/src/main/java/com/droiddeck/launcher/stores/xbox/Xodus.kt @@ -5,7 +5,6 @@ import com.droiddeck.launcher.core.AddonPack import com.droiddeck.launcher.runtime.LinuxNetworkLinkComponent import com.droiddeck.launcher.runtime.LinuxRuntime import com.droiddeck.launcher.runtime.ProotFastPath -import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.stores.StoreInstallRoot import org.json.JSONObject import java.io.Closeable @@ -107,7 +106,6 @@ internal object Xodus { remove("LD_PRELOAD"); remove("LD_AUDIT"); remove("LD_LIBRARY_PATH") put("PROOT_LOADER", LinuxRuntime.prootLoader(app).path) put("PROOT_TMP_DIR", LinuxRuntime.prootTempDir(app).path) - if (SessionPrefs.prootNoSeccomp(app)) put("PROOT_NO_SECCOMP", "1") fastPathKey?.let { ProotFastPath.hostEnv(it).let { (key, value) -> put(key, value) } } LinuxRuntime.prootLibraryPath(app).takeIf { it.isNotEmpty() }?.let { put("LD_LIBRARY_PATH", it) } } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/AgentPanels.kt b/app/src/main/java/com/droiddeck/launcher/ui/AgentPanels.kt index a462fca130..db538977f5 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/AgentPanels.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/AgentPanels.kt @@ -67,13 +67,18 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay import kotlinx.coroutines.withContext +@Composable +private fun agentPanelFrame(): Modifier = + Modifier.fillMaxWidth().clip(Shape14).background(MaterialTheme.colorScheme.surface) + .border(1.dp, LocalPalette.current.line, Shape14).padding(horizontal = 14.dp, vertical = 10.dp) + /** The model, reasoning effort, permissions and plan mode for the next turns; a conversation keeps going with whatever is chosen. */ @Composable internal fun AgentModelPicker() { val context = LocalContext.current val pal = LocalPalette.current val models = remember(AgentHost.harness) { AgentHost.models(context) } - Column(Modifier.fillMaxWidth().padding(bottom = 10.dp), verticalArrangement = Arrangement.spacedBy(10.dp)) { + Column(agentPanelFrame(), verticalArrangement = Arrangement.spacedBy(10.dp)) { Row(horizontalArrangement = Arrangement.spacedBy(8.dp), modifier = Modifier.horizontalScroll(rememberScrollState())) { val choices = listOf(AgentHarness.Model("", stringResource(R.string.agent_model_default))) + models for (choice in choices) { @@ -269,12 +274,8 @@ internal fun AgentProcessList(modifier: Modifier) { @Composable internal fun AgentUsage() { val context = LocalContext.current - val colors = MaterialTheme.colorScheme val pal = LocalPalette.current - Column( - Modifier.fillMaxWidth().clip(Shape14).background(colors.surface).border(1.dp, pal.line, Shape14).padding(horizontal = 14.dp, vertical = 10.dp), - verticalArrangement = Arrangement.spacedBy(8.dp), - ) { + Column(agentPanelFrame(), verticalArrangement = Arrangement.spacedBy(8.dp)) { if (AgentHost.window > 0) UsageRow( stringResource(R.string.agent_usage_context), stringResource(R.string.agent_usage_of, tokens(AgentHost.context), tokens(AgentHost.window)), diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt index 917a46e71d..b7bf1caaa0 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndScreen.kt @@ -88,6 +88,7 @@ import com.droiddeck.launcher.input.SecondScreenDisplay import com.droiddeck.launcher.core.DownloadSource import com.droiddeck.launcher.core.PhantomProcessLimit import com.droiddeck.launcher.core.PhantomProcessStatus +import com.droiddeck.launcher.session.FullscreenMode import com.droiddeck.launcher.session.SessionPrefs import kotlin.math.roundToInt import kotlinx.coroutines.withTimeoutOrNull @@ -176,7 +177,8 @@ class FrontEndState( val orientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, val launcherOrientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER, val homePage: String = com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_STEAM, - val launcherFullscreen: Boolean = true, + val launcherFullscreenMode: FullscreenMode = FullscreenMode.ALWAYS, + val sessionFullscreenMode: FullscreenMode = FullscreenMode.ALWAYS, val launcherFrost: Boolean = false, val frostWallpaper: Boolean = true, val frostCards: Boolean = true, @@ -276,7 +278,7 @@ class FrontEndActions( val onShareSessionLog: (File) -> Unit = {}, val onSaveSessionLog: (File) -> Unit = {}, val onDeleteSessionLog: (File, () -> Unit) -> Unit = { _, done -> done() }, - val onClearLogs: () -> Unit = {}, + val onClearLogs: (() -> Unit) -> Unit = {}, val onResetSettings: () -> Unit = {}, val onOffline: () -> Unit, val onOfflineAuto: () -> Unit = {}, @@ -288,7 +290,8 @@ class FrontEndActions( val onOrientation: (Int) -> Unit = {}, val onLauncherOrientation: (Int) -> Unit = {}, val onHomePage: (String) -> Unit = {}, - val onLauncherFullscreen: (Boolean) -> Unit = {}, + val onLauncherFullscreenMode: (FullscreenMode) -> Unit = {}, + val onSessionFullscreenMode: (FullscreenMode) -> Unit = {}, val onLauncherFrost: (Boolean) -> Unit = {}, val onFrostWallpaper: (Boolean) -> Unit = {}, val onFrostCards: (Boolean) -> Unit = {}, @@ -711,9 +714,12 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com if (anyFocused) return } } + val launcherFullscreen = s.launcherFullscreenMode.hidesSystemBars( + androidx.compose.ui.platform.LocalConfiguration.current.orientation, + ) androidx.compose.foundation.layout.BoxWithConstraints( modifier = Modifier.fillMaxSize().background(if (LocalFrost.current != null) Color.Transparent else colors.background) - .windowInsetsPadding(if (s.launcherFullscreen) WindowInsets.displayCutout else WindowInsets.systemBars) + .windowInsetsPadding(if (launcherFullscreen) WindowInsets.displayCutout else WindowInsets.systemBars) .onFocusChanged { anyFocused = it.hasFocus }, ) { val bottomNavigation = maxHeight > maxWidth diff --git a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt index 4047781350..b2e989f568 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/FrontEndSetup.kt @@ -85,6 +85,7 @@ import com.droiddeck.launcher.core.DeviceSupport import com.droiddeck.launcher.core.DownloadSource import com.droiddeck.launcher.core.PhantomProcessLimit import com.droiddeck.launcher.core.PhantomProcessStatus +import com.droiddeck.launcher.session.FullscreenMode import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.stores.download.StoreDownloadTier import com.droiddeck.launcher.R @@ -586,11 +587,17 @@ internal fun SetupPanel( SessionPrefs.setOrientation(ctx, "desktop", value) }, ) - ToggleRow( - host, "launcher-fullscreen", stringResource(R.string.setup_fullscreen), - if (s.launcherFullscreen) stringResource(R.string.setup_fullscreen_on) else stringResource(R.string.setup_fullscreen_off), - s.launcherFullscreen, - ) { a.onLauncherFullscreen(it) } + val fullscreenModes = FullscreenMode.entries.map { it to stringResource(it.label) } + ChoiceRow( + host, "launcher-fullscreen", stringResource(R.string.setup_launcher_fullscreen), + stringResource(R.string.setup_fullscreen_on), + fullscreenModes, s.launcherFullscreenMode, onPick = a.onLauncherFullscreenMode, + ) + ChoiceRow( + host, "session-fullscreen", stringResource(R.string.setup_session_fullscreen), + stringResource(R.string.setup_fullscreen_on), + fullscreenModes, s.sessionFullscreenMode, onPick = a.onSessionFullscreenMode, + ) ToggleRow( host, "page-swipe", stringResource(R.string.setup_page_swipe), stringResource(R.string.setup_page_swipe_hint), PageSwipe.on, @@ -678,89 +685,102 @@ internal fun SetupPanel( } } DEVELOPER_TAB -> { - val devContext = LocalContext.current + var manageLogs by rememberSaveable { mutableStateOf(false) } SettingsGroup(stringResource(R.string.dev_tools_title)) { - ToggleRow(host, "developer-tools", stringResource(R.string.dev_tools_title), stringResource(R.string.dev_tools_hint), DeveloperTools.on) { - DeveloperTools.set(devContext, it) + ToggleRow(host, "developer-tools", stringResource(R.string.dev_tools_show), stringResource(R.string.dev_tools_hint), DeveloperTools.on, sideBySide = true) { + DeveloperTools.set(ctx, it) + } + if (DeveloperTools.on) ToggleRow(host, "agent-commands", stringResource(R.string.setup_agent_commands), stringResource(R.string.setup_agent_commands_hint), s.agentCommands, sideBySide = true) { a.onAgentCommands() } + if (DeveloperTools.on && com.droiddeck.launcher.agent.AgentHost.available) { + ToggleRow(host, "agent-pet", stringResource(R.string.rail_agent), stringResource(R.string.dev_harness_overlay_hint), AgentPet.enabled, sideBySide = true) { + AgentPet.set(ctx, it) + } + if (AgentPet.enabled && !AgentPet.allowed && AgentPet.usesOverlayWindows(com.droiddeck.launcher.session.QuestExperimental.isSupported())) ActionRow( + stringResource(R.string.setup_agent_pet_float), stringResource(R.string.setup_agent_pet_float_hint), + stringResource(R.string.setup_agent_pet_allow), onClick = { AgentPet.requestFloating(ctx) }, sideBySide = true, + ) } - if (DeveloperTools.on) ActionRow( - stringResource(R.string.dev_ui_zoo), stringResource(R.string.dev_ui_zoo_hint), stringResource(R.string.dev_ui_zoo_open), - onClick = { DevPreview.zoo = true }, modifier = Modifier.testTag("dev-ui-zoo"), - ) - if (DeveloperTools.on) ToggleRow( - host, "preview-shortcuts", stringResource(R.string.dev_preview_shortcuts), stringResource(R.string.dev_preview_shortcuts_hint), - DevPreview.shortcuts, - ) { DevPreview.setShortcuts(devContext, it) } } - SettingsGroup(stringResource(R.string.dev_group_logs)) { - ToggleRow(host, "logs", stringResource(R.string.setup_logs), stringResource(R.string.setup_logs_hint), s.logsEnabled) { a.onLogs() } + if (DeveloperTools.on) SettingsGroup(stringResource(R.string.dev_group_previews)) { + ActionRow( + stringResource(R.string.dev_ui_zoo), stringResource(R.string.dev_ui_zoo_hint), stringResource(R.string.dev_ui_zoo_open), + onClick = { DevPreview.zoo = true }, modifier = Modifier.testTag("dev-ui-zoo"), sideBySide = true, + ) + ToggleRow( + host, "preview-shortcuts", stringResource(R.string.dev_preview_shortcuts), stringResource(R.string.dev_preview_shortcuts_hint), + DevPreview.shortcuts, sideBySide = true, + ) { DevPreview.setShortcuts(ctx, it) } + } + SettingsGroup(stringResource(R.string.dev_group_diagnostics)) { + ToggleRow(host, "logs", stringResource(R.string.setup_logs), stringResource(R.string.setup_logs_hint), s.logsEnabled, sideBySide = true) { a.onLogs() } if (DeveloperTools.on) ToggleRow( host, "enhanced-diagnostics", stringResource(R.string.setup_enhanced_diagnostics), - stringResource(R.string.setup_enhanced_diagnostics_hint), s.enhancedDiagnosticsArmed, + stringResource(R.string.setup_enhanced_diagnostics_hint), s.enhancedDiagnosticsArmed, sideBySide = true, ) { a.onEnhancedDiagnostics() } ToggleRow( host, "game-debug-logs", stringResource(R.string.setup_game_debug_logs), stringResource(if (s.gameDebugLogsNeedsRestart) R.string.setup_game_debug_logs_restart else R.string.setup_game_debug_logs_hint), s.gameDebugLogsEnabled, - enabled = s.logsEnabled, + enabled = s.logsEnabled, sideBySide = true, ) { a.onGameDebugLogs() } - if (DeveloperTools.on) ToggleRow(host, "vacdiag", stringResource(R.string.setup_vac_diag), stringResource(R.string.setup_vac_diag_hint), s.vacDiagnostics) { a.onVacDiagnostics() } - if (DeveloperTools.on) ToggleRow(host, "agent-commands", stringResource(R.string.setup_agent_commands), null, s.agentCommands) { a.onAgentCommands() } - if (DeveloperTools.on && com.droiddeck.launcher.agent.AgentHost.available) { - val agentContext = androidx.compose.ui.platform.LocalContext.current - ToggleRow(host, "agent-pet", stringResource(R.string.setup_agent_pet), stringResource(R.string.setup_agent_pet_hint), AgentPet.enabled) { - AgentPet.set(agentContext, it) - } - if (AgentPet.enabled && !AgentPet.allowed && AgentPet.usesOverlayWindows(com.droiddeck.launcher.session.QuestExperimental.isSupported())) ActionRow( - stringResource(R.string.setup_agent_pet_float), stringResource(R.string.setup_agent_pet_float_hint), - stringResource(R.string.setup_agent_pet_allow), onClick = { AgentPet.requestFloating(agentContext) }, - ) - } - if (DeveloperTools.on) ToggleRow(host, "graphics-logs", stringResource(R.string.setup_graphics_logs), stringResource(R.string.setup_graphics_logs_hint), s.graphicsLogs) { a.onGraphicsLogs() } - if (DeveloperTools.on && !s.adreno && com.droiddeck.launcher.session.SessionPrefs.steamGpuCompositingAllowed()) ToggleRow(host, "steam-gpu-drawing", stringResource(R.string.setup_steam_gpu_drawing), stringResource(R.string.setup_steam_gpu_drawing_hint), s.steamGpuDrawing) { a.onSteamGpuDrawing() } + if (DeveloperTools.on) ToggleRow(host, "vacdiag", stringResource(R.string.setup_vac_diag), stringResource(R.string.setup_vac_diag_hint), s.vacDiagnostics, sideBySide = true) { a.onVacDiagnostics() } + if (DeveloperTools.on) ToggleRow(host, "graphics-logs", stringResource(R.string.setup_graphics_logs), stringResource(R.string.setup_graphics_logs_hint), s.graphicsLogs, sideBySide = true) { a.onGraphicsLogs() } + if (DeveloperTools.on && !s.adreno && com.droiddeck.launcher.session.SessionPrefs.steamGpuCompositingAllowed()) ToggleRow(host, "steam-gpu-drawing", stringResource(R.string.setup_steam_gpu_drawing), stringResource(R.string.setup_steam_gpu_drawing_hint), s.steamGpuDrawing, sideBySide = true) { a.onSteamGpuDrawing() } + } + SettingsGroup(stringResource(R.string.dev_group_log_files)) { ActionRow(stringResource(R.string.setup_latest_logs), stringResource(R.string.drawer_logs_hint), stringResource(R.string.drawer_share_logs), a.onShareLogs, - progress = com.droiddeck.launcher.session.SessionLogShare.progress) - androidx.compose.material3.HorizontalDivider() - Text(stringResource(R.string.setup_log_sessions), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, - color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)) - Text(stringResource(R.string.setup_log_export_hint), fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, - modifier = Modifier.padding(start = 14.dp, end = 14.dp, bottom = 8.dp)) - val sessionLogs = remember(ctx, logsRefresh) { com.droiddeck.launcher.session.SessionLogShare.sessions(ctx).asReversed() } - if (sessionLogs.isEmpty()) { - Text(stringResource(R.string.setup_log_empty), fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, - modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)) - } - sessionLogs.forEach { folder -> - val active = folder == com.droiddeck.launcher.session.SessionPaths.current() - var details by remember(folder) { mutableStateOf(null) } - LaunchedEffect(folder, logsRefresh) { - details = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) { - com.droiddeck.launcher.session.SessionLogShare.details(folder) - } + progress = com.droiddeck.launcher.session.SessionLogShare.progress, sideBySide = true) + ActionRow( + stringResource(R.string.setup_saved_logs), stringResource(R.string.dev_log_manage_hint), + stringResource(if (manageLogs) R.string.common_close else R.string.setup_manage), + onClick = { manageLogs = !manageLogs }, sideBySide = true, + ) + if (manageLogs) { + Text(stringResource(R.string.setup_log_sessions), fontSize = 13.sp, fontWeight = FontWeight.SemiBold, + color = MaterialTheme.colorScheme.onSurfaceVariant, modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)) + Text(stringResource(R.string.setup_log_export_hint), fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.padding(start = 14.dp, end = 14.dp, bottom = 8.dp)) + val sessionLogs = remember(ctx, logsRefresh) { com.droiddeck.launcher.session.SessionLogShare.sessions(ctx).asReversed() } + if (sessionLogs.isEmpty()) { + Text(stringResource(R.string.setup_log_empty), fontSize = 13.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, + modifier = Modifier.padding(horizontal = 14.dp, vertical = 10.dp)) } - Column(Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 8.dp)) { - Text(folder.name, fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = MaterialTheme.colorScheme.onBackground, - maxLines = 1, overflow = TextOverflow.Ellipsis) - details?.let { detail -> - Text( - stringResource(R.string.setup_log_size_date, - android.text.format.Formatter.formatShortFileSize(ctx, detail.sizeBytes), - "${android.text.format.DateFormat.getDateFormat(ctx).format(java.util.Date(detail.modifiedAt))} ${android.text.format.DateFormat.getTimeFormat(ctx).format(java.util.Date(detail.modifiedAt))}"), - fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, - ) + sessionLogs.forEach { folder -> + val active = folder == com.droiddeck.launcher.session.SessionPaths.current() + var details by remember(folder) { mutableStateOf(null) } + LaunchedEffect(folder, logsRefresh) { + details = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) { + com.droiddeck.launcher.session.SessionLogShare.details(folder) + } } - if (active) Text(stringResource(R.string.setup_log_current), fontSize = 12.sp, color = MaterialTheme.colorScheme.primary) - Row(Modifier.fillMaxWidth().padding(top = 6.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) { - SecondaryButton(stringResource(R.string.setup_log_share), enabled = com.droiddeck.launcher.session.SessionLogShare.progress == null, compact = true, modifier = Modifier.weight(1f)) { a.onShareSessionLog(folder) } - SecondaryButton(stringResource(R.string.setup_log_save), enabled = com.droiddeck.launcher.session.SessionLogShare.progress == null, compact = true, modifier = Modifier.weight(1f)) { a.onSaveSessionLog(folder) } - SecondaryButton(stringResource(R.string.setup_log_delete), compact = true, enabled = !active, modifier = Modifier.weight(1f)) { deleteSessionLogs = folder } + Column(Modifier.fillMaxWidth().padding(horizontal = 14.dp, vertical = 8.dp)) { + Text(folder.name, fontSize = 14.sp, fontWeight = FontWeight.SemiBold, color = MaterialTheme.colorScheme.onBackground, + maxLines = 1, overflow = TextOverflow.Ellipsis) + details?.let { detail -> + Text( + stringResource(R.string.setup_log_size_date, + android.text.format.Formatter.formatShortFileSize(ctx, detail.sizeBytes), + "${android.text.format.DateFormat.getDateFormat(ctx).format(java.util.Date(detail.modifiedAt))} ${android.text.format.DateFormat.getTimeFormat(ctx).format(java.util.Date(detail.modifiedAt))}"), + fontSize = 12.sp, color = MaterialTheme.colorScheme.onSurfaceVariant, + ) + } + if (active) Text(stringResource(R.string.setup_log_current), fontSize = 12.sp, color = MaterialTheme.colorScheme.primary) + Row(Modifier.fillMaxWidth().padding(top = 6.dp), horizontalArrangement = Arrangement.spacedBy(8.dp)) { + SecondaryButton(stringResource(R.string.setup_log_share), enabled = com.droiddeck.launcher.session.SessionLogShare.progress == null, compact = true, modifier = Modifier.weight(1f)) { a.onShareSessionLog(folder) } + SecondaryButton(stringResource(R.string.setup_log_save), enabled = com.droiddeck.launcher.session.SessionLogShare.progress == null, compact = true, modifier = Modifier.weight(1f)) { a.onSaveSessionLog(folder) } + SecondaryButton(stringResource(R.string.setup_log_delete), compact = true, enabled = !active, modifier = Modifier.weight(1f)) { deleteSessionLogs = folder } + } } + androidx.compose.material3.HorizontalDivider() } - androidx.compose.material3.HorizontalDivider() + ActionRow(stringResource(R.string.setup_saved_logs_hint, com.droiddeck.launcher.session.SessionPaths.KEEP_SESSIONS), + null, stringResource(R.string.setup_clear_logs), + onClick = { a.onClearLogs { logsRefresh++ } }, sideBySide = true) } - ActionRow(stringResource(R.string.setup_saved_logs), stringResource(R.string.setup_saved_logs_hint, com.droiddeck.launcher.session.SessionPaths.KEEP_SESSIONS), stringResource(R.string.setup_clear_logs), a.onClearLogs) + } + SettingsGroup(stringResource(R.string.dev_group_reset)) { ActionRow(stringResource(R.string.setup_reset_settings), stringResource(R.string.setup_reset_settings_hint), - stringResource(R.string.setup_reset_settings_button), a.onResetSettings) + stringResource(R.string.setup_reset_settings_button), a.onResetSettings, sideBySide = true) } } GLASSES_TAB -> GlassesSetupPanel() diff --git a/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt b/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt index 69aa3c6f97..45edd262af 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/PerformanceDialog.kt @@ -46,9 +46,7 @@ fun PerformancePage( fsyncFirst: Boolean, gamescopeRealtime: Boolean, gpuClockPin: Boolean, - prootNoSeccomp: Boolean, - prootFastPath: Boolean, - nativeUserland: Boolean, + nativeDesktopAvailable: Boolean, desktopAsUser: Boolean, cursorComposite: Boolean, guestHostname: String, @@ -65,9 +63,6 @@ fun PerformancePage( onFsyncFirst: (Boolean) -> Unit, onGamescopeRealtime: (Boolean) -> Unit, onGpuClockPin: (Boolean) -> Unit, - onProotNoSeccomp: (Boolean) -> Unit, - onProotFastPath: (Boolean) -> Unit, - onNativeUserland: (Boolean) -> Unit, onDesktopAsUser: (Boolean) -> Unit, onCursorComposite: (Boolean) -> Unit, onGuestHostname: (String) -> Unit, @@ -152,26 +147,6 @@ fun PerformancePage( stringResource(R.string.perf_fastsync_hint), fastSync, onChange = onFastSync, ) - ToggleRow( - host, "seccomp", stringResource(R.string.perf_seccomp), - stringResource(R.string.perf_seccomp_hint), - prootNoSeccomp, onChange = onProotNoSeccomp, - ) - ToggleRow( - host, "fastpath", stringResource(R.string.perf_fastpath), - when { - nativeUserland -> stringResource(R.string.perf_fastpath_needs_proot) - prootNoSeccomp -> stringResource(R.string.perf_fastpath_needs_seccomp) - else -> stringResource(R.string.perf_fastpath_hint) - }, - prootFastPath && !prootNoSeccomp && !nativeUserland, enabled = !prootNoSeccomp && !nativeUserland, - onChange = onProotFastPath, - ) - ToggleRow( - host, "nativeuserland", stringResource(R.string.perf_native_userland), - stringResource(R.string.perf_native_userland_hint), - nativeUserland, onChange = onNativeUserland, - ) ToggleRow( host, "cursorcomposite", stringResource(R.string.perf_cursor_composite), stringResource(R.string.perf_cursor_composite_hint), @@ -198,8 +173,8 @@ fun PerformancePage( } ToggleRow( host, "desktopasuser", stringResource(R.string.perf_desktop_as_user), - stringResource(if (nativeUserland) R.string.perf_desktop_as_user_hint else R.string.perf_desktop_as_user_needs_native), - desktopAsUser && nativeUserland, enabled = nativeUserland, + stringResource(R.string.perf_desktop_as_user_hint), + desktopAsUser && nativeDesktopAvailable, enabled = nativeDesktopAvailable, onChange = onDesktopAsUser, ) } diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt index 84f8e3a01e..74b3db0887 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SessionOverlay.kt @@ -177,6 +177,7 @@ import com.droiddeck.launcher.gpu.ScreenEffectLooks import com.droiddeck.launcher.gpu.Cardboard import com.droiddeck.launcher.gpu.SteamVr import com.droiddeck.launcher.gpu.ScreenEffects +import com.droiddeck.launcher.session.FullscreenMode import com.droiddeck.launcher.session.SessionPrefs import com.droiddeck.launcher.session.ComponentsManager import com.droiddeck.launcher.input.PC_KEY_GROUP_IDS @@ -409,6 +410,8 @@ class DrawerActions( val paused: Boolean = false, val orientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, val onOrientation: (Int) -> Unit = {}, + val fullscreenMode: FullscreenMode = FullscreenMode.ALWAYS, + val onFullscreenMode: (FullscreenMode) -> Unit = {}, val onResume: () -> Unit = {}, val onPipAutoEnter: (Boolean) -> Unit = {}, val unfoldedControls: Boolean? = null, @@ -1010,6 +1013,10 @@ private fun DrawerDisplayPage(host: MenuHost, a: DrawerActions, track: (String) if (a.gameZoomAvailable) GameZoomRow(a.gameZoom, track, a.onGameZoom) ChoiceRow(host, "orientation", stringResource(R.string.setup_session_orientation), null, orientations, a.orientation, chipModifier = track("orientation"), onPick = a.onOrientation) + ChoiceRow(host, "session-fullscreen", stringResource(R.string.setup_session_fullscreen), + stringResource(R.string.setup_fullscreen_on), + FullscreenMode.entries.map { it to stringResource(it.label) }, a.fullscreenMode, + chipModifier = track("session-fullscreen"), onPick = a.onFullscreenMode) if (a.steam) PicturePositionRow(host, a.picturePosition, track("picture-position"), onPick = a.onPicturePosition) } val filters = SessionPrefs.upscalerChoices(LocalContext.current) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SettingsIndex.kt b/app/src/main/java/com/droiddeck/launcher/ui/SettingsIndex.kt index 26985370a5..088a10248b 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SettingsIndex.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SettingsIndex.kt @@ -85,9 +85,6 @@ internal object SettingsIndex { s(SettingsSection.PERFORMANCE, R.string.perf_esync, "esync", "sync", "wine"), s(SettingsSection.PERFORMANCE, R.string.perf_fsync, "fsync", "sync", "wine"), s(SettingsSection.PERFORMANCE, R.string.perf_fastsync, "ntsync", "sync", "wine"), - s(SettingsSection.PERFORMANCE, R.string.perf_seccomp, "proot"), - s(SettingsSection.PERFORMANCE, R.string.perf_fastpath, "proot"), - s(SettingsSection.PERFORMANCE, R.string.perf_native_userland, "proot"), s(SettingsSection.PERFORMANCE, R.string.perf_cursor_composite, "mouse", "cursor"), s(SettingsSection.PERFORMANCE, R.string.perf_hostname, "name"), s(SettingsSection.PERFORMANCE, R.string.perf_desktop_as_user, "root", "user", "sudo", "fakeroot"), @@ -116,7 +113,8 @@ internal object SettingsIndex { s(SettingsSection.LAUNCHER, R.string.setup_home, "home screen", "launcher"), s(SettingsSection.LAUNCHER, R.string.setup_launcher_orientation, "rotate", "portrait"), s(SettingsSection.LAUNCHER, R.string.setup_session_orientation, "rotate", "portrait"), - s(SettingsSection.LAUNCHER, R.string.setup_fullscreen), + s(SettingsSection.LAUNCHER, R.string.setup_launcher_fullscreen, "status bar", "navigation bar", "portrait"), + s(SettingsSection.LAUNCHER, R.string.setup_session_fullscreen, "status bar", "navigation bar", "portrait"), s(SettingsSection.LAUNCHER, R.string.setup_page_swipe, "gesture"), s(SettingsSection.LAUNCHER, R.string.setup_controller_haptics, "vibration", "rumble"), s(SettingsSection.LAUNCHER, R.string.setup_dual_screen_launcher, "thor", "second screen", "bottom screen"), @@ -130,7 +128,8 @@ internal object SettingsIndex { s(SettingsSection.DEVELOPER, R.string.setup_game_debug_logs, "logs", "wine", "proton"), SettingsEntry(SettingsPlace.SETTINGS, R.string.setup_enhanced_diagnostics, section = SettingsSection.DEVELOPER, words = listOf("logs"), developer = true), s(SettingsSection.DEVELOPER, R.string.setup_reset_settings, "default"), - s(SettingsSection.DEVELOPER, R.string.dev_tools_title, "agent", "ai", "claude", "codex"), + s(SettingsSection.DEVELOPER, R.string.dev_tools_show, "agent", "ai", "claude", "codex"), + SettingsEntry(SettingsPlace.SETTINGS, R.string.setup_agent_commands, section = SettingsSection.DEVELOPER, words = listOf("debugging tools", "cli"), developer = true), SettingsEntry(SettingsPlace.SETTINGS, R.string.setup_graphics_logs, section = SettingsSection.DEVELOPER, words = listOf("logs", "gpu"), developer = true), d(R.string.drawer_page_display, R.string.drawer_frame_limit, "fps", "cap", "limit", "non-steam", "desktop"), diff --git a/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt b/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt index 53a617b31b..b9ddae4311 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/SettingsWidgets.kt @@ -526,7 +526,7 @@ fun SettingsGroup(title: String, compact: Boolean = false, detail: String? = nul } @Composable -fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hintLines: Int? = null, stacked: Boolean = false, tightControlSpacing: Boolean = false, control: @Composable () -> Unit) { +fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hintLines: Int? = null, stacked: Boolean = false, tightControlSpacing: Boolean = false, sideBySide: Boolean = false, control: @Composable () -> Unit) { val compact = LocalCompactSettings.current val colors = MaterialTheme.colorScheme val pal = LocalPalette.current @@ -536,7 +536,7 @@ fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hint lineHeight = if (compact) 14.sp else androidx.compose.ui.unit.TextUnit.Unspecified, minLines = hintLines ?: 1, maxLines = hintLines ?: Int.MAX_VALUE, overflow = TextOverflow.Ellipsis) } - if (compact && !stacked) Column( + if (compact && !stacked && !sideBySide) Column( modifier = Modifier.searchTarget(label).fillMaxWidth().background(bg).padding(horizontal = 10.dp, vertical = 6.dp), ) { Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) { @@ -545,7 +545,7 @@ fun SettingsRow(label: String, hint: String?, highlighted: Boolean = false, hint control() } if (hint != null || hintLines != null) hintText(11.sp) - } else if (stacked || LocalNarrowPane.current) Column( + } else if (stacked || (LocalNarrowPane.current && !sideBySide)) Column( modifier = Modifier.searchTarget(label).fillMaxWidth().background(bg).padding( horizontal = if (compact) 10.dp else 14.dp, vertical = if (tightControlSpacing) 2.dp else if (compact) 6.dp else 12.dp), @@ -613,8 +613,8 @@ fun UncertainMark(description: String) { } @Composable -fun ToggleRow(host: MenuHost, key: String, label: String, hint: String?, checked: Boolean, enabled: Boolean = true, chipModifier: Modifier = Modifier, onChange: (Boolean) -> Unit) = - SettingsRow(label, hint) { +fun ToggleRow(host: MenuHost, key: String, label: String, hint: String?, checked: Boolean, enabled: Boolean = true, chipModifier: Modifier = Modifier, sideBySide: Boolean = false, onChange: (Boolean) -> Unit) = + SettingsRow(label, hint, sideBySide = sideBySide) { ToggleSwitch(checked, enabled, label, chipModifier.testTag("setting-$key")) { host.open = null; onChange(it) } } @@ -774,8 +774,10 @@ fun MultiRow( } @Composable -fun ActionRow(label: String, hint: String?, button: String, onClick: () -> Unit, progress: Float? = null, modifier: Modifier = Modifier) { - SettingsRow(label, hint) { SecondaryButton(button, modifier = modifier, progress = progress, onClick = onClick) } +fun ActionRow(label: String, hint: String?, button: String, onClick: () -> Unit, progress: Float? = null, modifier: Modifier = Modifier, sideBySide: Boolean = false) { + SettingsRow(label, hint, sideBySide = sideBySide) { + SecondaryButton(button, compact = sideBySide, modifier = modifier, progress = progress, onClick = onClick) + } } @Composable diff --git a/app/src/main/res/color/wireless_pairing_key_text.xml b/app/src/main/res/color/wireless_pairing_key_text.xml new file mode 100644 index 0000000000..62b63fbefb --- /dev/null +++ b/app/src/main/res/color/wireless_pairing_key_text.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/wireless_pairing_key.xml b/app/src/main/res/drawable/wireless_pairing_key.xml new file mode 100644 index 0000000000..51bffe4ff2 --- /dev/null +++ b/app/src/main/res/drawable/wireless_pairing_key.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/wireless_pairing_panel.xml b/app/src/main/res/drawable/wireless_pairing_panel.xml new file mode 100644 index 0000000000..4e88b9b826 --- /dev/null +++ b/app/src/main/res/drawable/wireless_pairing_panel.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/layout/wireless_pairing_keypad.xml b/app/src/main/res/layout/wireless_pairing_keypad.xml new file mode 100644 index 0000000000..159a4e75fd --- /dev/null +++ b/app/src/main/res/layout/wireless_pairing_keypad.xml @@ -0,0 +1,38 @@ + + + + +