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

Commit 540f4d6d authored by Todd Poynor's avatar Todd Poynor
Browse files

BatteryManager: Add property ENERGY_COUNTER and long data type properties

Change-Id: Ie7f9b19c5cd47a48bb33af03d51acddaa14b0243
parent 07d5e7d5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -19578,6 +19578,7 @@ package android.os {
  public class BatteryProperty implements android.os.Parcelable {
    method public int describeContents();
    method public int getInt();
    method public long getLong();
    method public void readFromParcel(android.os.Parcel);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final int CAPACITY = 4; // 0x4
@@ -19585,6 +19586,7 @@ package android.os {
    field public static final android.os.Parcelable.Creator CREATOR;
    field public static final int CURRENT_AVERAGE = 3; // 0x3
    field public static final int CURRENT_NOW = 2; // 0x2
    field public static final int ENERGY_COUNTER = 4; // 0x4
  }
  public class Binder implements android.os.IBinder {
+2 −2
Original line number Diff line number Diff line
@@ -146,9 +146,9 @@ public class BatteryManager {
                return null;
        }

        BatteryProperty prop = new BatteryProperty(Integer.MIN_VALUE);
        BatteryProperty prop = new BatteryProperty();
        if ((mBatteryPropertiesRegistrar.getProperty(id, prop) == 0) &&
            (prop.getInt() != Integer.MIN_VALUE))
            (prop.getLong() != Long.MIN_VALUE))
            return prop;
        else
            return null;
+20 −10
Original line number Diff line number Diff line
@@ -53,20 +53,18 @@ public class BatteryProperty implements Parcelable {
     */
    public static final int CAPACITY = 4;

    private int mValueInt;

    /**
     * @hide
     * Battery remaining energy in nanowatt-hours, as a long integer.
     */
    public BatteryProperty(int value) {
        mValueInt = value;
    }
    public static final int ENERGY_COUNTER = 4;

    private long mValueLong;

    /**
     * @hide
     */
    public BatteryProperty() {
        mValueInt = Integer.MIN_VALUE;
        mValueLong = Long.MIN_VALUE;
    }

    /**
@@ -79,9 +77,21 @@ public class BatteryProperty implements Parcelable {
     * @return The queried property value, or Integer.MIN_VALUE if not supported.
     */
    public int getInt() {
        return mValueInt;
        return (int)mValueLong;
    }

    /**
     * Return the value of a property of long type previously queried
     * via {@link BatteryManager#getProperty
     * BatteryManager.getProperty()}.  If the platform does
     * not provide the property queried, this value will be
     * Long.MIN_VALUE.
     *
     * @return The queried property value, or Long.MIN_VALUE if not supported.
     */
    public long getLong() {
        return mValueLong;
    }
    /*
     * Parcel read/write code must be kept in sync with
     * frameworks/native/services/batteryservice/BatteryProperty.cpp
@@ -92,11 +102,11 @@ public class BatteryProperty implements Parcelable {
    }

    public void readFromParcel(Parcel p) {
        mValueInt = p.readInt();
        mValueLong = p.readLong();
    }

    public void writeToParcel(Parcel p, int flags) {
        p.writeInt(mValueInt);
        p.writeLong(mValueLong);
    }

    public static final Parcelable.Creator<BatteryProperty> CREATOR