Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +12 −4 Original line number Diff line number Diff line Loading @@ -279,6 +279,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb private int mLastBiometricMode; private boolean mLastScreenOffAnimationPlaying; private float mQsExpansion; private boolean mAlternateBouncerReceivedDownTouch = false; final Set<KeyguardViewManagerCallback> mCallbacks = new HashSet<>(); private boolean mIsModernAlternateBouncerEnabled; private boolean mIsBackAnimationEnabled; Loading Loading @@ -1389,6 +1390,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb pw.println(" mPendingWakeupAction: " + mPendingWakeupAction); pw.println(" isBouncerShowing(): " + isBouncerShowing()); pw.println(" bouncerIsOrWillBeShowing(): " + primaryBouncerIsOrWillBeShowing()); pw.println(" mAlternateBouncerReceivedDownTouch: " + mAlternateBouncerReceivedDownTouch); pw.println(" Registered KeyguardViewManagerCallbacks:"); for (KeyguardViewManagerCallback callback : mCallbacks) { pw.println(" " + callback); Loading Loading @@ -1449,11 +1451,17 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb */ public boolean onTouch(MotionEvent event) { boolean handledTouch = false; if (event.getAction() == MotionEvent.ACTION_UP && mAlternateBouncerInteractor.isVisibleState() && mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime()) { if (mAlternateBouncerInteractor.isVisibleState()) { if (event.getAction() == MotionEvent.ACTION_DOWN) { mAlternateBouncerReceivedDownTouch = true; } else if (event.getAction() == MotionEvent.ACTION_UP && mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime() && mAlternateBouncerReceivedDownTouch) { showPrimaryBouncer(true); } handledTouch = true; } else { mAlternateBouncerReceivedDownTouch = false; } // Forward NPVC touches to callbacks in case they want to respond to touches Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java +42 −11 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.systemui.statusbar.phone; import static com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_HIDDEN; import static com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_VISIBLE; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; Loading Loading @@ -729,30 +728,62 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { } @Test public void testAlternateBouncerOnTouch_actionDown_doesNotHandleTouch() { public void testAlternateBouncerOnTouch_actionDownThenUp_noMinTimeShown_noHideAltBouncer() { reset(mAlternateBouncerInteractor); // GIVEN the alternate bouncer has shown for a minimum amount of time when(mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime()).thenReturn(false); when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); // WHEN ACTION_DOWN and ACTION_UP touch event comes boolean touchHandledDown = mStatusBarKeyguardViewManager.onTouch( MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0)); boolean touchHandledUp = mStatusBarKeyguardViewManager.onTouch( MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_UP, 0f, 0f, 0)); // THEN the touches are handled (doesn't let touches through to underlying views) assertTrue(touchHandledDown); assertTrue(touchHandledUp); // THEN alternate bouncer does NOT attempt to hide since min showing time wasn't met verify(mAlternateBouncerInteractor, never()).hide(); } @Test public void testAlternateBouncerOnTouch_actionDownThenUp_handlesTouch_hidesAltBouncer() { reset(mAlternateBouncerInteractor); // GIVEN the alternate bouncer has shown for a minimum amount of time when(mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime()).thenReturn(true); when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); // WHEN ACTION_DOWN touch event comes boolean touchHandled = mStatusBarKeyguardViewManager.onTouch( // WHEN ACTION_DOWN and ACTION_UP touch event comes boolean touchHandledDown = mStatusBarKeyguardViewManager.onTouch( MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0)); boolean touchHandledUp = mStatusBarKeyguardViewManager.onTouch( MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_UP, 0f, 0f, 0)); // THEN the touch is not handled assertFalse(touchHandled); // THEN the touches are handled assertTrue(touchHandledDown); assertTrue(touchHandledUp); // THEN alternate bouncer attempts to hide verify(mAlternateBouncerInteractor).hide(); } @Test public void testAlternateBouncerOnTouch_actionUp_handlesTouch() { public void testAlternateBouncerOnTouch_actionUp_doesNotHideAlternateBouncer() { reset(mAlternateBouncerInteractor); // GIVEN the alternate bouncer has shown for a minimum amount of time when(mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime()).thenReturn(true); when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); // WHEN ACTION_UP touch event comes boolean touchHandled = mStatusBarKeyguardViewManager.onTouch( // WHEN only ACTION_UP touch event comes mStatusBarKeyguardViewManager.onTouch( MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_UP, 0f, 0f, 0)); // THEN the touch is handled assertTrue(touchHandled); // THEN the alternateBouncer doesn't hide verify(mAlternateBouncerInteractor, never()).hide(); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +12 −4 Original line number Diff line number Diff line Loading @@ -279,6 +279,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb private int mLastBiometricMode; private boolean mLastScreenOffAnimationPlaying; private float mQsExpansion; private boolean mAlternateBouncerReceivedDownTouch = false; final Set<KeyguardViewManagerCallback> mCallbacks = new HashSet<>(); private boolean mIsModernAlternateBouncerEnabled; private boolean mIsBackAnimationEnabled; Loading Loading @@ -1389,6 +1390,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb pw.println(" mPendingWakeupAction: " + mPendingWakeupAction); pw.println(" isBouncerShowing(): " + isBouncerShowing()); pw.println(" bouncerIsOrWillBeShowing(): " + primaryBouncerIsOrWillBeShowing()); pw.println(" mAlternateBouncerReceivedDownTouch: " + mAlternateBouncerReceivedDownTouch); pw.println(" Registered KeyguardViewManagerCallbacks:"); for (KeyguardViewManagerCallback callback : mCallbacks) { pw.println(" " + callback); Loading Loading @@ -1449,11 +1451,17 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb */ public boolean onTouch(MotionEvent event) { boolean handledTouch = false; if (event.getAction() == MotionEvent.ACTION_UP && mAlternateBouncerInteractor.isVisibleState() && mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime()) { if (mAlternateBouncerInteractor.isVisibleState()) { if (event.getAction() == MotionEvent.ACTION_DOWN) { mAlternateBouncerReceivedDownTouch = true; } else if (event.getAction() == MotionEvent.ACTION_UP && mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime() && mAlternateBouncerReceivedDownTouch) { showPrimaryBouncer(true); } handledTouch = true; } else { mAlternateBouncerReceivedDownTouch = false; } // Forward NPVC touches to callbacks in case they want to respond to touches Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java +42 −11 Original line number Diff line number Diff line Loading @@ -19,7 +19,6 @@ package com.android.systemui.statusbar.phone; import static com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_HIDDEN; import static com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_VISIBLE; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; Loading Loading @@ -729,30 +728,62 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { } @Test public void testAlternateBouncerOnTouch_actionDown_doesNotHandleTouch() { public void testAlternateBouncerOnTouch_actionDownThenUp_noMinTimeShown_noHideAltBouncer() { reset(mAlternateBouncerInteractor); // GIVEN the alternate bouncer has shown for a minimum amount of time when(mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime()).thenReturn(false); when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); // WHEN ACTION_DOWN and ACTION_UP touch event comes boolean touchHandledDown = mStatusBarKeyguardViewManager.onTouch( MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0)); boolean touchHandledUp = mStatusBarKeyguardViewManager.onTouch( MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_UP, 0f, 0f, 0)); // THEN the touches are handled (doesn't let touches through to underlying views) assertTrue(touchHandledDown); assertTrue(touchHandledUp); // THEN alternate bouncer does NOT attempt to hide since min showing time wasn't met verify(mAlternateBouncerInteractor, never()).hide(); } @Test public void testAlternateBouncerOnTouch_actionDownThenUp_handlesTouch_hidesAltBouncer() { reset(mAlternateBouncerInteractor); // GIVEN the alternate bouncer has shown for a minimum amount of time when(mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime()).thenReturn(true); when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); // WHEN ACTION_DOWN touch event comes boolean touchHandled = mStatusBarKeyguardViewManager.onTouch( // WHEN ACTION_DOWN and ACTION_UP touch event comes boolean touchHandledDown = mStatusBarKeyguardViewManager.onTouch( MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0)); boolean touchHandledUp = mStatusBarKeyguardViewManager.onTouch( MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_UP, 0f, 0f, 0)); // THEN the touch is not handled assertFalse(touchHandled); // THEN the touches are handled assertTrue(touchHandledDown); assertTrue(touchHandledUp); // THEN alternate bouncer attempts to hide verify(mAlternateBouncerInteractor).hide(); } @Test public void testAlternateBouncerOnTouch_actionUp_handlesTouch() { public void testAlternateBouncerOnTouch_actionUp_doesNotHideAlternateBouncer() { reset(mAlternateBouncerInteractor); // GIVEN the alternate bouncer has shown for a minimum amount of time when(mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime()).thenReturn(true); when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); // WHEN ACTION_UP touch event comes boolean touchHandled = mStatusBarKeyguardViewManager.onTouch( // WHEN only ACTION_UP touch event comes mStatusBarKeyguardViewManager.onTouch( MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_UP, 0f, 0f, 0)); // THEN the touch is handled assertTrue(touchHandled); // THEN the alternateBouncer doesn't hide verify(mAlternateBouncerInteractor, never()).hide(); } }