Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java +21 −6 Original line number Diff line number Diff line Loading @@ -60,10 +60,6 @@ public class KeyguardBouncer { private final FalsingManager mFalsingManager; private final DismissCallbackRegistry mDismissCallbackRegistry; private final Handler mHandler; protected KeyguardHostView mKeyguardView; protected ViewGroup mRoot; private boolean mShowingSoon; private int mBouncerPromptReason; private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback = new KeyguardUpdateMonitorCallback() { @Override Loading @@ -72,7 +68,14 @@ public class KeyguardBouncer { } }; private final Runnable mRemoveViewRunnable = this::removeView; 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, LockPatternUtils lockPatternUtils, ViewGroup container, Loading Loading @@ -252,6 +255,7 @@ public class KeyguardBouncer { mKeyguardView.cancelDismissAction(); mKeyguardView.cleanUp(); } mIsAnimatingAway = false; if (mRoot != null) { mRoot.setVisibility(View.INVISIBLE); if (destroyView) { Loading @@ -267,6 +271,7 @@ public class KeyguardBouncer { * See {@link StatusBarKeyguardViewManager#startPreHideAnimation}. */ public void startPreHideAnimation(Runnable runnable) { mIsAnimatingAway = true; if (mKeyguardView != null) { mKeyguardView.startDisappearAnimation(runnable); } else if (runnable != null) { Loading @@ -290,7 +295,16 @@ public class KeyguardBouncer { } 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() { Loading @@ -308,7 +322,8 @@ public class KeyguardBouncer { * @see StatusBarKeyguardViewManager#onPanelExpansionChanged */ 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); mKeyguardView.setAlpha(MathUtils.constrain(alpha, 0f, 1f)); mKeyguardView.setTranslationY(fraction * mKeyguardView.getHeight()); Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java +8 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ public abstract class PanelBar extends FrameLayout { public static final String TAG = PanelBar.class.getSimpleName(); private static final boolean SPEW = false; private boolean mBouncerShowing; private boolean mExpanded; public static final void LOG(String fmt, Object... args) { if (!DEBUG) return; Loading Loading @@ -71,10 +72,15 @@ public abstract class PanelBar extends FrameLayout { : IMPORTANT_FOR_ACCESSIBILITY_AUTO; setImportantForAccessibility(important); updateVisibility(); if (mPanel != null) mPanel.setImportantForAccessibility(important); } private void updateVisibility() { mPanel.setVisibility(mExpanded || mBouncerShowing ? VISIBLE : INVISIBLE); } public boolean panelEnabled() { return true; } Loading Loading @@ -124,7 +130,8 @@ public abstract class PanelBar extends FrameLayout { boolean fullyOpened = false; if (SPEW) LOG("panelExpansionChanged: start state=%d", mState); PanelView pv = mPanel; pv.setVisibility(expanded || mBouncerShowing ? VISIBLE : INVISIBLE); mExpanded = expanded; updateVisibility(); // adjust any other panels that may be partially visible if (expanded) { if (mState == STATE_CLOSED) { Loading packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +4 −2 Original line number Diff line number Diff line Loading @@ -150,8 +150,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mBouncer.setExpansion(expansion); if (expansion == 1) { mBouncer.onFullyHidden(); updateStates(); } else if (!mBouncer.isShowing()) { } else if (!mBouncer.isShowing() && !mBouncer.isAnimatingAway()) { mBouncer.show(true /* resetSecuritySelection */, false /* notifyFalsing */); } else if (noLongerTracking) { // Notify that falsing manager should stop its session when user stops touching, Loading @@ -159,6 +158,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb // data. mBouncer.onFullyShown(); } if (expansion == 0 || expansion == 1) { updateStates(); } } mLastTracking = tracking; } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java +31 −4 Original line number Diff line number Diff line Loading @@ -22,8 +22,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyInt; 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.reset; import static org.mockito.Mockito.spy; Loading Loading @@ -238,9 +236,19 @@ public class KeyguardBouncerTest extends SysuiTestCase { } @Test public void testIsShowing() { public void testIsShowing_animated() { 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()); } Loading Loading @@ -268,6 +276,25 @@ public class KeyguardBouncerTest extends SysuiTestCase { 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 public void testIsSecure() { Assert.assertTrue("Bouncer is secure before inflating views", mBouncer.isSecure()); Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java +21 −6 Original line number Diff line number Diff line Loading @@ -60,10 +60,6 @@ public class KeyguardBouncer { private final FalsingManager mFalsingManager; private final DismissCallbackRegistry mDismissCallbackRegistry; private final Handler mHandler; protected KeyguardHostView mKeyguardView; protected ViewGroup mRoot; private boolean mShowingSoon; private int mBouncerPromptReason; private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback = new KeyguardUpdateMonitorCallback() { @Override Loading @@ -72,7 +68,14 @@ public class KeyguardBouncer { } }; private final Runnable mRemoveViewRunnable = this::removeView; 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, LockPatternUtils lockPatternUtils, ViewGroup container, Loading Loading @@ -252,6 +255,7 @@ public class KeyguardBouncer { mKeyguardView.cancelDismissAction(); mKeyguardView.cleanUp(); } mIsAnimatingAway = false; if (mRoot != null) { mRoot.setVisibility(View.INVISIBLE); if (destroyView) { Loading @@ -267,6 +271,7 @@ public class KeyguardBouncer { * See {@link StatusBarKeyguardViewManager#startPreHideAnimation}. */ public void startPreHideAnimation(Runnable runnable) { mIsAnimatingAway = true; if (mKeyguardView != null) { mKeyguardView.startDisappearAnimation(runnable); } else if (runnable != null) { Loading @@ -290,7 +295,16 @@ public class KeyguardBouncer { } 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() { Loading @@ -308,7 +322,8 @@ public class KeyguardBouncer { * @see StatusBarKeyguardViewManager#onPanelExpansionChanged */ 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); mKeyguardView.setAlpha(MathUtils.constrain(alpha, 0f, 1f)); mKeyguardView.setTranslationY(fraction * mKeyguardView.getHeight()); Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java +8 −1 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ public abstract class PanelBar extends FrameLayout { public static final String TAG = PanelBar.class.getSimpleName(); private static final boolean SPEW = false; private boolean mBouncerShowing; private boolean mExpanded; public static final void LOG(String fmt, Object... args) { if (!DEBUG) return; Loading Loading @@ -71,10 +72,15 @@ public abstract class PanelBar extends FrameLayout { : IMPORTANT_FOR_ACCESSIBILITY_AUTO; setImportantForAccessibility(important); updateVisibility(); if (mPanel != null) mPanel.setImportantForAccessibility(important); } private void updateVisibility() { mPanel.setVisibility(mExpanded || mBouncerShowing ? VISIBLE : INVISIBLE); } public boolean panelEnabled() { return true; } Loading Loading @@ -124,7 +130,8 @@ public abstract class PanelBar extends FrameLayout { boolean fullyOpened = false; if (SPEW) LOG("panelExpansionChanged: start state=%d", mState); PanelView pv = mPanel; pv.setVisibility(expanded || mBouncerShowing ? VISIBLE : INVISIBLE); mExpanded = expanded; updateVisibility(); // adjust any other panels that may be partially visible if (expanded) { if (mState == STATE_CLOSED) { Loading
packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +4 −2 Original line number Diff line number Diff line Loading @@ -150,8 +150,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mBouncer.setExpansion(expansion); if (expansion == 1) { mBouncer.onFullyHidden(); updateStates(); } else if (!mBouncer.isShowing()) { } else if (!mBouncer.isShowing() && !mBouncer.isAnimatingAway()) { mBouncer.show(true /* resetSecuritySelection */, false /* notifyFalsing */); } else if (noLongerTracking) { // Notify that falsing manager should stop its session when user stops touching, Loading @@ -159,6 +158,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb // data. mBouncer.onFullyShown(); } if (expansion == 0 || expansion == 1) { updateStates(); } } mLastTracking = tracking; } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java +31 −4 Original line number Diff line number Diff line Loading @@ -22,8 +22,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.anyInt; 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.reset; import static org.mockito.Mockito.spy; Loading Loading @@ -238,9 +236,19 @@ public class KeyguardBouncerTest extends SysuiTestCase { } @Test public void testIsShowing() { public void testIsShowing_animated() { 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()); } Loading Loading @@ -268,6 +276,25 @@ public class KeyguardBouncerTest extends SysuiTestCase { 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 public void testIsSecure() { Assert.assertTrue("Bouncer is secure before inflating views", mBouncer.isSecure()); Loading