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

Commit 1aa958f5 authored by Raff Tsai's avatar Raff Tsai Committed by Android (Google) Code Review
Browse files

Merge "Sync lastest SettingsLib interface"

parents 2ad3a3e0 791ad4d5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ public class BatteryBroadcastReceiver extends BroadcastReceiver {
            if (Intent.ACTION_BATTERY_CHANGED.equals(intent.getAction())) {
                final String batteryLevel = Utils.getBatteryPercentage(intent);
                final String batteryStatus = Utils.getBatteryStatus(
                        mContext.getResources(), intent);
                        mContext, intent);
                if (forceUpdate) {
                    mBatteryListener.onBatteryChanged(BatteryUpdateType.MANUAL);
                } else if(!batteryLevel.equals(mBatteryLevel)) {
+4 −6
Original line number Diff line number Diff line
@@ -232,9 +232,8 @@ public class BatteryInfo {
        info.batteryPercentString = Utils.formatPercentage(info.batteryLevel);
        info.mCharging = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0;
        info.averageTimeToDischarge = estimate.getAverageDischargeTime();
        final Resources resources = context.getResources();

        info.statusLabel = Utils.getBatteryStatus(resources, batteryBroadcast);
        info.statusLabel = Utils.getBatteryStatus(context, batteryBroadcast);
        if (!info.mCharging) {
            updateBatteryInfoDischarging(context, shortString, estimate, info);
        } else {
@@ -261,12 +260,11 @@ public class BatteryInfo {
                    R.string.power_remaining_charging_duration_only, timeString);
            info.chargeLabel = context.getString(resId, info.batteryPercentString, timeString);
        } else {
            final String chargeStatusLabel = resources.getString(
                    R.string.battery_info_status_charging_lower);
            final String chargeStatusLabel = Utils.getBatteryStatus(context, batteryBroadcast);
            info.remainingLabel = null;
            info.chargeLabel = info.batteryLevel == 100 ? info.batteryPercentString :
                    resources.getString(R.string.power_charging, info.batteryPercentString,
                            chargeStatusLabel);
                            chargeStatusLabel.toLowerCase());
        }
    }

+6 −7
Original line number Diff line number Diff line
@@ -42,7 +42,6 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;

import org.robolectric.annotation.Config;

@RunWith(RobolectricTestRunner.class)
@@ -87,7 +86,7 @@ public class BatteryBroadcastReceiverTest {
        assertThat(mBatteryBroadcastReceiver.mBatteryLevel)
                .isEqualTo(Utils.getBatteryPercentage(mChargingIntent));
        assertThat(mBatteryBroadcastReceiver.mBatteryStatus)
            .isEqualTo(Utils.getBatteryStatus(mContext.getResources(), mChargingIntent));
                .isEqualTo(Utils.getBatteryStatus(mContext, mChargingIntent));
        verify(mBatteryListener).onBatteryChanged(BatteryUpdateType.BATTERY_LEVEL);
    }

@@ -111,7 +110,7 @@ public class BatteryBroadcastReceiverTest {
    public void testOnReceive_batteryDataNotChanged_listenerNotInvoked() {
        final String batteryLevel = Utils.getBatteryPercentage(mChargingIntent);
        final String batteryStatus =
            Utils.getBatteryStatus(mContext.getResources(), mChargingIntent);
                Utils.getBatteryStatus(mContext, mChargingIntent);
        mBatteryBroadcastReceiver.mBatteryLevel = batteryLevel;
        mBatteryBroadcastReceiver.mBatteryStatus = batteryStatus;

@@ -136,7 +135,7 @@ public class BatteryBroadcastReceiverTest {
        assertThat(mBatteryBroadcastReceiver.mBatteryLevel)
                .isEqualTo(Utils.getBatteryPercentage(mChargingIntent));
        assertThat(mBatteryBroadcastReceiver.mBatteryStatus)
            .isEqualTo(Utils.getBatteryStatus(mContext.getResources(), mChargingIntent));
                .isEqualTo(Utils.getBatteryStatus(mContext, mChargingIntent));
        // 2 times because register will force update the battery
        verify(mBatteryListener, times(2)).onBatteryChanged(BatteryUpdateType.MANUAL);
    }