core: BatteryManager: Add few more Battery broadcast intents
* maximum_capacity
* design_capacity
Change-Id: Idfa9207cc8bd35469876f3094f3bc948741c94bf
Signed-off-by: Jyotiraditya Panda <jyotiraditya@aospa.co>
Signed-off-by: Adithya R <gh0strider.2k18.reborn@gmail.com>
diff --git a/core/java/android/os/BatteryManager.java b/core/java/android/os/BatteryManager.java
index 25fba60..63608f1 100644
--- a/core/java/android/os/BatteryManager.java
+++ b/core/java/android/os/BatteryManager.java
@@ -164,6 +164,20 @@
public static final String EXTRA_CHARGING_STATUS = "android.os.extra.CHARGING_STATUS";
/**
+ * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
+ * Int value representing the estimated battery full charge capacity in microampere-hours.
+ * {@hide}
+ */
+ public static final String EXTRA_MAXIMUM_CAPACITY = "android.os.extra.MAXIMUM_CAPACITY";
+
+ /**
+ * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
+ * Int value representing the battery full charge design capacity in microampere-hours.
+ * {@hide}
+ */
+ public static final String EXTRA_DESIGN_CAPACITY = "android.os.extra.DESIGN_CAPACITY";
+
+ /**
* Extra for {@link android.content.Intent#ACTION_BATTERY_LEVEL_CHANGED}:
* Contains list of Bundles representing battery events
* @hide
diff --git a/services/core/java/com/android/server/BatteryService.java b/services/core/java/com/android/server/BatteryService.java
index 5a44ac8..cd993e4 100644
--- a/services/core/java/com/android/server/BatteryService.java
+++ b/services/core/java/com/android/server/BatteryService.java
@@ -157,6 +157,8 @@
private int mLastChargeCounter;
private int mLastBatteryCycleCount;
private int mLastCharingState;
+ private int mLastBatteryFullCharge;
+ private int mLastBatteryFullChargeDesign;
private int mSequence = 1;
@@ -539,6 +541,9 @@
|| mHealthInfo.maxChargingVoltageMicrovolts != mLastMaxChargingVoltage
|| mHealthInfo.batteryChargeCounterUah != mLastChargeCounter
|| mInvalidCharger != mLastInvalidCharger
+ || mHealthInfo.batteryFullChargeUah != mLastBatteryFullCharge
+ || mHealthInfo.batteryFullChargeDesignCapacityUah !=
+ mLastBatteryFullChargeDesign
|| mHealthInfo.batteryCycleCount != mLastBatteryCycleCount
|| mHealthInfo.chargingState != mLastCharingState)) {
@@ -724,6 +729,8 @@
mLastInvalidCharger = mInvalidCharger;
mLastBatteryCycleCount = mHealthInfo.batteryCycleCount;
mLastCharingState = mHealthInfo.chargingState;
+ mLastBatteryFullCharge = mHealthInfo.batteryFullChargeUah;
+ mLastBatteryFullChargeDesign = mHealthInfo.batteryFullChargeDesignCapacityUah;
}
}
@@ -757,6 +764,10 @@
intent.putExtra(BatteryManager.EXTRA_CHARGE_COUNTER, mHealthInfo.batteryChargeCounterUah);
intent.putExtra(BatteryManager.EXTRA_CYCLE_COUNT, mHealthInfo.batteryCycleCount);
intent.putExtra(BatteryManager.EXTRA_CHARGING_STATUS, mHealthInfo.chargingState);
+ intent.putExtra(BatteryManager.EXTRA_MAXIMUM_CAPACITY, mHealthInfo.batteryFullChargeUah);
+ intent.putExtra(
+ BatteryManager.EXTRA_DESIGN_CAPACITY,
+ mHealthInfo.batteryFullChargeDesignCapacityUah);
if (DEBUG) {
Slog.d(TAG, "Sending ACTION_BATTERY_CHANGED. scale:" + BATTERY_SCALE
+ ", info:" + mHealthInfo.toString());
@@ -796,6 +807,10 @@
event.putLong(BatteryManager.EXTRA_EVENT_TIMESTAMP, now);
event.putInt(BatteryManager.EXTRA_CYCLE_COUNT, mHealthInfo.batteryCycleCount);
event.putInt(BatteryManager.EXTRA_CHARGING_STATUS, mHealthInfo.chargingState);
+ event.putInt(BatteryManager.EXTRA_MAXIMUM_CAPACITY, mHealthInfo.batteryFullChargeUah);
+ event.putInt(
+ BatteryManager.EXTRA_DESIGN_CAPACITY,
+ mHealthInfo.batteryFullChargeDesignCapacityUah);
boolean queueWasEmpty = mBatteryLevelsEventQueue.isEmpty();
mBatteryLevelsEventQueue.add(event);