Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3091fa1 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Automerger Merge Worker
Browse files

Merge "Fix race condition between lockNow() and updateLockscreenTimeout" into sc-dev am: 7db87a5e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14666650

Change-Id: I41cfd92a491c58f2b70b7b303b2c3a66c764cbe3
parents 94d12cfb 7db87a5e
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -595,6 +595,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    private KeyCombinationManager mKeyCombinationManager;
    private SingleKeyGestureDetector mSingleKeyGestureDetector;

    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;
@@ -4817,6 +4819,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    mKeyguardDelegate.doKeyguardTimeout(options);
                }
                mLockScreenTimerActive = false;
                mLockNowPending = false;
                options = null;
            }
        }
@@ -4826,7 +4829,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    }

    ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout();
    final ScreenLockTimeout mScreenLockTimeout = new ScreenLockTimeout();

    @Override
    public void lockNow(Bundle options) {
@@ -4838,6 +4841,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.
@@ -4853,6 +4859,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);