summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/haptics/qs/QSLongPressEffectTest.kt10
-rw-r--r--packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffect.kt15
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt5
3 files changed, 29 insertions, 1 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/haptics/qs/QSLongPressEffectTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/haptics/qs/QSLongPressEffectTest.kt
index 366b55db4f20..329f90a1006a 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/haptics/qs/QSLongPressEffectTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/haptics/qs/QSLongPressEffectTest.kt
@@ -398,6 +398,16 @@ class QSLongPressEffectTest : SysuiTestCase() {
verify(controller).onTransitionAnimationCancelled(newOccludedState)
}
+ @Test
+ fun onTileLongClick_whileIdle_performsLongClick() =
+ testWhileInState(QSLongPressEffect.State.IDLE) {
+ // WHEN a long-click is detected by the view
+ val longClicks = longPressEffect.onTileLongClick()
+
+ // THEN the long click is handled
+ assertThat(longClicks).isTrue()
+ }
+
private fun testWithScope(initialize: Boolean = true, test: suspend TestScope.() -> Unit) =
with(kosmos) {
testScope.runTest {
diff --git a/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffect.kt b/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffect.kt
index 2e792497906e..b82aa817afd8 100644
--- a/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffect.kt
+++ b/packages/SystemUI/src/com/android/systemui/haptics/qs/QSLongPressEffect.kt
@@ -215,6 +215,21 @@ constructor(
return true
}
+ fun onTileLongClick(): Boolean {
+ if (state == State.IDLE) {
+ // This case represents a long-click detected outside of the QSLongPressEffect. This can
+ // be due to accessibility services
+ qsTile?.longClick(expandable)
+ logEvent(
+ qsTile?.tileSpec,
+ state,
+ "long click action triggered from OnLongClickListener",
+ )
+ return true
+ }
+ return false
+ }
+
/**
* Get the appropriate state for a click action.
*
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
index 18b1f071f44e..1fb76f1eaa7f 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileViewImpl.kt
@@ -415,7 +415,10 @@ constructor(
initLongPressEffectCallback()
init(
{ _: View -> longPressEffect.onTileClick() },
- { _: View -> true }, // Haptics and long-clicks are handled by [QSLongPressEffect]
+ { _: View ->
+ longPressEffect.onTileLongClick()
+ true
+ }, // Haptics and long-clicks are handled by [QSLongPressEffect]
)
} else {
val expandable = Expandable.fromView(this)