Sync lastest SettingsLib interface
Test: rebuild Change-Id: I3131f701deb47acae9f19436cbe66e077ea004ee
This commit is contained in:
@@ -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)) {
|
||||
|
@@ -133,7 +133,7 @@ public class BatteryInfo {
|
||||
remaining = context.getString(R.string.remaining_length_format,
|
||||
Formatter.formatShortElapsedTime(context, remainingTimeUs / 1000));
|
||||
}
|
||||
view.setBottomLabels(new CharSequence[] {timeString, remaining});
|
||||
view.setBottomLabels(new CharSequence[]{timeString, remaining});
|
||||
}
|
||||
|
||||
public static void getBatteryInfo(final Context context, final Callback callback) {
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user