Merge "Update the conditions of power plugged determination." into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
c2c6c5d058
@@ -307,12 +307,13 @@ public class BatteryInfo {
|
||||
info.pluggedStatus = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
|
||||
info.mCharging = info.pluggedStatus != 0;
|
||||
info.averageTimeToDischarge = estimate.getAverageDischargeTime();
|
||||
info.isLongLife =
|
||||
batteryBroadcast.getIntExtra(
|
||||
BatteryManager.EXTRA_CHARGING_STATUS,
|
||||
BatteryManager.CHARGING_POLICY_DEFAULT)
|
||||
== BatteryManager.CHARGING_POLICY_ADAPTIVE_LONGLIFE;
|
||||
|
||||
final int chargingPolicy =
|
||||
batteryBroadcast.getIntExtra(
|
||||
BatteryManager.EXTRA_CHARGING_STATUS,
|
||||
BatteryManager.CHARGING_POLICY_DEFAULT);
|
||||
|
||||
info.isLongLife = chargingPolicy == BatteryManager.CHARGING_POLICY_ADAPTIVE_LONGLIFE;
|
||||
info.statusLabel = Utils.getBatteryStatus(context, batteryBroadcast, isCompactStatus);
|
||||
info.batteryStatus =
|
||||
batteryBroadcast.getIntExtra(
|
||||
@@ -326,7 +327,15 @@ public class BatteryInfo {
|
||||
.getPowerUsageFeatureProvider()
|
||||
.isBatteryDefend(info);
|
||||
}
|
||||
if (!info.mCharging) {
|
||||
Log.d(
|
||||
TAG,
|
||||
"chargingPolicy = "
|
||||
+ chargingPolicy
|
||||
+ ", pluggedStatus = "
|
||||
+ info.pluggedStatus
|
||||
+ ", batteryStatus = "
|
||||
+ info.batteryStatus);
|
||||
if (!isPluggedIn(context, info.mCharging, chargingPolicy)) {
|
||||
updateBatteryInfoDischarging(context, shortString, estimate, info);
|
||||
} else {
|
||||
updateBatteryInfoCharging(
|
||||
@@ -556,6 +565,14 @@ public class BatteryInfo {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isPluggedIn(Context context, boolean isCharging, int chargingPolicy) {
|
||||
return isCharging
|
||||
|| (chargingPolicy == BatteryManager.CHARGING_POLICY_ADAPTIVE_LONGLIFE
|
||||
&& FeatureFactory.getFeatureFactory()
|
||||
.getBatterySettingsFeatureProvider()
|
||||
.isChargingOptimizationMode(context));
|
||||
}
|
||||
|
||||
public interface BatteryDataParser {
|
||||
void onParsingStarted(long startTime, long endTime);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user