summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/CryptKeeper.java
diff options
context:
space:
mode:
authorPaul Lawrence <paullawrence@google.com>2014-05-16 07:56:04 -0700
committerPaul Lawrence <paullawrence@google.com>2014-05-16 11:43:21 -0700
commit73456acfb45beb7a95b5aee5a1f7566d3b803a86 (patch)
tree8355ed6a14b290ec3b20efb93ebce974935b7ebf /src/com/android/settings/CryptKeeper.java
parent3f7e0571d3baaa9dd2ad887067fb8d86f597f71b (diff)
downloadpackages_apps_Settings-73456acfb45beb7a95b5aee5a1f7566d3b803a86.zip
packages_apps_Settings-73456acfb45beb7a95b5aee5a1f7566d3b803a86.tar.gz
packages_apps_Settings-73456acfb45beb7a95b5aee5a1f7566d3b803a86.tar.bz2
Improve power fail/reset
On power fail/reset, an encrypted device will sit at the enter password screen indefinitely, chirping. This is designed to attract the attention of the user. However, it also flattens the battery, and the user who's attention is not drawn will discover a discharged phone the next morning. We have had many complaints about this. Keep current functionality, but power down after 10 minutes. It's a compromise, but seems reasonable. @bug 12582489 Change-Id: I895c0147bed978ecf6984af2c748f971dfa0d221
Diffstat (limited to 'src/com/android/settings/CryptKeeper.java')
-rw-r--r--src/com/android/settings/CryptKeeper.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index 1efe98f..c4e3e66 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -120,6 +120,8 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
private LockPatternView mLockPatternView;
/** Number of calls to {@link #notifyUser()} to ignore before notifying. */
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)
@@ -287,6 +289,14 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
// Notify the user again in 5 seconds.
mHandler.removeMessages(MESSAGE_NOTIFY);
mHandler.sendEmptyMessageDelayed(MESSAGE_NOTIFY, 5 * 1000);
+
+ if (mWakeLock.isHeld()) {
+ if (mReleaseWakeLockCountdown > 0) {
+ --mReleaseWakeLockCountdown;
+ } else {
+ mWakeLock.release();
+ }
+ }
}
/**
@@ -624,8 +634,12 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
if (pm != null) {
mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, TAG);
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
// immediately.
if (mLockPatternView == null) {