summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com
diff options
context:
space:
mode:
authorAdrian Roos <roosa@google.com>2015-07-14 19:17:00 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-07-14 19:17:07 +0000
commit9c013a211768c661f1142aba31c690daa76c66f7 (patch)
tree61950f73f1d16cd47065408025fa2afbd16bb66c /packages/SystemUI/src/com
parentd72fc63aae69a7dbff4287dd56cc20d3f617277e (diff)
parent7b04311d88e377c67b4c663091b6b1c63c932c52 (diff)
downloadframeworks_base-9c013a211768c661f1142aba31c690daa76c66f7.zip
frameworks_base-9c013a211768c661f1142aba31c690daa76c66f7.tar.gz
frameworks_base-9c013a211768c661f1142aba31c690daa76c66f7.tar.bz2
Merge "Show charging speed on Keyguard" into mnc-dr-dev
Diffstat (limited to 'packages/SystemUI/src/com')
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java34
1 files changed, 32 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
index 07a055c..fc2b1ec 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
@@ -26,6 +26,7 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.res.Resources;
import android.graphics.Color;
import android.os.BatteryManager;
import android.os.BatteryStats;
@@ -45,6 +46,7 @@ import android.view.View;
public class KeyguardIndicationController {
private static final String TAG = "KeyguardIndicationController";
+ private static final boolean DEBUG_CHARGING_CURRENT = false;
private static final int MSG_HIDE_TRANSIENT = 1;
@@ -52,6 +54,9 @@ public class KeyguardIndicationController {
private final KeyguardIndicationTextView mTextView;
private final IBatteryStats mBatteryInfo;
+ private final int mSlowThreshold;
+ private final int mFastThreshold;
+
private String mRestingIndication;
private String mTransientIndication;
private int mTransientTextColor;
@@ -59,11 +64,18 @@ public class KeyguardIndicationController {
private boolean mPowerPluggedIn;
private boolean mPowerCharged;
+ private int mChargingSpeed;
+ private int mChargingCurrent;
public KeyguardIndicationController(Context context, KeyguardIndicationTextView textView) {
mContext = context;
mTextView = textView;
+ Resources res = context.getResources();
+ mSlowThreshold = res.getInteger(R.integer.config_chargingSlowlyThreshold);
+ mFastThreshold = res.getInteger(R.integer.config_chargingFastThreshold);
+
+
mBatteryInfo = IBatteryStats.Stub.asInterface(
ServiceManager.getService(BatteryStats.SERVICE_NAME));
KeyguardUpdateMonitor.getInstance(context).registerCallback(mUpdateMonitor);
@@ -150,7 +162,11 @@ public class KeyguardIndicationController {
return mTransientIndication;
}
if (mPowerPluggedIn) {
- return computePowerIndication();
+ String indication = computePowerIndication();
+ if (DEBUG_CHARGING_CURRENT) {
+ indication = indication + mChargingCurrent;
+ }
+ return indication;
}
return mRestingIndication;
}
@@ -174,7 +190,19 @@ public class KeyguardIndicationController {
}
// Fall back to simple charging label.
- return mContext.getResources().getString(R.string.keyguard_plugged_in);
+ int chargingId;
+ switch (mChargingSpeed) {
+ case KeyguardUpdateMonitor.BatteryStatus.CHARGING_FAST:
+ chargingId = R.string.keyguard_plugged_in_charging_fast;
+ break;
+ case KeyguardUpdateMonitor.BatteryStatus.CHARGING_SLOWLY:
+ chargingId = R.string.keyguard_plugged_in_charging_slowly;
+ break;
+ default:
+ chargingId = R.string.keyguard_plugged_in;
+ break;
+ }
+ return mContext.getResources().getString(chargingId);
}
KeyguardUpdateMonitorCallback mUpdateMonitor = new KeyguardUpdateMonitorCallback() {
@@ -184,6 +212,8 @@ public class KeyguardIndicationController {
|| status.status == BatteryManager.BATTERY_STATUS_FULL;
mPowerPluggedIn = status.isPluggedIn() && isChargingOrFull;
mPowerCharged = status.isCharged();
+ mChargingCurrent = status.maxChargingCurrent;
+ mChargingSpeed = status.getChargingSpeed(mSlowThreshold, mFastThreshold);
updateIndication();
}
};