Loading packages/Keyguard/res/values/config.xml +4 −4 Original line number Diff line number Diff line Loading @@ -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> packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +28 −9 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -617,10 +620,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); Loading Loading @@ -806,13 +824,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; } /** Loading Loading @@ -844,9 +863,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; } } Loading Loading @@ -1422,7 +1441,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; } Loading packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +6 −6 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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, Loading Loading @@ -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; } Loading Loading @@ -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(); } Loading Loading
packages/Keyguard/res/values/config.xml +4 −4 Original line number Diff line number Diff line Loading @@ -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>
packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java +28 −9 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -617,10 +620,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); Loading Loading @@ -806,13 +824,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; } /** Loading Loading @@ -844,9 +863,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; } } Loading Loading @@ -1422,7 +1441,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; } Loading
packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +6 −6 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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, Loading Loading @@ -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; } Loading Loading @@ -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(); } Loading