Revert "Fix "Dock defend string and tips in settings are incorrectly" issue"

This reverts commit d1114107df.

Reason for revert: Likely culprit for b/349578829  - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Change-Id: I905a439c73e120efa094f097d59f68d0bedb0648
This commit is contained in:
Chaitanya Cheemala
2024-06-26 15:47:11 +00:00
committed by Android (Google) Code Review
parent d1114107df
commit 4cfc0d8156
3 changed files with 4 additions and 48 deletions

View File

@@ -53,8 +53,7 @@ public class BatteryInfo {
public int batteryStatus; public int batteryStatus;
public int pluggedStatus; public int pluggedStatus;
public boolean discharging = true; public boolean discharging = true;
public boolean isBatteryDefender = false; public boolean isBatteryDefender;
public boolean isLongLife = false;
public boolean isFastCharging; public boolean isFastCharging;
public long remainingTimeUs = 0; public long remainingTimeUs = 0;
public long averageTimeToDischarge = EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN; public long averageTimeToDischarge = EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN;
@@ -307,7 +306,7 @@ public class BatteryInfo {
info.pluggedStatus = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0); info.pluggedStatus = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
info.mCharging = info.pluggedStatus != 0; info.mCharging = info.pluggedStatus != 0;
info.averageTimeToDischarge = estimate.getAverageDischargeTime(); info.averageTimeToDischarge = estimate.getAverageDischargeTime();
info.isLongLife = info.isBatteryDefender =
batteryBroadcast.getIntExtra( batteryBroadcast.getIntExtra(
BatteryManager.EXTRA_CHARGING_STATUS, BatteryManager.EXTRA_CHARGING_STATUS,
BatteryManager.CHARGING_POLICY_DEFAULT) BatteryManager.CHARGING_POLICY_DEFAULT)
@@ -320,7 +319,7 @@ public class BatteryInfo {
info.isFastCharging = info.isFastCharging =
BatteryStatus.getChargingSpeed(context, batteryBroadcast) BatteryStatus.getChargingSpeed(context, batteryBroadcast)
== BatteryStatus.CHARGING_FAST; == BatteryStatus.CHARGING_FAST;
if (info.isLongLife) { if (info.isBatteryDefender) {
info.isBatteryDefender = info.isBatteryDefender =
FeatureFactory.getFeatureFactory() FeatureFactory.getFeatureFactory()
.getPowerUsageFeatureProvider() .getPowerUsageFeatureProvider()

View File

@@ -600,7 +600,7 @@ public class BatteryUtils {
context.getContentResolver(), SETTINGS_GLOBAL_DOCK_DEFENDER_BYPASS, 0) context.getContentResolver(), SETTINGS_GLOBAL_DOCK_DEFENDER_BYPASS, 0)
== 1) { == 1) {
return DockDefenderMode.TEMPORARILY_BYPASSED; return DockDefenderMode.TEMPORARILY_BYPASSED;
} else if (batteryInfo.isLongLife } else if (batteryInfo.isBatteryDefender
&& FeatureFactory.getFeatureFactory() && FeatureFactory.getFeatureFactory()
.getPowerUsageFeatureProvider() .getPowerUsageFeatureProvider()
.isExtraDefend()) { .isExtraDefend()) {

View File

@@ -789,40 +789,6 @@ public class BatteryInfoTest {
expectedChargeLabel); 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 { private enum ChargingSpeed {
FAST, FAST,
REGULAR, REGULAR,
@@ -835,15 +801,6 @@ public class BatteryInfoTest {
DOCKED 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( private Intent createIntentForGetBatteryInfoTest(
ChargingType chargingType, ChargingSpeed chargingSpeed, int batteryLevel) { ChargingType chargingType, ChargingSpeed chargingSpeed, int batteryLevel) {
return createBatteryIntent( return createBatteryIntent(