Merge "Only show "charging" if the battery is really charging." into jb-mr1.1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
386165a3ae
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user