Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0a141fd6 authored by Yunfan Chen's avatar Yunfan Chen
Browse files

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
parent de6724e2
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -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(),
+4 −1
Original line number Diff line number Diff line
@@ -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
+4 −1
Original line number Diff line number Diff line
@@ -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 {
+4 −1
Original line number Diff line number Diff line
@@ -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) {