Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9ca35eb authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Do not allow bouncer translation when scrimmed

We had special cases when the bouncer shouldn't be translated but that
doesn't really scale. It's much simpler to just check if it's being
scrimmed - because otherwse it mus be translated.

Change-Id: Ide0af6718f1792ef1a1e16fa39512a2b3a0ba8be
Bug: 78222122
Fixes: 78205990
Fixes: 78140990
Test: atest packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java
Test: atest packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java
Test: go/sysui-bouncer-tests
parent 5a36c134
Loading
Loading
Loading
Loading
+13 −7
Original line number Original line Diff line number Diff line
@@ -54,8 +54,8 @@ public class KeyguardBouncer {


    private static final String TAG = "KeyguardBouncer";
    private static final String TAG = "KeyguardBouncer";
    static final float ALPHA_EXPANSION_THRESHOLD = 0.95f;
    static final float ALPHA_EXPANSION_THRESHOLD = 0.95f;
    private static final float EXPANSION_HIDDEN = 1f;
    static final float EXPANSION_HIDDEN = 1f;
    private static final float EXPANSION_VISIBLE = 0f;
    static final float EXPANSION_VISIBLE = 0f;


    protected final Context mContext;
    protected final Context mContext;
    protected final ViewMediatorCallback mCallback;
    protected final ViewMediatorCallback mCallback;
@@ -86,6 +86,7 @@ public class KeyguardBouncer {
    private boolean mShowingSoon;
    private boolean mShowingSoon;
    private int mBouncerPromptReason;
    private int mBouncerPromptReason;
    private boolean mIsAnimatingAway;
    private boolean mIsAnimatingAway;
    private boolean mIsScrimmed;


    public KeyguardBouncer(Context context, ViewMediatorCallback callback,
    public KeyguardBouncer(Context context, ViewMediatorCallback callback,
            LockPatternUtils lockPatternUtils, ViewGroup container,
            LockPatternUtils lockPatternUtils, ViewGroup container,
@@ -103,17 +104,17 @@ public class KeyguardBouncer {
    }
    }


    public void show(boolean resetSecuritySelection) {
    public void show(boolean resetSecuritySelection) {
        show(resetSecuritySelection, true /* animated */);
        show(resetSecuritySelection, true /* scrimmed */);
    }
    }


    /**
    /**
     * Shows the bouncer.
     * Shows the bouncer.
     *
     *
     * @param resetSecuritySelection Cleans keyguard view
     * @param resetSecuritySelection Cleans keyguard view
     * @param animated true when the bouncer show show animated, false when the user will be
     * @param isScrimmed true when the bouncer show show scrimmed, false when the user will be
     *                 dragging it and animation should be deferred.
     *                 dragging it and translation should be deferred.
     */
     */
    public void show(boolean resetSecuritySelection, boolean animated) {
    public void show(boolean resetSecuritySelection, boolean isScrimmed) {
        final int keyguardUserId = KeyguardUpdateMonitor.getCurrentUser();
        final int keyguardUserId = KeyguardUpdateMonitor.getCurrentUser();
        if (keyguardUserId == UserHandle.USER_SYSTEM && UserManager.isSplitSystemUser()) {
        if (keyguardUserId == UserHandle.USER_SYSTEM && UserManager.isSplitSystemUser()) {
            // In split system user mode, we never unlock system user.
            // In split system user mode, we never unlock system user.
@@ -126,9 +127,10 @@ public class KeyguardBouncer {
        // are valid.
        // are valid.
        // Later, at the end of the animation, when the bouncer is at the top of the screen,
        // Later, at the end of the animation, when the bouncer is at the top of the screen,
        // onFullyShown() will be called and FalsingManager will stop recording touches.
        // onFullyShown() will be called and FalsingManager will stop recording touches.
        if (animated) {
        if (isScrimmed) {
            setExpansion(EXPANSION_VISIBLE);
            setExpansion(EXPANSION_VISIBLE);
        }
        }
        mIsScrimmed = isScrimmed;


        if (resetSecuritySelection) {
        if (resetSecuritySelection) {
            // showPrimarySecurityScreen() updates the current security method. This is needed in
            // showPrimarySecurityScreen() updates the current security method. This is needed in
@@ -164,6 +166,10 @@ public class KeyguardBouncer {
        mCallback.onBouncerVisiblityChanged(true /* shown */);
        mCallback.onBouncerVisiblityChanged(true /* shown */);
    }
    }


    public boolean isShowingScrimmed() {
        return isShowing() && mIsScrimmed;
    }

    /**
    /**
     * This method must be called at the end of the bouncer animation when
     * This method must be called at the end of the bouncer animation when
     * the translation is performed manually by the user, otherwise FalsingManager
     * the translation is performed manually by the user, otherwise FalsingManager
+0 −11
Original line number Original line Diff line number Diff line
@@ -947,17 +947,6 @@ public abstract class PanelView extends FrameLayout {
        return mClosing || mLaunchingNotification;
        return mClosing || mLaunchingNotification;
    }
    }


    /**
     * Bouncer might need a scrim when you double tap on notifications or edit QS.
     * On other cases, when you drag up the bouncer with the finger or just fling,
     * the scrim should be hidden to avoid occluding the clock.
     *
     * @return true when we need a scrim to show content on top of the notification panel.
     */
    public boolean needsScrimming() {
        return !isTracking() && !isCollapsing() && !isFullyCollapsed();
    }

    public boolean isTracking() {
    public boolean isTracking() {
        return mTracking;
        return mTracking;
    }
    }
+6 −6
Original line number Original line Diff line number Diff line
@@ -3977,12 +3977,12 @@ public class StatusBar extends SystemUI implements DemoMode,
    private void showBouncerIfKeyguard() {
    private void showBouncerIfKeyguard() {
        if ((mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)
        if ((mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)
                && !mKeyguardViewMediator.isHiding()) {
                && !mKeyguardViewMediator.isHiding()) {
            showBouncer(true /* animated */);
            showBouncer(true /* scrimmed */);
        }
        }
    }
    }


    protected void showBouncer(boolean animated) {
    protected void showBouncer(boolean scrimmed) {
        mStatusBarKeyguardViewManager.showBouncer(animated);
        mStatusBarKeyguardViewManager.showBouncer(scrimmed);
    }
    }


    private void instantExpandNotificationsPanel() {
    private void instantExpandNotificationsPanel() {
@@ -4096,7 +4096,7 @@ public class StatusBar extends SystemUI implements DemoMode,
    public void onTrackingStopped(boolean expand) {
    public void onTrackingStopped(boolean expand) {
        if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) {
        if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) {
            if (!expand && !mUnlockMethodCache.canSkipBouncer()) {
            if (!expand && !mUnlockMethodCache.canSkipBouncer()) {
                showBouncer(false /* animated */);
                showBouncer(false /* scrimmed */);
            }
            }
        }
        }
    }
    }
@@ -4235,7 +4235,7 @@ public class StatusBar extends SystemUI implements DemoMode,
    @Override
    @Override
    public void onLockedRemoteInput(ExpandableNotificationRow row, View clicked) {
    public void onLockedRemoteInput(ExpandableNotificationRow row, View clicked) {
        mLeaveOpenOnKeyguardHide = true;
        mLeaveOpenOnKeyguardHide = true;
        showBouncer(true /* animated */);
        showBouncer(true /* scrimmed */);
        mPendingRemoteInputView = clicked;
        mPendingRemoteInputView = clicked;
    }
    }


@@ -4705,7 +4705,7 @@ public class StatusBar extends SystemUI implements DemoMode,
            // Bouncer needs the front scrim when it's on top of an activity,
            // Bouncer needs the front scrim when it's on top of an activity,
            // tapping on a notification, editing QS or being dismissed by
            // tapping on a notification, editing QS or being dismissed by
            // FLAG_DISMISS_KEYGUARD_ACTIVITY.
            // FLAG_DISMISS_KEYGUARD_ACTIVITY.
            ScrimState state = mIsOccluded || mNotificationPanel.needsScrimming()
            ScrimState state = mStatusBarKeyguardViewManager.bouncerNeedsScrimming()
                    || mStatusBarKeyguardViewManager.willDismissWithAction()
                    || mStatusBarKeyguardViewManager.willDismissWithAction()
                    || mStatusBarKeyguardViewManager.isFullscreenBouncer() ?
                    || mStatusBarKeyguardViewManager.isFullscreenBouncer() ?
                    ScrimState.BOUNCER_SCRIMMED : ScrimState.BOUNCER;
                    ScrimState.BOUNCER_SCRIMMED : ScrimState.BOUNCER;
+15 −8
Original line number Original line Diff line number Diff line
@@ -31,6 +31,7 @@ import android.view.ViewGroup;
import android.view.ViewRootImpl;
import android.view.ViewRootImpl;
import android.view.WindowManagerGlobal;
import android.view.WindowManagerGlobal;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.LatencyTracker;
import com.android.internal.util.LatencyTracker;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitor;
@@ -158,7 +159,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        mNotificationPanelView.setBouncerTop(mBouncer.getTop());
        mNotificationPanelView.setBouncerTop(mBouncer.getTop());
    }
    }


    private void onPanelExpansionChanged(float expansion, boolean tracking) {
    @VisibleForTesting
    void onPanelExpansionChanged(float expansion, boolean tracking) {
        // We don't want to translate the bounce when:
        // We don't want to translate the bounce when:
        // • Keyguard is occluded, because we're in a FLAG_SHOW_WHEN_LOCKED activity and need to
        // • Keyguard is occluded, because we're in a FLAG_SHOW_WHEN_LOCKED activity and need to
        //   conserve the original animation.
        //   conserve the original animation.
@@ -166,13 +168,14 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        // • Keyguard will be dismissed by an action. a.k.a: FLAG_DISMISS_KEYGUARD_ACTIVITY
        // • Keyguard will be dismissed by an action. a.k.a: FLAG_DISMISS_KEYGUARD_ACTIVITY
        // • Full-screen user switcher is displayed.
        // • Full-screen user switcher is displayed.
        if (mNotificationPanelView.isUnlockHintRunning()) {
        if (mNotificationPanelView.isUnlockHintRunning()) {
            mBouncer.setExpansion(1);
            mBouncer.setExpansion(KeyguardBouncer.EXPANSION_HIDDEN);
        } else if (mOccluded || mBouncer.willDismissWithAction()
        } else if (mBouncer.willDismissWithAction() || mBouncer.isShowingScrimmed()
                || mStatusBar.isFullScreenUserSwitcherState()) {
                || mStatusBar.isFullScreenUserSwitcherState()) {
            mBouncer.setExpansion(0);
            mBouncer.setExpansion(KeyguardBouncer.EXPANSION_VISIBLE);
        } else if (mShowing && !mDozing) {
        } else if (mShowing && !mDozing) {
            mBouncer.setExpansion(expansion);
            mBouncer.setExpansion(expansion);
            if (expansion != 1 && tracking && mStatusBar.isKeyguardCurrentlySecure()
            if (expansion != KeyguardBouncer.EXPANSION_HIDDEN && tracking
                    && mStatusBar.isKeyguardCurrentlySecure()
                    && !mBouncer.isShowing() && !mBouncer.isAnimatingAway()) {
                    && !mBouncer.isShowing() && !mBouncer.isAnimatingAway()) {
                mBouncer.show(false /* resetSecuritySelection */, false /* animated */);
                mBouncer.show(false /* resetSecuritySelection */, false /* animated */);
            }
            }
@@ -215,9 +218,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        cancelPendingWakeupAction();
        cancelPendingWakeupAction();
    }
    }


    public void showBouncer(boolean animated) {
    public void showBouncer(boolean scrimmed) {
        if (mShowing) {
        if (mShowing && !mBouncer.isShowing()) {
            mBouncer.show(false /* resetSecuritySelection */, animated);
            mBouncer.show(false /* resetSecuritySelection */, scrimmed);
        }
        }
        updateStates();
        updateStates();
    }
    }
@@ -725,6 +728,10 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        return mBouncer.willDismissWithAction();
        return mBouncer.willDismissWithAction();
    }
    }


    public boolean bouncerNeedsScrimming() {
        return mBouncer.isShowingScrimmed();
    }

    public void dump(PrintWriter pw) {
    public void dump(PrintWriter pw) {
        pw.println("StatusBarKeyguardViewManager:");
        pw.println("StatusBarKeyguardViewManager:");
        pw.println("  mShowing: " + mShowing);
        pw.println("  mShowing: " + mShowing);
+10 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package com.android.systemui.statusbar.phone;
package com.android.systemui.statusbar.phone;


import static com.google.common.truth.Truth.assertThat;

import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.ArgumentMatchers.eq;
@@ -325,6 +327,14 @@ public class KeyguardBouncerTest extends SysuiTestCase {
        }
        }
    }
    }


    @Test
    public void testIsShowingScrimmed() {
        mBouncer.show(false /* resetSecuritySelection */, true /* animate */);
        assertThat(mBouncer.isShowingScrimmed()).isTrue();
        mBouncer.show(false /* resetSecuritySelection */, false /* animate */);
        assertThat(mBouncer.isShowingScrimmed()).isFalse();
    }

    @Test
    @Test
    public void testWillDismissWithAction() {
    public void testWillDismissWithAction() {
        mBouncer.ensureView();
        mBouncer.ensureView();
Loading