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

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

Merge "Implement a PowerCalculator to attribute system service power to apps"

parents f13bc467 6c3defc2
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -743,6 +743,12 @@ public abstract class BatteryStats implements Parcelable {
        @UnsupportedAppUsage
        public abstract ArrayMap<String, ? extends Pkg> getPackageStats();

        /**
         * Returns the proportion of power consumed by the System Service
         * calls made by this UID.
         */
        public abstract double getProportionalSystemServiceUsage();

        public abstract ControllerActivityCounter getWifiControllerActivity();
        public abstract ControllerActivityCounter getBluetoothControllerActivity();
        public abstract ControllerActivityCounter getModemControllerActivity();
@@ -2881,6 +2887,17 @@ public abstract class BatteryStats implements Parcelable {
     */
    public abstract int getDischargeAmountScreenDozeSinceCharge();

    /**
     * Returns the approximate CPU time (in microseconds) spent by the system server handling
     * incoming service calls from apps.
     *
     * @param cluster the index of the CPU cluster.
     * @param step the index of the CPU speed. This is not the actual speed of the CPU.
     * @see com.android.internal.os.PowerProfile#getNumCpuClusters()
     * @see com.android.internal.os.PowerProfile#getNumSpeedStepsInCpuCluster(int)
     */
    public abstract long getSystemServiceTimeAtCpuSpeed(int cluster, int step);

    /**
     * Returns the total, last, or current battery uptime in microseconds.
     *
+4 −1
Original line number Diff line number Diff line
@@ -129,6 +129,7 @@ public class BatterySipper implements Comparable<BatterySipper> {
    public double videoPowerMah;
    public double wakeLockPowerMah;
    public double wifiPowerMah;
    public double systemServiceCpuPowerMah;

    //                           ****************
    // This list must be kept current with atoms.proto (frameworks/base/cmds/statsd/src/atoms.proto)
@@ -242,6 +243,7 @@ public class BatterySipper implements Comparable<BatterySipper> {
        videoPowerMah += other.videoPowerMah;
        proportionalSmearMah += other.proportionalSmearMah;
        totalSmearedPowerMah += other.totalSmearedPowerMah;
        systemServiceCpuPowerMah += other.systemServiceCpuPowerMah;
    }

    /**
@@ -253,7 +255,8 @@ public class BatterySipper implements Comparable<BatterySipper> {
    public double sumPower() {
        totalPowerMah = usagePowerMah + wifiPowerMah + gpsPowerMah + cpuPowerMah +
                sensorPowerMah + mobileRadioPowerMah + wakeLockPowerMah + cameraPowerMah +
                flashlightPowerMah + bluetoothPowerMah + audioPowerMah + videoPowerMah;
                flashlightPowerMah + bluetoothPowerMah + audioPowerMah + videoPowerMah
                + systemServiceCpuPowerMah;
        totalSmearedPowerMah = totalPowerMah + screenPowerMah + proportionalSmearMah;

        return totalPowerMah;
+8 −0
Original line number Diff line number Diff line
@@ -133,6 +133,7 @@ public class BatteryStatsHelper {
    private double mMaxDrainedPower;

    PowerCalculator mCpuPowerCalculator;
    SystemServicePowerCalculator mSystemServicePowerCalculator;
    PowerCalculator mWakelockPowerCalculator;
    MobileRadioPowerCalculator mMobileRadioPowerCalculator;
    PowerCalculator mWifiPowerCalculator;
@@ -396,6 +397,11 @@ public class BatteryStatsHelper {
        }
        mCpuPowerCalculator.reset();

        if (mSystemServicePowerCalculator == null) {
            mSystemServicePowerCalculator = new SystemServicePowerCalculator(mPowerProfile, mStats);
        }
        mSystemServicePowerCalculator.reset();

        if (mMemoryPowerCalculator == null) {
            mMemoryPowerCalculator = new MemoryPowerCalculator(mPowerProfile);
        }
@@ -588,6 +594,8 @@ public class BatteryStatsHelper {
            mFlashlightPowerCalculator.calculateApp(app, u, mRawRealtimeUs, mRawUptimeUs,
                    mStatsType);
            mMediaPowerCalculator.calculateApp(app, u, mRawRealtimeUs, mRawUptimeUs, mStatsType);
            mSystemServicePowerCalculator.calculateApp(app, u, mRawRealtimeUs, mRawUptimeUs,
                    mStatsType);

            final double totalPower = app.sumPower();
            if (DEBUG && totalPower != 0) {
+363 −97

File changed.

Preview size limit exceeded, changes collapsed.

+2 −1
Original line number Diff line number Diff line
@@ -115,7 +115,8 @@ public class BinderCallsStats implements BinderInternal.Observer {
                    if (uidEntry != null) {
                        ArrayMap<CallStatKey, CallStat> callStats = uidEntry.mCallStats;
                        mCallStatsObserver.noteCallStats(uidEntry.workSourceUid,
                                uidEntry.incrementalCallCount, callStats.values());
                                uidEntry.incrementalCallCount, callStats.values(),
                                mNativeTids.toArray());
                        uidEntry.incrementalCallCount = 0;
                        for (int j = callStats.size() - 1; j >= 0; j--) {
                            callStats.valueAt(j).incrementalCallCount = 0;
Loading