Update the chargeLabel when battery level is full

Before this cl, it will show "100% - charging", which doesn't make
sense. This cl removes "- charging", and only show "100%" in this
case

Bug: 62559153
Test: RunSettingsRoboTests
Change-Id: Id124fe4098e21b4a69c4a7d3d522fa227faab65d
This commit is contained in:
jackqdyulei
2017-06-23 13:52:36 -07:00
parent d793590678
commit 543c1f2cf5
2 changed files with 14 additions and 2 deletions

View File

@@ -227,8 +227,9 @@ public class BatteryInfo {
final String chargeStatusLabel = resources.getString( final String chargeStatusLabel = resources.getString(
R.string.battery_info_status_charging_lower); R.string.battery_info_status_charging_lower);
info.remainingLabel = null; info.remainingLabel = null;
info.chargeLabel = resources.getString( info.chargeLabel = info.batteryLevel == 100 ? info.batteryPercentString :
R.string.power_charging, info.batteryPercentString, chargeStatusLabel); resources.getString(R.string.power_charging, info.batteryPercentString,
chargeStatusLabel);
} }
} }
return info; return info;

View File

@@ -164,4 +164,15 @@ public class BatteryInfoTest {
assertThat(info.remainingLabel.toString()) assertThat(info.remainingLabel.toString())
.isEqualTo(TEST_CHARGE_TIME_REMAINING_STRINGIFIED); .isEqualTo(TEST_CHARGE_TIME_REMAINING_STRINGIFIED);
} }
@Test
public void testGetBatteryInfo_pluggedInWithFullBattery_onlyShowBatteryLevel() {
mChargingBatteryBroadcast.putExtra(BatteryManager.EXTRA_LEVEL, 100);
BatteryInfo info = BatteryInfo.getBatteryInfo(mContext, mChargingBatteryBroadcast,
mBatteryStats, SystemClock.elapsedRealtime() * 1000, false /* shortString */,
1000, false /* basedOnUsage */);
assertThat(info.chargeLabel).isEqualTo("100%");
}
} }