Improve UDFPS unlock animation experience

- Don't expand shade if touch started from KG and then
ended when KG was not longer showing. This can happen
if the security setting is set to swpe to open,
and the user transitions to the SHADE. Then, the touch can
be canceled if a window is transitioning to landscape.
- Don't propagate notification panel expansion to the bouncer
when the device is unlocking with biometric (MODE_DISMISS_BOUNCER).
Since KeyguardBouncer.EXPANSION_VISIBLE = 0 panel expansion, calls
during the unlock transition to collapse the notification panel
unintentionally end up showing the bouncer.
- If the KG isn't showing and the bouncer is in transit, reset the
bouncer expansion to HIDDEN.

Test: open fruit ninja (which is locked to landscape)
and swipe to unlock, notice that panel does not expand on unlock
Test: unlock using udfps by sliding finger from slightly below/diagonal
of the UDFPS sensor (so that the bouncer transition begins), and then
successfully authenticate with UDFPS => observe the bouncer UI doesn't
flash on the screen after successful authentication.
Test: atest StatusBarKeyguardViewManagerTest
Fixes: 240487038
Fixes: 240763673
Merged-In: I9e1fb108147ffb4c812ea2b94a50d6201eaf008a
Change-Id: I9e1fb108147ffb4c812ea2b94a50d6201eaf008a
This commit is contained in:
Beverly
2022-08-02 13:58:34 +00:00
committed by Beverly Tai
parent 9737d33e4f
commit d63046028f
3 changed files with 32 additions and 19 deletions

View File

