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

Commit bc6125a9 authored by Dmitri Plotnikov's avatar Dmitri Plotnikov
Browse files

Introduce PowerStatsProcessor for phone calls

Bug: 323970018
Test: atest FrameworksServicesTests PowerStatsTests
Test: atest --host FrameworksServicesTestsRavenwood PowerStatsTestsRavenwood

Change-Id: Icdcd6f2b1dfee5f092834e2c54a50a4fd8f8bdd8
parent f925a76e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ import com.android.server.power.stats.BatteryStatsImpl;
import com.android.server.power.stats.BatteryUsageStatsProvider;
import com.android.server.power.stats.CpuAggregatedPowerStatsProcessor;
import com.android.server.power.stats.MobileRadioAggregatedPowerStatsProcessor;
import com.android.server.power.stats.PhoneCallAggregatedPowerStatsProcessor;
import com.android.server.power.stats.PowerStatsAggregator;
import com.android.server.power.stats.PowerStatsExporter;
import com.android.server.power.stats.PowerStatsScheduler;
@@ -489,6 +490,9 @@ public final class BatteryStatsService extends IBatteryStats.Stub
                        AggregatedPowerStatsConfig.STATE_PROCESS_STATE)
                .setProcessor(
                        new MobileRadioAggregatedPowerStatsProcessor(mPowerProfile));
        config.trackPowerComponent(BatteryConsumer.POWER_COMPONENT_PHONE,
                        BatteryConsumer.POWER_COMPONENT_MOBILE_RADIO)
                .setProcessor(new PhoneCallAggregatedPowerStatsProcessor());
        return config;
    }

+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ class AggregatedPowerStats {
                aggregatedPowerStatsConfig.getPowerComponentsAggregatedStatsConfigs();
        mPowerComponentStats = new PowerComponentAggregatedPowerStats[configs.size()];
        for (int i = 0; i < configs.size(); i++) {
            mPowerComponentStats[i] = new PowerComponentAggregatedPowerStats(configs.get(i));
            mPowerComponentStats[i] = new PowerComponentAggregatedPowerStats(this, configs.get(i));
        }
    }

+34 −0
Original line number Diff line number Diff line
@@ -85,6 +85,9 @@ public class AggregatedPowerStatsConfig {
         * Configures which states should be tracked as separate dimensions for the entire device.
         */
        public PowerComponent trackDeviceStates(@TrackedState int... states) {
            if (mTrackedDeviceStates != null) {
                throw new IllegalStateException("Component is already configured");
            }
            mTrackedDeviceStates = states;
            return this;
        }
@@ -93,6 +96,9 @@ public class AggregatedPowerStatsConfig {
         * Configures which states should be tracked as separate dimensions on a per-UID basis.
         */
        public PowerComponent trackUidStates(@TrackedState int... states) {
            if (mTrackedUidStates != null) {
                throw new IllegalStateException("Component is already configured");
            }
            mTrackedUidStates = states;
            return this;
        }
@@ -153,6 +159,7 @@ public class AggregatedPowerStatsConfig {
            }
            return false;
        }

    }

    private final List<PowerComponent> mPowerComponents = new ArrayList<>();
@@ -168,6 +175,33 @@ public class AggregatedPowerStatsConfig {
        return builder;
    }

    /**
     * Creates a configuration for the specified power component, which is a subcomponent
     * of a different power component.  The tracked states will be the same as the parent
     * component's.
     */
    public PowerComponent trackPowerComponent(int powerComponentId,
            int parentPowerComponentId) {
        PowerComponent parent = null;
        for (int i = 0; i < mPowerComponents.size(); i++) {
            PowerComponent powerComponent = mPowerComponents.get(i);
            if (powerComponent.getPowerComponentId() == parentPowerComponentId) {
                parent = powerComponent;
                break;
            }
        }

        if (parent == null) {
            throw new IllegalArgumentException(
                    "Parent component " + parentPowerComponentId + " is not configured");
        }

        PowerComponent powerComponent = trackPowerComponent(powerComponentId);
        powerComponent.mTrackedDeviceStates = parent.mTrackedDeviceStates;
        powerComponent.mTrackedUidStates = parent.mTrackedUidStates;
        return powerComponent;
    }

    public List<PowerComponent> getPowerComponentsAggregatedStatsConfigs() {
        return mPowerComponents;
    }
+1 −2
Original line number Diff line number Diff line
@@ -405,8 +405,7 @@ public class MobileRadioAggregatedPowerStatsProcessor extends AggregatedPowerSta
        return "idle: " + mStatsLayout.getDeviceIdleTime(stats)
                + " sleep: " + mStatsLayout.getDeviceSleepTime(stats)
                + " scan: " + mStatsLayout.getDeviceScanTime(stats)
                + " power-data: " + mStatsLayout.getDevicePowerEstimate(stats)
                + " power-call: " + mStatsLayout.getDeviceCallPowerEstimate(stats);
                + " power: " + mStatsLayout.getDevicePowerEstimate(stats);
    }

    @Override
+1 −1
Original line number Diff line number Diff line
@@ -140,7 +140,7 @@ public class MobileRadioPowerStatsCollector extends PowerStatsCollector {
        MobileRadioStatsArrayLayout() {}

        MobileRadioStatsArrayLayout(@NonNull PowerStats.Descriptor descriptor) {
            fromExtras(descriptor.extras);
            super(descriptor);
        }

        void addDeviceMobileActivity() {
Loading