mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-26 00:06:02 +00:00
Add live suspend policy to session drawer
This commit is contained in:
1 parent
ae614ce476
commit
015ac26e07
3 files changed
+39
-2
No files matched your search
@@ -135,6 +135,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
|||||||
private var frameGenEngine by mutableStateOf(FrameGen.ENGINE_OFF)
|
private var frameGenEngine by mutableStateOf(FrameGen.ENGINE_OFF)
|
||||||
private var frameGenMultiplier by mutableStateOf(2)
|
private var frameGenMultiplier by mutableStateOf(2)
|
||||||
private var fexPreset by mutableStateOf("")
|
private var fexPreset by mutableStateOf("")
|
||||||
|
private var suspendPolicy by mutableStateOf(SessionPrefs.SUSPEND_MANUAL)
|
||||||
private var oscMode by mutableStateOf(SessionPrefs.OSC_AUTO)
|
private var oscMode by mutableStateOf(SessionPrefs.OSC_AUTO)
|
||||||
private var shapeMode by mutableStateOf(SessionPrefs.SHAPE_AUTO)
|
private var shapeMode by mutableStateOf(SessionPrefs.SHAPE_AUTO)
|
||||||
private var secondScreenMode by mutableStateOf(SecondScreenMode.NONE)
|
private var secondScreenMode by mutableStateOf(SecondScreenMode.NONE)
|
||||||
@@ -260,7 +261,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
|||||||
fillScreen = if (SessionState.mode == SessionService.MODE_STEAM) fillScreen else null,
|
fillScreen = if (SessionState.mode == SessionService.MODE_STEAM) fillScreen else null,
|
||||||
frameGenEngine = frameGenEngine, frameGenMultiplier = frameGenMultiplier,
|
frameGenEngine = frameGenEngine, frameGenMultiplier = frameGenMultiplier,
|
||||||
lsfgReady = LsfgNative.isInstalled(this@SessionActivity),
|
lsfgReady = LsfgNative.isInstalled(this@SessionActivity),
|
||||||
oscMode = oscMode, touchMode = touchMode,
|
oscMode = oscMode, suspendPolicy = suspendPolicy, touchMode = touchMode,
|
||||||
touchAuto = if (usingTouchpad()) "touchpad" else "direct",
|
touchAuto = if (usingTouchpad()) "touchpad" else "direct",
|
||||||
shapeMode = shapeMode, fexPreset = fexPreset,
|
shapeMode = shapeMode, fexPreset = fexPreset,
|
||||||
secondScreenMode = secondScreenMode,
|
secondScreenMode = secondScreenMode,
|
||||||
@@ -283,6 +284,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
|||||||
backActionsInverted = inverted
|
backActionsInverted = inverted
|
||||||
},
|
},
|
||||||
onOsc = { v -> SessionPrefs.setOscMode(this@SessionActivity, v); readPrefs(); updateOnScreenControls() },
|
onOsc = { v -> SessionPrefs.setOscMode(this@SessionActivity, v); readPrefs(); updateOnScreenControls() },
|
||||||
|
onSuspendPolicy = { policy ->
|
||||||
|
SessionPrefs.setSuspendPolicy(this@SessionActivity, SessionState.mode, policy)
|
||||||
|
suspendPolicy = policy
|
||||||
|
SessionService.suspendPolicyChanged(this@SessionActivity)
|
||||||
|
},
|
||||||
onTouch = { v -> SessionPrefs.setTouchMode(this@SessionActivity, v); readPrefs() },
|
onTouch = { v -> SessionPrefs.setTouchMode(this@SessionActivity, v); readPrefs() },
|
||||||
onShape = { v -> SessionPrefs.setShapeMode(this@SessionActivity, v); readPrefs() },
|
onShape = { v -> SessionPrefs.setShapeMode(this@SessionActivity, v); readPrefs() },
|
||||||
onFexPreset = { v -> SessionPrefs.setFexPreset(this@SessionActivity, v); readPrefs() },
|
onFexPreset = { v -> SessionPrefs.setFexPreset(this@SessionActivity, v); readPrefs() },
|
||||||
@@ -391,6 +397,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
|||||||
frameGenEngine = FrameGen.engine(this)
|
frameGenEngine = FrameGen.engine(this)
|
||||||
frameGenMultiplier = FrameGen.multiplier(this)
|
frameGenMultiplier = FrameGen.multiplier(this)
|
||||||
fexPreset = SessionPrefs.fexPreset(this)
|
fexPreset = SessionPrefs.fexPreset(this)
|
||||||
|
suspendPolicy = SessionPrefs.suspendPolicy(this, SessionState.mode)
|
||||||
oscMode = SessionPrefs.oscMode(this)
|
oscMode = SessionPrefs.oscMode(this)
|
||||||
shapeMode = SessionPrefs.shapeMode(this)
|
shapeMode = SessionPrefs.shapeMode(this)
|
||||||
backActionsInverted = SessionPrefs.backActionsInverted(this)
|
backActionsInverted = SessionPrefs.backActionsInverted(this)
|
||||||
|
|||||||
@@ -144,6 +144,13 @@ class SessionService : Service() {
|
|||||||
updateSuspendPolicy()
|
updateSuspendPolicy()
|
||||||
return START_NOT_STICKY
|
return START_NOT_STICKY
|
||||||
}
|
}
|
||||||
|
ACTION_SUSPEND_POLICY_CHANGED -> {
|
||||||
|
if (!SessionState.running) return START_NOT_STICKY
|
||||||
|
suspendPolicy = SessionPrefs.suspendPolicy(this, SessionState.mode)
|
||||||
|
suspendAttemptFailed = false
|
||||||
|
updateSuspendPolicy()
|
||||||
|
return START_NOT_STICKY
|
||||||
|
}
|
||||||
ACTION_RESUME -> {
|
ACTION_RESUME -> {
|
||||||
activityVisible = true
|
activityVisible = true
|
||||||
screenOn = (getSystemService(Context.POWER_SERVICE) as? PowerManager)?.isInteractive ?: screenOn
|
screenOn = (getSystemService(Context.POWER_SERVICE) as? PowerManager)?.isInteractive ?: screenOn
|
||||||
@@ -1016,6 +1023,7 @@ class SessionService : Service() {
|
|||||||
const val ACTION_RESUME = "com.droiddeck.launcher.RESUME_SESSION"
|
const val ACTION_RESUME = "com.droiddeck.launcher.RESUME_SESSION"
|
||||||
const val ACTION_HOME_GUIDE = "com.droiddeck.launcher.HOME_GUIDE"
|
const val ACTION_HOME_GUIDE = "com.droiddeck.launcher.HOME_GUIDE"
|
||||||
const val ACTION_AGENT_START = "com.droiddeck.launcher.AGENT_START"
|
const val ACTION_AGENT_START = "com.droiddeck.launcher.AGENT_START"
|
||||||
|
private const val ACTION_SUSPEND_POLICY_CHANGED = "com.droiddeck.launcher.SUSPEND_POLICY_CHANGED"
|
||||||
private const val ACTION_ACTIVITY_VISIBLE = "com.droiddeck.launcher.ACTIVITY_VISIBLE"
|
private const val ACTION_ACTIVITY_VISIBLE = "com.droiddeck.launcher.ACTIVITY_VISIBLE"
|
||||||
private const val ACTION_ACTIVITY_HIDDEN = "com.droiddeck.launcher.ACTIVITY_HIDDEN"
|
private const val ACTION_ACTIVITY_HIDDEN = "com.droiddeck.launcher.ACTIVITY_HIDDEN"
|
||||||
private const val ACTION_TRACK_AUXILIARY = "com.droiddeck.launcher.TRACK_AUXILIARY"
|
private const val ACTION_TRACK_AUXILIARY = "com.droiddeck.launcher.TRACK_AUXILIARY"
|
||||||
@@ -1070,6 +1078,11 @@ class SessionService : Service() {
|
|||||||
context.startService(Intent(context, SessionService::class.java).setAction(ACTION_RESUME))
|
context.startService(Intent(context, SessionService::class.java).setAction(ACTION_RESUME))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun suspendPolicyChanged(context: Context) {
|
||||||
|
if (!SessionState.running) return
|
||||||
|
context.startService(Intent(context, SessionService::class.java).setAction(ACTION_SUSPEND_POLICY_CHANGED))
|
||||||
|
}
|
||||||
|
|
||||||
/** Let the session service clean up the PTY's proot tree if the control screen closes. */
|
/** Let the session service clean up the PTY's proot tree if the control screen closes. */
|
||||||
fun stopTerminalProcess(context: Context, pid: Int) {
|
fun stopTerminalProcess(context: Context, pid: Int) {
|
||||||
if (pid > 1) context.startService(
|
if (pid > 1) context.startService(
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ import com.droiddeck.launcher.input.SecondScreenMode
|
|||||||
import kotlinx.coroutines.flow.collect
|
import kotlinx.coroutines.flow.collect
|
||||||
|
|
||||||
private val drawerPageTitles = listOf("Now", "Controls", "Session")
|
private val drawerPageTitles = listOf("Now", "Controls", "Session")
|
||||||
private val drawerPageEntries = listOf("hud", "touch", "shape")
|
private val drawerPageEntries = listOf("hud", "touch", "suspend")
|
||||||
|
|
||||||
private class DrawerFocus {
|
private class DrawerFocus {
|
||||||
private val requesters = HashMap<String, FocusRequester>()
|
private val requesters = HashMap<String, FocusRequester>()
|
||||||
@@ -194,6 +194,7 @@ class DrawerActions(
|
|||||||
val frameGenMultiplier: Int,
|
val frameGenMultiplier: Int,
|
||||||
val lsfgReady: Boolean,
|
val lsfgReady: Boolean,
|
||||||
val oscMode: String,
|
val oscMode: String,
|
||||||
|
val suspendPolicy: String,
|
||||||
val backActionsInverted: Boolean,
|
val backActionsInverted: Boolean,
|
||||||
val touchMode: String,
|
val touchMode: String,
|
||||||
val touchAuto: String,
|
val touchAuto: String,
|
||||||
@@ -213,6 +214,7 @@ class DrawerActions(
|
|||||||
val onSteamMenu: (() -> Unit)?,
|
val onSteamMenu: (() -> Unit)?,
|
||||||
val onQam: (() -> Unit)?,
|
val onQam: (() -> Unit)?,
|
||||||
val onOsc: (String) -> Unit,
|
val onOsc: (String) -> Unit,
|
||||||
|
val onSuspendPolicy: (String) -> Unit,
|
||||||
val onBackActionsInverted: (Boolean) -> Unit,
|
val onBackActionsInverted: (Boolean) -> Unit,
|
||||||
val onTouch: (String) -> Unit,
|
val onTouch: (String) -> Unit,
|
||||||
val onShape: (String) -> Unit,
|
val onShape: (String) -> Unit,
|
||||||
@@ -475,6 +477,21 @@ fun SessionDrawer(open: Boolean, page: Int, controllerActive: Boolean, onPageCha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SettingsGroup("Session behavior") {
|
||||||
|
ChoiceRow(
|
||||||
|
host, "suspend", "Background behavior",
|
||||||
|
"Applies now and to future sessions in this mode.",
|
||||||
|
listOf(
|
||||||
|
SessionPrefs.SUSPEND_AUTO to "Auto",
|
||||||
|
SessionPrefs.SUSPEND_MANUAL to "Manual",
|
||||||
|
SessionPrefs.SUSPEND_NEVER to "Never",
|
||||||
|
),
|
||||||
|
a.suspendPolicy,
|
||||||
|
note = "Auto pauses in the background and resumes when visible. Manual pauses there and waits for Resume. Never keeps the session running.",
|
||||||
|
chipModifier = focus.track(page, "suspend"),
|
||||||
|
onPick = a.onSuspendPolicy,
|
||||||
|
)
|
||||||
|
}
|
||||||
SettingsGroup("Next session") {
|
SettingsGroup("Next session") {
|
||||||
ChoiceRow(host, "shape", "Screen ratio", null,
|
ChoiceRow(host, "shape", "Screen ratio", null,
|
||||||
SessionPrefs.shapeChoices, a.shapeMode,
|
SessionPrefs.shapeChoices, a.shapeMode,
|
||||||
|
|||||||
Reference in new issue
Block a user