Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b8643876 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Don't show low battery tip when estimation is zero"

parents 3df8494f efb1bbd5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ public class LowBatteryDetector implements BatteryTipDetector {
    public BatteryTip detect() {
        final boolean powerSaveModeOn = mPowerManager.isPowerSaveMode();
        final boolean lowBattery = mBatteryInfo.batteryLevel <= mWarningLevel
                || (mBatteryInfo.discharging
                || (mBatteryInfo.discharging && mBatteryInfo.remainingTimeUs != 0
                && mBatteryInfo.remainingTimeUs < TimeUnit.HOURS.toMicros(mPolicy.lowBatteryHour));

        int state = BatteryTip.StateType.INVISIBLE;
+7 −0
Original line number Diff line number Diff line
@@ -105,6 +105,13 @@ public class LowBatteryDetectorTest {
        assertThat(mLowBatteryDetector.detect().isVisible()).isFalse();
    }

    @Test
    public void testDetect_timeEstimationZero_tipInvisible() {
        mBatteryInfo.batteryLevel = 50;
        mBatteryInfo.remainingTimeUs = 0;
        assertThat(mLowBatteryDetector.detect().isVisible()).isFalse();
    }

    @Test
    public void testDetect_noEarlyWarning_tipInvisible() {
        mBatteryInfo.remainingTimeUs = TimeUnit.DAYS.toMicros(1);