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

* commit '6893aeee48adc1f8b8aebde5e21b7e1294acfaf2':
  Fix stuck scrim on keyguard-less devices
This commit is contained in:
Adrian Roos
2015-07-17 01:11:37 +00:00
committed by Android Git Automerger
2 changed files with 43 additions and 11 deletions

View File

@@ -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() {
if (mKeyguardDelegate != null) {
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();
}

View File

@@ -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;
mKeyguardState.deviceHasKeyguard = false;
hideScrim();
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,13 +320,15 @@ public class KeyguardServiceDelegate {
}
public void showScrim() {
if (!mKeyguardState.deviceHasKeyguard) return;
mScrim.post(new Runnable() {
@Override
public void run() {
mScrim.setVisibility(View.VISIBLE);
}
});
synchronized (mKeyguardState) {
if (!mKeyguardState.deviceHasKeyguard) return;
mScrim.post(new Runnable() {
@Override
public void run() {
mScrim.setVisibility(View.VISIBLE);
}
});
}
}
public void hideScrim() {