From bcbe9481ced5d8004714b1c76df5df498d25bafe Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Wed, 23 Nov 2016 17:37:49 +0100 Subject: [PATCH] Fix issue when starting FLAG_DISMISS_KEYGUARD while occluded Since KS.dismiss comes in before KG.setOccluded, we didn't defer Keyguard going away until the shade was closed, which lead to an ugly switch to the normal shade during the dismissal animation. Test: Start FLAG_DISMISS_KEYGUARD while occluded to show bouncer, make sure unlock animation is clean. Test: Open settings from shade while Keyguard is occluded, make sure animation is clean. Change-Id: I31bdeb8077570ef2c50759321178f03601f1fa0d --- .../systemui/statusbar/phone/PhoneStatusBar.java | 12 +++++++++--- .../phone/StatusBarKeyguardViewManager.java | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 2b74c84759e56..2c613581bf290 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -3572,10 +3572,18 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, final boolean dismissShade, final boolean afterKeyguardGone, final boolean deferred) { - dismissKeyguardThenExecute(() -> { + final Runnable dismissAction = () -> { if (runnable != null) { AsyncTask.execute(runnable); } + }; + dismissKeyguardThenExecute(() -> { + if (mStatusBarKeyguardViewManager.isShowing() + && mStatusBarKeyguardViewManager.isOccluded()) { + mStatusBarKeyguardViewManager.addAfterKeyguardGoneRunnable(runnable); + } else { + dismissAction.run(); + } if (dismissShade) { if (mExpandedVisible) { animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_RECENTS_PANEL, true /* force */, @@ -3664,8 +3672,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, private void dismissKeyguardThenExecute(OnDismissAction action, Runnable cancelAction, boolean afterKeyguardGone) { - afterKeyguardGone |= mStatusBarKeyguardViewManager.isShowing() - && mStatusBarKeyguardViewManager.isOccluded(); if (mStatusBarKeyguardViewManager.isShowing()) { mStatusBarKeyguardViewManager.dismissWithAction(action, cancelAction, afterKeyguardGone); 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 42636708fae3c..2e279b233d7f3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -40,6 +40,8 @@ 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; + /** * Manages creating, showing, hiding and resetting the keyguard within the status bar. Calls back * via {@link ViewMediatorCallback} to poke the wake lock and report that the keyguard is done, @@ -90,6 +92,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb protected boolean mLastRemoteInputActive; private OnDismissAction mAfterKeyguardGoneAction; + private final ArrayList mAfterKeyguardGoneRunnables = new ArrayList<>(); private boolean mDeviceWillWakeUp; private boolean mDeferScrimFadeOut; @@ -164,6 +167,13 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb updateStates(); } + /** + * Adds a {@param runnable} to be executed after Keyguard is gone. + */ + public void addAfterKeyguardGoneRunnable(Runnable runnable) { + mAfterKeyguardGoneRunnables.add(runnable); + } + /** * Reset the state of the view. */ @@ -418,6 +428,10 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mAfterKeyguardGoneAction.onDismiss(); mAfterKeyguardGoneAction = null; } + for (int i = 0; i < mAfterKeyguardGoneRunnables.size(); i++) { + mAfterKeyguardGoneRunnables.get(i).run(); + } + mAfterKeyguardGoneRunnables.clear(); } /**