if (mKeyguardTokenWatcher == null) {
mKeyguardTokenWatcher = new KeyguardTokenWatcher(this);
}
switch (msg.what) {
case KEYGUARD_DISABLE:
final Pair<IBinder, String> pair = (Pair<IBinder, String>)msg.obj;
mKeyguardTokenWatcher.acquire(pair.first, pair.second);
break;
case KEYGUARD_REENABLE:
mKeyguardTokenWatcher.release((IBinder)msg.obj);
break;
case KEYGUARD_POLICY_CHANGED:
mAllowDisableKeyguard = ALLOW_DISABLE_UNKNOWN;
if (mKeyguardTokenWatcher.isAcquired()) {
// If we are currently disabled we need to know if the keyguard
// should be re-enabled, so determine the allow state immediately.
mKeyguardTokenWatcher.updateAllowState();
if (mAllowDisableKeyguard != ALLOW_DISABLE_YES) {
mPolicy.enableKeyguard(true);
}
} else {
// lazily evaluate this next time we're asked to disable keyguard
mPolicy.enableKeyguard(true);
}
break;
}