am a0a8e154: Improvements to lock screen management:
Merge commit 'a0a8e1546a6f722cb886f3badac9de711d1b0e3b' * commit 'a0a8e1546a6f722cb886f3badac9de711d1b0e3b': Improvements to lock screen management:
This commit is contained in:
@@ -84,7 +84,7 @@ import android.view.WindowManagerPolicy;
|
||||
* thread of the keyguard.
|
||||
*/
|
||||
public class KeyguardViewMediator implements KeyguardViewCallback,
|
||||
KeyguardUpdateMonitor.ConfigurationChangeCallback, KeyguardUpdateMonitor.SimStateCallback {
|
||||
KeyguardUpdateMonitor.SimStateCallback {
|
||||
private final static boolean DEBUG = false && Config.LOGD;
|
||||
private final static boolean DBG_WAKE = DEBUG || true;
|
||||
|
||||
@@ -104,6 +104,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
|
||||
private static final int WAKE_WHEN_READY = 8;
|
||||
private static final int KEYGUARD_DONE = 9;
|
||||
private static final int KEYGUARD_DONE_DRAWING = 10;
|
||||
private static final int HIDE_KEYGUARD = 11;
|
||||
|
||||
/**
|
||||
* The default amount of time we stay awake (used for all key input)
|
||||
@@ -245,7 +246,6 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
|
||||
|
||||
mUpdateMonitor = new KeyguardUpdateMonitor(context);
|
||||
|
||||
mUpdateMonitor.registerConfigurationChangeCallback(this);
|
||||
mUpdateMonitor.registerSimStateCallback(this);
|
||||
|
||||
mKeyguardViewProperties =
|
||||
@@ -434,6 +434,21 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
|
||||
return mShowing || mNeedToReshowWhenReenabled || !mUpdateMonitor.isDeviceProvisioned();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the change is resulting in the keyguard beign dismissed,
|
||||
* meaning the screen can turn on immediately. Otherwise returns false.
|
||||
*/
|
||||
public boolean doLidChangeTq(boolean isLidOpen) {
|
||||
mKeyboardOpen = isLidOpen;
|
||||
|
||||
if (mUpdateMonitor.isKeyguardBypassEnabled() && mKeyboardOpen
|
||||
&& !mKeyguardViewProperties.isSecure() && mKeyguardViewManager.isShowing()) {
|
||||
if (DEBUG) Log.d(TAG, "bypassing keyguard on sliding open of keyboard with non-secure keyguard");
|
||||
mHandler.sendEmptyMessage(HIDE_KEYGUARD);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the keyguard if the settings are appropriate.
|
||||
@@ -558,26 +573,6 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link KeyguardUpdateMonitor} callbacks.
|
||||
*/
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void onOrientationChange(boolean inPortrait) {
|
||||
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void onKeyboardChange(boolean isKeyboardOpen) {
|
||||
mKeyboardOpen = isKeyboardOpen;
|
||||
|
||||
if (mUpdateMonitor.isKeyguardBypassEnabled() && mKeyboardOpen
|
||||
&& !mKeyguardViewProperties.isSecure() && mKeyguardViewManager.isShowing()) {
|
||||
if (DEBUG) Log.d(TAG, "bypassing keyguard on sliding open of keyboard with non-secure keyguard");
|
||||
keyguardDone(true);
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void onSimStateChanged(IccCard.State simState) {
|
||||
if (DEBUG) Log.d(TAG, "onSimStateChanged: " + simState);
|
||||
@@ -615,6 +610,10 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSecure() {
|
||||
return mKeyguardViewProperties.isSecure();
|
||||
}
|
||||
|
||||
private BroadcastReceiver mBroadCastReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
@@ -793,6 +792,10 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
|
||||
return;
|
||||
case KEYGUARD_DONE_DRAWING:
|
||||
handleKeyguardDoneDrawing();
|
||||
return;
|
||||
case HIDE_KEYGUARD:
|
||||
keyguardDone(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1050,9 +1050,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
* given the situation with the keyguard.
|
||||
*/
|
||||
void launchHomeFromHotKey() {
|
||||
if (mKeyguardMediator.isShowing()) {
|
||||
if (!mHideKeyguard && mKeyguardMediator.isShowing()) {
|
||||
// don't launch home if keyguard showing
|
||||
} else if (mKeyguardMediator.isInputRestricted()) {
|
||||
} else if (!mHideKeyguard && mKeyguardMediator.isInputRestricted()) {
|
||||
// when in keyguard restricted mode, must first verify unlock
|
||||
// before launching home
|
||||
mKeyguardMediator.verifyUnlock(new OnKeyguardExitResult() {
|
||||
@@ -1370,6 +1370,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
if (localLOGV) Log.i(TAG, "finishLayoutLw::mHideKeyguard="+mHideKeyguard);
|
||||
if (mHideKeyguard) {
|
||||
changed |= mKeyguard.hideLw(true);
|
||||
if (!mKeyguardMediator.isShowing()) {
|
||||
mHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
mKeyguardMediator.keyguardDone(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
changed |= mKeyguard.showLw(true);
|
||||
}
|
||||
@@ -1410,12 +1417,20 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
if (event.keycode == RawInputEvent.SW_LID) {
|
||||
// lid changed state
|
||||
mLidOpen = event.value == 0;
|
||||
boolean awakeNow = mKeyguardMediator.doLidChangeTq(mLidOpen);
|
||||
updateRotation(Surface.FLAGS_ORIENTATION_ANIMATION_DISABLE);
|
||||
if (keyguardIsShowingTq()) {
|
||||
if (awakeNow) {
|
||||
// If the lid opening and we don't have to keep the
|
||||
// keyguard up, then we can turn on the screen
|
||||
// immediately.
|
||||
mKeyguardMediator.pokeWakelock();
|
||||
} else if (keyguardIsShowingTq()) {
|
||||
if (mLidOpen) {
|
||||
// only do this if it's opening -- closing the device shouldn't turn it
|
||||
// off, but it also shouldn't turn it on.
|
||||
mKeyguardMediator.pokeWakelock();
|
||||
// If we are opening the lid and not hiding the
|
||||
// keyguard, then we need to have it turn on the
|
||||
// screen once it is shown.
|
||||
mKeyguardMediator.onWakeKeyWhenKeyguardShowingTq(
|
||||
KeyEvent.KEYCODE_POWER);
|
||||
}
|
||||
} else {
|
||||
// Light up the keyboard if we are sliding up.
|
||||
|
||||
Reference in New Issue
Block a user