Merge "Fix race condition between lockNow() and updateLockscreenTimeout" into rvc-dev am: 665a84d29d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14673293 Change-Id: Ib92a9130bb53ab410758cd14d468af33bbdd7026
This commit is contained in:
@@ -608,6 +608,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
|
||||
private int mPowerButtonSuppressionDelayMillis = POWER_BUTTON_SUPPRESSION_DELAY_DEFAULT_MILLIS;
|
||||
|
||||
private boolean mLockNowPending = false;
|
||||
|
||||
private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3;
|
||||
private static final int MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK = 4;
|
||||
private static final int MSG_KEYGUARD_DRAWN_COMPLETE = 5;
|
||||
@@ -4941,6 +4943,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
mKeyguardDelegate.doKeyguardTimeout(options);
|
||||
}
|
||||
mLockScreenTimerActive = false;
|
||||
mLockNowPending = false;
|
||||
options = null;
|
||||
}
|
||||
}
|
||||
@@ -4950,7 +4953,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
}
|
||||
}
|
||||
|
||||
ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout();
|
||||
final ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout();
|
||||
|
||||
@Override
|
||||
public void lockNow(Bundle options) {
|
||||
@@ -4962,6 +4965,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
mScreenLockTimeout.setLockOptions(options);
|
||||
}
|
||||
mHandler.post(mScreenLockTimeout);
|
||||
synchronized (mScreenLockTimeout) {
|
||||
mLockNowPending = true;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO (b/113840485): Move this logic to DisplayPolicy when lockscreen supports multi-display.
|
||||
@@ -4977,6 +4983,10 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
|
||||
private void updateLockScreenTimeout() {
|
||||
synchronized (mScreenLockTimeout) {
|
||||
if (mLockNowPending) {
|
||||
Log.w(TAG, "lockNow pending, ignore updating lockscreen timeout");
|
||||
return;
|
||||
}
|
||||
final boolean enable = !mAllowLockscreenWhenOnDisplays.isEmpty()
|
||||
&& mDefaultDisplayPolicy.isAwake()
|
||||
&& mKeyguardDelegate != null && mKeyguardDelegate.isSecure(mCurrentUserId);
|
||||
|
||||
Reference in New Issue
Block a user