RESTRICT AUTOMERGE Only handle altBouncer touches if up & down received

Test: atest StatusBarKeyguardViewManagerTest
Test: manually longpress a notification on the lockscreen
and allow finger to linger - alternate bouncer shows
and doesn't disappear on fingerUP
Fixes: 270285915

Change-Id: I57bab58a47b9227fc13876edd3f6af22a840c147
This commit is contained in:
Beverly
2023-03-10 16:28:51 +00:00
committed by Beverly Tai
parent b1f7b0017b
commit 2b9a0e9e0f
2 changed files with 55 additions and 16 deletions

View File

@@ -279,6 +279,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
private int mLastBiometricMode; private int mLastBiometricMode;
private boolean mLastScreenOffAnimationPlaying; private boolean mLastScreenOffAnimationPlaying;
private float mQsExpansion; private float mQsExpansion;
private boolean mAlternateBouncerReceivedDownTouch = false;
final Set<KeyguardViewManagerCallback> mCallbacks = new HashSet<>(); final Set<KeyguardViewManagerCallback> mCallbacks = new HashSet<>();
private boolean mIsModernAlternateBouncerEnabled; private boolean mIsModernAlternateBouncerEnabled;
private boolean mIsBackAnimationEnabled; private boolean mIsBackAnimationEnabled;
@@ -1389,6 +1390,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
pw.println(" mPendingWakeupAction: " + mPendingWakeupAction); pw.println(" mPendingWakeupAction: " + mPendingWakeupAction);
pw.println(" isBouncerShowing(): " + isBouncerShowing()); pw.println(" isBouncerShowing(): " + isBouncerShowing());
pw.println(" bouncerIsOrWillBeShowing(): " + primaryBouncerIsOrWillBeShowing()); pw.println(" bouncerIsOrWillBeShowing(): " + primaryBouncerIsOrWillBeShowing());
pw.println(" mAlternateBouncerReceivedDownTouch: " + mAlternateBouncerReceivedDownTouch);
pw.println(" Registered KeyguardViewManagerCallbacks:"); pw.println(" Registered KeyguardViewManagerCallbacks:");
for (KeyguardViewManagerCallback callback : mCallbacks) { for (KeyguardViewManagerCallback callback : mCallbacks) {
pw.println(" " + callback); pw.println(" " + callback);
@@ -1449,11 +1451,17 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
*/ */
public boolean onTouch(MotionEvent event) { public boolean onTouch(MotionEvent event) {
boolean handledTouch = false; boolean handledTouch = false;
if (event.getAction() == MotionEvent.ACTION_UP if (mAlternateBouncerInteractor.isVisibleState()) {
&& mAlternateBouncerInteractor.isVisibleState() if (event.getAction() == MotionEvent.ACTION_DOWN) {
&& mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime()) { mAlternateBouncerReceivedDownTouch = true;
showPrimaryBouncer(true); } else if (event.getAction() == MotionEvent.ACTION_UP
&& mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime()
&& mAlternateBouncerReceivedDownTouch) {
showPrimaryBouncer(true);
}
handledTouch = true; handledTouch = true;
} else {
mAlternateBouncerReceivedDownTouch = false;
} }
// Forward NPVC touches to callbacks in case they want to respond to touches // Forward NPVC touches to callbacks in case they want to respond to touches

View File

@@ -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_HIDDEN;
import static com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_VISIBLE; 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.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyBoolean;
@@ -729,30 +728,62 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
} }
@Test @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 // GIVEN the alternate bouncer has shown for a minimum amount of time
when(mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime()).thenReturn(true); when(mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime()).thenReturn(false);
when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true);
// WHEN ACTION_DOWN touch event comes // WHEN ACTION_DOWN and ACTION_UP touch event comes
boolean touchHandled = mStatusBarKeyguardViewManager.onTouch( boolean touchHandledDown = mStatusBarKeyguardViewManager.onTouch(
MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0)); 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 // THEN the touches are handled (doesn't let touches through to underlying views)
assertFalse(touchHandled); assertTrue(touchHandledDown);
assertTrue(touchHandledUp);
// THEN alternate bouncer does NOT attempt to hide since min showing time wasn't met
verify(mAlternateBouncerInteractor, never()).hide();
} }
@Test @Test
public void testAlternateBouncerOnTouch_actionUp_handlesTouch() { public void testAlternateBouncerOnTouch_actionDownThenUp_handlesTouch_hidesAltBouncer() {
reset(mAlternateBouncerInteractor);
// GIVEN the alternate bouncer has shown for a minimum amount of time // GIVEN the alternate bouncer has shown for a minimum amount of time
when(mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime()).thenReturn(true); when(mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime()).thenReturn(true);
when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true);
// WHEN ACTION_UP touch event comes // WHEN ACTION_DOWN and ACTION_UP touch event comes
boolean touchHandled = mStatusBarKeyguardViewManager.onTouch( 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)); MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_UP, 0f, 0f, 0));
// THEN the touch is handled // THEN the touches are handled
assertTrue(touchHandled); assertTrue(touchHandledDown);
assertTrue(touchHandledUp);
// THEN alternate bouncer attempts to hide
verify(mAlternateBouncerInteractor).hide();
}
@Test
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 only ACTION_UP touch event comes
mStatusBarKeyguardViewManager.onTouch(
MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_UP, 0f, 0f, 0));
// THEN the alternateBouncer doesn't hide
verify(mAlternateBouncerInteractor, never()).hide();
} }
} }