[Bug Fix] "Dock defend string and tips in settings are incorrectly" issue
Symptom: After the dock defend was triggered, the battery tips still show "Future-Bypass" dock defend mode. It should be the "Active" dock defend mode. Root Cause: The original `BatteryInfo.isBatteryDefender` was implemented by using `longlife`, due to the charging limit also reuse `longlife` issue, we replace the implementation of `BatteryInfo.isBatteryDefender` with HAL API call `isTempDefend` and `isDwellDefend`. However, the dock defend also needs `longlife`, the original `BatteryInfo.isBatteryDefender`. So the dock defend checking failed after replacing the implementation of `BatteryInfo.isBatteryDefender` Solution: - Add new property isLonglife in BatteryInfo - Replace all isBatteryDefender reference that needs isLonglife Bug: 348563863 Test: Manual Test and robotest Test: http://ab/I08300010291126076 (unit test) Test: http://ab/I67800010291096764 (robo test) Flag: EXEMPT bugfix Change-Id: I58424927522acc29dc49261a2c24829a5b34ef85
This commit is contained in:
@@ -789,6 +789,40 @@ public class BatteryInfoTest {
|
||||
expectedChargeLabel);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBatteryInfo_longlife_shouldSetLonglife() {
|
||||
var batteryIntent = createIntentForLongLifeTest(/* hasLongLife= */ true);
|
||||
|
||||
var batteryInfo =
|
||||
BatteryInfo.getBatteryInfo(
|
||||
mContext,
|
||||
batteryIntent,
|
||||
mBatteryUsageStats,
|
||||
/* estimate= */ MOCK_ESTIMATE,
|
||||
/* elapsedRealtimeUs= */ 0L,
|
||||
/* shortString= */ false,
|
||||
/* currentTimeMs= */ 0L);
|
||||
|
||||
assertThat(batteryInfo.isLongLife).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getBatteryInfo_noLonglife_shouldNotLonglife() {
|
||||
var batteryIntent = createIntentForLongLifeTest(/* hasLongLife= */ false);
|
||||
|
||||
var batteryInfo =
|
||||
BatteryInfo.getBatteryInfo(
|
||||
mContext,
|
||||
batteryIntent,
|
||||
mBatteryUsageStats,
|
||||
/* estimate= */ MOCK_ESTIMATE,
|
||||
/* elapsedRealtimeUs= */ 0L,
|
||||
/* shortString= */ false,
|
||||
/* currentTimeMs= */ 0L);
|
||||
|
||||
assertThat(batteryInfo.isLongLife).isFalse();
|
||||
}
|
||||
|
||||
private enum ChargingSpeed {
|
||||
FAST,
|
||||
REGULAR,
|
||||
@@ -801,6 +835,15 @@ public class BatteryInfoTest {
|
||||
DOCKED
|
||||
}
|
||||
|
||||
private Intent createIntentForLongLifeTest(Boolean hasLongLife) {
|
||||
return new Intent(Intent.ACTION_BATTERY_CHANGED)
|
||||
.putExtra(
|
||||
BatteryManager.EXTRA_CHARGING_STATUS,
|
||||
hasLongLife
|
||||
? BatteryManager.CHARGING_POLICY_ADAPTIVE_LONGLIFE
|
||||
: BatteryManager.CHARGING_POLICY_DEFAULT);
|
||||
}
|
||||
|
||||
private Intent createIntentForGetBatteryInfoTest(
|
||||
ChargingType chargingType, ChargingSpeed chargingSpeed, int batteryLevel) {
|
||||
return createBatteryIntent(
|
||||
|
Reference in New Issue
Block a user