From 5277deaa591cabb163fa7ad0b139219c3f13313c Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Thu, 18 May 2017 02:05:29 +0200 Subject: [PATCH] Fix ordering of notifying dismiss callback Otherwise all unlocks will result in onDismissCancelled. Also fixes a race condition bug where we call reportKeyguardShowingChanged but we don't wait until the state is updated. Then, we called onDismissSucceeded such that KeyguardManager.isDeviceLocked would still return true. Fix this by waiting for the message to be processed. Note that delays shouldn't be a problem here as we are soon calling reportKeyguardShowingChanged from the UiOffloadThread. Test: KeyguardLockedTests Change-Id: I0b312a5f02be3a3d1028d8bf0cd1b8e6a33476ce Fixes: 38219395 --- .../com/android/systemui/keyguard/KeyguardViewMediator.java | 2 +- .../java/com/android/server/trust/TrustManagerService.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index f618a2c55e7dd..b083aa60ee29a 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -1808,11 +1808,11 @@ public class KeyguardViewMediator extends SystemUI { mWakeAndUnlocking = false; setShowingLocked(false); + mDismissCallbackRegistry.notifyDismissSucceeded(); mStatusBarKeyguardViewManager.hide(startTime, fadeoutDuration); resetKeyguardDonePendingLocked(); mHideAnimationRun = false; adjustStatusBarLocked(); - mDismissCallbackRegistry.notifyDismissSucceeded(); sendUserPresentBroadcast(); mUpdateMonitor.setKeyguardGoingAway(false /* goingAway */); } diff --git a/services/core/java/com/android/server/trust/TrustManagerService.java b/services/core/java/com/android/server/trust/TrustManagerService.java index 8e06a51238ee4..e12dc1d59a72f 100644 --- a/services/core/java/com/android/server/trust/TrustManagerService.java +++ b/services/core/java/com/android/server/trust/TrustManagerService.java @@ -795,6 +795,10 @@ public class TrustManagerService extends SystemService { // coalesce refresh messages. mHandler.removeMessages(MSG_KEYGUARD_SHOWING_CHANGED); mHandler.sendEmptyMessage(MSG_KEYGUARD_SHOWING_CHANGED); + + // Make sure handler processes the message before returning, such that isDeviceLocked + // after this call will retrieve the correct value. + mHandler.runWithScissors(() -> {}, 0); } @Override