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

Commit e2002790 authored by Priyanka Advani's avatar Priyanka Advani Committed by Android (Google) Code Review
Browse files

Merge "Revert "Fix "Dock defend string and tips in settings are incorrectly" issue"" into main

parents 943a43d1 4cfc0d81
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -53,8 +53,7 @@ public class BatteryInfo {
    public int batteryStatus;
    public int pluggedStatus;
    public boolean discharging = true;
    public boolean isBatteryDefender = false;
    public boolean isLongLife = false;
    public boolean isBatteryDefender;
    public boolean isFastCharging;
    public long remainingTimeUs = 0;
    public long averageTimeToDischarge = EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN;
@@ -307,7 +306,7 @@ public class BatteryInfo {
        info.pluggedStatus = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
        info.mCharging = info.pluggedStatus != 0;
        info.averageTimeToDischarge = estimate.getAverageDischargeTime();
        info.isLongLife =
        info.isBatteryDefender =
                batteryBroadcast.getIntExtra(
                                BatteryManager.EXTRA_CHARGING_STATUS,
                                BatteryManager.CHARGING_POLICY_DEFAULT)
@@ -320,7 +319,7 @@ public class BatteryInfo {
        info.isFastCharging =
                BatteryStatus.getChargingSpeed(context, batteryBroadcast)
                        == BatteryStatus.CHARGING_FAST;
        if (info.isLongLife) {
        if (info.isBatteryDefender) {
            info.isBatteryDefender =
                    FeatureFactory.getFeatureFactory()
                            .getPowerUsageFeatureProvider()
+1 −1
Original line number Diff line number Diff line
@@ -600,7 +600,7 @@ public class BatteryUtils {
                            context.getContentResolver(), SETTINGS_GLOBAL_DOCK_DEFENDER_BYPASS, 0)
                    == 1) {
                return DockDefenderMode.TEMPORARILY_BYPASSED;
            } else if (batteryInfo.isLongLife
            } else if (batteryInfo.isBatteryDefender
                    && FeatureFactory.getFeatureFactory()
                            .getPowerUsageFeatureProvider()
                            .isExtraDefend()) {
+0 −43
Original line number Diff line number Diff line
@@ -789,40 +789,6 @@ public class BatteryInfoTest {
                expectedChargeLabel);
    }

    @Test
    public void getBatteryInfo_longlife_shouldSetLonglife() {
        var batteryIntent = createIntentForLongLifeTest(/* hasLongLife= */ true);

        var batteryInfo =
                BatteryInfo.getBatteryInfo(
                        mContext,
                        batteryIntent,
                        mBatteryUsageStats,
                        /* estimate= */ MOCK_ESTIMATE,
                        /* elapsedRealtimeUs= */ 0L,
                        /* shortString= */ false,
                        /* currentTimeMs= */ 0L);

        assertThat(batteryInfo.isLongLife).isTrue();
    }

    @Test
    public void getBatteryInfo_noLonglife_shouldNotLonglife() {
        var batteryIntent = createIntentForLongLifeTest(/* hasLongLife= */ false);

        var batteryInfo =
                BatteryInfo.getBatteryInfo(
                        mContext,
                        batteryIntent,
                        mBatteryUsageStats,
                        /* estimate= */ MOCK_ESTIMATE,
                        /* elapsedRealtimeUs= */ 0L,
                        /* shortString= */ false,
                        /* currentTimeMs= */ 0L);

        assertThat(batteryInfo.isLongLife).isFalse();
    }

    private enum ChargingSpeed {
        FAST,
        REGULAR,
@@ -835,15 +801,6 @@ public class BatteryInfoTest {
        DOCKED
    }

    private Intent createIntentForLongLifeTest(Boolean hasLongLife) {
        return new Intent(Intent.ACTION_BATTERY_CHANGED)
                .putExtra(
                        BatteryManager.EXTRA_CHARGING_STATUS,
                        hasLongLife
                                ? BatteryManager.CHARGING_POLICY_ADAPTIVE_LONGLIFE
                                : BatteryManager.CHARGING_POLICY_DEFAULT);
    }

    private Intent createIntentForGetBatteryInfoTest(
            ChargingType chargingType, ChargingSpeed chargingSpeed, int batteryLevel) {
        return createBatteryIntent(