summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Makoto Onuki <omakoto@google.com> 2018-06-04 13:54:25 -0700
committer Makoto Onuki <omakoto@google.com> 2018-06-04 13:54:25 -0700
commit1d146e4493b208e2dcdd201c1a1948d3558cd5a8 (patch)
tree522b64c4ab3e89891ec0fac907f321e82ec05662
parent23621e7f027657bd8e103f476e65ace2fd5f3bce (diff)
Ensure automatic battery saver won't stick
Fixes: 80527470 Test: Manual tests: Test 1: (make sure automatic BS won't stick) - Set up automatic battery saver at N% - Wait until the battery goes below N% -> Battery saver will turn on - Turn off the device - Charge it until the battery goes above N% - Turn on the device - Make sure battery saver is off. Test 1: (make sure manual BS will stick) - Make sure the battery level is above the automatic threshold - Manually enable BS - Reboot - Make sure battery saver is on. Change-Id: I677fd586f6b25d0200392941cac2d13b57fe10b3
-rw-r--r--services/core/java/com/android/server/power/batterysaver/BatterySaverStateMachine.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/power/batterysaver/BatterySaverStateMachine.java b/services/core/java/com/android/server/power/batterysaver/BatterySaverStateMachine.java
index 06559df98351..dd6d71e3b7a3 100644
--- a/services/core/java/com/android/server/power/batterysaver/BatterySaverStateMachine.java
+++ b/services/core/java/com/android/server/power/batterysaver/BatterySaverStateMachine.java
@@ -141,8 +141,14 @@ public class BatterySaverStateMachine {
if (DEBUG) {
Slog.d(TAG, "onBootCompleted");
}
- // This is called with the power manager lock held. Don't do any
+ // Just booted. We don't want LOW_POWER_MODE to be persisted, so just always clear it.
+ putGlobalSetting(Global.LOW_POWER_MODE, 0);
+
+ // This is called with the power manager lock held. Don't do anything that may call to
+ // upper services. (e.g. don't call into AM directly)
+ // So use a BG thread.
runOnBgThread(() -> {
+
final ContentResolver cr = mContext.getContentResolver();
cr.registerContentObserver(Settings.Global.getUriFor(
Settings.Global.LOW_POWER_MODE),