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
diff --git a/src/com/android/settings/fuelgauge/BatteryInfo.java b/src/com/android/settings/fuelgauge/BatteryInfo.java
index e9863b3..5eada88 100644
--- a/src/com/android/settings/fuelgauge/BatteryInfo.java
+++ b/src/com/android/settings/fuelgauge/BatteryInfo.java
@@ -227,8 +227,9 @@
final String chargeStatusLabel = resources.getString(
R.string.battery_info_status_charging_lower);
info.remainingLabel = null;
- info.chargeLabel = resources.getString(
- R.string.power_charging, info.batteryPercentString, chargeStatusLabel);
+ info.chargeLabel = info.batteryLevel == 100 ? info.batteryPercentString :
+ resources.getString(R.string.power_charging, info.batteryPercentString,
+ chargeStatusLabel);
}
}
return info;
diff --git a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
index cf1146e..715e4f0 100644
--- a/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
+++ b/tests/robotests/src/com/android/settings/fuelgauge/BatteryInfoTest.java
@@ -164,4 +164,15 @@
assertThat(info.remainingLabel.toString())
.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%");
+ }
}