summaryrefslogtreecommitdiff
path: root/packages/SystemUI/src
diff options
context:
space:
mode:
authorWesley.CW Wang <wesleycwwang@google.com>2020-11-19 20:56:53 +0800
committerWesley Wang <wesleycwwang@google.com>2020-12-07 18:31:30 +0000
commit30f92a367d4a3d773af1bb58c295bd383acd8298 (patch)
tree04d949af0dcf190052578d85f586fafc9126a020 /packages/SystemUI/src
parent28829eb1166a614c0376f69acceca87ebeb25b83 (diff)
Make AOD battery text field support BatteryDefender
- Add overheat flag into BatteryStatus - Update AOD battery indication to support new state when BatteryDefender is enable Screenshot: https://screenshot.googleplex.com/BYyUYS7VGtyG3i7.png Bug: 173080412 Test: atest SystemUITests:com.android.systemui.statusbar.KeyguardIndicationControllerTest Merged-In: I74f32136ba034d2dea19f71e1e7cecc022cd9fa9 Change-Id: I9aee4e6408d762639818e7aac42a781f12cd69ff
Diffstat (limited to 'packages/SystemUI/src')
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java21
2 files changed, 20 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 60541eb56afc..60cd24019b97 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -2579,6 +2579,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
return true;
}
+ // change in battery overheat
+ if (current.health != old.health) {
+ return true;
+ }
+
return false;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
index 7e1dc6634cec..39d2f71e7e0b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
@@ -118,6 +118,8 @@ public class KeyguardIndicationController implements StateListener,
private boolean mPowerPluggedIn;
private boolean mPowerPluggedInWired;
private boolean mPowerCharged;
+ private boolean mBatteryOverheated;
+ private boolean mEnableBatteryDefender;
private int mChargingSpeed;
private int mChargingWattage;
private int mBatteryLevel;
@@ -401,7 +403,7 @@ public class KeyguardIndicationController implements StateListener,
} else if (!TextUtils.isEmpty(mAlignmentIndication)) {
mTextView.switchIndication(mAlignmentIndication);
mTextView.setTextColor(mContext.getColor(R.color.misalignment_text_color));
- } else if (mPowerPluggedIn) {
+ } else if (mPowerPluggedIn || mEnableBatteryDefender) {
String indication = computePowerIndication();
if (animate) {
animateText(mTextView, indication);
@@ -421,7 +423,7 @@ public class KeyguardIndicationController implements StateListener,
String trustManagedIndication = getTrustManagedIndication();
String powerIndication = null;
- if (mPowerPluggedIn) {
+ if (mPowerPluggedIn || mEnableBatteryDefender) {
powerIndication = computePowerIndication();
}
@@ -451,7 +453,7 @@ public class KeyguardIndicationController implements StateListener,
} else if (!TextUtils.isEmpty(mAlignmentIndication)) {
mTextView.switchIndication(mAlignmentIndication);
isError = true;
- } else if (mPowerPluggedIn) {
+ } else if (mPowerPluggedIn || mEnableBatteryDefender) {
if (DEBUG_CHARGING_SPEED) {
powerIndication += ", " + (mChargingWattage / 1000) + " mW";
}
@@ -528,8 +530,15 @@ public class KeyguardIndicationController implements StateListener,
return mContext.getResources().getString(R.string.keyguard_charged);
}
- final boolean hasChargingTime = mChargingTimeRemaining > 0;
int chargingId;
+ String percentage = NumberFormat.getPercentInstance().format(mBatteryLevel / 100f);
+
+ if (mBatteryOverheated) {
+ chargingId = R.string.keyguard_plugged_in_charging_limited;
+ return mContext.getResources().getString(chargingId, percentage);
+ }
+
+ final boolean hasChargingTime = mChargingTimeRemaining > 0;
if (mPowerPluggedInWired) {
switch (mChargingSpeed) {
case BatteryStatus.CHARGING_FAST:
@@ -554,8 +563,6 @@ public class KeyguardIndicationController implements StateListener,
: R.string.keyguard_plugged_in_wireless;
}
- String percentage = NumberFormat.getPercentInstance()
- .format(mBatteryLevel / 100f);
if (hasChargingTime) {
// We now have battery percentage in these strings and it's expected that all
// locales will also have it in the future. For now, we still have to support the old
@@ -685,6 +692,8 @@ public class KeyguardIndicationController implements StateListener,
mChargingWattage = status.maxChargingWattage;
mChargingSpeed = status.getChargingSpeed(mContext);
mBatteryLevel = status.level;
+ mBatteryOverheated = status.isOverheated();
+ mEnableBatteryDefender = mBatteryOverheated && status.isPluggedIn();
try {
mChargingTimeRemaining = mPowerPluggedIn
? mBatteryInfo.computeChargeTimeRemaining() : -1;