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

Commit 1f0a6621 authored by Daniel Sandler's avatar Daniel Sandler Committed by Automerger Merge Worker
Browse files

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

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

Change-Id: I52ec38b96a54250bf25ef0da255e20b7a2f65f71
parents e72a13d4 7e742dca
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -621,6 +621,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;
@@ -5008,6 +5010,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    mKeyguardDelegate.doKeyguardTimeout(options);
                }
                mLockScreenTimerActive = false;
                mLockNowPending = false;
                options = null;
            }
        }
@@ -5017,7 +5020,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        }
    }

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

    @Override
    public void lockNow(Bundle options) {
@@ -5029,6 +5032,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.
@@ -5044,6 +5050,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);