refactor: remove PRoot tracer assumptions

This commit is contained in:
Kurt Himebauch committed 2026-12-05 16:32:36 -05:00
commit 57ce8e8534
23 files changed
+139 -362

No files matched your search

@@ -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
@@ -200,7 +201,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)
@@ -1352,8 +1354,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)
@@ -1462,7 +1468,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,
@@ -1792,11 +1799,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
@@ -2106,7 +2117,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
@@ -128,6 +128,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
@@ -643,6 +644,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)
@@ -940,7 +942,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()
@@ -2103,6 +2106,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) {
@@ -3309,6 +3318,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)
@@ -6664,6 +6674,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()
@@ -7377,7 +7389,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
if (hasFocus && airTriggersOpen) RedMagicAirTriggers.open(this)
if (hasFocus && !pipUi) {
retryFieldKeyboard(true)
goFullscreen()
applySessionFullscreen()
refreshClipboard()
}
updatePointerCapture()
@@ -7387,19 +7399,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
}
}
}
}
@@ -66,7 +66,7 @@ object LegacyNames {
Files.deleteIfExists(path)
}
/** Stands in for a /sys/class/thermal the kernel won't list; proot adds the bound zones' mount points to it. */
/** Directory for thermal zones when Android prevents listing /sys/class/thermal. */
const val NO_THERMAL = "etc/droiddeck/no-thermal"
@Synchronized
@@ -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 }
}
}
@@ -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)
@@ -43,7 +43,6 @@ internal class SessionSuspendController(
val parent: Int,
val started: Long,
val state: Char,
val tracer: Int,
)
private data class TaskIdentity(val process: ProcessRecord, val tid: Int, val started: Long)
@@ -186,7 +185,7 @@ internal class SessionSuspendController(
val liveHelpers = helpers.filter { pid ->
records.values.any { it.pid == pid && it.role == Role.HELPER_ROOT && it.started == byPid[pid]?.started }
}
for (process in descendants(root, processes, byPid) + processes.filter { it.tracer == root }) {
for (process in descendants(root, processes, byPid)) {
records.putIfAbsent(process.pid to process.started, ProcessRecord(process.pid, process.started, Role.SESSION_CHILD))
}
for (helper in liveHelpers) {
@@ -229,10 +228,7 @@ internal class SessionSuspendController(
val base = File(procRoot, pid.toString())
try {
val fields = readStat(File(base, "stat"))
val tracer = File(base, "status").useLines { lines ->
lines.firstOrNull { it.startsWith("TracerPid:") }?.substringAfter(':')?.trim()?.toIntOrNull() ?: 0
}
return ProcessInfo(pid, fields[1].toInt(), fields[19].toLong(), fields[0].first(), tracer)
return ProcessInfo(pid, fields[1].toInt(), fields[19].toLong(), fields[0].first())
} catch (error: IOException) {
if (procRoot.list()?.contains(pid.toString()) == false) return null
throw error
@@ -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",
@@ -86,6 +86,7 @@ import com.droiddeck.launcher.gpu.FrameGen
import com.droiddeck.launcher.gpu.Lossless
import com.droiddeck.launcher.input.SecondScreenDisplay
import com.droiddeck.launcher.core.DownloadSource
import com.droiddeck.launcher.session.FullscreenMode
import com.droiddeck.launcher.session.SessionPrefs
import kotlin.math.roundToInt
import kotlinx.coroutines.withTimeoutOrNull
@@ -172,7 +173,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,
@@ -284,7 +286,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 = {},
@@ -648,9 +651,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
@@ -83,6 +83,7 @@ import androidx.compose.ui.layout.onGloballyPositioned
import com.droiddeck.launcher.core.AppLanguage
import com.droiddeck.launcher.core.DeviceSupport
import com.droiddeck.launcher.core.DownloadSource
import com.droiddeck.launcher.session.FullscreenMode
import com.droiddeck.launcher.session.SessionPrefs
import com.droiddeck.launcher.stores.download.StoreDownloadTier
import com.droiddeck.launcher.R
@@ -522,11 +523,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,
@@ -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
@@ -406,6 +407,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,
@@ -1009,6 +1012,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)
@@ -112,7 +112,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"),
+3
View File
@@ -1024,6 +1024,9 @@
<string name="setup_orientation_landscape">Landscape</string>
<string name="setup_orientation_reverse">Reverse landscape</string>
<string name="setup_fullscreen">Fullscreen</string>
<string name="setup_launcher_fullscreen">Launcher fullscreen</string>
<string name="setup_session_fullscreen">Session fullscreen</string>
<string name="setup_fullscreen_landscape_only">Landscape only</string>
<string name="setup_fullscreen_on">Hides the Android status and navigation bars</string>
<string name="setup_fullscreen_off">Shows the Android status and navigation bars</string>
<string name="setup_page_swipe">Swipe between pages</string>
@@ -255,21 +255,9 @@ class SessionSuspendControllerTest {
assertTrue(fixture.signals.count { it.pid == GAME && it.signal == STOP } >= 16)
}
@Test fun lateReparentedTraceeIsDiscoveredAndResumed() {
val fixture = fixture(17)
val late = Group(600, 1, ROOT, mutableListOf(Task(600, 6000, 'S')))
fixture.afterSleep = {
if (fixture.root.threads.first().state == 'T' && late !in fixture.groups) fixture.groups += late
}
fixture.controller.freeze { assertTrue(it) }
assertEquals('t', late.threads.first().state)
fixture.controller.resume { assertTrue(it) }
assertEquals('S', late.threads.first().state)
}
@Test fun descendantHelperKeepsRootStopAndResumeOrdering() {
val fixture = fixture(17)
val helper = Group(700, ROOT, 0, mutableListOf(Task(700, 7000, 'S')))
val helper = Group(700, ROOT, mutableListOf(Task(700, 7000, 'S')))
fixture.groups += helper
fixture.helpers += helper.pid
fixture.sync()
@@ -283,7 +271,7 @@ class SessionSuspendControllerTest {
@Test fun retainedHelperDoesNotAdoptAReusedPidOnRefreeze() {
val fixture = fixture(17)
val helper = Group(700, 9000, 0, mutableListOf(Task(700, 7000, 'S')))
val helper = Group(700, 9000, mutableListOf(Task(700, 7000, 'S')))
fixture.groups += helper
fixture.helpers += helper.pid
fixture.sync()
@@ -399,7 +387,6 @@ class SessionSuspendControllerTest {
fixture.controller.freeze { assertTrue(it) }
fixture.game.threads.first().apply { started++; state = 'S' }
fixture.game.parent = 1
fixture.game.tracer = 0
fixture.sync()
val before = fixture.signals.size
fixture.controller.resume { assertTrue(it) }
@@ -486,12 +473,12 @@ class SessionSuspendControllerTest {
Fixture(temporary.newFolder(), temporary.newFolder(), count, executor)
private data class Task(val tid: Int, var started: Long, var state: Char, var cpu: Long = 0)
private data class Group(val pid: Int, var parent: Int, var tracer: Int, val threads: MutableList<Task>)
private data class Group(val pid: Int, var parent: Int, val threads: MutableList<Task>)
private data class SentSignal(val pid: Int, val signal: Int)
private class Fixture(val proc: File, tmp: File, count: Int, executor: QueueExecutor) {
val root = Group(ROOT, 9000, 0, mutableListOf(Task(ROOT, 1000, 'S')))
val game = Group(GAME, ROOT, ROOT, MutableList(count) { Task(GAME + it, 2000L + it, 'S') })
val root = Group(ROOT, 9000, mutableListOf(Task(ROOT, 1000, 'S')))
val game = Group(GAME, ROOT, MutableList(count) { Task(GAME + it, 2000L + it, 'S') })
val groups = mutableListOf(root, game)
val helpers = mutableListOf<Int>()
val signals = mutableListOf<SentSignal>()
@@ -608,8 +595,7 @@ class SessionSuspendControllerTest {
if (group == game && missingGameStat) stat.delete()
else stat.writeText(stat(group, group.threads.first()))
File(dir, "status").writeText(
"TracerPid: ${group.tracer}\n" +
if (group == game) "VmRSS:\t$gameResidentKb kB\nVmSwap:\t$gameSwapKb kB\n" else "",
if (group == game) "VmRSS:\t$gameResidentKb kB\nVmSwap:\t$gameSwapKb kB\n" else "",
)
if (group == game) File(dir, "maps").writeText("7f00000000-7f00001000 r-xp 00000000 fe:05 42 /usr/local/lib/libddsession.so\n")
val taskDir = File(dir, "task")
+2 -5
View File
@@ -522,11 +522,8 @@ the old behavior and the old requirement.
Steam client under FEX (14, against 55 without the handoff), Splinter Cell through Ubisoft
Connect (14, against 65), Star Wars: Galaxy of Heroes (EA, 14), 9 Years of Shadows (GOG, 14),
run mode with 40 background jobs (1), the desktop at rest (17–20) and
with a terminal's 40 background jobs (20). PRoot sessions keep the old behavior and still need
the developer option: with the limit on, Android killed 30 of their processes and the session
failed;
- Wine-heavy launchers and anti-cheat;
- a settings switch for `childProcessHandoff`.
with a terminal's 40 background jobs (20).
- Wine-heavy launchers and anti-cheat.
7. A (the isolated tier) only if B stops working on a future Android; it needs a file and socket
broker and keeps the GPU outside.
+2 -1
View File
@@ -41,7 +41,8 @@ Links of the form `droiddeck://settings/<section>` open a Settings section direc
| Use as Home screen | Settings › Launcher (`droiddeck://settings/launcher`) | home screen, launcher |
| Launcher orientation | Settings › Launcher (`droiddeck://settings/launcher`) | rotate, portrait |
| Session orientation | Settings › Launcher (`droiddeck://settings/launcher`) | rotate, portrait |
| Fullscreen | Settings › Launcher (`droiddeck://settings/launcher`) | |
| Launcher fullscreen | Settings › Launcher (`droiddeck://settings/launcher`) | status bar, navigation bar, portrait |
| Session fullscreen | Settings › Launcher (`droiddeck://settings/launcher`) | status bar, navigation bar, portrait |
| Swipe between pages | Settings › Launcher (`droiddeck://settings/launcher`) | gesture |
| Controller haptics | Settings › Launcher (`droiddeck://settings/launcher`) | vibration, rumble |
| Dual screen launcher | Settings › Launcher (`droiddeck://settings/launcher`) | thor, second screen, bottom screen |
@@ -805,7 +805,6 @@ export STEAM_RUNTIME=1
[ -d "$X64_HOME/steamrt-shim/bin" ] && export PATH=$X64_HOME/steamrt-shim/bin:$PATH
export LD_LIBRARY_PATH=$STEAM_X64/steamrt64:$STEAM_X64/steamrt64/panorama:$X64_HOME/steamrt-libs
export STEAM_STEAMRT_RECURSION_GUARD=1
export DD_WEBHELPER_HIDE_TRACER=1
}
x64_manifest_version() {
@@ -9,7 +9,7 @@ for v in $(compgen -e); do
case $v in FEX_*) unset "$v" ;; esac
done
unset LD_LIBRARY_PATH LD_PRELOAD STEAM_RUNTIME_STEAMRT STEAM_STEAMRT_RECURSION_GUARD \
LIBGL_ALWAYS_SOFTWARE LIBGL_DRI3_DISABLE GALLIUM_DRIVER DD_WEBHELPER_HIDE_TRACER
LIBGL_ALWAYS_SOFTWARE LIBGL_DRI3_DISABLE GALLIUM_DRIVER
game_display=${DISPLAY:-}
if [ -f "$x64_home/arm-session.env" ]; then
@@ -5,7 +5,7 @@ arm=/root/.local/share/Steam/steamrtarm64
for v in $(compgen -e); do
case $v in FEX_*) unset "$v" ;; esac
done
unset LD_PRELOAD LIBGL_ALWAYS_SOFTWARE LIBGL_DRI3_DISABLE DD_WEBHELPER_HIDE_TRACER DD_X64_ARM_WEBHELPER
unset LD_PRELOAD LIBGL_ALWAYS_SOFTWARE LIBGL_DRI3_DISABLE DD_X64_ARM_WEBHELPER
if [ -f "$x64_home/arm-session.env" ]; then
eval "$(grep -E '^declare -x (VK_ICD_FILENAMES|VK_DRIVER_FILES|GALLIUM_DRIVER|MESA_LOADER_DRIVER_OVERRIDE|LIBGL_KOPPER_DRI2|TU_DEBUG|ZINK_DEBUG|ZINK_DESCRIPTORS|MESA_NO_ERROR|MESA_DISK_CACHE_DATABASE)=' "$x64_home/arm-session.env")"
fi
+3 -12
View File
@@ -609,18 +609,9 @@ static FILE *synthesize(int table) {
return out;
}
int dd_status_without_tracer(const char *path, int flags, const void *caller) __attribute__((visibility("hidden")));
const char *dd_oom_adj_redirect(const char *path, int writing) __attribute__((visibility("hidden")));
static FILE *open_stream(fopen_fn real, const char *path, const char *mode, const void *caller) {
int status = mode && mode[0] == 'r' && !strchr(mode, '+')
? dd_status_without_tracer(path, O_RDONLY | O_CLOEXEC, caller) : -1;
if (status >= 0) {
FILE *copy = fdopen(status, "r");
if (copy == NULL) close(status);
return copy;
}
static FILE *open_stream(fopen_fn real, const char *path, const char *mode) {
path = dd_oom_adj_redirect(path, mode && (mode[0] == 'w' || mode[0] == 'a' || strchr(mode, '+')));
int table = path && mode && mode[0] == 'r' ? denied_table(path) : -1;
FILE *f;
@@ -666,13 +657,13 @@ int dd_net_open(const char *path, int flags, int fd) {
FILE *fopen(const char *path, const char *mode) {
static fopen_fn real;
if (real == NULL) real = (fopen_fn) dlsym(RTLD_NEXT, "fopen");
return open_stream(real, path, mode, __builtin_return_address(0));
return open_stream(real, path, mode);
}
FILE *fopen64(const char *path, const char *mode) {
static fopen_fn real;
if (real == NULL) real = (fopen_fn) dlsym(RTLD_NEXT, "fopen64");
return open_stream(real, path, mode, __builtin_return_address(0));
return open_stream(real, path, mode);
}
#define NL_REQUEST_MAX 1024
+6 -9
View File
@@ -11,7 +11,6 @@
#include <string.h>
#include <sys/types.h>
int dd_status_without_tracer(const char *path, int flags, const void *caller) __attribute__((visibility("hidden")));
int dd_writable_retry(int dirfd, const char *path, int flags) __attribute__((visibility("hidden")));
int dd_ntsync_open(const char *path, int flags) __attribute__((visibility("hidden")));
const char *dd_oom_adj_redirect(const char *path, int writing) __attribute__((visibility("hidden")));
@@ -43,7 +42,7 @@ static int is_trace_marker(const char *path) {
|| strcmp(path, "/sys/kernel/debug/tracing/trace_marker") == 0);
}
static int open_from(const char *path, int flags, mode_t mode, const void *caller) {
static int session_open(const char *path, int flags, mode_t mode) {
int fd;
if (is_trace_marker(path)) {
@@ -51,7 +50,6 @@ static int open_from(const char *path, int flags, mode_t mode, const void *calle
return -1;
}
path = dd_oom_adj_redirect(path, (flags & O_ACCMODE) != O_RDONLY);
if ((fd = dd_status_without_tracer(path, flags, caller)) >= 0) return fd;
if ((fd = dd_ntsync_open(path, flags)) != -2) return fd;
if ((fd = dd_venc_open(path, flags)) != -2) return fd;
if ((fd = dd_vdec_open(path, flags)) != -2) return fd;
@@ -66,7 +64,7 @@ static int open_from(const char *path, int flags, mode_t mode, const void *calle
return dd_net_open(path, flags, fd);
}
static int openat_from(int dirfd, const char *path, int flags, mode_t mode, const void *caller) {
static int session_openat(int dirfd, const char *path, int flags, mode_t mode) {
int fd;
if (is_trace_marker(path)) {
@@ -74,7 +72,6 @@ static int openat_from(int dirfd, const char *path, int flags, mode_t mode, cons
return -1;
}
path = dd_oom_adj_redirect(path, (flags & O_ACCMODE) != O_RDONLY);
if ((fd = dd_status_without_tracer(path, flags, caller)) >= 0) return fd;
if ((fd = dd_ntsync_open(path, flags)) != -2) return fd;
if ((fd = dd_venc_open(path, flags)) != -2) return fd;
if ((fd = dd_vdec_open(path, flags)) != -2) return fd;
@@ -96,7 +93,7 @@ int open(const char *path, int flags, ...) {
va_start(ap, flags);
mode = va_arg(ap, mode_t);
va_end(ap);
return open_from(path, flags, mode, __builtin_return_address(0));
return session_open(path, flags, mode);
}
int openat(int dirfd, const char *path, int flags, ...) {
@@ -106,7 +103,7 @@ int openat(int dirfd, const char *path, int flags, ...) {
va_start(ap, flags);
mode = va_arg(ap, mode_t);
va_end(ap);
return openat_from(dirfd, path, flags, mode, __builtin_return_address(0));
return session_openat(dirfd, path, flags, mode);
}
#ifdef __OFF_T_MATCHES_OFF64_T
@@ -120,7 +117,7 @@ int open64(const char *path, int flags, ...) {
va_start(ap, flags);
mode = va_arg(ap, mode_t);
va_end(ap);
return open_from(path, flags | O_LARGEFILE, mode, __builtin_return_address(0));
return session_open(path, flags | O_LARGEFILE, mode);
}
int openat64(int dirfd, const char *path, int flags, ...) {
@@ -130,6 +127,6 @@ int openat64(int dirfd, const char *path, int flags, ...) {
va_start(ap, flags);
mode = va_arg(ap, mode_t);
va_end(ap);
return openat_from(dirfd, path, flags | O_LARGEFILE, mode, __builtin_return_address(0));
return session_openat(dirfd, path, flags | O_LARGEFILE, mode);
}
#endif
-122
View File
@@ -1,122 +0,0 @@
/*
* Ported from WinNative (maxjivi05, feature/wayland-gamescope, 2026-09-18/19), GPL-3.0.
*/
#define _GNU_SOURCE
#include <ctype.h>
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <unistd.h>
#define STATUS_MAX 16384
#define TRACER_FIELD "\nTracerPid:\t"
int dd_from_ntdll(const void *caller) __attribute__((visibility("hidden")));
static const char *skip_digits(const char *s) {
const char *end = s;
while (isdigit((unsigned char)*end)) end++;
return end == s ? NULL : end;
}
static long status_pid(const char *path) {
const char *rest;
long pid = 0;
if (path == NULL || strncmp(path, "/proc/", 6) != 0) return -1;
path += 6;
if (strncmp(path, "self/", 5) == 0) rest = path + 4;
else if (strncmp(path, "thread-self/", 12) == 0) rest = path + 11;
else if ((rest = skip_digits(path)) == NULL) return -1;
else pid = strtol(path, NULL, 10);
if (strncmp(rest, "/task/", 6) == 0 && (rest = skip_digits(rest + 6)) == NULL) return -1;
return strcmp(rest, "/status") == 0 ? pid : -1;
}
static int is_web_helper(const void *caller) {
if (strcmp(program_invocation_short_name, "steamwebhelper") != 0 &&
strcmp(program_invocation_short_name, "vrwebhelper") != 0)
return 0;
const char *hide = getenv("DD_WEBHELPER_HIDE_TRACER");
Dl_info info;
if (hide && hide[0] == '1' && caller && dladdr(caller, &info) && info.dli_fname
&& strstr(info.dli_fname, "libtier0_s.so"))
return 0;
return 1;
}
static int write_all(int fd, const char *data, size_t len) {
while (len > 0) {
ssize_t n = write(fd, data, len);
if (n < 0 && errno == EINTR) continue;
if (n <= 0) return -1;
data += n;
len -= (size_t)n;
}
return 0;
}
static int read_only_copy(const char *data, size_t len, int flags) {
char path[] = "/tmp/.droiddeck-status-XXXXXX";
int rw = mkostemp(path, O_CLOEXEC);
if (rw < 0) return -1;
int ro = -1;
if (write_all(rw, data, len) == 0)
ro = (int)syscall(SYS_openat, AT_FDCWD, path, O_RDONLY | (flags & O_CLOEXEC));
unlink(path);
close(rw);
return ro;
}
static __attribute__((noinline)) int status_copy(const char *path, int flags, long pid) {
char text[STATUS_MAX];
size_t len = 0;
int saved = errno;
int out = -1;
// through the next open(): the native userland's hook gives the app's ids as root's there
static int (*next_open)(const char *, int, ...) = NULL;
if (!next_open) next_open = (int (*)(const char *, int, ...))dlsym(RTLD_NEXT, "open");
int in = next_open ? next_open(path, O_RDONLY | O_CLOEXEC) : (int)syscall(SYS_openat, AT_FDCWD, path, O_RDONLY | O_CLOEXEC);
if (in < 0) goto done;
for (;;) {
ssize_t n = read(in, text + len, sizeof(text) - 1 - len);
if (n < 0 && errno == EINTR) continue;
if (n <= 0) break;
len += (size_t)n;
}
close(in);
text[len] = '\0';
char *field = strstr(text, TRACER_FIELD);
if (field == NULL) goto done;
char *value = field + strlen(TRACER_FIELD);
char *line_end = strchr(value, '\n');
if (line_end == NULL || line_end == value) goto done;
memmove(value + 1, line_end, len - (size_t)(line_end - text) + 1);
*value = '0';
len = (size_t)(value + 1 - text) + strlen(value + 1);
if (pid != 0 && pid != getpid() && (out = read_only_copy(text, len, flags)) >= 0) goto done;
out = memfd_create("status", (flags & O_CLOEXEC) ? MFD_CLOEXEC : 0);
if (out < 0) goto done;
if (write_all(out, text, len) != 0 || lseek(out, 0, SEEK_SET) != 0) {
close(out);
out = -1;
}
done:
errno = saved;
return out;
}
__attribute__((visibility("hidden"))) int dd_status_without_tracer(const char *path, int flags, const void *caller) {
long pid;
if ((flags & O_ACCMODE) != O_RDONLY || (pid = status_pid(path)) < 0 || is_web_helper(caller) || dd_from_ntdll(caller))
return -1;
return status_copy(path, flags, pid);
}
@@ -8,7 +8,6 @@ PRELOAD = Path(__file__).resolve().parents[1] / "linuxfs/preload"
LIMIT = 1024
WRAPPERS = {
"descriptor.c": ("dd_descriptor_unlink", "dd_descriptor_rmdir", "dd_descriptor_remove", "dd_descriptor_rename"),
"tracer.c": ("dd_status_without_tracer",),
}
-154
View File
@@ -1,154 +0,0 @@
import os
from pathlib import Path
import shutil
import subprocess
import tempfile
import unittest
PRELOAD = Path(__file__).resolve().parents[1] / "linuxfs/preload"
NTDLL = r"""
#define _GNU_SOURCE
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
__attribute__((noinline)) int ntdll_open(const char *path) {
int fd = open(path, O_RDONLY | O_CLOEXEC);
__asm__ volatile("" ::: "memory");
return fd;
}
__attribute__((noinline)) int ntdll_openat(const char *path) {
int fd = openat(AT_FDCWD, path, O_RDONLY | O_CLOEXEC);
__asm__ volatile("" ::: "memory");
return fd;
}
__attribute__((noinline)) FILE *ntdll_fopen(const char *path) {
FILE *f = fopen(path, "r");
__asm__ volatile("" ::: "memory");
return f;
}
"""
PROGRAM = r"""
#define _GNU_SOURCE
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
#include <unistd.h>
int ntdll_open(const char *path);
int ntdll_openat(const char *path);
FILE *ntdll_fopen(const char *path);
static void report(const char *name, int fd) {
char link[64], target[256] = "", text[16384], *field;
ssize_t n;
long tracer = -1;
if (fd < 0) {
printf("%s failed\n", name);
return;
}
snprintf(link, sizeof(link), "/proc/self/fd/%d", fd);
n = readlink(link, target, sizeof(target) - 1);
target[n > 0 ? n : 0] = '\0';
n = pread(fd, text, sizeof(text) - 1, 0);
text[n > 0 ? n : 0] = '\0';
if ((field = strstr(text, "\nTracerPid:\t")) != NULL) tracer = strtol(field + 12, NULL, 10);
const char *kind = strncmp(target, "/proc/", 6) == 0 ? "proc"
: strncmp(target, "/memfd:", 7) == 0 ? "memfd"
: strncmp(target, "/tmp/.droiddeck-status-", 23) == 0 ? "copy" : target;
printf("%s kind=%s tracer=%s rdonly=%d vm=%d\n", name, kind, tracer == 0 ? "hidden" : tracer > 0 ? "shown" : "missing",
(fcntl(fd, F_GETFL) & O_ACCMODE) == O_RDONLY, strstr(text, "\nVmRSS:") != NULL);
close(fd);
}
static void report_stream(const char *name, FILE *f) {
if (f == NULL) {
printf("%s failed\n", name);
return;
}
report(name, dup(fileno(f)));
fclose(f);
}
int main(void) {
int ready[2];
if (pipe(ready) != 0) return 1;
pid_t child = fork();
if (child == 0) {
char ok = ptrace(PTRACE_TRACEME, 0, NULL, NULL) == 0;
if (write(ready[1], &ok, 1) != 1) _exit(1);
for (;;) pause();
}
char ok = 0;
if (read(ready[0], &ok, 1) != 1 || !ok) {
kill(child, SIGKILL);
waitpid(child, NULL, 0);
puts("no ptrace");
return 0;
}
char other[64], self[64];
snprintf(other, sizeof(other), "/proc/%d/status", (int)child);
snprintf(self, sizeof(self), "/proc/%d/status", (int)getpid());
report("main_other_open", open(other, O_RDONLY | O_CLOEXEC));
report_stream("main_other_fopen", fopen(other, "r"));
report("main_self_open", open("/proc/self/status", O_RDONLY | O_CLOEXEC));
report("ntdll_other_open", ntdll_open(other));
report("ntdll_other_openat", ntdll_openat(other));
report_stream("ntdll_other_fopen", ntdll_fopen(other));
report_stream("ntdll_self_fopen", ntdll_fopen(self));
kill(child, SIGKILL);
waitpid(child, NULL, 0);
return 0;
}
"""
class TracerPreloadTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
if not shutil.which("cc"):
raise unittest.SkipTest("no compiler")
cls.tmp = tempfile.TemporaryDirectory()
tmp = Path(cls.tmp.name)
(tmp / "ntdll.c").write_text(NTDLL)
(tmp / "prog.c").write_text(PROGRAM)
sources = sorted(str(p) for p in PRELOAD.glob("*.c"))
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-Wall", "-pthread", "-o", str(tmp / "libddsession.so"), *sources, "-ldl"],
check=True)
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(tmp / "ntdll.so"), str(tmp / "ntdll.c")], check=True)
subprocess.run(["cc", "-O1", "-o", str(tmp / "prog"), str(tmp / "prog.c"), str(tmp / "ntdll.so"), "-Wl,-rpath," + str(tmp)],
check=True)
env = dict(os.environ, LD_PRELOAD=str(tmp / "libddsession.so"))
out = subprocess.run([str(tmp / "prog")], env=env, capture_output=True, text=True, timeout=60)
if out.returncode != 0:
raise AssertionError(out.stdout + out.stderr)
if "no ptrace" in out.stdout:
raise unittest.SkipTest("ptrace not allowed")
cls.lines = dict(line.split(" ", 1) for line in out.stdout.splitlines())
@classmethod
def tearDownClass(cls):
cls.tmp.cleanup()
def test_other_programs_still_see_no_tracer(self):
self.assertEqual(self.lines["main_other_open"], "kind=copy tracer=hidden rdonly=1 vm=1")
self.assertEqual(self.lines["main_other_fopen"], "kind=copy tracer=hidden rdonly=1 vm=1")
self.assertEqual(self.lines["main_self_open"], "kind=memfd tracer=hidden rdonly=0 vm=1")
def test_wine_reads_the_real_status_file(self):
for name in ("ntdll_other_open", "ntdll_other_openat", "ntdll_other_fopen"):
self.assertEqual(self.lines[name], "kind=proc tracer=shown rdonly=1 vm=1", name)
self.assertEqual(self.lines["ntdll_self_fopen"], "kind=proc tracer=hidden rdonly=1 vm=1")
if __name__ == "__main__":
unittest.main()