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

Commit 62eb3013 authored by Michael Wachenschwanz's avatar Michael Wachenschwanz Committed by Android Build Coastguard Worker
Browse files

Revert "Add power stats collector and processor for Camera and GNSS"

This reverts commit 5be91008.

Reason for revert: b/356723894
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:7b93613dbc30f0d2b718490047636696b5bb62c0)
Merged-In: I9d127507fb50a0aad27af9dcf4e30785eb378594
Change-Id: I9d127507fb50a0aad27af9dcf4e30785eb378594
parent 7e5d57fa
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -200,8 +200,6 @@ public abstract class BatteryConsumer {
            POWER_COMPONENT_AUDIO,
            POWER_COMPONENT_AUDIO,
            POWER_COMPONENT_VIDEO,
            POWER_COMPONENT_VIDEO,
            POWER_COMPONENT_FLASHLIGHT,
            POWER_COMPONENT_FLASHLIGHT,
            POWER_COMPONENT_CAMERA,
            POWER_COMPONENT_GNSS,
    };
    };


    static final int COLUMN_INDEX_BATTERY_CONSUMER_TYPE = 0;
    static final int COLUMN_INDEX_BATTERY_CONSUMER_TYPE = 0;
+1 −2
Original line number Original line Diff line number Diff line
@@ -1994,8 +1994,7 @@ public abstract class BatteryStats {


        // STATES2 bits that are used for Power Stats tracking
        // STATES2 bits that are used for Power Stats tracking
        public static final int IMPORTANT_FOR_POWER_STATS_STATES2 =
        public static final int IMPORTANT_FOR_POWER_STATS_STATES2 =
                STATE2_VIDEO_ON_FLAG | STATE2_FLASHLIGHT_FLAG | STATE2_CAMERA_FLAG
                STATE2_VIDEO_ON_FLAG | STATE2_FLASHLIGHT_FLAG | STATE2_CAMERA_FLAG;
                | STATE2_GPS_SIGNAL_QUALITY_MASK;


        @UnsupportedAppUsage
        @UnsupportedAppUsage
        public int states2;
        public int states2;
+7 −33
Original line number Original line Diff line number Diff line
@@ -128,10 +128,8 @@ import com.android.server.power.stats.BatteryStatsDumpHelperImpl;
import com.android.server.power.stats.BatteryStatsImpl;
import com.android.server.power.stats.BatteryStatsImpl;
import com.android.server.power.stats.BatteryUsageStatsProvider;
import com.android.server.power.stats.BatteryUsageStatsProvider;
import com.android.server.power.stats.BluetoothPowerStatsProcessor;
import com.android.server.power.stats.BluetoothPowerStatsProcessor;
import com.android.server.power.stats.CameraPowerStatsProcessor;
import com.android.server.power.stats.CpuPowerStatsProcessor;
import com.android.server.power.stats.CpuPowerStatsProcessor;
import com.android.server.power.stats.FlashlightPowerStatsProcessor;
import com.android.server.power.stats.FlashlightPowerStatsProcessor;
import com.android.server.power.stats.GnssPowerStatsProcessor;
import com.android.server.power.stats.MobileRadioPowerStatsProcessor;
import com.android.server.power.stats.MobileRadioPowerStatsProcessor;
import com.android.server.power.stats.PhoneCallPowerStatsProcessor;
import com.android.server.power.stats.PhoneCallPowerStatsProcessor;
import com.android.server.power.stats.PowerStatsAggregator;
import com.android.server.power.stats.PowerStatsAggregator;
@@ -530,19 +528,10 @@ public final class BatteryStatsService extends IBatteryStats.Stub
                        AggregatedPowerStatsConfig.STATE_SCREEN,
                        AggregatedPowerStatsConfig.STATE_SCREEN,
                        AggregatedPowerStatsConfig.STATE_PROCESS_STATE)
                        AggregatedPowerStatsConfig.STATE_PROCESS_STATE)
                .setProcessor(
                .setProcessor(
                        new AudioPowerStatsProcessor(mPowerProfile, mPowerStatsUidResolver));
                        new AudioPowerStatsProcessor(mPowerProfile,
                                mPowerStatsUidResolver));


        config.trackPowerComponent(BatteryConsumer.POWER_COMPONENT_VIDEO)
        config.trackPowerComponent(BatteryConsumer.POWER_COMPONENT_VIDEO)
                .trackDeviceStates(
                        AggregatedPowerStatsConfig.STATE_POWER,
                        AggregatedPowerStatsConfig.STATE_SCREEN)
                .trackUidStates(
                        AggregatedPowerStatsConfig.STATE_POWER,
                        AggregatedPowerStatsConfig.STATE_SCREEN,
                        AggregatedPowerStatsConfig.STATE_PROCESS_STATE)
                .setProcessor(new VideoPowerStatsProcessor(mPowerProfile, mPowerStatsUidResolver));

        config.trackPowerComponent(BatteryConsumer.POWER_COMPONENT_FLASHLIGHT)
                .trackDeviceStates(
                .trackDeviceStates(
                        AggregatedPowerStatsConfig.STATE_POWER,
                        AggregatedPowerStatsConfig.STATE_POWER,
                        AggregatedPowerStatsConfig.STATE_SCREEN)
                        AggregatedPowerStatsConfig.STATE_SCREEN)
