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

Commit 2bd8b6e4 authored by Lucas Dupin's avatar Lucas Dupin Committed by android-build-merger
Browse files

Merge "Do not allow bouncer translation when scrimmed" into pi-dev

am: 0a72c6b0

Change-Id: Ie566271b08b196be697f13f5f38d263d78fa3bbd
parents a54d7db2 0a72c6b0
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -54,8 +54,8 @@ public class KeyguardBouncer {

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

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

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

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

    /**
     * Shows the bouncer.
     *
     * @param resetSecuritySelection Cleans keyguard view
     * @param animated true when the bouncer show show animated, false when the user will be
     *                 dragging it and animation should be deferred.
     * @param isScrimmed true when the bouncer show show scrimmed, false when the user will be
     *                 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();
        if (keyguardUserId == UserHandle.USER_SYSTEM && UserManager.isSplitSystemUser()) {
            // In split system user mode, we never unlock system user.
@@ -126,9 +127,10 @@ public class KeyguardBouncer {
        // are valid.
        // 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.
        if (animated) {
        if (isScrimmed) {
            setExpansion(EXPANSION_VISIBLE);
        }
        mIsScrimmed = isScrimmed;

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

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

    /**
     * This method must be called at the end of the bouncer animation when
     * the translation is performed manually by the user, otherwise FalsingManager
+0 −11
Original line number Diff line number Diff line
@@ -948,17 +948,6 @@ public abstract class PanelView extends FrameLayout {
        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() {
        return mTracking;
    }
+6 −6
Original line number Diff line number Diff line
@@ -3977,12 +3977,12 @@ public class StatusBar extends SystemUI implements DemoMode,
    private void showBouncerIfKeyguard() {
        if ((mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED)
                && !mKeyguardViewMediator.isHiding()) {
            showBouncer(true /* animated */);
            showBouncer(true /* scrimmed */);
        }
    }

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

    private void instantExpandNotificationsPanel() {
@@ -4096,7 +4096,7 @@ public class StatusBar extends SystemUI implements DemoMode,
    public void onTrackingStopped(boolean expand) {
        if (mState == StatusBarState.KEYGUARD || mState == StatusBarState.SHADE_LOCKED) {
            if (!expand && !mUnlockMethodCache.canSkipBouncer()) {
                showBouncer(false /* animated */);
                showBouncer(false /* scrimmed */);
            }
        }
    }
@@ -4235,7 +4235,7 @@ public class StatusBar extends SystemUI implements DemoMode,
    @Override
    public void onLockedRemoteInput(ExpandableNotificationRow row, View clicked) {
        mLeaveOpenOnKeyguardHide = true;
        showBouncer(true /* animated */);
        showBouncer(true /* scrimmed */);
        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,
            // tapping on a notification, editing QS or being dismissed by
            // FLAG_DISMISS_KEYGUARD_ACTIVITY.
            ScrimState state = mIsOccluded || mNotificationPanel.needsScrimming()
            ScrimState state = mStatusBarKeyguardViewManager.bouncerNeedsScrimming()
                    || mStatusBarKeyguardViewManager.willDismissWithAction()
                    || mStatusBarKeyguardViewManager.isFullscreenBouncer() ?
                    ScrimState.BOUNCER_SCRIMMED : ScrimState.BOUNCER;
+15 −8
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.view.ViewGroup;
import android.view.ViewRootImpl;
import android.view.WindowManagerGlobal;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.LatencyTracker;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardUpdateMonitor;
@@ -158,7 +159,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        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:
        // • Keyguard is occluded, because we're in a FLAG_SHOW_WHEN_LOCKED activity and need to
        //   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
        // • Full-screen user switcher is displayed.
        if (mNotificationPanelView.isUnlockHintRunning()) {
            mBouncer.setExpansion(1);
        } else if (mOccluded || mBouncer.willDismissWithAction()
            mBouncer.setExpansion(KeyguardBouncer.EXPANSION_HIDDEN);
        } else if (mBouncer.willDismissWithAction() || mBouncer.isShowingScrimmed()
                || mStatusBar.isFullScreenUserSwitcherState()) {
            mBouncer.setExpansion(0);
            mBouncer.setExpansion(KeyguardBouncer.EXPANSION_VISIBLE);
        } else if (mShowing && !mDozing) {
            mBouncer.setExpansion(expansion);
            if (expansion != 1 && tracking && mStatusBar.isKeyguardCurrentlySecure()
            if (expansion != KeyguardBouncer.EXPANSION_HIDDEN && tracking
                    && mStatusBar.isKeyguardCurrentlySecure()
                    && !mBouncer.isShowing() && !mBouncer.isAnimatingAway()) {
                mBouncer.show(false /* resetSecuritySelection */, false /* animated */);
            }
@@ -215,9 +218,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
        cancelPendingWakeupAction();
    }

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

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

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

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.anyInt;
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
    public void testWillDismissWithAction() {
        mBouncer.ensureView();
Loading