diff options
| author | 2022-05-03 12:27:37 +0000 | |
|---|---|---|
| committer | 2022-05-03 12:27:37 +0000 | |
| commit | 1d1d37ca6872ad47a0883d9045334703a7b31fbb (patch) | |
| tree | 73a21ad7e9fcc8d75cb94cf514702e8fd0009ebc | |
| parent | b41c2879b4ea55307a135c7fa8836adcf1f7bdb2 (diff) | |
| parent | 901f3ca26334175701d982cfcffb8222c1443833 (diff) | |
Merge "Disable battery saver notification based on predicted time left" into tm-dev
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/power/PowerUI.java | 9 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java | 6 |
2 files changed, 6 insertions, 9 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java index 623bb12be5b0..dcdd784bd2a1 100644 --- a/packages/SystemUI/src/com/android/systemui/power/PowerUI.java +++ b/packages/SystemUI/src/com/android/systemui/power/PowerUI.java @@ -397,16 +397,12 @@ public class PowerUI extends CoreStartable implements CommandQueue.Callbacks { final boolean playSound = currentSnapshot.getBucket() != lastSnapshot.getBucket() || lastSnapshot.getPlugged(); - final long timeRemainingMillis = currentSnapshot.getTimeRemainingMillis(); if (shouldShowHybridWarning(currentSnapshot)) { mWarnings.showLowBatteryWarning(playSound); // mark if we've already shown a warning this cycle. This will prevent the notification // trigger from spamming users by only showing low/critical warnings once per cycle - if ((timeRemainingMillis != NO_ESTIMATE_AVAILABLE - && timeRemainingMillis <= currentSnapshot.getSevereThresholdMillis()) - || currentSnapshot.getBatteryLevel() - <= currentSnapshot.getSevereLevelThreshold()) { + if (currentSnapshot.getBatteryLevel() <= currentSnapshot.getSevereLevelThreshold()) { mSevereWarningShownThisChargeCycle = true; mLowWarningShownThisChargeCycle = true; if (DEBUG) { @@ -461,7 +457,8 @@ public class PowerUI extends CoreStartable implements CommandQueue.Callbacks { @VisibleForTesting boolean shouldDismissHybridWarning(BatteryStateSnapshot snapshot) { return snapshot.getPlugged() - || snapshot.getTimeRemainingMillis() > snapshot.getLowThresholdMillis(); + || snapshot.getBatteryLevel() + > snapshot.getLowLevelThreshold(); } protected void maybeShowBatteryWarning( diff --git a/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java b/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java index 91f8a403f3b5..4e9b2325b899 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/power/PowerUITest.java @@ -498,8 +498,8 @@ public class PowerUITest extends SysuiTestCase { // We should dismiss if the device is plugged in state.mPlugged = true; - state.mTimeRemainingMillis = Duration.ofHours(1).toMillis(); - state.mLowThresholdMillis = Duration.ofHours(2).toMillis(); + state.mBatteryLevel = 19; + state.mLowLevelThreshold = 20; boolean shouldDismiss = mPowerUI.shouldDismissHybridWarning(state.get()); assertThat(shouldDismiss).isTrue(); @@ -509,7 +509,7 @@ public class PowerUITest extends SysuiTestCase { assertThat(shouldDismiss).isFalse(); // If we go over the low warning threshold we should dismiss - state.mTimeRemainingMillis = Duration.ofHours(3).toMillis(); + state.mBatteryLevel = 21; shouldDismiss = mPowerUI.shouldDismissHybridWarning(state.get()); assertThat(shouldDismiss).isTrue(); } |