summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Wesley Wang <wesleycwwang@google.com> 2022-03-29 03:31:55 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-03-29 03:31:55 +0000
commitc49fa4a78a15249043be539cecfdcc7e457215c4 (patch)
treea0ebfa46175bc0d1b681785b0771e089483f067b
parentc0666397b1936ded0500a6d5ae9cdda857ad6362 (diff)
parent0685bc263de99c7cf04abb41c75f5dad6a539eb4 (diff)
Merge "Package battery saver schedule mode in severe battery intent" into tm-dev
-rw-r--r--packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java25
1 files changed, 10 insertions, 15 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
index 369a552a934a..2435497193e4 100644
--- a/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
+++ b/packages/SystemUI/src/com/android/systemui/power/PowerNotificationWarnings.java
@@ -120,7 +120,8 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
"PNW.autoSaverNoThanks";
private static final String ACTION_ENABLE_SEVERE_BATTERY_DIALOG = "PNW.enableSevereDialog";
-
+ private static final String EXTRA_SCHEDULED_BY_PERCENTAGE =
+ "extra_scheduled_by_percentage";
public static final String BATTERY_SAVER_SCHEDULE_SCREEN_INTENT_ACTION =
"com.android.settings.BATTERY_SAVER_SCHEDULE_SETTINGS";
@@ -264,6 +265,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
if (showSevereLowBatteryDialog()) {
mBroadcastSender.sendBroadcast(new Intent(ACTION_ENABLE_SEVERE_BATTERY_DIALOG)
.setPackage(mContext.getPackageName())
+ .putExtra(EXTRA_SCHEDULED_BY_PERCENTAGE, isScheduledByPercentage())
.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY
| Intent.FLAG_RECEIVER_FOREGROUND));
// Reset the state once dialog been enabled
@@ -271,7 +273,7 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
mPlaySound = false;
return;
}
- if (!showLowBatteryNotification()) {
+ if (isScheduledByPercentage()) {
return;
}
@@ -327,26 +329,19 @@ public class PowerNotificationWarnings implements PowerUI.WarningsUI {
}
/**
- * Disable low battery warning notification if battery saver schedule mode set as
- * "Based on percentage".
+ * Checking battery saver schedule mode is set as "Based on percentage" or not.
*
- * return {@code false} if scheduled by percentage.
+ * return {@code true} if scheduled by percentage.
*/
- private boolean showLowBatteryNotification() {
+ private boolean isScheduledByPercentage() {
final ContentResolver resolver = mContext.getContentResolver();
final int mode = Settings.Global.getInt(resolver, Global.AUTOMATIC_POWER_SAVE_MODE,
PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE);
- // Return true if battery saver schedule mode will not trigger by percentage.
- if (mode != PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE) {
- return true;
- }
-
- // Return true if battery saver mode trigger percentage is less than 0, which means it is
+ // Return false if battery saver mode trigger percentage is less than 0, which means it is
// set as "Based on routine" mode, otherwise it will be "Based on percentage" mode.
- final int threshold =
- Settings.Global.getInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0);
- return threshold <= 0;
+ return mode == PowerManager.POWER_SAVE_MODE_TRIGGER_PERCENTAGE
+ && Settings.Global.getInt(resolver, Global.LOW_POWER_MODE_TRIGGER_LEVEL, 0) > 0;
}
private void showAutoSaverSuggestionNotification() {