Update battery health state intent (2/3)

- Update the extra from overheated to longlife

Bug: 278192441
Test: make SettingsRoboTests

Change-Id: I5a906e64effbd9aaf84446c0670249afefdf7da8
This commit is contained in:
Wesley Wang
2023-04-19 20:00:31 +08:00
parent 1cc7d75d91
commit cf1190c7cb
10 changed files with 85 additions and 63 deletions

View File

@@ -254,18 +254,18 @@ public class BatteryInfoTest {
}
@Test
public void testGetBatteryInfo_chargingWithOverheated_updateChargeLabel() {
public void testGetBatteryInfo_chargingWithDefender_updateChargeLabel() {
doReturn(TEST_CHARGE_TIME_REMAINING)
.when(mBatteryUsageStats)
.getChargeTimeRemainingMs();
mChargingBatteryBroadcast
.putExtra(BatteryManager.EXTRA_HEALTH, BatteryManager.BATTERY_HEALTH_OVERHEAT);
mChargingBatteryBroadcast.putExtra(BatteryManager.EXTRA_CHARGING_STATUS,
BatteryManager.CHARGING_POLICY_ADAPTIVE_LONGLIFE);
BatteryInfo info = BatteryInfo.getBatteryInfo(mContext, mChargingBatteryBroadcast,
mBatteryUsageStats, MOCK_ESTIMATE, SystemClock.elapsedRealtime() * 1000,
false /* shortString */);
assertThat(info.isOverheated).isTrue();
assertThat(info.isBatteryDefender).isTrue();
assertThat(info.chargeLabel.toString()).contains(STATUS_CHARGING_PAUSED);
}
@@ -278,7 +278,8 @@ public class BatteryInfoTest {
50 /* level */,
100 /* scale */,
BatteryManager.BATTERY_STATUS_CHARGING)
.putExtra(BatteryManager.EXTRA_HEALTH, BatteryManager.BATTERY_HEALTH_OVERHEAT);
.putExtra(BatteryManager.EXTRA_CHARGING_STATUS,
BatteryManager.CHARGING_POLICY_ADAPTIVE_LONGLIFE);
BatteryInfo info = BatteryInfo.getBatteryInfo(mContext, intent,
mBatteryUsageStats, MOCK_ESTIMATE, SystemClock.elapsedRealtime() * 1000,
@@ -290,8 +291,8 @@ public class BatteryInfoTest {
@Test
public void testGetBatteryInfo_dockDefenderTemporarilyBypassed_updateChargeLabel() {
doReturn(REMAINING_TIME).when(mBatteryUsageStats).getChargeTimeRemainingMs();
mChargingBatteryBroadcast
.putExtra(BatteryManager.EXTRA_HEALTH, BatteryManager.BATTERY_HEALTH_GOOD);
mChargingBatteryBroadcast.putExtra(BatteryManager.EXTRA_CHARGING_STATUS,
BatteryManager.CHARGING_POLICY_DEFAULT);
Settings.Global.putInt(mContext.getContentResolver(),
BatteryUtils.SETTINGS_GLOBAL_DOCK_DEFENDER_BYPASS, 1);
@@ -309,8 +310,8 @@ public class BatteryInfoTest {
@Test
public void testGetBatteryInfo_dockDefenderFutureBypass_updateChargeLabel() {
doReturn(false).when(mFeatureFactory.powerUsageFeatureProvider).isExtraDefend();
mChargingBatteryBroadcast
.putExtra(BatteryManager.EXTRA_HEALTH, BatteryManager.BATTERY_HEALTH_GOOD);
mChargingBatteryBroadcast.putExtra(BatteryManager.EXTRA_CHARGING_STATUS,
BatteryManager.CHARGING_POLICY_DEFAULT);
BatteryInfo info = BatteryInfo.getBatteryInfo(mContext,
BatteryTestUtils.getCustomBatteryIntent(BatteryManager.BATTERY_PLUGGED_DOCK,