From 0a141fd6fa614024c6d6d3deb8bf8b321eb1f597 Mon Sep 17 00:00:00 2001 From: Yunfan Chen Date: Mon, 24 Apr 2023 16:34:54 +0800 Subject: [PATCH] Let gesture detector take display ID as param (2/n) The gesture detector was taking the DisplayTracker and always use the default display to system UI as the display to monitor input events. To support the effort to handle transient animation when the bars are hidden by the app, we need to support a multi-display awared environment. This change simply altered the constructor params and make corresponding changes to its caller to make it be possible to monitor inputs on any of the given displays. No actual funtional changes in this patch. Bug: 277290737 Test: m Change-Id: I05ea38f409e3f2e7282b608dd841855e80559f3c --- .../systemui/statusbar/gesture/GenericGestureDetector.kt | 5 ++--- .../systemui/statusbar/gesture/SwipeUpGestureHandler.kt | 5 ++++- .../android/systemui/statusbar/gesture/TapGestureDetector.kt | 5 ++++- .../systemui/statusbar/gesture/GenericGestureDetectorTest.kt | 5 ++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/gesture/GenericGestureDetector.kt b/packages/SystemUI/src/com/android/systemui/statusbar/gesture/GenericGestureDetector.kt index 92a8356b7f07e..1aeb6b304ea17 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/gesture/GenericGestureDetector.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/gesture/GenericGestureDetector.kt @@ -22,7 +22,6 @@ import android.os.Looper import android.view.Choreographer import android.view.InputEvent import android.view.MotionEvent -import com.android.systemui.settings.DisplayTracker import com.android.systemui.shared.system.InputChannelCompat import com.android.systemui.shared.system.InputMonitorCompat @@ -39,7 +38,7 @@ import com.android.systemui.shared.system.InputMonitorCompat */ abstract class GenericGestureDetector( private val tag: String, - private val displayTracker: DisplayTracker + private val displayId: Int, ) { /** * Active callbacks, each associated with a tag. Gestures will only be monitored if @@ -87,7 +86,7 @@ abstract class GenericGestureDetector( internal open fun startGestureListening() { stopGestureListening() - inputMonitor = InputMonitorCompat(tag, displayTracker.defaultDisplayId).also { + inputMonitor = InputMonitorCompat(tag, displayId).also { inputReceiver = it.getInputReceiver( Looper.getMainLooper(), Choreographer.getInstance(), diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/gesture/SwipeUpGestureHandler.kt b/packages/SystemUI/src/com/android/systemui/statusbar/gesture/SwipeUpGestureHandler.kt index 6d60f4a9affa0..2fd0a5324d15c 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/gesture/SwipeUpGestureHandler.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/gesture/SwipeUpGestureHandler.kt @@ -36,7 +36,10 @@ abstract class SwipeUpGestureHandler( displayTracker: DisplayTracker, private val logger: SwipeUpGestureLogger, private val loggerTag: String, -) : GenericGestureDetector(SwipeUpGestureHandler::class.simpleName!!, displayTracker) { +) : GenericGestureDetector( + SwipeUpGestureHandler::class.simpleName!!, + displayTracker.defaultDisplayId +) { private var startY: Float = 0f private var startTime: Long = 0L diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/gesture/TapGestureDetector.kt b/packages/SystemUI/src/com/android/systemui/statusbar/gesture/TapGestureDetector.kt index a901d59795764..ed30f2fc2e109 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/gesture/TapGestureDetector.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/gesture/TapGestureDetector.kt @@ -32,7 +32,10 @@ import javax.inject.Inject class TapGestureDetector @Inject constructor( private val context: Context, displayTracker: DisplayTracker -) : GenericGestureDetector(TapGestureDetector::class.simpleName!!, displayTracker) { +) : GenericGestureDetector( + TapGestureDetector::class.simpleName!!, + displayTracker.defaultDisplayId +) { private val gestureListener = object : GestureDetector.SimpleOnGestureListener() { override fun onSingleTapUp(e: MotionEvent): Boolean { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/gesture/GenericGestureDetectorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/gesture/GenericGestureDetectorTest.kt index 746544a3563f4..d3f5adeb05bb7 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/gesture/GenericGestureDetectorTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/gesture/GenericGestureDetectorTest.kt @@ -118,7 +118,10 @@ class GenericGestureDetectorTest : SysuiTestCase() { assertThat(oldCallbackNotified).isFalse() } - inner class TestGestureDetector : GenericGestureDetector("fakeTag", displayTracker) { + inner class TestGestureDetector : GenericGestureDetector( + "fakeTag", + displayTracker.defaultDisplayId + ) { var isGestureListening = false override fun onInputEvent(ev: InputEvent) {