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
This commit is contained in:
Yunfan Chen
2023-04-24 16:34:54 +08:00
parent de6724e24f
commit 0a141fd6fa
4 changed files with 14 additions and 6 deletions

View File

@@ -22,7 +22,6 @@ import android.os.Looper
import android.view.Choreographer import android.view.Choreographer
import android.view.InputEvent import android.view.InputEvent
import android.view.MotionEvent import android.view.MotionEvent
import com.android.systemui.settings.DisplayTracker
import com.android.systemui.shared.system.InputChannelCompat import com.android.systemui.shared.system.InputChannelCompat
import com.android.systemui.shared.system.InputMonitorCompat import com.android.systemui.shared.system.InputMonitorCompat
@@ -39,7 +38,7 @@ import com.android.systemui.shared.system.InputMonitorCompat
*/ */
abstract class GenericGestureDetector( abstract class GenericGestureDetector(
private val tag: String, 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 * Active callbacks, each associated with a tag. Gestures will only be monitored if
@@ -87,7 +86,7 @@ abstract class GenericGestureDetector(
internal open fun startGestureListening() { internal open fun startGestureListening() {
stopGestureListening() stopGestureListening()
inputMonitor = InputMonitorCompat(tag, displayTracker.defaultDisplayId).also { inputMonitor = InputMonitorCompat(tag, displayId).also {
inputReceiver = it.getInputReceiver( inputReceiver = it.getInputReceiver(
Looper.getMainLooper(), Looper.getMainLooper(),
Choreographer.getInstance(), Choreographer.getInstance(),

View File

@@ -36,7 +36,10 @@ abstract class SwipeUpGestureHandler(
displayTracker: DisplayTracker, displayTracker: DisplayTracker,
private val logger: SwipeUpGestureLogger, private val logger: SwipeUpGestureLogger,
private val loggerTag: String, private val loggerTag: String,
) : GenericGestureDetector(SwipeUpGestureHandler::class.simpleName!!, displayTracker) { ) : GenericGestureDetector(
SwipeUpGestureHandler::class.simpleName!!,
displayTracker.defaultDisplayId
) {
private var startY: Float = 0f private var startY: Float = 0f
private var startTime: Long = 0L private var startTime: Long = 0L

View File

@@ -32,7 +32,10 @@ import javax.inject.Inject
class TapGestureDetector @Inject constructor( class TapGestureDetector @Inject constructor(
private val context: Context, private val context: Context,
displayTracker: DisplayTracker displayTracker: DisplayTracker
) : GenericGestureDetector(TapGestureDetector::class.simpleName!!, displayTracker) { ) : GenericGestureDetector(
TapGestureDetector::class.simpleName!!,
displayTracker.defaultDisplayId
) {
private val gestureListener = object : GestureDetector.SimpleOnGestureListener() { private val gestureListener = object : GestureDetector.SimpleOnGestureListener() {
override fun onSingleTapUp(e: MotionEvent): Boolean { override fun onSingleTapUp(e: MotionEvent): Boolean {

View File

@@ -118,7 +118,10 @@ class GenericGestureDetectorTest : SysuiTestCase() {
assertThat(oldCallbackNotified).isFalse() assertThat(oldCallbackNotified).isFalse()
} }
inner class TestGestureDetector : GenericGestureDetector("fakeTag", displayTracker) { inner class TestGestureDetector : GenericGestureDetector(
"fakeTag",
displayTracker.defaultDisplayId
) {
var isGestureListening = false var isGestureListening = false
override fun onInputEvent(ev: InputEvent) { override fun onInputEvent(ev: InputEvent) {