@@ -551,20 +540,10 @@ public final class BatteryStatsService extends IBatteryStats.Stub
                        AggregatedPowerStatsConfig.STATE_SCREEN,
                        AggregatedPowerStatsConfig.STATE_SCREEN,
                        AggregatedPowerStatsConfig.STATE_PROCESS_STATE)
                        AggregatedPowerStatsConfig.STATE_PROCESS_STATE)
                .setProcessor(
                .setProcessor(
                        new FlashlightPowerStatsProcessor(mPowerProfile, mPowerStatsUidResolver));
                        new VideoPowerStatsProcessor(mPowerProfile,
                                mPowerStatsUidResolver));


        config.trackPowerComponent(BatteryConsumer.POWER_COMPONENT_CAMERA)
        config.trackPowerComponent(BatteryConsumer.POWER_COMPONENT_FLASHLIGHT)
                .trackDeviceStates(
                        AggregatedPowerStatsConfig.STATE_POWER,
                        AggregatedPowerStatsConfig.STATE_SCREEN)
                .trackUidStates(
                        AggregatedPowerStatsConfig.STATE_POWER,
                        AggregatedPowerStatsConfig.STATE_SCREEN,
                        AggregatedPowerStatsConfig.STATE_PROCESS_STATE)
                .setProcessor(
                        new CameraPowerStatsProcessor(mPowerProfile, mPowerStatsUidResolver));

        config.trackPowerComponent(BatteryConsumer.POWER_COMPONENT_GNSS)
                .trackDeviceStates(
                .trackDeviceStates(
                        AggregatedPowerStatsConfig.STATE_POWER,
                        AggregatedPowerStatsConfig.STATE_POWER,
                        AggregatedPowerStatsConfig.STATE_SCREEN)
                        AggregatedPowerStatsConfig.STATE_SCREEN)
@@ -573,7 +552,8 @@ public final class BatteryStatsService extends IBatteryStats.Stub
                        AggregatedPowerStatsConfig.STATE_SCREEN,
                        AggregatedPowerStatsConfig.STATE_SCREEN,
                        AggregatedPowerStatsConfig.STATE_PROCESS_STATE)
                        AggregatedPowerStatsConfig.STATE_PROCESS_STATE)
                .setProcessor(
                .setProcessor(
                        new GnssPowerStatsProcessor(mPowerProfile, mPowerStatsUidResolver));
                        new FlashlightPowerStatsProcessor(mPowerProfile,
                                mPowerStatsUidResolver));
        return config;
        return config;
    }
    }


@@ -659,12 +639,6 @@ public final class BatteryStatsService extends IBatteryStats.Stub
                BatteryConsumer.POWER_COMPONENT_FLASHLIGHT,
                BatteryConsumer.POWER_COMPONENT_FLASHLIGHT,
                Flags.streamlinedMiscBatteryStats());
                Flags.streamlinedMiscBatteryStats());


        mStats.setPowerStatsCollectorEnabled(BatteryConsumer.POWER_COMPONENT_CAMERA,
                Flags.streamlinedMiscBatteryStats());
        mBatteryUsageStatsProvider.setPowerStatsExporterEnabled(
                BatteryConsumer.POWER_COMPONENT_CAMERA,
                Flags.streamlinedMiscBatteryStats());

        mWorker.systemServicesReady();
        mWorker.systemServicesReady();
        mStats.systemServicesReady(mContext);
        mStats.systemServicesReady(mContext);
        mCpuWakeupStats.systemServicesReady();
        mCpuWakeupStats.systemServicesReady();
