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

Commit e9b9b73a authored by Bart Sears's avatar Bart Sears
Browse files

Revert "Adding per UID WiFi power distribution."

This CL is breaking the clockwork settings app in master.  Reverting
until Adam has a chance to investigate.

This reverts commit b943fabf.

Change-Id: Ieb11423c11cf9874a6175dce49843d0e1080c590
parent b943fabf
Loading
Loading
Loading
Loading
+16 −56
Original line number Original line Diff line number Diff line
@@ -268,15 +268,6 @@ public abstract class BatteryStats implements Parcelable {
         */
         */
        public abstract long getTotalTimeLocked(long elapsedRealtimeUs, int which);
        public abstract long getTotalTimeLocked(long elapsedRealtimeUs, int which);


        /**
         * Returns the total time in microseconds associated with this Timer since the
         * 'mark' was last set.
         *
         * @param elapsedRealtimeUs current elapsed realtime of system in microseconds
         * @return a time in microseconds
         */
        public abstract long getTimeSinceMarkLocked(long elapsedRealtimeUs);

        /**
        /**
         * Temporary for debugging.
         * Temporary for debugging.
         */
         */
@@ -342,16 +333,6 @@ public abstract class BatteryStats implements Parcelable {
         */
         */
        public abstract ArrayMap<String, ? extends Pkg> getPackageStats();
        public abstract ArrayMap<String, ? extends Pkg> getPackageStats();
        
        
        /**
         * Returns the time in milliseconds that this app kept the WiFi controller in the
         * specified state <code>type</code>.
         * @param type one of {@link #CONTROLLER_IDLE_TIME}, {@link #CONTROLLER_RX_TIME}, or
         *             {@link #CONTROLLER_TX_TIME}.
         * @param which one of {@link #STATS_CURRENT}, {@link #STATS_SINCE_CHARGED}, or
         *              {@link #STATS_SINCE_UNPLUGGED}.
         */
        public abstract long getWifiControllerActivity(int type, int which);

        /**
        /**
         * {@hide}
         * {@hide}
         */
         */
@@ -1933,6 +1914,7 @@ public abstract class BatteryStats implements Parcelable {
    public static final int NETWORK_MOBILE_TX_DATA = 1;
    public static final int NETWORK_MOBILE_TX_DATA = 1;
    public static final int NETWORK_WIFI_RX_DATA = 2;
    public static final int NETWORK_WIFI_RX_DATA = 2;
    public static final int NETWORK_WIFI_TX_DATA = 3;
    public static final int NETWORK_WIFI_TX_DATA = 3;

    public static final int NUM_NETWORK_ACTIVITY_TYPES = NETWORK_WIFI_TX_DATA + 1;
    public static final int NUM_NETWORK_ACTIVITY_TYPES = NETWORK_WIFI_TX_DATA + 1;


    public abstract long getNetworkActivityBytes(int type, int which);
    public abstract long getNetworkActivityBytes(int type, int which);
@@ -1941,25 +1923,10 @@ public abstract class BatteryStats implements Parcelable {
    public static final int CONTROLLER_IDLE_TIME = 0;
    public static final int CONTROLLER_IDLE_TIME = 0;
    public static final int CONTROLLER_RX_TIME = 1;
    public static final int CONTROLLER_RX_TIME = 1;
    public static final int CONTROLLER_TX_TIME = 2;
    public static final int CONTROLLER_TX_TIME = 2;
    public static final int CONTROLLER_POWER_DRAIN = 3;
    public static final int CONTROLLER_ENERGY = 3;
    public static final int NUM_CONTROLLER_ACTIVITY_TYPES = CONTROLLER_POWER_DRAIN + 1;
    public static final int NUM_CONTROLLER_ACTIVITY_TYPES = CONTROLLER_ENERGY + 1;


    /**
     * For {@link #CONTROLLER_IDLE_TIME}, {@link #CONTROLLER_RX_TIME}, and
     * {@link #CONTROLLER_TX_TIME}, returns the time spent (in milliseconds) in the
     * respective state.
     * For {@link #CONTROLLER_POWER_DRAIN}, returns the power used by the controller in
     * milli-ampere-milliseconds (mAms).
     */
    public abstract long getBluetoothControllerActivity(int type, int which);
    public abstract long getBluetoothControllerActivity(int type, int which);

    /**
     * For {@link #CONTROLLER_IDLE_TIME}, {@link #CONTROLLER_RX_TIME}, and
     * {@link #CONTROLLER_TX_TIME}, returns the time spent (in milliseconds) in the
     * respective state.
     * For {@link #CONTROLLER_POWER_DRAIN}, returns the power used by the controller in
     * milli-ampere-milliseconds (mAms).
     */
    public abstract long getWifiControllerActivity(int type, int which);
    public abstract long getWifiControllerActivity(int type, int which);


    /**
    /**
@@ -2651,7 +2618,7 @@ public abstract class BatteryStats implements Parcelable {
                        label = "???";
                        label = "???";
                }
                }
                dumpLine(pw, uid, category, POWER_USE_ITEM_DATA, label,
                dumpLine(pw, uid, category, POWER_USE_ITEM_DATA, label,
                        BatteryStatsHelper.makemAh(bs.totalPowerMah));
                        BatteryStatsHelper.makemAh(bs.value));
            }
            }
        }
        }


@@ -3295,13 +3262,6 @@ public abstract class BatteryStats implements Parcelable {
        sb.append(")");
        sb.append(")");
        pw.println(sb.toString());
        pw.println(sb.toString());


        sb.setLength(0);
        sb.append(prefix);
        sb.append("  WiFi Energy use: ").append(BatteryStatsHelper.makemAh(
                getWifiControllerActivity(CONTROLLER_POWER_DRAIN, which) / (double)(1000*60*60)));
        sb.append(" mAh");
        pw.println(sb.toString());

        sb.setLength(0);
        sb.setLength(0);
        sb.append(prefix);
        sb.append(prefix);
                sb.append("  Bluetooth on: "); formatTimeMs(sb, bluetoothOnTime / 1000);
                sb.append("  Bluetooth on: "); formatTimeMs(sb, bluetoothOnTime / 1000);
@@ -3416,48 +3376,48 @@ public abstract class BatteryStats implements Parcelable {
                final BatterySipper bs = sippers.get(i);
                final BatterySipper bs = sippers.get(i);
                switch (bs.drainType) {
                switch (bs.drainType) {
                    case IDLE:
                    case IDLE:
                        pw.print(prefix); pw.print("    Idle: "); printmAh(pw, bs.totalPowerMah);
                        pw.print(prefix); pw.print("    Idle: "); printmAh(pw, bs.value);
                        pw.println();
                        pw.println();
                        break;
                        break;
                    case CELL:
                    case CELL:
                        pw.print(prefix); pw.print("    Cell standby: "); printmAh(pw, bs.totalPowerMah);
                        pw.print(prefix); pw.print("    Cell standby: "); printmAh(pw, bs.value);
                        pw.println();
                        pw.println();
                        break;
                        break;
                    case PHONE:
                    case PHONE:
                        pw.print(prefix); pw.print("    Phone calls: "); printmAh(pw, bs.totalPowerMah);
                        pw.print(prefix); pw.print("    Phone calls: "); printmAh(pw, bs.value);
                        pw.println();
                        pw.println();
                        break;
                        break;
                    case WIFI:
                    case WIFI:
                        pw.print(prefix); pw.print("    Wifi: "); printmAh(pw, bs.totalPowerMah);
                        pw.print(prefix); pw.print("    Wifi: "); printmAh(pw, bs.value);
                        pw.println();
                        pw.println();
                        break;
                        break;
                    case BLUETOOTH:
                    case BLUETOOTH:
                        pw.print(prefix); pw.print("    Bluetooth: "); printmAh(pw, bs.totalPowerMah);
                        pw.print(prefix); pw.print("    Bluetooth: "); printmAh(pw, bs.value);
                        pw.println();
                        pw.println();
                        break;
                        break;
                    case SCREEN:
                    case SCREEN:
                        pw.print(prefix); pw.print("    Screen: "); printmAh(pw, bs.totalPowerMah);
                        pw.print(prefix); pw.print("    Screen: "); printmAh(pw, bs.value);
                        pw.println();
                        pw.println();
                        break;
                        break;
                    case FLASHLIGHT:
                    case FLASHLIGHT:
                        pw.print(prefix); pw.print("    Flashlight: "); printmAh(pw, bs.totalPowerMah);
                        pw.print(prefix); pw.print("    Flashlight: "); printmAh(pw, bs.value);
                        pw.println();
                        pw.println();
                        break;
                        break;
                    case APP:
                    case APP:
                        pw.print(prefix); pw.print("    Uid ");
                        pw.print(prefix); pw.print("    Uid ");
                        UserHandle.formatUid(pw, bs.uidObj.getUid());
                        UserHandle.formatUid(pw, bs.uidObj.getUid());
                        pw.print(": "); printmAh(pw, bs.totalPowerMah); pw.println();
                        pw.print(": "); printmAh(pw, bs.value); pw.println();
                        break;
                        break;
                    case USER:
                    case USER:
                        pw.print(prefix); pw.print("    User "); pw.print(bs.userId);
                        pw.print(prefix); pw.print("    User "); pw.print(bs.userId);
                        pw.print(": "); printmAh(pw, bs.totalPowerMah); pw.println();
                        pw.print(": "); printmAh(pw, bs.value); pw.println();
                        break;
                        break;
                    case UNACCOUNTED:
                    case UNACCOUNTED:
                        pw.print(prefix); pw.print("    Unaccounted: "); printmAh(pw, bs.totalPowerMah);
                        pw.print(prefix); pw.print("    Unaccounted: "); printmAh(pw, bs.value);
                        pw.println();
                        pw.println();
                        break;
                        break;
                    case OVERCOUNTED:
                    case OVERCOUNTED:
                        pw.print(prefix); pw.print("    Over-counted: "); printmAh(pw, bs.totalPowerMah);
                        pw.print(prefix); pw.print("    Over-counted: "); printmAh(pw, bs.value);
                        pw.println();
                        pw.println();
                        break;
                        break;
                }
                }
+0 −1
Original line number Original line Diff line number Diff line
@@ -109,7 +109,6 @@ interface IBatteryStats {
    void noteWifiBatchedScanStoppedFromSource(in WorkSource ws);
    void noteWifiBatchedScanStoppedFromSource(in WorkSource ws);
    void noteWifiMulticastEnabledFromSource(in WorkSource ws);
    void noteWifiMulticastEnabledFromSource(in WorkSource ws);
    void noteWifiMulticastDisabledFromSource(in WorkSource ws);
    void noteWifiMulticastDisabledFromSource(in WorkSource ws);
    void noteWifiRadioPowerState(int powerState, long timestampNs);
    void noteNetworkInterfaceType(String iface, int type);
    void noteNetworkInterfaceType(String iface, int type);
    void noteNetworkStatsEnabled();
    void noteNetworkStatsEnabled();
    void noteDeviceIdleMode(boolean enabled, boolean fromActive, boolean fromMotion);
    void noteDeviceIdleMode(boolean enabled, boolean fromActive, boolean fromMotion);
+34 −50
Original line number Original line Diff line number Diff line
@@ -23,25 +23,17 @@ import android.os.BatteryStats.Uid;
public class BatterySipper implements Comparable<BatterySipper> {
public class BatterySipper implements Comparable<BatterySipper> {
    public int userId;
    public int userId;
    public Uid uidObj;
    public Uid uidObj;
    public double totalPowerMah;
    public double value;
    public double[] values;
    public DrainType drainType;
    public DrainType drainType;


    /**
    // Measured in milliseconds.
     * Generic usage time in milliseconds.
    public long usageTime;
     */
    public long cpuTime;
    public long usageTimeMs;
    public long gpsTime;

    public long wifiRunningTime;
    /**
    public long cpuFgTime;
     * Generic power usage in mAh.
    public long wakeLockTime;
     */
    public double usagePowerMah;

    // Subsystem usage times.
    public long cpuTimeMs;
    public long gpsTimeMs;
    public long wifiRunningTimeMs;
    public long cpuFgTimeMs;
    public long wakeLockTimeMs;


    public long mobileRxPackets;
    public long mobileRxPackets;
    public long mobileTxPackets;
    public long mobileTxPackets;
@@ -60,13 +52,12 @@ public class BatterySipper implements Comparable<BatterySipper> {
    public String packageWithHighestDrain;
    public String packageWithHighestDrain;


    // Measured in mAh (milli-ampere per hour).
    // Measured in mAh (milli-ampere per hour).
    // These are included when summed.
    public double wifiPower;
    public double wifiPowerMah;
    public double cpuPower;
    public double cpuPowerMah;
    public double wakeLockPower;
    public double wakeLockPowerMah;
    public double mobileRadioPower;
    public double mobileRadioPowerMah;
    public double gpsPower;
    public double gpsPowerMah;
    public double sensorPower;
    public double sensorPowerMah;


    public enum DrainType {
    public enum DrainType {
        IDLE,
        IDLE,
@@ -82,12 +73,17 @@ public class BatterySipper implements Comparable<BatterySipper> {
        OVERCOUNTED
        OVERCOUNTED
    }
    }


    public BatterySipper(DrainType drainType, Uid uid, double value) {
    public BatterySipper(DrainType drainType, Uid uid, double[] values) {
        this.totalPowerMah = value;
        this.values = values;
        if (values != null) value = values[0];
        this.drainType = drainType;
        this.drainType = drainType;
        uidObj = uid;
        uidObj = uid;
    }
    }


    public double[] getValues() {
        return values;
    }

    public void computeMobilemspp() {
    public void computeMobilemspp() {
        long packets = mobileRxPackets+mobileTxPackets;
        long packets = mobileRxPackets+mobileTxPackets;
        mobilemspp = packets > 0 ? (mobileActive / (double)packets) : 0;
        mobilemspp = packets > 0 ? (mobileActive / (double)packets) : 0;
@@ -105,7 +101,7 @@ public class BatterySipper implements Comparable<BatterySipper> {
            }
            }
        }
        }
        // Return the flipped value because we want the items in descending order
        // Return the flipped value because we want the items in descending order
        return Double.compare(other.totalPowerMah, totalPowerMah);
        return Double.compare(other.value, value);
    }
    }


    /**
    /**
@@ -127,14 +123,11 @@ public class BatterySipper implements Comparable<BatterySipper> {
     * Add stats from other to this BatterySipper.
     * Add stats from other to this BatterySipper.
     */
     */
    public void add(BatterySipper other) {
    public void add(BatterySipper other) {
        totalPowerMah += other.totalPowerMah;
        cpuTime += other.cpuTime;
        usageTimeMs += other.usageTimeMs;
        gpsTime += other.gpsTime;
        usagePowerMah += other.usagePowerMah;
        wifiRunningTime += other.wifiRunningTime;
        cpuTimeMs += other.cpuTimeMs;
        cpuFgTime += other.cpuFgTime;
        gpsTimeMs += other.gpsTimeMs;
        wakeLockTime += other.wakeLockTime;
        wifiRunningTimeMs += other.wifiRunningTimeMs;
        cpuFgTimeMs += other.cpuFgTimeMs;
        wakeLockTimeMs += other.wakeLockTimeMs;
        mobileRxPackets += other.mobileRxPackets;
        mobileRxPackets += other.mobileRxPackets;
        mobileTxPackets += other.mobileTxPackets;
        mobileTxPackets += other.mobileTxPackets;
        mobileActive += other.mobileActive;
        mobileActive += other.mobileActive;
@@ -145,20 +138,11 @@ public class BatterySipper implements Comparable<BatterySipper> {
        mobileTxBytes += other.mobileTxBytes;
        mobileTxBytes += other.mobileTxBytes;
        wifiRxBytes += other.wifiRxBytes;
        wifiRxBytes += other.wifiRxBytes;
        wifiTxBytes += other.wifiTxBytes;
        wifiTxBytes += other.wifiTxBytes;
        wifiPowerMah += other.wifiPowerMah;
        wifiPower += other.wifiPower;
        gpsPowerMah += other.gpsPowerMah;
        gpsPower += other.gpsPower;
        cpuPowerMah += other.cpuPowerMah;
        cpuPower += other.cpuPower;
        sensorPowerMah += other.sensorPowerMah;
        sensorPower += other.sensorPower;
        mobileRadioPowerMah += other.mobileRadioPowerMah;
        mobileRadioPower += other.mobileRadioPower;
        wakeLockPowerMah += other.wakeLockPowerMah;
        wakeLockPower += other.wakeLockPower;
    }

    /**
     * Sum all the powers and store the value into `value`.
     * @return the sum of all the power in this BatterySipper.
     */
    public double sumPower() {
        return totalPowerMah = usagePowerMah + wifiPowerMah + gpsPowerMah + cpuPowerMah + sensorPowerMah
                + mobileRadioPowerMah + wakeLockPowerMah;
    }
    }
}
}
+537 −186

File changed.

Preview size limit exceeded, changes collapsed.

+54 −318

File changed.

Preview size limit exceeded, changes collapsed.

Loading