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

Commit 6e9d040d authored by Adrian Roos's avatar Adrian Roos Committed by Android Git Automerger
Browse files

am ec7ba2a7: am 6893aeee: am 5536bb48: Merge "Fix stuck scrim on keyguard-less...

am ec7ba2a7: am 6893aeee: am 5536bb48: Merge "Fix stuck scrim on keyguard-less devices" into mnc-dev

* commit 'ec7ba2a7':
  Fix stuck scrim on keyguard-less devices
parents e0968e14 ec7ba2a7
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -358,6 +358,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {

    boolean mSystemReady;
    boolean mSystemBooted;
    private boolean mDeferBindKeyguard;
    boolean mHdmiPlugged;
    HdmiControl mHdmiControl;
    IUiModeManager mUiModeManager;
@@ -6014,6 +6015,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {

        readCameraLensCoverState();
        updateUiMode();
        boolean bindKeyguardNow;
        synchronized (mLock) {
            updateOrientationListenerLp();
            mSystemReady = true;
@@ -6023,13 +6025,36 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                    updateSettings();
                }
            });

            bindKeyguardNow = mDeferBindKeyguard;
            if (bindKeyguardNow) {
                // systemBooted ran but wasn't able to bind to the Keyguard, we'll do it now.
                mDeferBindKeyguard = false;
            }
        }

        if (bindKeyguardNow) {
            mKeyguardDelegate.bindService(mContext);
            mKeyguardDelegate.onBootCompleted();
        }
    }

    /** {@inheritDoc} */
    @Override
    public void systemBooted() {
        boolean bindKeyguardNow = false;
        synchronized (mLock) {
            // Time to bind Keyguard; take care to only bind it once, either here if ready or
            // in systemReady if not.
            if (mKeyguardDelegate != null) {
                bindKeyguardNow = true;
            } else {
                // Because mKeyguardDelegate is null, we know that the synchronized block in
                // systemReady didn't run yet and setting this will actually have an effect.
                mDeferBindKeyguard = true;
            }
        }
        if (bindKeyguardNow) {
            mKeyguardDelegate.bindService(mContext);
            mKeyguardDelegate.onBootCompleted();
        }
+17 −10
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ public class KeyguardServiceDelegate {
    private final KeyguardState mKeyguardState = new KeyguardState();
    private DrawnListener mDrawnListenerWhenConnect;

    /* package */ static final class KeyguardState {
    private static final class KeyguardState {
        KeyguardState() {
            // Assume keyguard is showing and secure until we know for sure. This is here in
            // the event something checks before the service is actually started.
@@ -119,8 +119,13 @@ public class KeyguardServiceDelegate {
            mKeyguardState.showing = false;
            mKeyguardState.showingAndNotOccluded = false;
            mKeyguardState.secure = false;
            synchronized (mKeyguardState) {
                // TODO: Fix synchronisation model in this class. The other state in this class
                // is at least self-healing but a race condition here can lead to the scrim being
                // stuck on keyguard-less devices.
                mKeyguardState.deviceHasKeyguard = false;
                hideScrim();
            }
        } else {
            if (DEBUG) Log.v(TAG, "*** Keyguard started");
        }
@@ -315,6 +320,7 @@ public class KeyguardServiceDelegate {
    }

    public void showScrim() {
        synchronized (mKeyguardState) {
            if (!mKeyguardState.deviceHasKeyguard) return;
            mScrim.post(new Runnable() {
                @Override
@@ -323,6 +329,7 @@ public class KeyguardServiceDelegate {
                }
            });
        }
    }

    public void hideScrim() {
        mScrim.post(new Runnable() {