diff options
author | John Spurlock <jspurlock@google.com> | 2014-09-14 11:10:22 -0400 |
---|---|---|
committer | John Spurlock <jspurlock@google.com> | 2014-09-14 14:07:23 -0400 |
commit | 8d4e6cb06005a2ce994360340a6191f0690db8f4 (patch) | |
tree | f33ad62f12c43f567d7c5ff514c6b66c2a858bdd /packages/SystemUI/src/com/android/systemui/power | |
parent | c68f27625bfd18d945ab214983ae05206b6f3bfa (diff) | |
download | frameworks_base-8d4e6cb06005a2ce994360340a6191f0690db8f4.zip frameworks_base-8d4e6cb06005a2ce994360340a6191f0690db8f4.tar.gz frameworks_base-8d4e6cb06005a2ce994360340a6191f0690db8f4.tar.bz2 |
Saver: PowerManager call to set low power mode.
- Add an explicit power manager call to set the low power mode state,
instead of trying manage everything around a single setting.
- When low-power mode is triggered by falling below the configured
threshold, it does not update the setting.
- The "is-enabled" api returns setting || below configured trigger.
- Move the snooze management into the new api call.
- Callers (sysui + settings) updated to use the api instead of the
setting.
- Handles the case where the level does an unpowered leap out of the
low battery level. (Possible if powered in-between while the device
is off)
Bug:17460535
Change-Id: Ic030504c9cad9868a7137abbe837b170da37852b
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/power')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java index 4c7f8ec..f184ad2 100644 --- a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java +++ b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java @@ -31,6 +31,7 @@ import android.media.AudioAttributes; import android.net.Uri; import android.os.AsyncTask; import android.os.Handler; +import android.os.PowerManager; import android.os.SystemClock; import android.os.UserHandle; import android.provider.Settings; @@ -72,6 +73,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { private final Context mContext; private final NotificationManager mNoMan; + private final PowerManager mPowerMan; private final Handler mHandler = new Handler(); private final Receiver mReceiver = new Receiver(); private final Intent mOpenBatterySettings = settings(Intent.ACTION_POWER_USAGE_SUMMARY); @@ -93,6 +95,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { public PowerNotificationWarnings(Context context, PhoneStatusBar phoneStatusBar) { mContext = context; mNoMan = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); + mPowerMan = (PowerManager) context.getSystemService(Context.POWER_SERVICE); mReceiver.init(); } @@ -356,9 +359,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { mSaverConfirmation = d; } - private void setSaverSetting(boolean mode) { - final int val = mode ? 1 : 0; - Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.LOW_POWER_MODE, val); + private void setSaverMode(boolean mode) { + mPowerMan.setPowerSaveMode(mode); } private final class Receiver extends BroadcastReceiver { @@ -384,7 +386,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { } else if (action.equals(ACTION_STOP_SAVER)) { dismissSaverNotification(); dismissLowBatteryNotification(); - setSaverSetting(false); + setSaverMode(false); } } } @@ -395,7 +397,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI { AsyncTask.execute(new Runnable() { @Override public void run() { - setSaverSetting(true); + setSaverMode(true); } }); } |