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

Commit 4b07f0a7 authored by Dmitri Plotnikov's avatar Dmitri Plotnikov Committed by Android (Google) Code Review
Browse files

Merge "Rename MeasuredEnergy to EnergyConsumer"

parents 20a4eeea 472367a9
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ public abstract class BatteryConsumer {
    @IntDef(prefix = {"POWER_MODEL_"}, value = {
            POWER_MODEL_UNDEFINED,
            POWER_MODEL_POWER_PROFILE,
            POWER_MODEL_MEASURED_ENERGY,
            POWER_MODEL_ENERGY_CONSUMPTION,
    })
    @Retention(RetentionPolicy.SOURCE)
    public @interface PowerModel {
@@ -150,9 +150,9 @@ public abstract class BatteryConsumer {
    public static final int POWER_MODEL_POWER_PROFILE = 1;

    /**
     * Power model that is based on energy consumption measured by on-device power monitors.
     * Power model that is based on energy consumption stats provided by PowerStats HAL.
     */
    public static final int POWER_MODEL_MEASURED_ENERGY = 2;
    public static final int POWER_MODEL_ENERGY_CONSUMPTION = 2;

    /**
     * Identifiers of consumed power aggregations.
@@ -469,8 +469,8 @@ public abstract class BatteryConsumer {
     */
    public static String powerModelToString(@BatteryConsumer.PowerModel int powerModel) {
        switch (powerModel) {
            case BatteryConsumer.POWER_MODEL_MEASURED_ENERGY:
                return "measured energy";
            case BatteryConsumer.POWER_MODEL_ENERGY_CONSUMPTION:
                return "energy consumption";
            case BatteryConsumer.POWER_MODEL_POWER_PROFILE:
                return "power profile";
            default:
@@ -484,7 +484,7 @@ public abstract class BatteryConsumer {
     */
    public static int powerModelToProtoEnum(@BatteryConsumer.PowerModel int powerModel) {
        switch (powerModel) {
            case BatteryConsumer.POWER_MODEL_MEASURED_ENERGY:
            case BatteryConsumer.POWER_MODEL_ENERGY_CONSUMPTION:
                return BatteryUsageStatsAtomsProto.PowerComponentModel.MEASURED_ENERGY;
            case BatteryConsumer.POWER_MODEL_POWER_PROFILE:
                return BatteryUsageStatsAtomsProto.PowerComponentModel.POWER_PROFILE;
+42 −36
Original line number Diff line number Diff line
@@ -1043,12 +1043,13 @@ public abstract class BatteryStats {

        /**
         * Returns the battery consumption (in microcoulombs) of bluetooth for this uid,
         * derived from on device power measurement data.
         * derived from {@link android.hardware.power.stats.EnergyConsumerType#BLUETOOTH} bucket
         * provided by the PowerStats service.
         * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
         *
         * {@hide}
         */
        public abstract long getBluetoothMeasuredBatteryConsumptionUC();
        public abstract long getBluetoothEnergyConsumptionUC();

        /**
         * Returns the battery consumption (in microcoulombs) of the uid's bluetooth usage
@@ -1057,17 +1058,18 @@ public abstract class BatteryStats {
         *
         * {@hide}
         */
        public abstract long getBluetoothMeasuredBatteryConsumptionUC(
        public abstract long getBluetoothEnergyConsumptionUC(
                @BatteryConsumer.ProcessState int processState);

        /**
         * Returns the battery consumption (in microcoulombs) of the uid's cpu usage, derived from
         * on device power measurement data.
         * derived from {@link android.hardware.power.stats.EnergyConsumerType#CPU} bucket
         * provided by the PowerStats service.
         * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
         *
         * {@hide}
         */
        public abstract long getCpuMeasuredBatteryConsumptionUC();
        public abstract long getCpuEnergyConsumptionUC();

        /**
         * Returns the battery consumption (in microcoulombs) of the uid's cpu usage when in the
@@ -1076,26 +1078,28 @@ public abstract class BatteryStats {
         *
         * {@hide}
         */
        public abstract long getCpuMeasuredBatteryConsumptionUC(
        public abstract long getCpuEnergyConsumptionUC(
                @BatteryConsumer.ProcessState int processState);

        /**
         * Returns the battery consumption (in microcoulombs) of the uid's GNSS usage, derived from
         * on device power measurement data.
         * derived from {@link android.hardware.power.stats.EnergyConsumerType#GNSS} bucket
         * provided by the PowerStats service.
         * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
         *
         * {@hide}
         */
        public abstract long getGnssMeasuredBatteryConsumptionUC();
        public abstract long getGnssEnergyConsumptionUC();

        /**
         * Returns the battery consumption (in microcoulombs) of the uid's radio usage, derived from
         * on device power measurement data.
         * derived from {@link android.hardware.power.stats.EnergyConsumerType#MOBILE_RADIO}
         * bucket provided by the PowerStats service.
         * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
         *
         * {@hide}
         */
        public abstract long getMobileRadioMeasuredBatteryConsumptionUC();
        public abstract long getMobileRadioEnergyConsumptionUC();

        /**
         * Returns the battery consumption (in microcoulombs) of the uid's radio usage when in the
@@ -1104,26 +1108,28 @@ public abstract class BatteryStats {
         *
         * {@hide}
         */
        public abstract long getMobileRadioMeasuredBatteryConsumptionUC(
        public abstract long getMobileRadioEnergyConsumptionUC(
                @BatteryConsumer.ProcessState int processState);

        /**
         * Returns the battery consumption (in microcoulombs) of the screen while on and uid active,
         * derived from on device power measurement data.
         * derived from {@link android.hardware.power.stats.EnergyConsumerType#DISPLAY} bucket
         * provided by the PowerStats service.
         * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
         *
         * {@hide}
         */
        public abstract long getScreenOnMeasuredBatteryConsumptionUC();
        public abstract long getScreenOnEnergyConsumptionUC();

        /**
         * Returns the battery consumption (in microcoulombs) of wifi for this uid,
         * derived from on device power measurement data.
         * derived from {@link android.hardware.power.stats.EnergyConsumerType#WIFI} bucket
         * provided by the PowerStats service.
         * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
         *
         * {@hide}
         */
        public abstract long getWifiMeasuredBatteryConsumptionUC();
        public abstract long getWifiEnergyConsumptionUC();

        /**
         * Returns the battery consumption (in microcoulombs) of the uid's wifi usage when in the
@@ -1132,7 +1138,7 @@ public abstract class BatteryStats {
         *
         * {@hide}
         */
        public abstract long getWifiMeasuredBatteryConsumptionUC(
        public abstract long getWifiEnergyConsumptionUC(
                @BatteryConsumer.ProcessState int processState);


@@ -1147,7 +1153,7 @@ public abstract class BatteryStats {
         *
         * {@hide}
         */
        public abstract @Nullable long[] getCustomConsumerMeasuredBatteryConsumptionUC();
        public abstract @Nullable long[] getCustomEnergyConsumerBatteryConsumptionUC();

        public static abstract class Sensor {

@@ -1776,7 +1782,7 @@ public abstract class BatteryStats {
    /**
     * Measured energy delta from the previous reading.
     */
    public static final class MeasuredEnergyDetails {
    public static final class EnergyConsumerDetails {
        /**
         * Description of the energy consumer, such as CPU, DISPLAY etc
         */
@@ -1986,8 +1992,8 @@ public abstract class BatteryStats {
        // Non-null when there is more detailed information at this step.
        public HistoryStepDetails stepDetails;

        // Non-null when there is measured energy information
        public MeasuredEnergyDetails measuredEnergyDetails;
        // Non-null when there is energy consumer information
        public EnergyConsumerDetails energyConsumerDetails;

        // Non-null when there is CPU usage information
        public CpuUsageDetails cpuUsageDetails;
@@ -2200,7 +2206,7 @@ public abstract class BatteryStats {
            eventCode = EVENT_NONE;
            eventTag = null;
            tagsFirstOccurrence = false;
            measuredEnergyDetails = null;
            energyConsumerDetails = null;
            cpuUsageDetails = null;
        }

@@ -2251,7 +2257,7 @@ public abstract class BatteryStats {
            }
            tagsFirstOccurrence = o.tagsFirstOccurrence;
            currentTime = o.currentTime;
            measuredEnergyDetails = o.measuredEnergyDetails;
            energyConsumerDetails = o.energyConsumerDetails;
            cpuUsageDetails = o.cpuUsageDetails;
        }

@@ -2858,7 +2864,7 @@ public abstract class BatteryStats {
     *
     * {@hide}
     */
    public abstract long getBluetoothMeasuredBatteryConsumptionUC();
    public abstract long getBluetoothEnergyConsumptionUC();

    /**
     * Returns the battery consumption (in microcoulombs) of the cpu, derived from on device power
@@ -2867,7 +2873,7 @@ public abstract class BatteryStats {
     *
     * {@hide}
     */
    public abstract long getCpuMeasuredBatteryConsumptionUC();
    public abstract long getCpuEnergyConsumptionUC();

    /**
     * Returns the battery consumption (in microcoulombs) of the GNSS, derived from on device power
@@ -2876,7 +2882,7 @@ public abstract class BatteryStats {
     *
     * {@hide}
     */
    public abstract long getGnssMeasuredBatteryConsumptionUC();
    public abstract long getGnssEnergyConsumptionUC();

    /**
     * Returns the battery consumption (in microcoulombs) of the radio, derived from on device power
@@ -2885,7 +2891,7 @@ public abstract class BatteryStats {
     *
     * {@hide}
     */
    public abstract long getMobileRadioMeasuredBatteryConsumptionUC();
    public abstract long getMobileRadioEnergyConsumptionUC();

    /**
     * Returns the battery consumption (in microcoulombs) of the screen while on, derived from on
@@ -2894,7 +2900,7 @@ public abstract class BatteryStats {
     *
     * {@hide}
     */
    public abstract long getScreenOnMeasuredBatteryConsumptionUC();
    public abstract long getScreenOnEnergyConsumptionUC();

    /**
     * Returns the battery consumption (in microcoulombs) of the screen in doze, derived from on
@@ -2903,7 +2909,7 @@ public abstract class BatteryStats {
     *
     * {@hide}
     */
    public abstract long getScreenDozeMeasuredBatteryConsumptionUC();
    public abstract long getScreenDozeEnergyConsumptionUC();

    /**
     * Returns the battery consumption (in microcoulombs) of wifi, derived from on
@@ -2912,7 +2918,7 @@ public abstract class BatteryStats {
     *
     * {@hide}
     */
    public abstract long getWifiMeasuredBatteryConsumptionUC();
    public abstract long getWifiEnergyConsumptionUC();

    /**
     * Returns the battery consumption (in microcoulombs) that each
@@ -2924,7 +2930,7 @@ public abstract class BatteryStats {
     *
     * {@hide}
     */
    public abstract @Nullable long[] getCustomConsumerMeasuredBatteryConsumptionUC();
    public abstract @Nullable long[] getCustomEnergyConsumerBatteryConsumptionUC();

    /**
     * Returns the names of all {@link android.hardware.power.stats.EnergyConsumer}'s
@@ -7088,19 +7094,19 @@ public abstract class BatteryStats {
                    }
                }
                boolean firstExtension = true;
                if (rec.measuredEnergyDetails != null) {
                if (rec.energyConsumerDetails != null) {
                    firstExtension = false;
                    if (!checkin) {
                        item.append(" ext=energy:");
                        item.append(rec.measuredEnergyDetails);
                        item.append(rec.energyConsumerDetails);
                    } else {
                        item.append(",XE");
                        for (int i = 0; i < rec.measuredEnergyDetails.consumers.length; i++) {
                            if (rec.measuredEnergyDetails.chargeUC[i] != POWER_DATA_UNAVAILABLE) {
                        for (int i = 0; i < rec.energyConsumerDetails.consumers.length; i++) {
                            if (rec.energyConsumerDetails.chargeUC[i] != POWER_DATA_UNAVAILABLE) {
                                item.append(',');
                                item.append(rec.measuredEnergyDetails.consumers[i].name);
                                item.append(rec.energyConsumerDetails.consumers[i].name);
                                item.append('=');
                                item.append(rec.measuredEnergyDetails.chargeUC[i]);
                                item.append(rec.energyConsumerDetails.chargeUC[i]);
                            }
                        }
                    }
+13 −13
Original line number Diff line number Diff line
@@ -22,10 +22,10 @@ import android.os.BatteryManager;
import android.os.BatteryStats;
import android.os.BatteryStats.BitDescription;
import android.os.BatteryStats.CpuUsageDetails;
import android.os.BatteryStats.EnergyConsumerDetails;
import android.os.BatteryStats.HistoryItem;
import android.os.BatteryStats.HistoryStepDetails;
import android.os.BatteryStats.HistoryTag;
import android.os.BatteryStats.MeasuredEnergyDetails;
import android.os.Build;
import android.os.Parcel;
import android.os.ParcelFormatException;
@@ -984,9 +984,9 @@ public class BatteryStatsHistory {
    /**
     * Records measured energy data.
     */
    public void recordMeasuredEnergyDetails(long elapsedRealtimeMs, long uptimeMs,
            MeasuredEnergyDetails measuredEnergyDetails) {
        mHistoryCur.measuredEnergyDetails = measuredEnergyDetails;
    public void recordEnergyConsumerDetails(long elapsedRealtimeMs, long uptimeMs,
            EnergyConsumerDetails energyConsumerDetails) {
        mHistoryCur.energyConsumerDetails = energyConsumerDetails;
        mHistoryCur.states2 |= HistoryItem.STATE2_EXTENSIONS_FLAG;
        writeHistoryItem(elapsedRealtimeMs, uptimeMs);
    }
@@ -1293,7 +1293,7 @@ public class BatteryStatsHistory {
                && mHistoryLastWritten.batteryPlugType == cur.batteryPlugType
                && mHistoryLastWritten.batteryTemperature == cur.batteryTemperature
                && mHistoryLastWritten.batteryVoltage == cur.batteryVoltage
                && mHistoryLastWritten.measuredEnergyDetails == null
                && mHistoryLastWritten.energyConsumerDetails == null
                && mHistoryLastWritten.cpuUsageDetails == null) {
            // We can merge this new change in with the last one.  Merging is
            // allowed as long as only the states have changed, and within those states
@@ -1396,7 +1396,7 @@ public class BatteryStatsHistory {
        cur.eventCode = HistoryItem.EVENT_NONE;
        cur.eventTag = null;
        cur.tagsFirstOccurrence = false;
        cur.measuredEnergyDetails = null;
        cur.energyConsumerDetails = null;
        cur.cpuUsageDetails = null;
        if (DEBUG) {
            Slog.i(TAG, "Writing history buffer: was " + mHistoryBufferLastPos
@@ -1517,7 +1517,7 @@ public class BatteryStatsHistory {
        if (stateIntChanged) {
            firstToken |= BatteryStatsHistory.DELTA_STATE_FLAG;
        }
        if (cur.measuredEnergyDetails != null) {
        if (cur.energyConsumerDetails != null) {
            extensionFlags |= BatteryStatsHistory.EXTENSION_MEASURED_ENERGY_FLAG;
            if (!mMeasuredEnergyHeaderWritten) {
                extensionFlags |= BatteryStatsHistory.EXTENSION_MEASURED_ENERGY_HEADER_FLAG;
@@ -1653,22 +1653,22 @@ public class BatteryStatsHistory {
        dest.writeDouble(cur.wifiRailChargeMah);
        if (extensionFlags != 0) {
            dest.writeInt(extensionFlags);
            if (cur.measuredEnergyDetails != null) {
            if (cur.energyConsumerDetails != null) {
                if (DEBUG) {
                    Slog.i(TAG, "WRITE DELTA: measuredEnergyDetails=" + cur.measuredEnergyDetails);
                    Slog.i(TAG, "WRITE DELTA: measuredEnergyDetails=" + cur.energyConsumerDetails);
                }
                if (!mMeasuredEnergyHeaderWritten) {
                    MeasuredEnergyDetails.EnergyConsumer[] consumers =
                            cur.measuredEnergyDetails.consumers;
                    EnergyConsumerDetails.EnergyConsumer[] consumers =
                            cur.energyConsumerDetails.consumers;
                    dest.writeInt(consumers.length);
                    for (MeasuredEnergyDetails.EnergyConsumer consumer : consumers) {
                    for (EnergyConsumerDetails.EnergyConsumer consumer : consumers) {
                        dest.writeInt(consumer.type);
                        dest.writeInt(consumer.ordinal);
                        dest.writeString(consumer.name);
                    }
                    mMeasuredEnergyHeaderWritten = true;
                }
                mVarintParceler.writeLongArray(dest, cur.measuredEnergyDetails.chargeUC);
                mVarintParceler.writeLongArray(dest, cur.energyConsumerDetails.chargeUC);
            }

            if (cur.cpuUsageDetails != null) {
+14 −14
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ public class BatteryStatsHistoryIterator implements Iterator<BatteryStats.Histor
    private final BatteryStats.HistoryStepDetails mReadHistoryStepDetails =
            new BatteryStats.HistoryStepDetails();
    private final SparseArray<BatteryStats.HistoryTag> mHistoryTags = new SparseArray<>();
    private BatteryStats.MeasuredEnergyDetails mMeasuredEnergyDetails;
    private BatteryStats.EnergyConsumerDetails mEnergyConsumerDetails;
    private BatteryStats.CpuUsageDetails mCpuUsageDetails;
    private final BatteryStatsHistory.VarintParceler mVarintParceler =
            new BatteryStatsHistory.VarintParceler();
@@ -230,8 +230,8 @@ public class BatteryStatsHistoryIterator implements Iterator<BatteryStats.Histor
        if ((cur.states2 & BatteryStats.HistoryItem.STATE2_EXTENSIONS_FLAG) != 0) {
            final int extensionFlags = src.readInt();
            if ((extensionFlags & BatteryStatsHistory.EXTENSION_MEASURED_ENERGY_HEADER_FLAG) != 0) {
                if (mMeasuredEnergyDetails == null) {
                    mMeasuredEnergyDetails = new BatteryStats.MeasuredEnergyDetails();
                if (mEnergyConsumerDetails == null) {
                    mEnergyConsumerDetails = new BatteryStats.EnergyConsumerDetails();
                }

                final int consumerCount = src.readInt();
@@ -241,28 +241,28 @@ public class BatteryStatsHistoryIterator implements Iterator<BatteryStats.Histor
                            "EnergyConsumer count too high: " + consumerCount
                                    + ". Max = " + MAX_ENERGY_CONSUMER_COUNT);
                }
                mMeasuredEnergyDetails.consumers =
                        new BatteryStats.MeasuredEnergyDetails.EnergyConsumer[consumerCount];
                mMeasuredEnergyDetails.chargeUC = new long[consumerCount];
                mEnergyConsumerDetails.consumers =
                        new BatteryStats.EnergyConsumerDetails.EnergyConsumer[consumerCount];
                mEnergyConsumerDetails.chargeUC = new long[consumerCount];
                for (int i = 0; i < consumerCount; i++) {
                    BatteryStats.MeasuredEnergyDetails.EnergyConsumer consumer =
                            new BatteryStats.MeasuredEnergyDetails.EnergyConsumer();
                    BatteryStats.EnergyConsumerDetails.EnergyConsumer consumer =
                            new BatteryStats.EnergyConsumerDetails.EnergyConsumer();
                    consumer.type = src.readInt();
                    consumer.ordinal = src.readInt();
                    consumer.name = src.readString();
                    mMeasuredEnergyDetails.consumers[i] = consumer;
                    mEnergyConsumerDetails.consumers[i] = consumer;
                }
            }

            if ((extensionFlags & BatteryStatsHistory.EXTENSION_MEASURED_ENERGY_FLAG) != 0) {
                if (mMeasuredEnergyDetails == null) {
                if (mEnergyConsumerDetails == null) {
                    throw new IllegalStateException("MeasuredEnergyDetails without a header");
                }

                mVarintParceler.readLongArray(src, mMeasuredEnergyDetails.chargeUC);
                cur.measuredEnergyDetails = mMeasuredEnergyDetails;
                mVarintParceler.readLongArray(src, mEnergyConsumerDetails.chargeUC);
                cur.energyConsumerDetails = mEnergyConsumerDetails;
            } else {
                cur.measuredEnergyDetails = null;
                cur.energyConsumerDetails = null;
            }

            if ((extensionFlags & BatteryStatsHistory.EXTENSION_CPU_USAGE_HEADER_FLAG) != 0) {
@@ -295,7 +295,7 @@ public class BatteryStatsHistoryIterator implements Iterator<BatteryStats.Histor
                cur.cpuUsageDetails = null;
            }
        } else {
            cur.measuredEnergyDetails = null;
            cur.energyConsumerDetails = null;
            cur.cpuUsageDetails = null;
        }
    }
+17 −17
Original line number Diff line number Diff line
@@ -37,15 +37,14 @@ import java.lang.annotation.RetentionPolicy;
import java.util.Arrays;

/**
 * Tracks the measured charge consumption of various subsystems according to their
 * Tracks the charge consumption of various subsystems according to their
 * {@link StandardPowerBucket} or custom power bucket (which is tied to
 * {@link android.hardware.power.stats.EnergyConsumer.ordinal}).
 *
 * This class doesn't use a TimeBase, and instead requires manually decisions about when to
 * This class doesn't use a TimeBase, and instead requires manual decisions about when to
 * accumulate since it is trivial. However, in the future, a TimeBase could be used instead.
 */
@VisibleForTesting
public class MeasuredEnergyStats {
public class EnergyConsumerStats {
    private static final String TAG = "MeasuredEnergyStats";

    // Note: {@link BatteryStats#VERSION} MUST be updated if standard
@@ -205,7 +204,7 @@ public class MeasuredEnergyStats {
         */
        private String getBucketName(int index) {
            if (isValidStandardBucket(index)) {
                return DebugUtils.valueToString(MeasuredEnergyStats.class, "POWER_BUCKET_", index);
                return DebugUtils.valueToString(EnergyConsumerStats.class, "POWER_BUCKET_", index);
            }
            final int customBucket = indexToCustomBucket(index);
            StringBuilder name = new StringBuilder().append("CUSTOM_").append(customBucket);
@@ -242,7 +241,7 @@ public class MeasuredEnergyStats {
     * supportedStandardBuckets must be of size {@link #NUMBER_STANDARD_POWER_BUCKETS}.
     * numCustomBuckets >= 0 is the number of (non-standard) custom power buckets on the device.
     */
    public MeasuredEnergyStats(MeasuredEnergyStats.Config config) {
    public EnergyConsumerStats(EnergyConsumerStats.Config config) {
        mConfig = config;
        final int numTotalBuckets = config.getNumberOfBuckets();
        mAccumulatedChargeMicroCoulomb = new long[numTotalBuckets];
@@ -259,15 +258,15 @@ public class MeasuredEnergyStats {
     * Reads a MeasuredEnergyStats from the supplied Parcel.
     */
    @Nullable
    public static MeasuredEnergyStats createFromParcel(Config config, Parcel in) {
    public static EnergyConsumerStats createFromParcel(Config config, Parcel in) {
        if (!in.readBoolean()) {
            return null;
        }
        return new MeasuredEnergyStats(config, in);
        return new EnergyConsumerStats(config, in);
    }

    /** Construct from parcel. */
    public MeasuredEnergyStats(MeasuredEnergyStats.Config config, Parcel in) {
    public EnergyConsumerStats(EnergyConsumerStats.Config config, Parcel in) {
        mConfig = config;

        final int size = in.readInt();
@@ -533,21 +532,22 @@ public class MeasuredEnergyStats {
     * possible (not necessarily supported) standard and custom buckets.
     *
     * Corresponding write performed by
     * {@link #writeSummaryToParcel(MeasuredEnergyStats, Parcel)}.
     * {@link #writeSummaryToParcel(EnergyConsumerStats, Parcel)}.
     *
     * @return a new MeasuredEnergyStats object as described.
     *         Returns null if the stats contain no non-0 information (such as if template is null
     *         or if the parcel indicates there is no data to populate).
     */
    public static @Nullable MeasuredEnergyStats createAndReadSummaryFromParcel(
            @Nullable Config config, Parcel in) {
    @Nullable
    public static EnergyConsumerStats createAndReadSummaryFromParcel(@Nullable Config config,
            Parcel in) {
        final int arraySize = in.readInt();
        // Check if any MeasuredEnergyStats exists on the parcel
        if (arraySize == 0) return null;

        if (config == null) {
            // Nothing supported anymore. Create placeholder object just to consume the parcel data.
            final MeasuredEnergyStats mes = new MeasuredEnergyStats(
            final EnergyConsumerStats mes = new EnergyConsumerStats(
                    new Config(new boolean[arraySize], null, new int[0], new String[]{""}));
            mes.readSummaryFromParcel(in);
            return null;
@@ -557,12 +557,12 @@ public class MeasuredEnergyStats {
            Slog.wtf(TAG, "Size of MeasuredEnergyStats parcel (" + arraySize
                    + ") does not match config (" + config.getNumberOfBuckets() + ").");
            // Something is horribly wrong. Just consume the parcel and return null.
            final MeasuredEnergyStats mes = new MeasuredEnergyStats(config);
            final EnergyConsumerStats mes = new EnergyConsumerStats(config);
            mes.readSummaryFromParcel(in);
            return null;
        }

        final MeasuredEnergyStats stats = new MeasuredEnergyStats(config);
        final EnergyConsumerStats stats = new EnergyConsumerStats(config);
        stats.readSummaryFromParcel(in);
        if (stats.containsInterestingData()) {
            return stats;
@@ -585,7 +585,7 @@ public class MeasuredEnergyStats {
     *
     * Corresponding read performed by {@link #createAndReadSummaryFromParcel}.
     */
    public static void writeSummaryToParcel(@Nullable MeasuredEnergyStats stats, Parcel dest) {
    public static void writeSummaryToParcel(@Nullable EnergyConsumerStats stats, Parcel dest) {
        if (stats == null) {
            dest.writeInt(0);
            return;
@@ -607,7 +607,7 @@ public class MeasuredEnergyStats {
    }

    /** Reset accumulated charges of the given stats. */
    public static void resetIfNotNull(@Nullable MeasuredEnergyStats stats) {
    public static void resetIfNotNull(@Nullable EnergyConsumerStats stats) {
        if (stats != null) stats.reset();
    }

Loading