Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6361e22f authored by Ruchi Kandoi's avatar Ruchi Kandoi
Browse files

batteryService: Add Charge Counter.



Bug: 27174034
Change-Id: Ib8bc8f617288c0ad543c67e0fa609c5a0c87b5fd
Signed-off-by: default avatarRuchi Kandoi <kandoiruchi@google.com>
parent c0b8c119
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -115,6 +115,13 @@ public class BatteryManager {
     */
    public static final String EXTRA_MAX_CHARGING_VOLTAGE = "max_charging_voltage";

    /**
     * Extra for {@link android.content.Intent#ACTION_BATTERY_CHANGED}:
     * integer containing the charge counter present in the battery.
     * {@hide}
     */
     public static final String EXTRA_CHARGE_COUNTER = "charge_counter";

    // values for "status" field in the ACTION_BATTERY_CHANGED Intent
    public static final int BATTERY_STATUS_UNKNOWN = 1;
    public static final int BATTERY_STATUS_CHARGING = 2;
+4 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ public class BatteryProperties implements Parcelable {
    public int batteryLevel;
    public int batteryVoltage;
    public int batteryTemperature;
    public int batteryChargeCounter;
    public String batteryTechnology;

    public BatteryProperties() {
@@ -47,6 +48,7 @@ public class BatteryProperties implements Parcelable {
        batteryLevel = other.batteryLevel;
        batteryVoltage = other.batteryVoltage;
        batteryTemperature = other.batteryTemperature;
        batteryChargeCounter = other.batteryChargeCounter;
        batteryTechnology = other.batteryTechnology;
    }

@@ -67,6 +69,7 @@ public class BatteryProperties implements Parcelable {
        batteryLevel = p.readInt();
        batteryVoltage = p.readInt();
        batteryTemperature = p.readInt();
        batteryChargeCounter = p.readInt();
        batteryTechnology = p.readString();
    }

@@ -82,6 +85,7 @@ public class BatteryProperties implements Parcelable {
        p.writeInt(batteryLevel);
        p.writeInt(batteryVoltage);
        p.writeInt(batteryTemperature);
        p.writeInt(batteryChargeCounter);
        p.writeString(batteryTechnology);
    }

+8 −1
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ public final class BatteryService extends SystemService {
    private boolean mLastBatteryLevelCritical;
    private int mLastMaxChargingCurrent;
    private int mLastMaxChargingVoltage;
    private int mLastChargeCounter;

    private int mInvalidCharger;
    private int mLastInvalidCharger;
@@ -341,6 +342,7 @@ public final class BatteryService extends SystemService {
                    + ", chargerWirelessOnline=" + mBatteryProps.chargerWirelessOnline
                    + ", maxChargingCurrent" + mBatteryProps.maxChargingCurrent
                    + ", maxChargingVoltage" + mBatteryProps.maxChargingVoltage
                    + ", chargeCounter" + mBatteryProps.batteryChargeCounter
                    + ", batteryStatus=" + mBatteryProps.batteryStatus
                    + ", batteryHealth=" + mBatteryProps.batteryHealth
                    + ", batteryPresent=" + mBatteryProps.batteryPresent
@@ -373,6 +375,7 @@ public final class BatteryService extends SystemService {
                mBatteryProps.batteryTemperature != mLastBatteryTemperature ||
                mBatteryProps.maxChargingCurrent != mLastMaxChargingCurrent ||
                mBatteryProps.maxChargingVoltage != mLastMaxChargingVoltage ||
                mBatteryProps.batteryChargeCounter != mLastChargeCounter ||
                mInvalidCharger != mLastInvalidCharger)) {

            if (mPlugType != mLastPlugType) {
@@ -501,6 +504,7 @@ public final class BatteryService extends SystemService {
            mLastBatteryTemperature = mBatteryProps.batteryTemperature;
            mLastMaxChargingCurrent = mBatteryProps.maxChargingCurrent;
            mLastMaxChargingVoltage = mBatteryProps.maxChargingVoltage;
            mLastChargeCounter = mBatteryProps.batteryChargeCounter;
            mLastBatteryLevelCritical = mBatteryLevelCritical;
            mLastInvalidCharger = mInvalidCharger;
        }
@@ -527,6 +531,7 @@ public final class BatteryService extends SystemService {
        intent.putExtra(BatteryManager.EXTRA_INVALID_CHARGER, mInvalidCharger);
        intent.putExtra(BatteryManager.EXTRA_MAX_CHARGING_CURRENT, mBatteryProps.maxChargingCurrent);
        intent.putExtra(BatteryManager.EXTRA_MAX_CHARGING_VOLTAGE, mBatteryProps.maxChargingVoltage);
        intent.putExtra(BatteryManager.EXTRA_CHARGE_COUNTER, mBatteryProps.batteryChargeCounter);
        if (DEBUG) {
            Slog.d(TAG, "Sending ACTION_BATTERY_CHANGED.  level:" + mBatteryProps.batteryLevel +
                    ", scale:" + BATTERY_SCALE + ", status:" + mBatteryProps.batteryStatus +
@@ -540,7 +545,8 @@ public final class BatteryService extends SystemService {
                    ", Wireless powered:" + mBatteryProps.chargerWirelessOnline +
                    ", icon:" + icon  + ", invalid charger:" + mInvalidCharger +
                    ", maxChargingCurrent:" + mBatteryProps.maxChargingCurrent +
                    ", maxChargingVoltage:" + mBatteryProps.maxChargingVoltage);
                    ", maxChargingVoltage:" + mBatteryProps.maxChargingVoltage +
                    ", chargeCounter:" + mBatteryProps.batteryChargeCounter);
        }

        mHandler.post(new Runnable() {
@@ -772,6 +778,7 @@ public final class BatteryService extends SystemService {
                pw.println("  Wireless powered: " + mBatteryProps.chargerWirelessOnline);
                pw.println("  Max charging current: " + mBatteryProps.maxChargingCurrent);
                pw.println("  Max charging voltage: " + mBatteryProps.maxChargingVoltage);
                pw.println("  Charge counter: " + mBatteryProps.batteryChargeCounter);
                pw.println("  status: " + mBatteryProps.batteryStatus);
                pw.println("  health: " + mBatteryProps.batteryHealth);
                pw.println("  present: " + mBatteryProps.batteryPresent);