Merge "Fix race condition between lockNow() and updateLockscreenTimeout" into pi-dev

This commit is contained in:
TreeHugger Robot
2021-06-09 20:27:07 +00:00
committed by Android (Google) Code Review

View File

@@ -819,6 +819,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
private boolean mAodShowing; private boolean mAodShowing;
private boolean mLockNowPending = false;
private static final int MSG_ENABLE_POINTER_LOCATION = 1; private static final int MSG_ENABLE_POINTER_LOCATION = 1;
private static final int MSG_DISABLE_POINTER_LOCATION = 2; private static final int MSG_DISABLE_POINTER_LOCATION = 2;
private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3; private static final int MSG_DISPATCH_MEDIA_KEY_WITH_WAKE_LOCK = 3;
@@ -7748,6 +7750,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mKeyguardDelegate.doKeyguardTimeout(options); mKeyguardDelegate.doKeyguardTimeout(options);
} }
mLockScreenTimerActive = false; mLockScreenTimerActive = false;
mLockNowPending = false;
options = null; options = null;
} }
} }
@@ -7757,7 +7760,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
} }
} }
ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout(); final ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout();
@Override @Override
public void lockNow(Bundle options) { public void lockNow(Bundle options) {
@@ -7769,10 +7772,17 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mScreenLockTimeout.setLockOptions(options); mScreenLockTimeout.setLockOptions(options);
} }
mHandler.post(mScreenLockTimeout); mHandler.post(mScreenLockTimeout);
synchronized (mScreenLockTimeout) {
mLockNowPending = true;
}
} }
private void updateLockScreenTimeout() { private void updateLockScreenTimeout() {
synchronized (mScreenLockTimeout) { synchronized (mScreenLockTimeout) {
if (mLockNowPending) {
Log.w(TAG, "lockNow pending, ignore updating lockscreen timeout");
return;
}
boolean enable = (mAllowLockscreenWhenOn && mAwake && boolean enable = (mAllowLockscreenWhenOn && mAwake &&
mKeyguardDelegate != null && mKeyguardDelegate.isSecure(mCurrentUserId)); mKeyguardDelegate != null && mKeyguardDelegate.isSecure(mCurrentUserId));
if (mLockScreenTimerActive != enable) { if (mLockScreenTimerActive != enable) {