From f5304ad7be35a42b41a4e1e79ce2c62747e67bfc Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Mon, 17 Jul 2017 18:31:13 +0200 Subject: [PATCH] Fix wrong nav bar animation when unlocking from AOD Visibility of navigation bar was set too late. Set it earlier such that it gets the right animation. In addition to that, fixes a bug where Keyguard unlock animation was terminated too early if there was already a scrim animation pending. Test: Wake-and-unlock from Aod Bug: 63726451 Change-Id: I9a45fb27db68d56904c0fade40ea1173176beae8 --- .../statusbar/phone/ScrimController.java | 9 +++++++- .../phone/StatusBarKeyguardViewManager.java | 22 +++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java index 6d3fcff61a1cc..6672f5e894142 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java @@ -25,6 +25,7 @@ import android.content.Context; import android.graphics.Color; import android.graphics.Rect; import android.graphics.drawable.Drawable; +import android.util.Log; import android.util.MathUtils; import android.view.View; import android.view.ViewGroup; @@ -102,6 +103,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, protected long mDurationOverride = -1; private long mAnimationDelay; private Runnable mOnAnimationFinished; + private boolean mDeferFinishedListener; private final Interpolator mInterpolator = new DecelerateInterpolator(); private boolean mDozing; private float mDozeInFrontAlpha; @@ -446,7 +448,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { - if (mOnAnimationFinished != null) { + if (!mDeferFinishedListener && mOnAnimationFinished != null) { mOnAnimationFinished.run(); mOnAnimationFinished = null; } @@ -557,7 +559,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, float animEndValue = -1; if (previousAnimator != null) { if (animate || alpha == currentAlpha) { + // We are not done yet! Defer calling the finished listener. + if (animate) { + mDeferFinishedListener = true; + } previousAnimator.cancel(); + mDeferFinishedListener = false; } else { animEndValue = ViewState.getChildTag(scrim, TAG_END_ALPHA); } 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 be338de7676fa..191b7a24b78f0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -16,6 +16,10 @@ package com.android.systemui.statusbar.phone; +import static com.android.keyguard.KeyguardHostView.OnDismissAction; +import static com.android.systemui.statusbar.phone.FingerprintUnlockController.MODE_WAKE_AND_UNLOCK; +import static com.android.systemui.statusbar.phone.FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING; + import android.content.ComponentCallbacks2; import android.content.Context; import android.os.Bundle; @@ -30,18 +34,15 @@ import android.view.WindowManagerGlobal; import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; +import com.android.keyguard.LatencyTracker; import com.android.keyguard.ViewMediatorCallback; import com.android.systemui.DejankUtils; -import com.android.keyguard.LatencyTracker; import com.android.systemui.Dependency; import com.android.systemui.SystemUIFactory; import com.android.systemui.keyguard.DismissCallbackRegistry; import com.android.systemui.statusbar.CommandQueue; import com.android.systemui.statusbar.RemoteInputController; -import static com.android.keyguard.KeyguardHostView.OnDismissAction; -import static com.android.systemui.statusbar.phone.FingerprintUnlockController.*; - import java.util.ArrayList; /** @@ -95,6 +96,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb protected boolean mLastRemoteInputActive; private boolean mLastDozing; private boolean mLastDeferScrimFadeOut; + private int mLastFpMode; private OnDismissAction mAfterKeyguardGoneAction; private final ArrayList mAfterKeyguardGoneRunnables = new ArrayList<>(); @@ -583,6 +585,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mLastRemoteInputActive = remoteInputActive; mLastDozing = mDozing; mLastDeferScrimFadeOut = mDeferScrimFadeOut; + mLastFpMode = mFingerprintUnlockController.getMode(); mStatusBar.onKeyguardViewManagerStatesUpdated(); } @@ -590,15 +593,20 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb * @return Whether the navigation bar should be made visible based on the current state. */ protected boolean isNavBarVisible() { - return (!(mShowing && !mOccluded) && !mDozing || mBouncer.isShowing() || mRemoteInputActive) - && !mDeferScrimFadeOut; + int fpMode = mFingerprintUnlockController.getMode(); + boolean keyguardShowing = mShowing && !mOccluded; + boolean hideWhileDozing = mDozing && fpMode != MODE_WAKE_AND_UNLOCK_PULSING; + return (!keyguardShowing && !hideWhileDozing || mBouncer.isShowing() + || mRemoteInputActive) && !mDeferScrimFadeOut; } /** * @return Whether the navigation bar was made visible based on the last known state. */ protected boolean getLastNavBarVisible() { - return (!(mLastShowing && !mLastOccluded) && !mLastDozing || mLastBouncerShowing + boolean keyguardShowing = mLastShowing && !mLastOccluded; + boolean hideWhileDozing = mLastDozing && mLastFpMode != MODE_WAKE_AND_UNLOCK_PULSING; + return (!keyguardShowing && !hideWhileDozing || mLastBouncerShowing || mLastRemoteInputActive) && !mLastDeferScrimFadeOut; }