Preserve second-screen choices across partial selections and migration retries

Track explicit whole-profile choices, including Auto, separately from inherited profiles so physical and main-screen overrides do not suppress legacy panel migration. Persist this distinction in library version 8 and read older selection records compatibly.

Keep saved Deck panels during unavailable-controller fallbacks and retain legacy preferences when migration fails. Add regressions for all three review findings, explicit Auto selection and older saved libraries.

Validation: all 992 input/UI tests passed.
This commit is contained in:
Delete228 committed 2026-11-07 02:44:47 +03:00
1 parent 281c2aea1b
commit aff9738748
5 files changed
+110 -13

No files matched your search

@@ -3317,17 +3317,22 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
if (pipUi || !started) return
val mode = if (requested == SecondScreenMode.DECK_CONTROLS || requested == SecondScreenMode.KEYBOARD_TRACKPAD) {
val remembered = SessionPrefs.secondScreenPanel(this)
if (remembered == SecondScreenMode.DECK_CONTROLS.id || remembered == SecondScreenMode.KEYBOARD_TRACKPAD.id) {
if (remembered == requested.id) {
val desktop = SessionState.mode == SessionService.MODE_DESKTOP
val library = com.droiddeck.launcher.input.InputLibraries.read(this)
val key = if (desktop) InputProfile.DESKTOP else InputProfile.GAME
if (key !in library.selections) {
val preset = if (requested == SecondScreenMode.DECK_CONTROLS) com.droiddeck.launcher.input.InputStockLayouts.DECK else com.droiddeck.launcher.input.InputStockLayouts.TRACKPAD
runCatching { com.droiddeck.launcher.input.InputLibraries.update(this) { it.selectPart(desktop, InputRole.SECONDARY, preset) } }
.onSuccess { refreshInputProfile() }
.onFailure { Log.w(TAG, "could not migrate the saved second-screen selection", it) }
val preset = if (requested == SecondScreenMode.DECK_CONTROLS) com.droiddeck.launcher.input.InputStockLayouts.DECK else com.droiddeck.launcher.input.InputStockLayouts.TRACKPAD
runCatching {
com.droiddeck.launcher.input.InputLibraries.update(this) { library ->
val selection = library.selections[key]
if (selection?.profileSelected == true || selection?.parts?.containsKey(InputRole.SECONDARY) == true) library
else library.selectPart(desktop, InputRole.SECONDARY, preset)
}
}.onSuccess {
refreshInputProfile()
SessionPrefs.setSecondScreenPanel(this, SecondScreenMode.CUSTOM_CONTROLS.id)
}.onFailure {
Log.w(TAG, "could not migrate the saved second-screen selection", it)
}
SessionPrefs.setSecondScreenPanel(this, SecondScreenMode.CUSTOM_CONTROLS.id)
}
SecondScreenMode.CUSTOM_CONTROLS
} else requested