summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java15
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardMessageArea.java14
2 files changed, 21 insertions, 8 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java
index 7f9bcac..716341f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BatteryController.java
@@ -68,9 +68,20 @@ public class BatteryController extends BroadcastReceiver {
final String action = intent.getAction();
if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
final int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
- final boolean plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0;
- final int icon = plugged ? R.drawable.stat_sys_battery_charge
+ final int status = intent.getIntExtra(BatteryManager.EXTRA_STATUS,
+ BatteryManager.BATTERY_STATUS_UNKNOWN);
+
+ boolean plugged = false;
+ switch (status) {
+ case BatteryManager.BATTERY_STATUS_CHARGING:
+ case BatteryManager.BATTERY_STATUS_FULL:
+ plugged = true;
+ break;
+ }
+
+ final int icon = plugged ? R.drawable.stat_sys_battery_charge
: R.drawable.stat_sys_battery;
+
int N = mIconViews.size();
for (int i=0; i<N; i++) {
ImageView v = mIconViews.get(i);
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMessageArea.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMessageArea.java
index ee5c4a6..210312a 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMessageArea.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMessageArea.java
@@ -21,6 +21,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.ContentResolver;
import android.content.Context;
+import android.os.BatteryManager;
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
@@ -51,7 +52,7 @@ class KeyguardMessageArea extends TextView {
boolean mShowingBouncer = false;
// last known plugged in state
- boolean mPluggedIn = false;
+ boolean mCharging = false;
// last known battery level
int mBatteryLevel = 100;
@@ -134,7 +135,8 @@ class KeyguardMessageArea extends TextView {
@Override
public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) {
mShowingBatteryInfo = status.isPluggedIn() || status.isBatteryLow();
- mPluggedIn = status.isPluggedIn();
+ mCharging = status.status == BatteryManager.BATTERY_STATUS_CHARGING
+ || status.status == BatteryManager.BATTERY_STATUS_FULL;
mBatteryLevel = status.level;
mBatteryCharged = status.isCharged();
mBatteryIsLow = status.isBatteryLow();
@@ -223,11 +225,11 @@ class KeyguardMessageArea extends TextView {
CharSequence string = null;
if (mShowingBatteryInfo && !mShowingMessage) {
// Battery status
- if (mPluggedIn) {
+ if (mCharging) {
// Charging, charged or waiting to charge.
- string = getContext().getString(mBatteryCharged ?
- com.android.internal.R.string.lockscreen_charged
- :com.android.internal.R.string.lockscreen_plugged_in, mBatteryLevel);
+ string = getContext().getString(mBatteryCharged
+ ? com.android.internal.R.string.lockscreen_charged
+ : com.android.internal.R.string.lockscreen_plugged_in, mBatteryLevel);
icon.value = CHARGING_ICON;
} else if (mBatteryIsLow) {
// Battery is low