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

Commit 4cfd9f24 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I2d09a84e,I111aab35 into pi-dev

* changes:
  Do not show bouncer when fading away
  KeyguardBouncer#isShowing fix
parents e41b39d6 28dc9d7d
Loading
Loading
Loading
Loading
+21 −6
Original line number Original line Diff line number Diff line
@@ -60,10 +60,6 @@ public class KeyguardBouncer {
    private final FalsingManager mFalsingManager;
    private final FalsingManager mFalsingManager;
    private final DismissCallbackRegistry mDismissCallbackRegistry;
    private final DismissCallbackRegistry mDismissCallbackRegistry;
    private final Handler mHandler;
    private final Handler mHandler;
    protected KeyguardHostView mKeyguardView;
    protected ViewGroup mRoot;
    private boolean mShowingSoon;
    private int mBouncerPromptReason;
    private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback =
    private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback =
            new KeyguardUpdateMonitorCallback() {
            new KeyguardUpdateMonitorCallback() {
                @Override
                @Override
@@ -72,7 +68,14 @@ public class KeyguardBouncer {
                }
                }
            };
            };
    private final Runnable mRemoveViewRunnable = this::removeView;
    private final Runnable mRemoveViewRunnable = this::removeView;

    private int mStatusBarHeight;
    private int mStatusBarHeight;
    private float mExpansion;
    protected KeyguardHostView mKeyguardView;
    protected ViewGroup mRoot;
    private boolean mShowingSoon;
    private int mBouncerPromptReason;
    private boolean mIsAnimatingAway;


    public KeyguardBouncer(Context context, ViewMediatorCallback callback,
    public KeyguardBouncer(Context context, ViewMediatorCallback callback,
            LockPatternUtils lockPatternUtils, ViewGroup container,
            LockPatternUtils lockPatternUtils, ViewGroup container,
@@ -252,6 +255,7 @@ public class KeyguardBouncer {
            mKeyguardView.cancelDismissAction();
            mKeyguardView.cancelDismissAction();
            mKeyguardView.cleanUp();
            mKeyguardView.cleanUp();
        }
        }
        mIsAnimatingAway = false;
        if (mRoot != null) {
        if (mRoot != null) {
            mRoot.setVisibility(View.INVISIBLE);
            mRoot.setVisibility(View.INVISIBLE);
            if (destroyView) {
            if (destroyView) {
@@ -267,6 +271,7 @@ public class KeyguardBouncer {
     * See {@link StatusBarKeyguardViewManager#startPreHideAnimation}.
     * See {@link StatusBarKeyguardViewManager#startPreHideAnimation}.
     */
     */
    public void startPreHideAnimation(Runnable runnable) {
    public void startPreHideAnimation(Runnable runnable) {
        mIsAnimatingAway = true;
        if (mKeyguardView != null) {
        if (mKeyguardView != null) {
            mKeyguardView.startDisappearAnimation(runnable);
            mKeyguardView.startDisappearAnimation(runnable);
        } else if (runnable != null) {
        } else if (runnable != null) {
@@ -290,7 +295,16 @@ public class KeyguardBouncer {
    }
    }


    public boolean isShowing() {
    public boolean isShowing() {
        return mShowingSoon || (mRoot != null && mRoot.getVisibility() == View.VISIBLE);
        return (mShowingSoon || (mRoot != null && mRoot.getVisibility() == View.VISIBLE))
                && mExpansion == 0;
    }

    /**
     * @return {@code true} when bouncer's pre-hide animation already started but isn't completely
     *         hidden yet, {@code false} otherwise.
     */
    public boolean isAnimatingAway() {
        return mIsAnimatingAway;
    }
    }


    public void prepare() {
    public void prepare() {
@@ -308,7 +322,8 @@ public class KeyguardBouncer {
     * @see StatusBarKeyguardViewManager#onPanelExpansionChanged
     * @see StatusBarKeyguardViewManager#onPanelExpansionChanged
     */
     */
    public void setExpansion(float fraction) {
    public void setExpansion(float fraction) {
        if (mKeyguardView != null) {
        mExpansion = fraction;
        if (mKeyguardView != null && !mIsAnimatingAway) {
            float alpha = MathUtils.map(ALPHA_EXPANSION_THRESHOLD, 1, 1, 0, fraction);
            float alpha = MathUtils.map(ALPHA_EXPANSION_THRESHOLD, 1, 1, 0, fraction);
            mKeyguardView.setAlpha(MathUtils.constrain(alpha, 0f, 1f));
            mKeyguardView.setAlpha(MathUtils.constrain(alpha, 0f, 1f));
            mKeyguardView.setTranslationY(fraction * mKeyguardView.getHeight());
            mKeyguardView.setTranslationY(fraction * mKeyguardView.getHeight());
+8 −1
Original line number Original line Diff line number Diff line
@@ -28,6 +28,7 @@ public abstract class PanelBar extends FrameLayout {
    public static final String TAG = PanelBar.class.getSimpleName();
    public static final String TAG = PanelBar.class.getSimpleName();
    private static final boolean SPEW = false;
    private static final boolean SPEW = false;
    private boolean mBouncerShowing;
    private boolean mBouncerShowing;
    private boolean mExpanded;


    public static final void LOG(String fmt, Object... args) {
    public static final void LOG(String fmt, Object... args) {
        if (!DEBUG) return;
        if (!DEBUG) return;
@@ -71,10 +72,15 @@ public abstract class PanelBar extends FrameLayout {
                : IMPORTANT_FOR_ACCESSIBILITY_AUTO;
                : IMPORTANT_FOR_ACCESSIBILITY_AUTO;


        setImportantForAccessibility(important);
        setImportantForAccessibility(important);
        updateVisibility();


        if (mPanel != null) mPanel.setImportantForAccessibility(important);
        if (mPanel != null) mPanel.setImportantForAccessibility(important);
    }
    }


    private void updateVisibility() {
        mPanel.setVisibility(mExpanded || mBouncerShowing ? VISIBLE : INVISIBLE);
    }

    public boolean panelEnabled() {
    public boolean panelEnabled() {
        return true;
        return true;
    }
    }
@@ -124,7 +130,8 @@ public abstract class PanelBar extends FrameLayout {
        boolean fullyOpened = false;
        boolean fullyOpened = false;
        if (SPEW) LOG("panelExpansionChanged: start state=%d", mState);
        if (SPEW) LOG("panelExpansionChanged: start state=%d", mState);
        PanelView pv = mPanel;
        PanelView pv = mPanel;
        pv.setVisibility(expanded || mBouncerShowing ? VISIBLE : INVISIBLE);
        mExpanded = expanded;
        updateVisibility();
        // adjust any other panels that may be partially visible
        // adjust any other panels that may be partially visible
        if (expanded) {
        if (expanded) {
            if (mState == STATE_CLOSED) {
            if (mState == STATE_CLOSED) {
+4 −2
Original line number Original line Diff line number Diff line
@@ -150,8 +150,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
            mBouncer.setExpansion(expansion);
            mBouncer.setExpansion(expansion);
            if (expansion == 1) {
            if (expansion == 1) {
                mBouncer.onFullyHidden();
                mBouncer.onFullyHidden();
                updateStates();
            } else if (!mBouncer.isShowing() && !mBouncer.isAnimatingAway()) {
            } else if (!mBouncer.isShowing()) {
                mBouncer.show(true /* resetSecuritySelection */, false /* notifyFalsing */);
                mBouncer.show(true /* resetSecuritySelection */, false /* notifyFalsing */);
            } else if (noLongerTracking) {
            } else if (noLongerTracking) {
                // Notify that falsing manager should stop its session when user stops touching,
                // Notify that falsing manager should stop its session when user stops touching,
@@ -159,6 +158,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
                // data.
                // data.
                mBouncer.onFullyShown();
                mBouncer.onFullyShown();
            }
            }
            if (expansion == 0 || expansion == 1) {
                updateStates();
            }
        }
        }
        mLastTracking = tracking;
        mLastTracking = tracking;
    }
    }
+31 −4
Original line number Original line Diff line number Diff line
@@ -22,8 +22,6 @@ import static org.mockito.ArgumentMatchers.any;
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;
import static org.mockito.Mockito.calls;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.spy;
@@ -238,9 +236,19 @@ public class KeyguardBouncerTest extends SysuiTestCase {
    }
    }


    @Test
    @Test
    public void testIsShowing() {
    public void testIsShowing_animated() {
        Assert.assertFalse("Show wasn't invoked yet", mBouncer.isShowing());
        Assert.assertFalse("Show wasn't invoked yet", mBouncer.isShowing());
        mBouncer.show(true);
        mBouncer.show(true /* reset */);
        Assert.assertTrue("Should be showing", mBouncer.isShowing());
    }

    @Test
    public void testIsShowing_forSwipeUp() {
        mBouncer.setExpansion(1f);
        mBouncer.show(true /* reset */, false /* animated */);
        Assert.assertFalse("Should only be showing after collapsing notification panel",
                mBouncer.isShowing());
        mBouncer.setExpansion(0f);
        Assert.assertTrue("Should be showing", mBouncer.isShowing());
        Assert.assertTrue("Should be showing", mBouncer.isShowing());
    }
    }


@@ -268,6 +276,25 @@ public class KeyguardBouncerTest extends SysuiTestCase {
        verify(mKeyguardHostView, never()).getSecurityMode();
        verify(mKeyguardHostView, never()).getSecurityMode();
    }
    }


    @Test
    public void testIsHiding_preHideOrHide() {
        Assert.assertFalse("Should not be hiding on initial state", mBouncer.isAnimatingAway());
        mBouncer.startPreHideAnimation(null /* runnable */);
        Assert.assertTrue("Should be hiding during pre-hide", mBouncer.isAnimatingAway());
        mBouncer.hide(false /* destroyView */);
        Assert.assertFalse("Should be hidden after hide()", mBouncer.isAnimatingAway());
    }

    @Test
    public void testIsHiding_skipsTranslation() {
        mBouncer.show(false /* reset */);
        reset(mKeyguardHostView);
        mBouncer.startPreHideAnimation(null /* runnable */);
        mBouncer.setExpansion(0.5f);
        verify(mKeyguardHostView, never()).setTranslationY(anyFloat());
        verify(mKeyguardHostView, never()).setAlpha(anyFloat());
    }

    @Test
    @Test
    public void testIsSecure() {
    public void testIsSecure() {
        Assert.assertTrue("Bouncer is secure before inflating views", mBouncer.isSecure());
        Assert.assertTrue("Bouncer is secure before inflating views", mBouncer.isSecure());