Merge "Improve power fail/reset"
This commit is contained in:
committed by
Android (Google) Code Review
commit
c9cf31ca55
@@ -120,6 +120,8 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
|
|||||||
private LockPatternView mLockPatternView;
|
private LockPatternView mLockPatternView;
|
||||||
/** Number of calls to {@link #notifyUser()} to ignore before notifying. */
|
/** Number of calls to {@link #notifyUser()} to ignore before notifying. */
|
||||||
private int mNotificationCountdown = 0;
|
private int mNotificationCountdown = 0;
|
||||||
|
/** Number of calls to {@link #notifyUser()} before we release the wakelock */
|
||||||
|
private int mReleaseWakeLockCountdown = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to propagate state through configuration changes (e.g. screen rotation)
|
* Used to propagate state through configuration changes (e.g. screen rotation)
|
||||||
@@ -287,6 +289,14 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
|
|||||||
// Notify the user again in 5 seconds.
|
// Notify the user again in 5 seconds.
|
||||||
mHandler.removeMessages(MESSAGE_NOTIFY);
|
mHandler.removeMessages(MESSAGE_NOTIFY);
|
||||||
mHandler.sendEmptyMessageDelayed(MESSAGE_NOTIFY, 5 * 1000);
|
mHandler.sendEmptyMessageDelayed(MESSAGE_NOTIFY, 5 * 1000);
|
||||||
|
|
||||||
|
if (mWakeLock.isHeld()) {
|
||||||
|
if (mReleaseWakeLockCountdown > 0) {
|
||||||
|
--mReleaseWakeLockCountdown;
|
||||||
|
} else {
|
||||||
|
mWakeLock.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -626,8 +636,12 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
|
|||||||
if (pm != null) {
|
if (pm != null) {
|
||||||
mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG);
|
mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG);
|
||||||
mWakeLock.acquire();
|
mWakeLock.acquire();
|
||||||
|
// Keep awake for 10 minutes - if the user hasn't been alerted by then
|
||||||
|
// best not to just drain their battery
|
||||||
|
mReleaseWakeLockCountdown = 96; // 96 * 5 + 120 = 600
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asynchronously throw up the IME, since there are issues with requesting it to be shown
|
// Asynchronously throw up the IME, since there are issues with requesting it to be shown
|
||||||
// immediately.
|
// immediately.
|
||||||
if (mLockPatternView == null) {
|
if (mLockPatternView == null) {
|
||||||
|
Reference in New Issue
Block a user