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

Commit e011905b authored by Dhavalkumar Chaudhary's avatar Dhavalkumar Chaudhary Committed by Android (Google) Code Review
Browse files

Merge "Cleanup after removal of the streamlined_misc_battery_stats flag" into main

parents 36f4dc8e 8acf72a7
Loading
Loading
Loading
Loading
+1 −218
Original line number Diff line number Diff line
@@ -1049,130 +1049,6 @@ public abstract class BatteryStats {
         */
        public abstract void getDeferredJobsLineLocked(StringBuilder sb, int which);

        /**
         * Returns the battery consumption (in microcoulombs) of bluetooth for this uid,
         * 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 getBluetoothEnergyConsumptionUC();

        /**
         * Returns the battery consumption (in microcoulombs) of the uid's bluetooth usage
         * when in the specified process state.
         * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
         *
         * {@hide}
         */
        public abstract long getBluetoothEnergyConsumptionUC(
                @BatteryConsumer.ProcessState int processState);

        /**
         * Returns the battery consumption (in microcoulombs) of the uid's cpu usage, derived from
         * 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 getCpuEnergyConsumptionUC();

        /**
         * Returns the battery consumption (in microcoulombs) of the uid's cpu usage when in the
         * specified process state.
         * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
         *
         * {@hide}
         */
        public abstract long getCpuEnergyConsumptionUC(
                @BatteryConsumer.ProcessState int processState);

        /**
         * Returns the battery consumption (in microcoulombs) of the uid's GNSS usage, derived from
         * 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 getGnssEnergyConsumptionUC();

        /**
         * Returns the battery consumption (in microcoulombs) of the uid's radio usage, derived from
         * 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 getMobileRadioEnergyConsumptionUC();

        /**
         * Returns the battery consumption (in microcoulombs) of the uid's radio usage when in the
         * specified process state.
         * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
         *
         * {@hide}
         */
        public abstract long getMobileRadioEnergyConsumptionUC(
                @BatteryConsumer.ProcessState int processState);

        /**
         * Returns the battery consumption (in microcoulombs) of the screen while on and uid active,
         * 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 getScreenOnEnergyConsumptionUC();

        /**
         * Returns the battery consumption (in microcoulombs) of wifi for this uid,
         * 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 getWifiEnergyConsumptionUC();

        /**
         * Returns the battery consumption (in microcoulombs) of the uid's wifi usage when in the
         * specified process state.
         * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
         *
         * {@hide}
         */
        public abstract long getWifiEnergyConsumptionUC(
                @BatteryConsumer.ProcessState int processState);



        /**
         * Returns the battery consumption (in microcoulombs) of UID's camera usage, derived from
         * on-device power measurement data.
         * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
         *
         * {@hide}
         */
        public abstract long getCameraEnergyConsumptionUC();

        /**
         * Returns the battery consumption (in microcoulombs) used by this uid for each
         * {@link android.hardware.power.stats.EnergyConsumer.ordinal} of (custom) energy consumer
         * type {@link android.hardware.power.stats.EnergyConsumerType#OTHER}).
         *
         * @return charge (in microcoulombs) consumed since last reset for each (custom) energy
         *         consumer of type OTHER, indexed by their ordinal. Returns null if no energy
         *         reporting is supported.
         *
         * {@hide}
         */
        public abstract @Nullable long[] getCustomEnergyConsumerBatteryConsumptionUC();

        public static abstract class Sensor {

            @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
@@ -2912,7 +2788,7 @@ public abstract class BatteryStats {
     *
     * {@hide}
     */
    public static final long POWER_DATA_UNAVAILABLE = -1L;
//    public static final long POWER_DATA_UNAVAILABLE = -1L;

    /**
     * Returned value if duration data is unavailable.
@@ -2921,99 +2797,6 @@ public abstract class BatteryStats {
     */
    public static final long DURATION_UNAVAILABLE = -1L;

    /**
     * Returns the battery consumption (in microcoulombs) of bluetooth, derived from on
     * device power measurement data.
     * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
     *
     * {@hide}
     */
    public abstract long getBluetoothEnergyConsumptionUC();

    /**
     * Returns the battery consumption (in microcoulombs) of the cpu, derived from on device power
     * measurement data.
     * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
     *
     * {@hide}
     */
    public abstract long getCpuEnergyConsumptionUC();

    /**
     * Returns the battery consumption (in microcoulombs) of the GNSS, derived from on device power
     * measurement data.
     * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
     *
     * {@hide}
     */
    public abstract long getGnssEnergyConsumptionUC();

    /**
     * Returns the battery consumption (in microcoulombs) of the radio, derived from on device power
     * measurement data.
     * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
     *
     * {@hide}
     */
    public abstract long getMobileRadioEnergyConsumptionUC();

    /**
     * Returns the battery consumption (in microcoulombs) of the phone calls, derived from on device
     * power measurement data.
     * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
     *
     * {@hide}
     */
    public abstract long getPhoneEnergyConsumptionUC();

    /**
     * Returns the battery consumption (in microcoulombs) of the screen while on, derived from on
     * device power measurement data.
     * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
     *
     * {@hide}
     */
    public abstract long getScreenOnEnergyConsumptionUC();

    /**
     * Returns the battery consumption (in microcoulombs) of the screen in doze, derived from on
     * device power measurement data.
     * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
     *
     * {@hide}
     */
    public abstract long getScreenDozeEnergyConsumptionUC();

    /**
     * Returns the battery consumption (in microcoulombs) of wifi, derived from on
     * device power measurement data.
     * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
     *
     * {@hide}
     */
    public abstract long getWifiEnergyConsumptionUC();

    /**
     * Returns the battery consumption (in microcoulombs) of camera, derived from on
     * device power measurement data.
     * Will return {@link #POWER_DATA_UNAVAILABLE} if data is unavailable.
     *
     * {@hide}
     */
    public abstract long getCameraEnergyConsumptionUC();

    /**
     * Returns the battery consumption (in microcoulombs) that each
     * {@link android.hardware.power.stats.EnergyConsumer.ordinal} of (custom) energy consumer
     * type {@link android.hardware.power.stats.EnergyConsumerType#OTHER}) consumed.
     *
     * @return charge (in microcoulombs) used by each (custom) energy consumer of type OTHER,
     * indexed by their ordinal. Returns null if no energy reporting is supported.
     *
     * {@hide}
     */
    public abstract @Nullable long[] getCustomEnergyConsumerBatteryConsumptionUC();

    /**
     * Returns the names of all {@link android.hardware.power.stats.EnergyConsumer}'s
     * of (custom) energy consumer type
+4 −5
Original line number Diff line number Diff line
@@ -16,9 +16,6 @@

package com.android.internal.power;


import static android.os.BatteryStats.POWER_DATA_UNAVAILABLE;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -48,6 +45,8 @@ import java.util.Arrays;
public class EnergyConsumerStats {
    private static final String TAG = "MeasuredEnergyStats";

    private static final long POWER_DATA_UNAVAILABLE = -1;

    // Note: {@link BatteryStats#VERSION} MUST be updated if standard
    // power bucket integers are modified/added/removed.
    public static final int POWER_BUCKET_UNKNOWN = -1;
@@ -464,7 +463,7 @@ public class EnergyConsumerStats {

    /**
     * Return accumulated charge (in microcouloumb) for a standard power bucket since last reset.
     * Returns {@link android.os.BatteryStats#POWER_DATA_UNAVAILABLE} if this data is unavailable.
     * Returns {@link POWER_DATA_UNAVAILABLE} if this data is unavailable.
     * @throws IllegalArgumentException if no such {@link StandardPowerBucket}.
     */
    public long getAccumulatedStandardBucketCharge(@StandardPowerBucket int bucket) {
@@ -476,7 +475,7 @@ public class EnergyConsumerStats {
     * Returns the accumulated charge (in microcouloumb) for the standard power bucket and
     * the specified state since last reset.
     *
     * Returns {@link android.os.BatteryStats#POWER_DATA_UNAVAILABLE} if this data is unavailable.
     * Returns {@link POWER_DATA_UNAVAILABLE} if this data is unavailable.
     */
    public long getAccumulatedStandardBucketCharge(@StandardPowerBucket int bucket, int state) {
        if (!mConfig.isSupportedMultiStateBucket(bucket)) {
+2 −2
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package com.android.internal.power;

import static android.os.BatteryStats.POWER_DATA_UNAVAILABLE;

import static com.android.internal.power.EnergyConsumerStats.NUMBER_STANDARD_POWER_BUCKETS;
import static com.android.internal.power.EnergyConsumerStats.POWER_BUCKET_BLUETOOTH;
import static com.android.internal.power.EnergyConsumerStats.POWER_BUCKET_CPU;
@@ -49,6 +47,8 @@ import java.util.Arrays;
 */
@SmallTest
public class EnergyConsumerStatsTest {
    private static final long POWER_DATA_UNAVAILABLE = -1;

    @Rule
    public final RavenwoodRule mRavenwood = new RavenwoodRule();

+4 −19
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import static android.net.NetworkCapabilities.TRANSPORT_CELLULAR;
import static android.net.NetworkCapabilities.TRANSPORT_WIFI;
import static android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK;
import static android.os.BatteryConsumer.POWER_COMPONENT_BASE;
import static android.os.BatteryStats.POWER_DATA_UNAVAILABLE;

import static com.android.internal.util.ConcurrentUtils.DIRECT_EXECUTOR;

@@ -2753,8 +2752,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
            final NetworkStatsManager networkStatsManager = mContext.getSystemService(
                    NetworkStatsManager.class);
            mHandler.post(() -> {
                mStats.updateWifiState(info, POWER_DATA_UNAVAILABLE, elapsedRealtime, uptime,
                        networkStatsManager);
                mStats.updateWifiState(info, elapsedRealtime, uptime, networkStatsManager);
            });
        }
    }
@@ -2774,8 +2772,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
            final long uptime = SystemClock.uptimeMillis();
            mHandler.post(() -> {
                synchronized (mStats) {
                    mStats.updateBluetoothStateLocked(
                            info, POWER_DATA_UNAVAILABLE, elapsedRealtime, uptime);
                    mStats.updateBluetoothStateLocked(info, elapsedRealtime, uptime);
                }
            });
        }
@@ -2797,8 +2794,8 @@ public final class BatteryStatsService extends IBatteryStats.Stub
            final NetworkStatsManager networkStatsManager = mContext.getSystemService(
                    NetworkStatsManager.class);
            mHandler.post(() -> {
                mStats.noteModemControllerActivity(info, POWER_DATA_UNAVAILABLE, elapsedRealtime,
                        uptime, networkStatsManager);
                mStats.noteModemControllerActivity(info, elapsedRealtime, uptime,
                        networkStatsManager);
            });
        }
    }
@@ -2998,15 +2995,6 @@ public final class BatteryStatsService extends IBatteryStats.Stub
        mPowerStatsStore.dumpTableOfContents(new IndentingPrintWriter(pw, "  "));
    }

    private void dumpMeasuredEnergyStats(PrintWriter pw) {
        // Wait for the completion of pending works if there is any
        awaitCompletion();
        syncStats("dump", BatteryExternalStatsWorker.UPDATE_ALL);
        synchronized (mStats) {
            mStats.dumpEnergyConsumerStatsLocked(pw);
        }
    }

    private void dumpPowerProfile(PrintWriter pw) {
        synchronized (mStats) {
            mStats.dumpPowerProfileLocked(pw);
@@ -3211,9 +3199,6 @@ public final class BatteryStatsService extends IBatteryStats.Stub
                } else if ("--cpu".equals(arg)) {
                    dumpCpuStats(pw);
                    return;
                } else  if ("--measured-energy".equals(arg)) {
                    dumpMeasuredEnergyStats(pw);
                    return;
                } else if ("--power-profile".equals(arg)) {
                    dumpPowerProfile(pw);
                    return;
+30 −123

File changed.

Preview size limit exceeded, changes collapsed.

Loading