diff options
author | Alexander Martinz <alex@amartinz.at> | 2017-08-25 12:01:11 +0200 |
---|---|---|
committer | alk3pInjection <webmaster@raspii.tech> | 2022-05-07 00:20:58 +0800 |
commit | b56b36abbdc4f34a924d106c0b954efb5d52bc3d (patch) | |
tree | 2548e0edd918a4836f06876ae165c9010d5045a8 /packages | |
parent | b22a41ebeb8fc9bf9093bf5a713edf2abb47f838 (diff) |
BatteryService: Add support for OEM fast charger detection
Allows to indicate, whether a device is charged using a
proprietary OEM fast charge solution, which write their status
to sysfs.
The OEM fast charge detection tries to be as generic as possible and is
configured via overlays.
Path to sysfs to read status
- core/res/res/values/custom_config.xml
- config_oemFastChargerStatusPath
Value expected from read status (Defaults to "1" if not specified)
- core/res/res/values/custom_config.xml
- config_oemFastChargerStatusValue
Change-Id: I6f3598a5a6a3efc76553261d2cf73094170d4110
Signed-off-by: Adithya R <gh0strider.2k18.reborn@gmail.com>
Diffstat (limited to 'packages')
-rw-r--r-- | packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatteryStatus.java | 9 | ||||
-rwxr-xr-x | packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java | 7 |
2 files changed, 14 insertions, 2 deletions
diff --git a/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatteryStatus.java b/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatteryStatus.java index b56ae3864fb7..63e0673459b2 100644 --- a/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatteryStatus.java +++ b/packages/SettingsLib/src/com/android/settingslib/fuelgauge/BatteryStatus.java @@ -27,6 +27,7 @@ import static android.os.BatteryManager.EXTRA_MAX_CHARGING_VOLTAGE; import static android.os.BatteryManager.EXTRA_PLUGGED; import static android.os.BatteryManager.EXTRA_PRESENT; import static android.os.BatteryManager.EXTRA_STATUS; +import static android.os.BatteryManager.EXTRA_OEM_FAST_CHARGER; import android.content.Context; import android.content.Intent; @@ -51,15 +52,17 @@ public class BatteryStatus { public final int plugged; public final int health; public final int maxChargingWattage; + public final boolean oemFastChargeStatus; public final boolean present; public BatteryStatus(int status, int level, int plugged, int health, - int maxChargingWattage, boolean present) { + int maxChargingWattage, boolean oemFastChargeStatus, boolean present) { this.status = status; this.level = level; this.plugged = plugged; this.health = health; this.maxChargingWattage = maxChargingWattage; + this.oemFastChargeStatus = oemFastChargeStatus; this.present = present; } @@ -68,6 +71,7 @@ public class BatteryStatus { plugged = batteryChangedIntent.getIntExtra(EXTRA_PLUGGED, 0); level = batteryChangedIntent.getIntExtra(EXTRA_LEVEL, 0); health = batteryChangedIntent.getIntExtra(EXTRA_HEALTH, BATTERY_HEALTH_UNKNOWN); + oemFastChargeStatus = batteryChangedIntent.getBooleanExtra(EXTRA_OEM_FAST_CHARGER, false); present = batteryChangedIntent.getBooleanExtra(EXTRA_PRESENT, true); final int maxChargingMicroAmp = batteryChangedIntent.getIntExtra(EXTRA_MAX_CHARGING_CURRENT, @@ -152,6 +156,9 @@ public class BatteryStatus { * @return the charing speed */ public final int getChargingSpeed(Context context) { + if (oemFastChargeStatus) { + return CHARGING_FAST; + } final int slowThreshold = context.getResources().getInteger( R.integer.config_chargingSlowlyThreshold); final int fastThreshold = context.getResources().getInteger( diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 450949881aa4..df1d818cf318 100755 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -1928,7 +1928,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab } // 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, 0, true); + mBatteryStatus = new BatteryStatus(BATTERY_STATUS_UNKNOWN, 100, 0, 0, 0, false, true); // Watch for interesting updates final IntentFilter filter = new IntentFilter(); @@ -3046,6 +3046,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab return true; } + // change in oem fast charging while plugged in + if (nowPluggedIn && current.oemFastChargeStatus != old.oemFastChargeStatus) { + return true; + } + // Battery either showed up or disappeared if (wasPresent != nowPresent) { return true; |