diff --git a/app/src/main/java/com/droiddeck/launcher/ui/DeckControlsPanel.kt b/app/src/main/java/com/droiddeck/launcher/ui/DeckControlsPanel.kt index 6671897af8..0951ac5f4e 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/DeckControlsPanel.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/DeckControlsPanel.kt @@ -151,7 +151,6 @@ class DeckControlsPanel( private fun select(tab: Tab) { if (pad != null) selectedWithPad = tab else selected = tab deckSource.release() - pad?.releaseTouch(this) for ((each, view) in tabViews) { val on = each == tab view.background = if (on) filled(CORNER_PILL, ACCENT) else null @@ -169,6 +168,7 @@ class DeckControlsPanel( } } content.removeAllViews() + pad?.releaseTouch(this) topBar.visibility = if (tab == Tab.GAMEPAD) View.GONE else View.VISIBLE content.addView( when (tab) { diff --git a/app/src/test/java/com/droiddeck/launcher/ui/DeckControlsPanelOwnershipTest.kt b/app/src/test/java/com/droiddeck/launcher/ui/DeckControlsPanelOwnershipTest.kt index b354801ade..15900692b1 100644 --- a/app/src/test/java/com/droiddeck/launcher/ui/DeckControlsPanelOwnershipTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/ui/DeckControlsPanelOwnershipTest.kt @@ -89,6 +89,49 @@ class DeckControlsPanelOwnershipTest { assertTrackpadStillHeld(position) } + @Test fun switchingTabsRemovesTheOldTouchSourceAfterChildrenRelease() { + val routed = recordTouchRoute() + holdFaceButton() + assertTrue(routed.last().isDown(PadState.A)) + descendants(panel).filterIsInstance().first { it.text == activity.getString(R.string.deck_tab_grips) }.performClick() + assertFalse(routed.last().isDown(PadState.A)) + assertEquals(0, JoyConPadTest.RecordingWriter.grips) + routed.clear() + bridge.applyExternal({ it.press(PadState.B, true) }, true) + assertTrue("removed tab still forwards a neutral touch source", routed.isEmpty()) + assertTrue(state().isDown(PadState.B)) + + descendants(panel).filterIsInstance().first { it.text == activity.getString(R.string.deck_tab_gamepad) }.performClick() + holdFaceButton() + assertTrue(routed.last().isDown(PadState.A)) + } + + @Test fun removingThePanelLeavesNoTouchSourceForLaterPhysicalInput() { + val routed = recordTouchRoute() + holdFaceButton() + root.removeView(panel) + assertFalse(routed.last().isDown(PadState.A)) + routed.clear() + bridge.applyExternal({ it.press(PadState.B, true) }, true) + assertTrue("removed panel still forwards a neutral touch source", routed.isEmpty()) + assertTrue(state().isDown(PadState.B)) + } + + private fun holdFaceButton() { + val buttons = child("FaceButtons") + buttons.layout(0, 0, 300, 300) + touch(buttons, MotionEvent.ACTION_DOWN, 150f, 240f) + } + + private fun recordTouchRoute(): MutableList { + val routed = mutableListOf() + bridge.setTouchRoute(object : PadBridge.TouchRoute { + override fun active() = true + override fun accept(state: PadState) { routed += PadState().apply { copyFrom(state) } } + }) + return routed + } + private fun assertTrackpadStillHeld(position: ShortArray) { assertEquals(32 or 128, JoyConPadTest.RecordingWriter.grips) assertArrayEquals(position, JoyConPadTest.RecordingWriter.deckPads) diff --git a/docs/development/unified-input-validation.md b/docs/development/unified-input-validation.md index c2fcf4fa1a..9bdd19ee53 100644 --- a/docs/development/unified-input-validation.md +++ b/docs/development/unified-input-validation.md @@ -119,6 +119,21 @@ pass with the same local build settings. APK SHA-256: These changes have host coverage only; Thor validation and new latency measurements remain pending. +### Panel tab teardown follow-up + +Tab changes now remove the old child views before releasing the panel's touch +source. Child detach callbacks can publish button releases, so source cleanup +must run after those callbacks to avoid retaining a neutral source. + +The new tab-switch regression fails before this fix and passes after it. It +checks held-button release, removal of the old source before later physical +input, and touch input after returning to the Gamepad tab. A second regression +confirms that whole-panel removal already releases the source correctly. +All **22 targeted tests** in the panel ownership, input ownership and second-screen +suites pass. The debug APK build, session-asset check and runtime-input +verification also pass. This follow-up has not been tested on Thor or benchmarked +on the device. + ## Manual AYN Thor results The user performed the following checks in the installed candidate. The desktop