Merge changes I2d09a84e,I111aab35 into pi-dev
* changes:
Do not show bouncer when fading away
KeyguardBouncer#isShowing fix
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
index 2a1813f..d609ae7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java
@@ -60,10 +60,6 @@
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
@@ -72,7 +68,14 @@
}
};
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,
@@ -252,6 +255,7 @@
mKeyguardView.cancelDismissAction();
mKeyguardView.cleanUp();
}
+ mIsAnimatingAway = false;
if (mRoot != null) {
mRoot.setVisibility(View.INVISIBLE);
if (destroyView) {
@@ -267,6 +271,7 @@
* See {@link StatusBarKeyguardViewManager#startPreHideAnimation}.
*/
public void startPreHideAnimation(Runnable runnable) {
+ mIsAnimatingAway = true;
if (mKeyguardView != null) {
mKeyguardView.startDisappearAnimation(runnable);
} else if (runnable != null) {
@@ -290,7 +295,16 @@
}
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() {
@@ -308,7 +322,8 @@
* @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());
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
index b448967..c4d7e72 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PanelBar.java
@@ -28,6 +28,7 @@
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;
@@ -71,10 +72,15 @@
: 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;
}
@@ -124,7 +130,8 @@
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) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index a9c467e..56a7b1b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -150,8 +150,7 @@
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,
@@ -159,6 +158,9 @@
// data.
mBouncer.onFullyShown();
}
+ if (expansion == 0 || expansion == 1) {
+ updateStates();
+ }
}
mLastTracking = tracking;
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java
index f3a8417..a37947d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/KeyguardBouncerTest.java
@@ -22,8 +22,6 @@
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;
@@ -238,9 +236,19 @@
}
@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());
}
@@ -269,6 +277,25 @@
}
@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());