Merge "Update battery charging status string" into sc-dev

This commit is contained in:
Wesley Wang
2021-05-12 14:57:30 +00:00
committed by Android (Google) Code Review
5 changed files with 21 additions and 10 deletions

View File

@@ -111,8 +111,9 @@ public class BatteryHeaderPreferenceController extends BasePreferenceController
private CharSequence generateLabel(BatteryInfo info) {
if (BatteryUtils.isBatteryDefenderOn(info)) {
return null;
} else if (info.remainingLabel == null) {
// Present status independently if no remaining time
} else if (info.remainingLabel == null
|| info.batteryStatus == BatteryManager.BATTERY_STATUS_NOT_CHARGING) {
// Present status only if no remaining time or status anomalous
return info.statusLabel;
} else if (info.statusLabel != null && !info.discharging) {
// Charging state

View File

@@ -46,6 +46,7 @@ public class BatteryInfo {
public CharSequence chargeLabel;
public CharSequence remainingLabel;
public int batteryLevel;
public int batteryStatus;
public boolean discharging = true;
public boolean isOverheated;
public long remainingTimeUs = 0;
@@ -238,6 +239,8 @@ public class BatteryInfo {
== BatteryManager.BATTERY_HEALTH_OVERHEAT;
info.statusLabel = Utils.getBatteryStatus(context, batteryBroadcast);
info.batteryStatus = batteryBroadcast.getIntExtra(
BatteryManager.EXTRA_STATUS, BatteryManager.BATTERY_STATUS_UNKNOWN);
if (!info.mCharging) {
updateBatteryInfoDischarging(context, shortString, estimate, info);
} else {