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

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

Merge "Ignore attribution data for unsupported custom power components" into main

parents 917810cd 4d9a352a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -869,6 +869,16 @@ public final class BatteryUsageStats implements Parcelable, Closeable {
            return mIncludesProcessStateData;
        }

        /**
         * Returns true if this Builder is configured to hold data for the specified
         * custom power component ID.
         */
        public boolean isSupportedCustomPowerComponent(int componentId) {
            return componentId >= BatteryConsumer.FIRST_CUSTOM_POWER_COMPONENT_ID
                    && componentId < BatteryConsumer.FIRST_CUSTOM_POWER_COMPONENT_ID
                    + mBatteryConsumerDataLayout.customPowerComponentCount;
        }

        /**
         * Constructs a read-only object using the Builder values.
         */
+5 −2
Original line number Diff line number Diff line
@@ -154,8 +154,11 @@ public class PowerStatsExporter {
                batteryUsageStatsBuilder.getAggregateBatteryConsumerBuilder(
                        BatteryUsageStats.AGGREGATE_BATTERY_CONSUMER_SCOPE_DEVICE);
        if (descriptor.powerComponentId >= BatteryConsumer.FIRST_CUSTOM_POWER_COMPONENT_ID) {
            if (batteryUsageStatsBuilder.isSupportedCustomPowerComponent(
                    descriptor.powerComponentId)) {
                deviceScope.addConsumedPowerForCustomComponent(descriptor.powerComponentId,
                        totalPower[0]);
            }
        } else {
            deviceScope.addConsumedPower(descriptor.powerComponentId,
                    totalPower[0], BatteryConsumer.POWER_MODEL_UNDEFINED);