am 71988c81: am 386165a3: Merge "Only show "charging" if the battery is really charging." into jb-mr1.1-dev
* commit '71988c81a3ae9d372c1eb2991f509a8c5c83f08c': Only show "charging" if the battery is really charging.
This commit is contained in:
@@ -68,9 +68,20 @@ public class BatteryController extends BroadcastReceiver {
|
|||||||
final String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
|
if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
|
||||||
final int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
final int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0);
|
||||||
final boolean plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0) != 0;
|
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
|
final int icon = plugged ? R.drawable.stat_sys_battery_charge
|
||||||
: R.drawable.stat_sys_battery;
|
: R.drawable.stat_sys_battery;
|
||||||
|
|
||||||
int N = mIconViews.size();
|
int N = mIconViews.size();
|
||||||
for (int i=0; i<N; i++) {
|
for (int i=0; i<N; i++) {
|
||||||
ImageView v = mIconViews.get(i);
|
ImageView v = mIconViews.get(i);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import android.animation.AnimatorListenerAdapter;
|
|||||||
import android.animation.ObjectAnimator;
|
import android.animation.ObjectAnimator;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.BatteryManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
@@ -51,7 +52,7 @@ class KeyguardMessageArea extends TextView {
|
|||||||
boolean mShowingBouncer = false;
|
boolean mShowingBouncer = false;
|
||||||
|
|
||||||
// last known plugged in state
|
// last known plugged in state
|
||||||
boolean mPluggedIn = false;
|
boolean mCharging = false;
|
||||||
|
|
||||||
// last known battery level
|
// last known battery level
|
||||||
int mBatteryLevel = 100;
|
int mBatteryLevel = 100;
|
||||||
@@ -134,7 +135,8 @@ class KeyguardMessageArea extends TextView {
|
|||||||
@Override
|
@Override
|
||||||
public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) {
|
public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) {
|
||||||
mShowingBatteryInfo = status.isPluggedIn() || status.isBatteryLow();
|
mShowingBatteryInfo = status.isPluggedIn() || status.isBatteryLow();
|
||||||
mPluggedIn = status.isPluggedIn();
|
mCharging = status.status == BatteryManager.BATTERY_STATUS_CHARGING
|
||||||
|
|| status.status == BatteryManager.BATTERY_STATUS_FULL;
|
||||||
mBatteryLevel = status.level;
|
mBatteryLevel = status.level;
|
||||||
mBatteryCharged = status.isCharged();
|
mBatteryCharged = status.isCharged();
|
||||||
mBatteryIsLow = status.isBatteryLow();
|
mBatteryIsLow = status.isBatteryLow();
|
||||||
@@ -223,11 +225,11 @@ class KeyguardMessageArea extends TextView {
|
|||||||
CharSequence string = null;
|
CharSequence string = null;
|
||||||
if (mShowingBatteryInfo && !mShowingMessage) {
|
if (mShowingBatteryInfo && !mShowingMessage) {
|
||||||
// Battery status
|
// Battery status
|
||||||
if (mPluggedIn) {
|
if (mCharging) {
|
||||||
// Charging, charged or waiting to charge.
|
// Charging, charged or waiting to charge.
|
||||||
string = getContext().getString(mBatteryCharged ?
|
string = getContext().getString(mBatteryCharged
|
||||||
com.android.internal.R.string.lockscreen_charged
|
? com.android.internal.R.string.lockscreen_charged
|
||||||
:com.android.internal.R.string.lockscreen_plugged_in, mBatteryLevel);
|
: com.android.internal.R.string.lockscreen_plugged_in, mBatteryLevel);
|
||||||
icon.value = CHARGING_ICON;
|
icon.value = CHARGING_ICON;
|
||||||
} else if (mBatteryIsLow) {
|
} else if (mBatteryIsLow) {
|
||||||
// Battery is low
|
// Battery is low
|
||||||
|
|||||||
Reference in New Issue
Block a user