am 5c0c5ac8: Handle case correctly when screen times out and locking immediately

* commit '5c0c5ac84552f80ddadc43f451c3a28c5c8c8f84':
  Handle case correctly when screen times out and locking immediately
This commit is contained in:
Jorim Jaggi
2015-09-18 00:48:41 +00:00
committed by Android Git Automerger

View File

@@ -652,6 +652,7 @@ public class KeyguardViewMediator extends SystemUI {
final boolean lockImmediately = final boolean lockImmediately =
mLockPatternUtils.getPowerButtonInstantlyLocks(currentUser) mLockPatternUtils.getPowerButtonInstantlyLocks(currentUser)
|| !mLockPatternUtils.isSecure(currentUser); || !mLockPatternUtils.isSecure(currentUser);
long timeout = getLockTimeout();
if (mExitSecureCallback != null) { if (mExitSecureCallback != null) {
if (DEBUG) Log.d(TAG, "pending exit secure callback cancelled"); if (DEBUG) Log.d(TAG, "pending exit secure callback cancelled");
@@ -666,9 +667,9 @@ public class KeyguardViewMediator extends SystemUI {
} }
} else if (mShowing) { } else if (mShowing) {
mPendingReset = true; mPendingReset = true;
} else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT } else if ((why == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT && timeout > 0)
|| (why == WindowManagerPolicy.OFF_BECAUSE_OF_USER && !lockImmediately)) { || (why == WindowManagerPolicy.OFF_BECAUSE_OF_USER && !lockImmediately)) {
doKeyguardLaterLocked(); doKeyguardLaterLocked(timeout);
} else if (!mLockPatternUtils.isLockScreenDisabled(currentUser)) { } else if (!mLockPatternUtils.isLockScreenDisabled(currentUser)) {
mPendingLock = true; mPendingLock = true;
} }
@@ -703,7 +704,7 @@ public class KeyguardViewMediator extends SystemUI {
KeyguardUpdateMonitor.getInstance(mContext).dispatchFinishedGoingToSleep(why); KeyguardUpdateMonitor.getInstance(mContext).dispatchFinishedGoingToSleep(why);
} }
private void doKeyguardLaterLocked() { private long getLockTimeout() {
// if the screen turned off because of timeout or the user hit the power button // if the screen turned off because of timeout or the user hit the power button
// and we don't need to lock immediately, set an alarm // and we don't need to lock immediately, set an alarm
// to enable it a little bit later (i.e, give the user a chance // to enable it a little bit later (i.e, give the user a chance
@@ -732,11 +733,19 @@ public class KeyguardViewMediator extends SystemUI {
} else { } else {
timeout = lockAfterTimeout; timeout = lockAfterTimeout;
} }
return timeout;
}
if (timeout <= 0) { private void doKeyguardLaterLocked() {
// Lock now long timeout = getLockTimeout();
if (timeout == 0) {
doKeyguardLocked(null); doKeyguardLocked(null);
} else { } else {
doKeyguardLaterLocked(timeout);
}
}
private void doKeyguardLaterLocked(long timeout) {
// Lock in the future // Lock in the future
long when = SystemClock.elapsedRealtime() + timeout; long when = SystemClock.elapsedRealtime() + timeout;
Intent intent = new Intent(DELAYED_KEYGUARD_ACTION); Intent intent = new Intent(DELAYED_KEYGUARD_ACTION);
@@ -747,7 +756,6 @@ public class KeyguardViewMediator extends SystemUI {
if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = " if (DEBUG) Log.d(TAG, "setting alarm to turn off keyguard, seq = "
+ mDelayedShowingSequence); + mDelayedShowingSequence);
} }
}
private void cancelDoKeyguardLaterLocked() { private void cancelDoKeyguardLaterLocked() {
mDelayedShowingSequence++; mDelayedShowingSequence++;