+7 −45
Original line number Original line Diff line number Diff line
@@ -298,8 +298,6 @@ public class BatteryStatsImpl extends BatteryStats {
    private final MobileRadioPowerStatsCollector mMobileRadioPowerStatsCollector;
    private final MobileRadioPowerStatsCollector mMobileRadioPowerStatsCollector;
    private final WifiPowerStatsCollector mWifiPowerStatsCollector;
    private final WifiPowerStatsCollector mWifiPowerStatsCollector;
    private final BluetoothPowerStatsCollector mBluetoothPowerStatsCollector;
    private final BluetoothPowerStatsCollector mBluetoothPowerStatsCollector;
    private final CameraPowerStatsCollector mCameraPowerStatsCollector;
    private final GnssPowerStatsCollector mGnssPowerStatsCollector;
    private final SparseBooleanArray mPowerStatsCollectorEnabled = new SparseBooleanArray();
    private final SparseBooleanArray mPowerStatsCollectorEnabled = new SparseBooleanArray();
    private final WifiPowerStatsCollector.WifiStatsRetriever mWifiStatsRetriever =
    private final WifiPowerStatsCollector.WifiStatsRetriever mWifiStatsRetriever =
            new WifiPowerStatsCollector.WifiStatsRetriever() {
            new WifiPowerStatsCollector.WifiStatsRetriever() {
@@ -1965,7 +1963,7 @@ public class BatteryStatsImpl extends BatteryStats {
    private class PowerStatsCollectorInjector implements CpuPowerStatsCollector.Injector,
    private class PowerStatsCollectorInjector implements CpuPowerStatsCollector.Injector,
            MobileRadioPowerStatsCollector.Injector, WifiPowerStatsCollector.Injector,
            MobileRadioPowerStatsCollector.Injector, WifiPowerStatsCollector.Injector,
            BluetoothPowerStatsCollector.Injector, EnergyConsumerPowerStatsCollector.Injector {
            BluetoothPowerStatsCollector.Injector {
        private PackageManager mPackageManager;
        private PackageManager mPackageManager;
        private PowerStatsCollector.ConsumedEnergyRetriever mConsumedEnergyRetriever;
        private PowerStatsCollector.ConsumedEnergyRetriever mConsumedEnergyRetriever;
        private NetworkStatsManager mNetworkStatsManager;
        private NetworkStatsManager mNetworkStatsManager;
@@ -5448,10 +5446,7 @@ public class BatteryStatsImpl extends BatteryStats {
        final int mappedUid = mapUid(uid);
        final int mappedUid = mapUid(uid);
        if (mGpsNesting == 0) {
        if (mGpsNesting == 0) {
            mHistory.recordStateStartEvent(elapsedRealtimeMs, uptimeMs,
            mHistory.recordStateStartEvent(elapsedRealtimeMs, uptimeMs,
                    HistoryItem.STATE_GPS_ON_FLAG, uid, "gnss");
                    HistoryItem.STATE_GPS_ON_FLAG);
            if (mPowerStatsCollectorEnabled.get(BatteryConsumer.POWER_COMPONENT_GNSS)) {
                mGnssPowerStatsCollector.schedule();
            }
        }
        }
        mGpsNesting++;
        mGpsNesting++;
@@ -5470,14 +5465,11 @@ public class BatteryStatsImpl extends BatteryStats {
        mGpsNesting--;
        mGpsNesting--;
        if (mGpsNesting == 0) {
        if (mGpsNesting == 0) {
            mHistory.recordStateStopEvent(elapsedRealtimeMs, uptimeMs,
            mHistory.recordStateStopEvent(elapsedRealtimeMs, uptimeMs,
                    HistoryItem.STATE_GPS_ON_FLAG, uid, "gnss");
                    HistoryItem.STATE_GPS_ON_FLAG);
            mHistory.recordGpsSignalQualityEvent(elapsedRealtimeMs, uptimeMs,
            mHistory.recordGpsSignalQualityEvent(elapsedRealtimeMs, uptimeMs,
                    GPS_SIGNAL_QUALITY_NONE);
                    GPS_SIGNAL_QUALITY_NONE);
            stopAllGpsSignalQualityTimersLocked(-1, elapsedRealtimeMs);
            stopAllGpsSignalQualityTimersLocked(-1, elapsedRealtimeMs);
            mGpsSignalQualityBin = -1;
            mGpsSignalQualityBin = -1;
            if (mPowerStatsCollectorEnabled.get(BatteryConsumer.POWER_COMPONENT_GNSS)) {
                mGnssPowerStatsCollector.schedule();
            }
        }
        }
        mFrameworkStatsLogger.gpsScanStateChanged(mapIsolatedUid(uid), workChain, /* on */ false);
        mFrameworkStatsLogger.gpsScanStateChanged(mapIsolatedUid(uid), workChain, /* on */ false);
@@ -6660,18 +6652,14 @@ public class BatteryStatsImpl extends BatteryStats {
        uid = mapUid(uid);
        uid = mapUid(uid);
        if (mCameraOnNesting++ == 0) {
        if (mCameraOnNesting++ == 0) {
            mHistory.recordState2StartEvent(elapsedRealtimeMs, uptimeMs,
            mHistory.recordState2StartEvent(elapsedRealtimeMs, uptimeMs,
                    HistoryItem.STATE2_CAMERA_FLAG, uid, "camera");
                    HistoryItem.STATE2_CAMERA_FLAG);
            mCameraOnTimer.startRunningLocked(elapsedRealtimeMs);
            mCameraOnTimer.startRunningLocked(elapsedRealtimeMs);
        }
        }
        getUidStatsLocked(uid, elapsedRealtimeMs, uptimeMs)
        getUidStatsLocked(uid, elapsedRealtimeMs, uptimeMs)
                .noteCameraTurnedOnLocked(elapsedRealtimeMs);
                .noteCameraTurnedOnLocked(elapsedRealtimeMs);
        if (mPowerStatsCollectorEnabled.get(BatteryConsumer.POWER_COMPONENT_CAMERA)) {
            mCameraPowerStatsCollector.schedule();
        } else {
        scheduleSyncExternalStatsLocked("camera-on", ExternalStatsSync.UPDATE_CAMERA);
        scheduleSyncExternalStatsLocked("camera-on", ExternalStatsSync.UPDATE_CAMERA);
    }
    }
    }
    @GuardedBy("this")
    @GuardedBy("this")
    public void noteCameraOffLocked(int uid, long elapsedRealtimeMs, long uptimeMs) {
    public void noteCameraOffLocked(int uid, long elapsedRealtimeMs, long uptimeMs) {
@@ -6681,18 +6669,14 @@ public class BatteryStatsImpl extends BatteryStats {
        uid = mapUid(uid);
        uid = mapUid(uid);
        if (--mCameraOnNesting == 0) {
        if (--mCameraOnNesting == 0) {
            mHistory.recordState2StopEvent(elapsedRealtimeMs, uptimeMs,
            mHistory.recordState2StopEvent(elapsedRealtimeMs, uptimeMs,
                    HistoryItem.STATE2_CAMERA_FLAG, uid, "camera");
                    HistoryItem.STATE2_CAMERA_FLAG);
            mCameraOnTimer.stopRunningLocked(elapsedRealtimeMs);
            mCameraOnTimer.stopRunningLocked(elapsedRealtimeMs);
        }
        }
        getUidStatsLocked(uid, elapsedRealtimeMs, uptimeMs)
        getUidStatsLocked(uid, elapsedRealtimeMs, uptimeMs)
                .noteCameraTurnedOffLocked(elapsedRealtimeMs);
                .noteCameraTurnedOffLocked(elapsedRealtimeMs);
        if (mPowerStatsCollectorEnabled.get(BatteryConsumer.POWER_COMPONENT_CAMERA)) {
            mCameraPowerStatsCollector.schedule();
        } else {
        scheduleSyncExternalStatsLocked("camera-off", ExternalStatsSync.UPDATE_CAMERA);
        scheduleSyncExternalStatsLocked("camera-off", ExternalStatsSync.UPDATE_CAMERA);
    }
    }
    }
    @GuardedBy("this")
    @GuardedBy("this")
    public void noteResetCameraLocked(long elapsedRealtimeMs, long uptimeMs) {
    public void noteResetCameraLocked(long elapsedRealtimeMs, long uptimeMs) {
@@ -11297,12 +11281,6 @@ public class BatteryStatsImpl extends BatteryStats {
                mPowerStatsCollectorInjector);
                mPowerStatsCollectorInjector);
        mBluetoothPowerStatsCollector.addConsumer(this::recordPowerStats);
        mBluetoothPowerStatsCollector.addConsumer(this::recordPowerStats);
        mCameraPowerStatsCollector = new CameraPowerStatsCollector(mPowerStatsCollectorInjector);
        mCameraPowerStatsCollector.addConsumer(this::recordPowerStats);
        mGnssPowerStatsCollector = new GnssPowerStatsCollector(mPowerStatsCollectorInjector);
        mGnssPowerStatsCollector.addConsumer(this::recordPowerStats);
        mStartCount++;
        mStartCount++;
        initTimersAndCounters();
        initTimersAndCounters();
        mOnBattery = mOnBatteryInternal = false;
        mOnBattery = mOnBatteryInternal = false;
@@ -14725,14 +14703,6 @@ public class BatteryStatsImpl extends BatteryStats {
                mPowerStatsCollectorEnabled.get(BatteryConsumer.POWER_COMPONENT_BLUETOOTH));
                mPowerStatsCollectorEnabled.get(BatteryConsumer.POWER_COMPONENT_BLUETOOTH));
        mBluetoothPowerStatsCollector.schedule();
        mBluetoothPowerStatsCollector.schedule();
        mCameraPowerStatsCollector.setEnabled(
                mPowerStatsCollectorEnabled.get(BatteryConsumer.POWER_COMPONENT_CAMERA));
        mCameraPowerStatsCollector.schedule();
        mGnssPowerStatsCollector.setEnabled(
                mPowerStatsCollectorEnabled.get(BatteryConsumer.POWER_COMPONENT_GNSS));
        mGnssPowerStatsCollector.schedule();
        mSystemReady = true;
        mSystemReady = true;
    }
    }
@@ -14751,10 +14721,6 @@ public class BatteryStatsImpl extends BatteryStats {
                return mWifiPowerStatsCollector;
                return mWifiPowerStatsCollector;
            case BatteryConsumer.POWER_COMPONENT_BLUETOOTH:
            case BatteryConsumer.POWER_COMPONENT_BLUETOOTH:
                return mBluetoothPowerStatsCollector;
                return mBluetoothPowerStatsCollector;
            case BatteryConsumer.POWER_COMPONENT_CAMERA:
                return mCameraPowerStatsCollector;
            case BatteryConsumer.POWER_COMPONENT_GNSS:
                return mGnssPowerStatsCollector;
        }
        }
        return null;
        return null;
    }
    }
@@ -16292,8 +16258,6 @@ public class BatteryStatsImpl extends BatteryStats {
        mMobileRadioPowerStatsCollector.forceSchedule();
        mMobileRadioPowerStatsCollector.forceSchedule();
        mWifiPowerStatsCollector.forceSchedule();
        mWifiPowerStatsCollector.forceSchedule();
        mBluetoothPowerStatsCollector.forceSchedule();
        mBluetoothPowerStatsCollector.forceSchedule();
        mCameraPowerStatsCollector.forceSchedule();
        mGnssPowerStatsCollector.forceSchedule();
    }
    }
    /**
    /**
@@ -16314,8 +16278,6 @@ public class BatteryStatsImpl extends BatteryStats {
        mMobileRadioPowerStatsCollector.collectAndDump(pw);
        mMobileRadioPowerStatsCollector.collectAndDump(pw);
        mWifiPowerStatsCollector.collectAndDump(pw);
        mWifiPowerStatsCollector.collectAndDump(pw);
        mBluetoothPowerStatsCollector.collectAndDump(pw);
        mBluetoothPowerStatsCollector.collectAndDump(pw);
        mCameraPowerStatsCollector.collectAndDump(pw);
        mGnssPowerStatsCollector.collectAndDump(pw);
    }
    }
    private final Runnable mWriteAsyncRunnable = () -> {
    private final Runnable mWriteAsyncRunnable = () -> {
+2 −6
Original line number Original line Diff line number Diff line
@@ -95,12 +95,8 @@ public class BatteryUsageStatsProvider {
                }
                }
                mPowerCalculators.add(new SensorPowerCalculator(
                mPowerCalculators.add(new SensorPowerCalculator(
                        mContext.getSystemService(SensorManager.class)));
                        mContext.getSystemService(SensorManager.class)));
                if (!mPowerStatsExporterEnabled.get(BatteryConsumer.POWER_COMPONENT_GNSS)) {
                mPowerCalculators.add(new GnssPowerCalculator(mPowerProfile));
                mPowerCalculators.add(new GnssPowerCalculator(mPowerProfile));
                }
                if (!mPowerStatsExporterEnabled.get(BatteryConsumer.POWER_COMPONENT_CAMERA)) {
                mPowerCalculators.add(new CameraPowerCalculator(mPowerProfile));
                mPowerCalculators.add(new CameraPowerCalculator(mPowerProfile));
                }
                if (!mPowerStatsExporterEnabled.get(BatteryConsumer.POWER_COMPONENT_FLASHLIGHT)) {
                if (!mPowerStatsExporterEnabled.get(BatteryConsumer.POWER_COMPONENT_FLASHLIGHT)) {
                    mPowerCalculators.add(new FlashlightPowerCalculator(mPowerProfile));
                    mPowerCalculators.add(new FlashlightPowerCalculator(mPowerProfile));
                }
                }
Loading