Skip to content

Commit 0b4fbff

Browse files
inthewavesthestinger
authored andcommitted
SystemUI: use generic charging string indication if battery is dead
This is a change in the July 2025 SystemUIGoogle from stock OS presumably for the bluejay battery patch. These changes are located in KeyguardIndicationControllerGoogle, so they're likely not going to be in AOSP (at least the indication text change).
1 parent bb165c2 commit 0b4fbff

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,11 @@ protected String computePowerChargingStringIndication() {
11621162
if (mPowerCharged) {
11631163
return mContext.getResources().getString(R.string.keyguard_charged);
11641164
}
1165+
String percentage = NumberFormat.getPercentInstance().format(mBatteryLevel / 100f);
1166+
if (mBatteryDead) {
1167+
return mContext.getResources().getString(R.string.keyguard_plugged_in, percentage);
1168+
}
1169+
11651170
final boolean hasChargingTime = mChargingTimeRemaining > 0;
11661171
int chargingId;
11671172
if (mPowerPluggedInWired) {
@@ -1196,7 +1201,6 @@ protected String computePowerChargingStringIndication() {
11961201
: R.string.keyguard_plugged_in;
11971202
}
11981203

1199-
String percentage = NumberFormat.getPercentInstance().format(mBatteryLevel / 100f);
12001204
if (hasChargingTime) {
12011205
String chargingTimeFormatted = Formatter.formatShortElapsedTimeRoundingUpToMinutes(
12021206
mContext, mChargingTimeRemaining);
@@ -1356,6 +1360,9 @@ public void onRefreshBatteryInfo(BatteryStatus status) {
13561360
mBatteryLevel = status.level;
13571361
mBatteryPresent = status.present;
13581362
mBatteryDefender = isBatteryDefender(status);
1363+
// stock OS uses batteryStatus.health != 4 as the condition for some reason, which seems
1364+
// wrong (4 corresponds to BatteryManager.BATTERY_HEALTH_DEAD)
1365+
mBatteryDead = status.health == BatteryManager.BATTERY_HEALTH_DEAD;
13591366
// when the battery is overheated, device doesn't charge so only guard on pluggedIn:
13601367
mEnableBatteryDefender = mBatteryDefender && status.isPluggedIn();
13611368
mIncompatibleCharger = status.incompatibleCharger.orElse(false);

0 commit comments

Comments
 (0)