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

Commit cb996104 authored by Hui Yu's avatar Hui Yu
Browse files

Move reading time field to inside HistoryItem.readFromParcel().

Also HistoryItem does not need to implement Parcelable interface,
just like other batterystats classes, readFromParcel() and
writeToParcel() are pair of symmetric methods, but those classes do
not implement Parcelable interface because readFromParcel() is not a
method of readFromParcel() interface.

Change-Id: I5ac974c9903c5639a6bb52fc0a53367f92187af0
Fix: 135442392
Test: reboot device and "adb shell dumpsys batterystats"
parent 5418160c
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -1554,7 +1554,10 @@ public abstract class BatteryStats implements Parcelable {
        }
    }

    public final static class HistoryItem implements Parcelable {
    /**
     * Battery history record.
     */
    public static final class HistoryItem {
        public HistoryItem next;

        // The time of this event in milliseconds, as per SystemClock.elapsedRealtime().
@@ -1789,16 +1792,10 @@ public abstract class BatteryStats implements Parcelable {
        public HistoryItem() {
        }

        public HistoryItem(long time, Parcel src) {
            this.time = time;
            numReadInts = 2;
        public HistoryItem(Parcel src) {
            readFromParcel(src);
        }

        public int describeContents() {
            return 0;
        }

        public void writeToParcel(Parcel dest, int flags) {
            dest.writeLong(time);
            int bat = (((int)cmd)&0xff)
@@ -1835,6 +1832,7 @@ public abstract class BatteryStats implements Parcelable {

        public void readFromParcel(Parcel src) {
            int start = src.dataPosition();
            time = src.readLong();
            int bat = src.readInt();
            cmd = (byte)(bat&0xff);
            batteryLevel = (byte)((bat>>8)&0xff);
+3 −6
Original line number Diff line number Diff line
@@ -3478,10 +3478,8 @@ public class BatteryStatsImpl extends BatteryStats {
        if (deltaTimeToken < DELTA_TIME_ABS) {
            cur.time += deltaTimeToken;
        } else if (deltaTimeToken == DELTA_TIME_ABS) {
            cur.time = src.readLong();
            cur.numReadInts += 2;
            if (DEBUG) Slog.i(TAG, "READ DELTA: ABS time=" + cur.time);
            cur.readFromParcel(src);
            if (DEBUG) Slog.i(TAG, "READ DELTA: ABS time=" + cur.time);
            return;
        } else if (deltaTimeToken == DELTA_TIME_INT) {
            int delta = src.readInt();
@@ -13459,9 +13457,8 @@ public class BatteryStatsImpl extends BatteryStats {
            return;
        }
        mHistory = mHistoryEnd = mHistoryCache = null;
        long time;
        while (in.dataAvail() > 0 && (time=in.readLong()) >= 0) {
            HistoryItem rec = new HistoryItem(time, in);
        while (in.dataAvail() > 0) {
            HistoryItem rec = new HistoryItem(in);
            addHistoryRecordLocked(rec);
        }
    }