RESTRICT AUTOMERGE Only handle altBouncer touches if up & down received am: 2b9a0e9e0f

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/21956398

Change-Id: Ib631563fb738f7a4bff54ac878033ba6385dd9cc
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Beverly
2023-03-14 14:08:49 +00:00
committed by Automerger Merge Worker
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 boolean mLastScreenOffAnimationPlaying;
private float mQsExpansion;
private boolean mAlternateBouncerReceivedDownTouch = false;
final Set<KeyguardViewManagerCallback> mCallbacks = new HashSet<>();
private boolean mIsModernAlternateBouncerEnabled;
private boolean mIsBackAnimationEnabled;
@@ -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);
@@ -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()) {
showPrimaryBouncer(true);
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

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_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;
@@ -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(true);
when(mAlternateBouncerInteractor.hasAlternateBouncerShownWithMinTime()).thenReturn(false);
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 (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_actionUp_handlesTouch() {
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_UP 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 handled
assertTrue(touchHandled);
// THEN the touches are handled
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();
}
}