diff options
| author | 2015-12-02 01:50:10 +0000 | |
|---|---|---|
| committer | 2015-12-02 01:50:10 +0000 | |
| commit | 82cfaa813b994ff1e5aaedbdfeeb4ced6e5dfcdb (patch) | |
| tree | d1100b062cb607de00d2a4ae13ecb68afe95bc97 | |
| parent | 7154bbf2d40dcdb86160781991d77573d173e976 (diff) | |
| parent | 0ede75507c43819d0417efe1f1ab5c626a608fc5 (diff) | |
Merge "Charging speed based on voltage" into mnc-dr2-dev
am: 0ede75507c
* commit '0ede75507c43819d0417efe1f1ab5c626a608fc5':
Charging speed based on voltage
3 files changed, 38 insertions, 19 deletions
diff --git a/packages/Keyguard/res/values/config.xml b/packages/Keyguard/res/values/config.xml index b398ab2320b0..bde6ed531353 100644 --- a/packages/Keyguard/res/values/config.xml +++ b/packages/Keyguard/res/values/config.xml @@ -23,9 +23,9 @@ <!-- 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 watts below which a charger is rated as "slow"; 1A @ 5V --> + <integer name="config_chargingSlowlyThreshold">5000000</integer> - <!-- Threshold in micro amperes above which a charger is rated as "fast" --> - <integer name="config_chargingFastThreshold">1500000</integer> + <!-- Threshold in micro watts above which a charger is rated as "fast"; 1.5A @ 5V --> + <integer name="config_chargingFastThreshold">7500000</integer> </resources> diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java index 57ee319f8ff3..fdabf9f49c25 100644 --- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -75,6 +75,7 @@ import static android.os.BatteryManager.BATTERY_STATUS_UNKNOWN; import static android.os.BatteryManager.EXTRA_HEALTH; import static android.os.BatteryManager.EXTRA_LEVEL; import static android.os.BatteryManager.EXTRA_MAX_CHARGING_CURRENT; +import static android.os.BatteryManager.EXTRA_MAX_CHARGING_VOLTAGE; import static android.os.BatteryManager.EXTRA_PLUGGED; import static android.os.BatteryManager.EXTRA_STATUS; @@ -155,6 +156,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { */ private static final int FINGERPRINT_STATE_CANCELLING_RESTARTING = 3; + private static final int DEFAULT_CHARGING_VOLTAGE_MICRO_VOLT = 5000000; + private static KeyguardUpdateMonitor sInstance; private final Context mContext; @@ -616,10 +619,25 @@ 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 int maxChargingMicroAmp = intent.getIntExtra(EXTRA_MAX_CHARGING_CURRENT, -1); + int maxChargingMicroVolt = intent.getIntExtra(EXTRA_MAX_CHARGING_VOLTAGE, -1); + final int maxChargingMicroWatt; + + if (maxChargingMicroVolt <= 0) { + maxChargingMicroVolt = DEFAULT_CHARGING_VOLTAGE_MICRO_VOLT; + } + if (maxChargingMicroAmp > 0) { + // Calculating muW = muA * muV / (10^6 mu^2 / mu); splitting up the divisor + // to maintain precision equally on both factors. + maxChargingMicroWatt = (maxChargingMicroAmp / 1000) + * (maxChargingMicroVolt / 1000); + } else { + maxChargingMicroWatt = -1; + } final Message msg = mHandler.obtainMessage( MSG_BATTERY_UPDATE, new BatteryStatus(status, level, plugged, health, - maxChargingCurrent)); + maxChargingMicroWatt)); mHandler.sendMessage(msg); } else if (TelephonyIntents.ACTION_SIM_STATE_CHANGED.equals(action)) { SimData args = SimData.fromIntent(intent); @@ -803,13 +821,14 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { public final int level; public final int plugged; public final int health; - public final int maxChargingCurrent; - public BatteryStatus(int status, int level, int plugged, int health, int maxChargingCurrent) { + public final int maxChargingWattage; + public BatteryStatus(int status, int level, int plugged, int health, + int maxChargingWattage) { this.status = status; this.level = level; this.plugged = plugged; this.health = health; - this.maxChargingCurrent = maxChargingCurrent; + this.maxChargingWattage = maxChargingWattage; } /** @@ -841,9 +860,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { } public final int getChargingSpeed(int slowThreshold, int fastThreshold) { - return maxChargingCurrent <= 0 ? CHARGING_UNKNOWN : - maxChargingCurrent < slowThreshold ? CHARGING_SLOWLY : - maxChargingCurrent > fastThreshold ? CHARGING_FAST : + return maxChargingWattage <= 0 ? CHARGING_UNKNOWN : + maxChargingWattage < slowThreshold ? CHARGING_SLOWLY : + maxChargingWattage > fastThreshold ? CHARGING_FAST : CHARGING_REGULAR; } } @@ -1419,7 +1438,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { } // change in charging current while plugged in - if (nowPluggedIn && current.maxChargingCurrent != old.maxChargingCurrent) { + if (nowPluggedIn && current.maxChargingWattage != old.maxChargingWattage) { return true; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index fd84345e9f77..0affb7a900f3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -48,8 +48,8 @@ import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; */ public class KeyguardIndicationController { - private static final String TAG = "KeyguardIndicationController"; - private static final boolean DEBUG_CHARGING_CURRENT = false; + private static final String TAG = "KeyguardIndication"; + private static final boolean DEBUG_CHARGING_SPEED = false; private static final int MSG_HIDE_TRANSIENT = 1; private static final int MSG_CLEAR_FP_MSG = 2; @@ -72,7 +72,7 @@ public class KeyguardIndicationController { private boolean mPowerPluggedIn; private boolean mPowerCharged; private int mChargingSpeed; - private int mChargingCurrent; + private int mChargingWattage; private String mMessageToShowOnScreenOn; public KeyguardIndicationController(Context context, KeyguardIndicationTextView textView, @@ -173,8 +173,8 @@ public class KeyguardIndicationController { } if (mPowerPluggedIn) { String indication = computePowerIndication(); - if (DEBUG_CHARGING_CURRENT) { - indication += ", " + (mChargingCurrent / 1000) + " mA"; + if (DEBUG_CHARGING_SPEED) { + indication += ", " + (mChargingWattage / 1000) + " mW"; } return indication; } @@ -231,7 +231,7 @@ public class KeyguardIndicationController { || status.status == BatteryManager.BATTERY_STATUS_FULL; mPowerPluggedIn = status.isPluggedIn() && isChargingOrFull; mPowerCharged = status.isCharged(); - mChargingCurrent = status.maxChargingCurrent; + mChargingWattage = status.maxChargingWattage; mChargingSpeed = status.getChargingSpeed(mSlowThreshold, mFastThreshold); updateIndication(); } |