Loading packages/SystemUI/src/com/android/systemui/shade/PulsingGestureListener.kt +6 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import com.android.systemui.Dumpable import com.android.systemui.dock.DockManager import com.android.systemui.dump.DumpManager import com.android.systemui.plugins.FalsingManager import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent import com.android.systemui.tuner.TunerService Loading @@ -49,6 +50,7 @@ class PulsingGestureListener @Inject constructor( private val dockManager: DockManager, private val centralSurfaces: CentralSurfaces, private val ambientDisplayConfiguration: AmbientDisplayConfiguration, private val statusBarStateController: StatusBarStateController, tunerService: TunerService, dumpManager: DumpManager ) : GestureDetector.SimpleOnGestureListener(), Dumpable { Loading @@ -74,7 +76,8 @@ class PulsingGestureListener @Inject constructor( } override fun onSingleTapConfirmed(e: MotionEvent): Boolean { if (singleTapEnabled && if (statusBarStateController.isPulsing && singleTapEnabled && !dockManager.isDocked && !falsingManager.isProximityNear && !falsingManager.isFalseTap(FalsingManager.MODERATE_PENALTY) Loading @@ -89,7 +92,8 @@ class PulsingGestureListener @Inject constructor( } override fun onDoubleTap(e: MotionEvent): Boolean { if ((doubleTapEnabled || singleTapEnabled) && if (statusBarStateController.isPulsing && (doubleTapEnabled || singleTapEnabled) && !falsingManager.isProximityNear && !falsingManager.isFalseDoubleTap ) { Loading packages/SystemUI/tests/src/com/android/systemui/shade/PulsingGestureListenerTest.kt +30 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.dock.DockManager import com.android.systemui.dump.DumpManager import com.android.systemui.plugins.FalsingManager import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.tuner.TunerService import com.android.systemui.tuner.TunerService.Tunable Loading Loading @@ -63,6 +64,8 @@ class PulsingGestureListenerTest : SysuiTestCase() { private lateinit var tunerService: TunerService @Mock private lateinit var dumpManager: DumpManager @Mock private lateinit var statusBarStateController: StatusBarStateController private lateinit var tunableCaptor: ArgumentCaptor<Tunable> private lateinit var underTest: PulsingGestureListener Loading @@ -77,6 +80,7 @@ class PulsingGestureListenerTest : SysuiTestCase() { dockManager, centralSurfaces, ambientDisplayConfiguration, statusBarStateController, tunerService, dumpManager ) Loading @@ -85,6 +89,8 @@ class PulsingGestureListenerTest : SysuiTestCase() { @Test fun testGestureDetector_singleTapEnabled() { whenever(statusBarStateController.isPulsing).thenReturn(true) // GIVEN tap is enabled, prox not covered whenever(ambientDisplayConfiguration.tapGestureEnabled(anyInt())).thenReturn(true) updateSettings() Loading @@ -102,6 +108,8 @@ class PulsingGestureListenerTest : SysuiTestCase() { @Test fun testGestureDetector_doubleTapEnabled() { whenever(statusBarStateController.isPulsing).thenReturn(true) // GIVEN double tap is enabled, prox not covered whenever(ambientDisplayConfiguration.doubleTapGestureEnabled(anyInt())).thenReturn(true) updateSettings() Loading @@ -119,6 +127,8 @@ class PulsingGestureListenerTest : SysuiTestCase() { @Test fun testGestureDetector_singleTapEnabled_falsing() { whenever(statusBarStateController.isPulsing).thenReturn(true) // GIVEN tap is enabled, prox not covered whenever(ambientDisplayConfiguration.tapGestureEnabled(anyInt())).thenReturn(true) updateSettings() Loading @@ -134,8 +144,24 @@ class PulsingGestureListenerTest : SysuiTestCase() { verify(centralSurfaces, never()).wakeUpIfDozing(anyLong(), anyObject(), anyString()) } @Test fun testGestureDetector_notPulsing_noFalsingCheck() { whenever(statusBarStateController.isPulsing).thenReturn(false) // GIVEN tap is enabled, prox not covered whenever(ambientDisplayConfiguration.tapGestureEnabled(anyInt())).thenReturn(true) // WHEN there's a tap underTest.onSingleTapConfirmed(downEv) // THEN the falsing manager never gets a call (because the device wasn't pulsing // during the tap) verify(falsingManager, never()).isFalseTap(anyInt()) } @Test fun testGestureDetector_doubleTapEnabled_falsing() { whenever(statusBarStateController.isPulsing).thenReturn(true) // GIVEN double tap is enabled, prox not covered whenever(ambientDisplayConfiguration.doubleTapGestureEnabled(anyInt())).thenReturn(true) updateSettings() Loading @@ -153,6 +179,8 @@ class PulsingGestureListenerTest : SysuiTestCase() { @Test fun testGestureDetector_singleTapEnabled_proxCovered() { whenever(statusBarStateController.isPulsing).thenReturn(true) // GIVEN tap is enabled, not a false tap based on classifiers whenever(ambientDisplayConfiguration.tapGestureEnabled(anyInt())).thenReturn(true) updateSettings() Loading @@ -170,6 +198,8 @@ class PulsingGestureListenerTest : SysuiTestCase() { @Test fun testGestureDetector_doubleTapEnabled_proxCovered() { whenever(statusBarStateController.isPulsing).thenReturn(true) // GIVEN double tap is enabled, not a false tap based on classifiers whenever(ambientDisplayConfiguration.doubleTapGestureEnabled(anyInt())).thenReturn(true) updateSettings() Loading Loading
packages/SystemUI/src/com/android/systemui/shade/PulsingGestureListener.kt +6 −2 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import com.android.systemui.Dumpable import com.android.systemui.dock.DockManager import com.android.systemui.dump.DumpManager import com.android.systemui.plugins.FalsingManager import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent import com.android.systemui.tuner.TunerService Loading @@ -49,6 +50,7 @@ class PulsingGestureListener @Inject constructor( private val dockManager: DockManager, private val centralSurfaces: CentralSurfaces, private val ambientDisplayConfiguration: AmbientDisplayConfiguration, private val statusBarStateController: StatusBarStateController, tunerService: TunerService, dumpManager: DumpManager ) : GestureDetector.SimpleOnGestureListener(), Dumpable { Loading @@ -74,7 +76,8 @@ class PulsingGestureListener @Inject constructor( } override fun onSingleTapConfirmed(e: MotionEvent): Boolean { if (singleTapEnabled && if (statusBarStateController.isPulsing && singleTapEnabled && !dockManager.isDocked && !falsingManager.isProximityNear && !falsingManager.isFalseTap(FalsingManager.MODERATE_PENALTY) Loading @@ -89,7 +92,8 @@ class PulsingGestureListener @Inject constructor( } override fun onDoubleTap(e: MotionEvent): Boolean { if ((doubleTapEnabled || singleTapEnabled) && if (statusBarStateController.isPulsing && (doubleTapEnabled || singleTapEnabled) && !falsingManager.isProximityNear && !falsingManager.isFalseDoubleTap ) { Loading
packages/SystemUI/tests/src/com/android/systemui/shade/PulsingGestureListenerTest.kt +30 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.dock.DockManager import com.android.systemui.dump.DumpManager import com.android.systemui.plugins.FalsingManager import com.android.systemui.plugins.statusbar.StatusBarStateController import com.android.systemui.statusbar.phone.CentralSurfaces import com.android.systemui.tuner.TunerService import com.android.systemui.tuner.TunerService.Tunable Loading Loading @@ -63,6 +64,8 @@ class PulsingGestureListenerTest : SysuiTestCase() { private lateinit var tunerService: TunerService @Mock private lateinit var dumpManager: DumpManager @Mock private lateinit var statusBarStateController: StatusBarStateController private lateinit var tunableCaptor: ArgumentCaptor<Tunable> private lateinit var underTest: PulsingGestureListener Loading @@ -77,6 +80,7 @@ class PulsingGestureListenerTest : SysuiTestCase() { dockManager, centralSurfaces, ambientDisplayConfiguration, statusBarStateController, tunerService, dumpManager ) Loading @@ -85,6 +89,8 @@ class PulsingGestureListenerTest : SysuiTestCase() { @Test fun testGestureDetector_singleTapEnabled() { whenever(statusBarStateController.isPulsing).thenReturn(true) // GIVEN tap is enabled, prox not covered whenever(ambientDisplayConfiguration.tapGestureEnabled(anyInt())).thenReturn(true) updateSettings() Loading @@ -102,6 +108,8 @@ class PulsingGestureListenerTest : SysuiTestCase() { @Test fun testGestureDetector_doubleTapEnabled() { whenever(statusBarStateController.isPulsing).thenReturn(true) // GIVEN double tap is enabled, prox not covered whenever(ambientDisplayConfiguration.doubleTapGestureEnabled(anyInt())).thenReturn(true) updateSettings() Loading @@ -119,6 +127,8 @@ class PulsingGestureListenerTest : SysuiTestCase() { @Test fun testGestureDetector_singleTapEnabled_falsing() { whenever(statusBarStateController.isPulsing).thenReturn(true) // GIVEN tap is enabled, prox not covered whenever(ambientDisplayConfiguration.tapGestureEnabled(anyInt())).thenReturn(true) updateSettings() Loading @@ -134,8 +144,24 @@ class PulsingGestureListenerTest : SysuiTestCase() { verify(centralSurfaces, never()).wakeUpIfDozing(anyLong(), anyObject(), anyString()) } @Test fun testGestureDetector_notPulsing_noFalsingCheck() { whenever(statusBarStateController.isPulsing).thenReturn(false) // GIVEN tap is enabled, prox not covered whenever(ambientDisplayConfiguration.tapGestureEnabled(anyInt())).thenReturn(true) // WHEN there's a tap underTest.onSingleTapConfirmed(downEv) // THEN the falsing manager never gets a call (because the device wasn't pulsing // during the tap) verify(falsingManager, never()).isFalseTap(anyInt()) } @Test fun testGestureDetector_doubleTapEnabled_falsing() { whenever(statusBarStateController.isPulsing).thenReturn(true) // GIVEN double tap is enabled, prox not covered whenever(ambientDisplayConfiguration.doubleTapGestureEnabled(anyInt())).thenReturn(true) updateSettings() Loading @@ -153,6 +179,8 @@ class PulsingGestureListenerTest : SysuiTestCase() { @Test fun testGestureDetector_singleTapEnabled_proxCovered() { whenever(statusBarStateController.isPulsing).thenReturn(true) // GIVEN tap is enabled, not a false tap based on classifiers whenever(ambientDisplayConfiguration.tapGestureEnabled(anyInt())).thenReturn(true) updateSettings() Loading @@ -170,6 +198,8 @@ class PulsingGestureListenerTest : SysuiTestCase() { @Test fun testGestureDetector_doubleTapEnabled_proxCovered() { whenever(statusBarStateController.isPulsing).thenReturn(true) // GIVEN double tap is enabled, not a false tap based on classifiers whenever(ambientDisplayConfiguration.doubleTapGestureEnabled(anyInt())).thenReturn(true) updateSettings() Loading