Merge "Fix stuck scrim on keyguard-less devices" into mnc-dev

This commit is contained in:
Adrian Roos
2015-07-17 00:43:16 +00:00
committed by Android (Google) Code Review
2 changed files with 43 additions and 12 deletions

View File

@@ -104,7 +104,6 @@ import com.android.internal.policy.PhoneWindow;
import android.view.Surface;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.Window;
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import android.view.WindowManagerInternal;
@@ -359,6 +358,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
boolean mSystemReady;
boolean mSystemBooted;
private boolean mDeferBindKeyguard;
boolean mHdmiPlugged;
HdmiControl mHdmiControl;
IUiModeManager mUiModeManager;
@@ -6012,6 +6012,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
readCameraLensCoverState();
updateUiMode();
boolean bindKeyguardNow;
synchronized (mLock) {
updateOrientationListenerLp();
mSystemReady = true;
@@ -6021,13 +6022,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 ShowListener mShowListenerWhenConnect;
/* 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");
}
@@ -307,13 +312,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() {