Skip to content

Commit

Permalink
SystemUI: Add current divider config for lockscreen charging
Browse files Browse the repository at this point in the history
* Some modern devices measure directly in mA instead uA.
* We will let devices specify config_currentInfoDivider to check
  if uA to mA conversion is required.
* Use same divider for wattage calculation.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
  • Loading branch information
neobuddy89 committed Jul 1, 2022
1 parent 0176b74 commit 90f5534
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/SystemUI/res/values/cr_config.xml
Expand Up @@ -65,4 +65,7 @@
<item>255,33</item>
-->
</string-array>

<!-- Charging info current divider, if needed -->
<integer name="config_currentInfoDivider" translatable="false">1000</integer>
</resources>
Expand Up @@ -166,6 +166,8 @@ public class KeyguardIndicationController {
private String mMessageToShowOnScreenOn;
private boolean mInited;

private int mCurrentDivider;

private KeyguardUpdateMonitorCallback mUpdateMonitorCallback;

private boolean mDozing;
Expand Down Expand Up @@ -230,6 +232,8 @@ public void init() {
mKeyguardStateController.addCallback(mKeyguardStateCallback);

mStatusBarStateListener.onDozingChanged(mStatusBarStateController.isDozing());

mCurrentDivider = mContext.getResources().getInteger(R.integer.config_currentInfoDivider);
}

public void setIndicationArea(ViewGroup indicationArea) {
Expand Down Expand Up @@ -370,7 +374,7 @@ private void updateBattery(boolean animate) {
if (mPowerPluggedIn || mEnableBatteryDefender) {
String powerIndication = computePowerIndication();
if (DEBUG_CHARGING_SPEED) {
powerIndication += ", " + (mChargingWattage / 1000) + " mW";
powerIndication += ", " + (mChargingWattage / mCurrentDivider) + " mW";
}

mRotateTextViewController.updateIndication(
Expand Down Expand Up @@ -854,11 +858,11 @@ protected String computePowerIndication() {
Settings.System.LOCKSCREEN_BATTERY_INFO, 1, UserHandle.USER_CURRENT) == 1;
if (showbatteryInfo) {
if (mChargingCurrent > 0) {
batteryInfo = batteryInfo + (mChargingCurrent / 1000) + "mA";
batteryInfo = batteryInfo + (mChargingCurrent / mCurrentDivider) + "mA";
}
if (mChargingWattage > 0) {
batteryInfo = (batteryInfo == "" ? "" : batteryInfo + " · ") +
String.format("%.1f" , (mChargingWattage / 1000 / 1000)) + "W";
String.format("%.1f" , (mChargingWattage / mCurrentDivider / 1000)) + "W";
}
if (mChargingVoltage > 0) {
batteryInfo = (batteryInfo == "" ? "" : batteryInfo + " · ") +
Expand Down

0 comments on commit 90f5534

Please sign in to comment.