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

Commit 39beb253 authored by Raff Tsai's avatar Raff Tsai
Browse files

Revert "Change battery tip text"

This reverts commit 2441b94c.

Reason for revert: <wrong commit>

Change-Id: I373fc065eafc81c26a8eba133255f9377d1d5d7f
parent 2441b94c
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -47,7 +47,6 @@ public class BatteryInfo {
    public long averageTimeToDischarge = Estimate.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN;
    public String batteryPercentString;
    public String statusLabel;
    public String suggestionLabel;
    private boolean mCharging;
    private BatteryStats mStats;
    private static final String LOG_TAG = "BatteryInfo";
@@ -248,7 +247,6 @@ public class BatteryInfo {
        final int status = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_STATUS,
                BatteryManager.BATTERY_STATUS_UNKNOWN);
        info.discharging = false;
        info.suggestionLabel = null;
        if (chargeTime > 0 && status != BatteryManager.BATTERY_STATUS_FULL) {
            info.remainingTimeUs = chargeTime;
            CharSequence timeString = StringUtil.formatElapsedTime(context,
@@ -284,11 +282,8 @@ public class BatteryInfo {
                    info.batteryPercentString,
                    estimate.isBasedOnUsage && !shortString
            );
            info.suggestionLabel = PowerUtil.getBatterySuggestionStringFormatted(
                    context, PowerUtil.convertUsToMs(drainTimeUs));
        } else {
            info.remainingLabel = null;
            info.suggestionLabel = null;
            info.chargeLabel = info.batteryPercentString;
        }
    }
+1 −1
Original line number Diff line number Diff line
@@ -62,6 +62,6 @@ public class LowBatteryDetector implements BatteryTipDetector {
        }

        return new LowBatteryTip(
                state, powerSaveModeOn, mBatteryInfo.suggestionLabel);
                state, powerSaveModeOn, mBatteryInfo.remainingLabel);
    }
}
+0 −17
Original line number Diff line number Diff line
@@ -65,9 +65,7 @@ public class BatteryInfoTest {
    private static final String STATUS_NOT_CHARGING = "Not charging";
    private static final long REMAINING_TIME_NULL = -1;
    private static final long REMAINING_TIME = 2;
    // Strings are defined in frameworks/base/packages/SettingsLib/res/values/strings.xml
    private static final String ENHANCED_STRING_SUFFIX = "based on your usage";
    private static final String EXTEND_PREFIX = "Extend battery life past";
    private static final long TEST_CHARGE_TIME_REMAINING = TimeUnit.MINUTES.toMicros(1);
    private static final String TEST_CHARGE_TIME_REMAINING_STRINGIFIED =
            "1 min left until fully charged";
@@ -150,10 +148,8 @@ public class BatteryInfoTest {

        // We only add special mention for the long string
        assertThat(info.remainingLabel.toString()).contains(ENHANCED_STRING_SUFFIX);
        assertThat(info.suggestionLabel).contains(EXTEND_PREFIX);
        // shortened string should not have extra text
        assertThat(info2.remainingLabel.toString()).doesNotContain(ENHANCED_STRING_SUFFIX);
        assertThat(info2.suggestionLabel).contains(EXTEND_PREFIX);
    }

    @Test
@@ -173,19 +169,6 @@ public class BatteryInfoTest {
                mContext.getString(R.string.power_remaining_duration_only_shutdown_imminent));
        assertThat(info2.remainingLabel.toString()).isEqualTo(
                mContext.getString(R.string.power_remaining_duration_only_shutdown_imminent));
        assertThat(info2.suggestionLabel).contains(EXTEND_PREFIX);
    }

    @Test
    public void getBatteryInfo_MoreThanOneDay_suggestionLabelIsCorrectString() {
        Estimate estimate = new Estimate(Duration.ofDays(3).toMillis(),
                true /* isBasedOnUsage */,
                1000 /* averageDischargeTime */);
        BatteryInfo info = BatteryInfo.getBatteryInfo(mContext, mDisChargingBatteryBroadcast,
                mBatteryStats, estimate, SystemClock.elapsedRealtime() * 1000,
                false /* shortString */);

        assertThat(info.suggestionLabel).doesNotContain(EXTEND_PREFIX);
    }

    @Test