diff options
author | Adrian Roos <roosa@google.com> | 2015-07-14 19:31:47 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-07-14 19:31:47 +0000 |
commit | a2231a754b92eb79e4b667c8b40fd0390ebb6dfb (patch) | |
tree | c718568c2486982f1a146d79c4797992f9cc370b /packages/Keyguard | |
parent | 779e5e0ed8489fe6faad35a061a82ad07618b5b3 (diff) | |
parent | 9c013a211768c661f1142aba31c690daa76c66f7 (diff) | |
download | frameworks_base-a2231a754b92eb79e4b667c8b40fd0390ebb6dfb.zip frameworks_base-a2231a754b92eb79e4b667c8b40fd0390ebb6dfb.tar.gz frameworks_base-a2231a754b92eb79e4b667c8b40fd0390ebb6dfb.tar.bz2 |
am 9c013a21: Merge "Show charging speed on Keyguard" into mnc-dr-dev
* commit '9c013a211768c661f1142aba31c690daa76c66f7':
Show charging speed on Keyguard
Diffstat (limited to 'packages/Keyguard')
-rw-r--r-- | packages/Keyguard/res/values/config.xml | 6 | ||||
-rw-r--r-- | packages/Keyguard/res/values/strings.xml | 8 | ||||
-rw-r--r-- | packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java | 22 |
3 files changed, 33 insertions, 3 deletions
diff --git a/packages/Keyguard/res/values/config.xml b/packages/Keyguard/res/values/config.xml index 8d9d6ee..b398ab2 100644 --- a/packages/Keyguard/res/values/config.xml +++ b/packages/Keyguard/res/values/config.xml @@ -22,4 +22,10 @@ <!-- Allow the menu hard key to be disabled in LockScreen on some devices [DO NOT TRANSLATE] --> <bool name="config_disableMenuKeyInLockScreen">false</bool> + + <!-- Threshold in micro amperes below which a charger is rated as "slow" --> + <integer name="config_chargingSlowlyThreshold">1000000</integer> + + <!-- Threshold in micro amperes above which a charger is rated as "fast" --> + <integer name="config_chargingFastThreshold">1500000</integer> </resources> diff --git a/packages/Keyguard/res/values/strings.xml b/packages/Keyguard/res/values/strings.xml index 748129c..14c8a2c 100644 --- a/packages/Keyguard/res/values/strings.xml +++ b/packages/Keyguard/res/values/strings.xml @@ -56,6 +56,14 @@ is not fully charged, say that it's charging. --> <string name="keyguard_plugged_in">Charging</string> + <!-- When the lock screen is showing and the phone plugged in, and the battery + is not fully charged, and it's plugged into a fast charger, say that it's charging fast. --> + <string name="keyguard_plugged_in_charging_fast">Charging rapidly</string> + + <!-- When the lock screen is showing and the phone plugged in, and the battery + is not fully charged, and it's plugged into a slow charger, say that it's charging slowly. --> + <string name="keyguard_plugged_in_charging_slowly">Charging slowly</string> + <!-- When the lock screen is showing and the battery is low, warn user to plug in the phone soon. --> <string name="keyguard_low_battery">Connect your charger.</string> diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java index 6574e4e..786919d 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -37,6 +37,7 @@ import static android.os.BatteryManager.EXTRA_STATUS; import static android.os.BatteryManager.EXTRA_PLUGGED; import static android.os.BatteryManager.EXTRA_LEVEL; import static android.os.BatteryManager.EXTRA_HEALTH; +import static android.os.BatteryManager.EXTRA_MAX_CHARGING_CURRENT; import android.media.AudioManager; import android.os.BatteryManager; @@ -489,8 +490,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { final int plugged = intent.getIntExtra(EXTRA_PLUGGED, 0); final int level = intent.getIntExtra(EXTRA_LEVEL, 0); final int health = intent.getIntExtra(EXTRA_HEALTH, BATTERY_HEALTH_UNKNOWN); + final int maxChargingCurrent = intent.getIntExtra(EXTRA_MAX_CHARGING_CURRENT, -1); final Message msg = mHandler.obtainMessage( - MSG_BATTERY_UPDATE, new BatteryStatus(status, level, plugged, health)); + MSG_BATTERY_UPDATE, new BatteryStatus(status, level, plugged, health, + maxChargingCurrent)); mHandler.sendMessage(msg); } else if (TelephonyIntents.ACTION_SIM_STATE_CHANGED.equals(action)) { SimData args = SimData.fromIntent(intent); @@ -641,15 +644,22 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { } public static class BatteryStatus { + public static final int CHARGING_UNKNOWN = -1; + public static final int CHARGING_SLOWLY = 0; + public static final int CHARGING_REGULAR = 1; + public static final int CHARGING_FAST = 2; + public final int status; public final int level; public final int plugged; public final int health; - public BatteryStatus(int status, int level, int plugged, int health) { + public final int maxChargingCurrent; + public BatteryStatus(int status, int level, int plugged, int health, int maxChargingCurrent) { this.status = status; this.level = level; this.plugged = plugged; this.health = health; + this.maxChargingCurrent = maxChargingCurrent; } /** @@ -680,6 +690,12 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { return level < LOW_BATTERY_THRESHOLD; } + public final int getChargingSpeed(int slowThreshold, int fastThreshold) { + return maxChargingCurrent <= 0 ? CHARGING_UNKNOWN : + maxChargingCurrent < slowThreshold ? CHARGING_SLOWLY : + maxChargingCurrent > fastThreshold ? CHARGING_FAST : + CHARGING_REGULAR; + } } public static KeyguardUpdateMonitor getInstance(Context context) { @@ -746,7 +762,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { } // Take a guess at initial SIM state, battery status and PLMN until we get an update - mBatteryStatus = new BatteryStatus(BATTERY_STATUS_UNKNOWN, 100, 0, 0); + mBatteryStatus = new BatteryStatus(BATTERY_STATUS_UNKNOWN, 100, 0, 0, 0); // Watch for interesting updates final IntentFilter filter = new IntentFilter(); |