@@ -165,6 +165,7 @@ public abstract class PanelViewController {
private float mInitialTouchY; private float mInitialTouchY;
private float mInitialTouchX; private float mInitialTouchX;
private boolean mTouchDisabled; private boolean mTouchDisabled;
private boolean mInitialTouchFromKeyguard;
/** /**
* Whether or not the PanelView can be expanded or collapsed with a drag. * Whether or not the PanelView can be expanded or collapsed with a drag.
@@ -394,6 +395,7 @@ public abstract class PanelViewController {
mInitialOffsetOnTouch = expandedHeight; mInitialOffsetOnTouch = expandedHeight;
mInitialTouchY = newY; mInitialTouchY = newY;
mInitialTouchX = newX; mInitialTouchX = newX;
mInitialTouchFromKeyguard = mStatusBarStateController.getState() == StatusBarState.KEYGUARD;
if (startTracking) { if (startTracking) {
mTouchSlopExceeded = true; mTouchSlopExceeded = true;
setExpandedHeight(mInitialOffsetOnTouch); setExpandedHeight(mInitialOffsetOnTouch);
@@ -416,20 +418,14 @@ public abstract class PanelViewController {
mStatusBarStateController.getState() == StatusBarState.KEYGUARD; mStatusBarStateController.getState() == StatusBarState.KEYGUARD;
final boolean expand; final boolean expand;
if (event.getActionMasked() == MotionEvent.ACTION_CANCEL || forceCancel) { if (mKeyguardStateController.isKeyguardFadingAway()
// If the keyguard is fading away, don't expand it again. This can happen if you're || (mInitialTouchFromKeyguard && !onKeyguard)) {
// swiping to unlock, the app below the keyguard is in landscape, and the screen // Don't expand for any touches that started from the keyguard and ended after the
// rotates while your finger is still down after the swipe to unlock. // keyguard is gone.
if (mKeyguardStateController.isKeyguardFadingAway()) { expand = false;
expand = false; } else if (event.getActionMasked() == MotionEvent.ACTION_CANCEL || forceCancel) {
} else if (onKeyguard) { if (onKeyguard) {
expand = true; expand = true;
} else if (mKeyguardStateController.isKeyguardFadingAway()) {
// If we're in the middle of dismissing the keyguard, don't expand due to the
// cancelled gesture. Gesture cancellation during an unlock is expected in some
// situations, such keeping your finger down while swiping to unlock to an app
// that is locked in landscape (the rotation will cancel the touch event).
expand = false;
} else { } else {
// If we get a cancel, put the shade back to the state it was in when the // If we get a cancel, put the shade back to the state it was in when the
// gesture started // gesture started
@@ -438,7 +434,6 @@ public abstract class PanelViewController {
} else { } else {
expand = flingExpands(vel, vectorVel, x, y); expand = flingExpands(vel, vectorVel, x, y);
} }
mDozeLog.traceFling(expand, mTouchAboveFalsingThreshold, mDozeLog.traceFling(expand, mTouchAboveFalsingThreshold,
mCentralSurfaces.isFalsingThresholdNeeded(), mCentralSurfaces.isFalsingThresholdNeeded(),
mCentralSurfaces.isWakeUpComingFromTouch()); mCentralSurfaces.isWakeUpComingFromTouch());

View File

@@ -19,6 +19,7 @@ package com.android.systemui.statusbar.phone;
import static android.view.WindowInsets.Type.navigationBars; import static android.view.WindowInsets.Type.navigationBars;
import static com.android.systemui.plugins.ActivityStarter.OnDismissAction; import static com.android.systemui.plugins.ActivityStarter.OnDismissAction;
import static com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_DISMISS_BOUNCER;
import static com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_UNLOCK_COLLAPSING; import static com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_UNLOCK_COLLAPSING;
import static com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK; import static com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK;
import static com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING; import static com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING;
@@ -381,6 +382,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
mBouncer.setExpansion(KeyguardBouncer.EXPANSION_VISIBLE); mBouncer.setExpansion(KeyguardBouncer.EXPANSION_VISIBLE);
} else if (mShowing && !hideBouncerOverDream) { } else if (mShowing && !hideBouncerOverDream) {
if (!isWakeAndUnlocking() if (!isWakeAndUnlocking()
&& !(mBiometricUnlockController.getMode() == MODE_DISMISS_BOUNCER)
&& !mCentralSurfaces.isInLaunchTransition() && !mCentralSurfaces.isInLaunchTransition()
&& !isUnlockCollapsing()) { && !isUnlockCollapsing()) {
mBouncer.setExpansion(fraction); mBouncer.setExpansion(fraction);
@@ -392,9 +394,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
} }
} else if (!mShowing && mBouncer.inTransit()) { } else if (!mShowing && mBouncer.inTransit()) {
// Keyguard is not visible anymore, but expansion animation was still running. // Keyguard is not visible anymore, but expansion animation was still running.
// We need to keep propagating the expansion state to the bouncer, otherwise it will be // We need to hide the bouncer, otherwise it will be stuck in transit.
// stuck in transit. mBouncer.setExpansion(KeyguardBouncer.EXPANSION_HIDDEN);
mBouncer.setExpansion(fraction);
} else if (mPulsing && fraction == KeyguardBouncer.EXPANSION_VISIBLE) { } else if (mPulsing && fraction == KeyguardBouncer.EXPANSION_VISIBLE) {
// Panel expanded while pulsing but didn't translate the bouncer (because we are // Panel expanded while pulsing but didn't translate the bouncer (because we are
// unlocked.) Let's simply wake-up to dismiss the lock screen. // unlocked.) Let's simply wake-up to dismiss the lock screen.

View File

@@ -192,12 +192,12 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
} }
@Test @Test
public void onPanelExpansionChanged_propagatesToBouncer_evenAfterHidden() { public void onPanelExpansionChanged_hideBouncer_afterKeyguardHidden() {
mStatusBarKeyguardViewManager.hide(0, 0); mStatusBarKeyguardViewManager.hide(0, 0);
when(mBouncer.inTransit()).thenReturn(true); when(mBouncer.inTransit()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT); mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
verify(mBouncer).setExpansion(eq(EXPANSION_EVENT.getFraction())); verify(mBouncer).setExpansion(eq(KeyguardBouncer.EXPANSION_HIDDEN));
} }
@Test @Test
@@ -238,6 +238,23 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
verify(mBouncer, never()).setExpansion(anyFloat()); verify(mBouncer, never()).setExpansion(anyFloat());
} }
@Test
public void onPanelExpansionChanged_neverTranslatesBouncerWhenDismissBouncer() {
// Since KeyguardBouncer.EXPANSION_VISIBLE = 0 panel expansion, if the unlock is dismissing
// the bouncer, there may be an onPanelExpansionChanged(0) call to collapse the panel
// which would mistakenly cause the bouncer to show briefly before its visibility
// is set to hide. Therefore, we don't want to propagate panelExpansionChanged to the
// bouncer if the bouncer is dismissing as a result of a biometric unlock.
when(mBiometricUnlockController.getMode())
.thenReturn(BiometricUnlockController.MODE_DISMISS_BOUNCER);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(
expansionEvent(
/* fraction= */ KeyguardBouncer.EXPANSION_VISIBLE,
/* expanded= */ true,
/* tracking= */ false));
verify(mBouncer, never()).setExpansion(anyFloat());
}
@Test @Test
public void onPanelExpansionChanged_neverTranslatesBouncerWhenLaunchingApp() { public void onPanelExpansionChanged_neverTranslatesBouncerWhenLaunchingApp() {
when(mCentralSurfaces.isInLaunchTransition()).thenReturn(true); when(mCentralSurfaces.isInLaunchTransition()).thenReturn(true);