Merge "Update full charged string (1/2)" into tm-dev am: 7dd6a1fcbe

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16938504

Change-Id: Ia14e5f381902817135f5fe6a1d09a5ef1ebc364e
This commit is contained in:
Wesley Wang
2022-02-21 14:12:33 +00:00
committed by Automerger Merge Worker
3 changed files with 24 additions and 1 deletions

View File

@@ -1160,6 +1160,8 @@
<string name="battery_info_status_not_charging">Connected, not charging</string>
<!-- Battery Info screen. Value for a status item. Used for diagnostic info screens, precise translation isn't needed -->
<string name="battery_info_status_full">Charged</string>
<!-- [CHAR_LIMIT=40] Battery Info screen. Value for a status item. A state which device is fully charged -->
<string name="battery_info_status_full_charged">Fully Charged</string>
<!-- Summary for settings preference disabled by administrator [CHAR LIMIT=50] -->
<string name="disabled_by_admin_summary_text">Controlled by admin</string>

View File

@@ -207,7 +207,9 @@ public class Utils {
final BatteryStatus batteryStatus = new BatteryStatus(batteryChangedIntent);
if (batteryStatus.isCharged()) {
statusString = res.getString(R.string.battery_info_status_full);
statusString = res.getString(compactStatus
? R.string.battery_info_status_full_charged
: R.string.battery_info_status_full);
} else {
if (status == BatteryManager.BATTERY_STATUS_CHARGING) {
if (compactStatus) {

View File

@@ -324,6 +324,15 @@ public class UtilsTest {
resources.getString(R.string.battery_info_status_full));
}
@Test
public void getBatteryStatus_statusIsFullAndUseCompactStatus_returnFullyChargedString() {
final Intent intent = new Intent().putExtra(BatteryManager.EXTRA_LEVEL, 100);
final Resources resources = mContext.getResources();
assertThat(Utils.getBatteryStatus(mContext, intent, /* compactStatus= */ true)).isEqualTo(
resources.getString(R.string.battery_info_status_full_charged));
}
@Test
public void getBatteryStatus_batteryLevelIs100_returnFullString() {
final Intent intent = new Intent().putExtra(BatteryManager.EXTRA_STATUS,
@@ -334,6 +343,16 @@ public class UtilsTest {
resources.getString(R.string.battery_info_status_full));
}
@Test
public void getBatteryStatus_batteryLevelIs100AndUseCompactStatus_returnFullyString() {
final Intent intent = new Intent().putExtra(BatteryManager.EXTRA_STATUS,
BatteryManager.BATTERY_STATUS_FULL);
final Resources resources = mContext.getResources();
assertThat(Utils.getBatteryStatus(mContext, intent, /* compactStatus= */ true)).isEqualTo(
resources.getString(R.string.battery_info_status_full_charged));
}
@Test
public void getBatteryStatus_batteryLevel99_returnChargingString() {
final Intent intent = new Intent();