mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 13:26:02 +00:00
fix: release panel touch source after tab teardown
Release the panel touch source after child detach callbacks finish publishing button releases. Cover tab switching and whole-panel removal with ownership regressions. Validation: 22 targeted JVM tests, debug APK build, session-asset check and runtime-input verification passed. Device validation remains pending.
This commit is contained in:
1 parent
884671a065
commit
5ee3ed07be
3 files changed
+59
-1
No files matched your search
@@ -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) {
|
||||
|
||||
@@ -89,6 +89,49 @@ class DeckControlsPanelOwnershipTest {
|
||||
assertTrackpadStillHeld(position)
|
||||
}
|
||||
|
||||
@Test fun switchingTabsRemovesTheOldTouchSourceAfterChildrenRelease() {
|
||||
val routed = recordTouchRoute()
|
||||
holdFaceButton()
|
||||
assertTrue(routed.last().isDown(PadState.A))
|
||||
descendants(panel).filterIsInstance<TextView>().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<TextView>().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<PadState> {
|
||||
val routed = mutableListOf<PadState>()
|
||||
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)
|
||||
|
||||
Reference in new issue
Block a user