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

Commit 42e60625 authored by Roshan Pius's avatar Roshan Pius
Browse files

Add new wifi tx power levels in Wifi activity energy

BUG: 27227497
Change-Id: I66db7f61a5e3a8223a008f7182bb56921145c831
parent 3ec7cfee
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1223,7 +1223,8 @@ public final class BatteryStatsService extends IBatteryStats.Stub
    // WiFi keeps an accumulated total of stats, unlike Bluetooth.
    // Keep the last WiFi stats so we can compute a delta.
    @GuardedBy("mExternalStatsLock")
    private WifiActivityEnergyInfo mLastInfo = new WifiActivityEnergyInfo(0, 0, 0, 0, 0, 0);
    private WifiActivityEnergyInfo mLastInfo =
            new WifiActivityEnergyInfo(0, 0, 0, new long[]{0}, 0, 0, 0);

    @GuardedBy("mExternalStatsLock")
    private WifiActivityEnergyInfo pullWifiEnergyInfoLocked() {
+24 −2
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package android.net.wifi;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.Arrays;

/**
 * Record of energy and activity information from controller and
 * underlying wifi stack state. Timestamp the record with elapsed
@@ -41,6 +43,11 @@ public final class WifiActivityEnergyInfo implements Parcelable {
     */
    public long mControllerTxTimeMs;

    /**
     * @hide
     */
    public long[] mControllerTxTimePerLevelMs;

    /**
     * @hide
     */
@@ -62,10 +69,12 @@ public final class WifiActivityEnergyInfo implements Parcelable {
    public static final int STACK_STATE_STATE_IDLE = 3;

    public WifiActivityEnergyInfo(long timestamp, int stackState,
                                  long txTime, long rxTime, long idleTime, long energyUsed) {
                                  long txTime, long[] txTimePerLevel, long rxTime, long idleTime,
                                  long energyUsed) {
        mTimestamp = timestamp;
        mStackState = stackState;
        mControllerTxTimeMs = txTime;
        mControllerTxTimePerLevelMs = txTimePerLevel;
        mControllerRxTimeMs = rxTime;
        mControllerIdleTimeMs = idleTime;
        mControllerEnergyUsed = energyUsed;
@@ -77,6 +86,7 @@ public final class WifiActivityEnergyInfo implements Parcelable {
            + " timestamp=" + mTimestamp
            + " mStackState=" + mStackState
            + " mControllerTxTimeMs=" + mControllerTxTimeMs
            + " mControllerTxTimePerLevelMs=" + Arrays.toString(mControllerTxTimePerLevelMs)
            + " mControllerRxTimeMs=" + mControllerRxTimeMs
            + " mControllerIdleTimeMs=" + mControllerIdleTimeMs
            + " mControllerEnergyUsed=" + mControllerEnergyUsed
@@ -89,11 +99,12 @@ public final class WifiActivityEnergyInfo implements Parcelable {
            long timestamp = in.readLong();
            int stackState = in.readInt();
            long txTime = in.readLong();
            long[] txTimePerLevel = in.createLongArray();
            long rxTime = in.readLong();
            long idleTime = in.readLong();
            long energyUsed = in.readLong();
            return new WifiActivityEnergyInfo(timestamp, stackState,
                    txTime, rxTime, idleTime, energyUsed);
                    txTime, txTimePerLevel, rxTime, idleTime, energyUsed);
        }
        public WifiActivityEnergyInfo[] newArray(int size) {
            return new WifiActivityEnergyInfo[size];
@@ -104,6 +115,7 @@ public final class WifiActivityEnergyInfo implements Parcelable {
        out.writeLong(mTimestamp);
        out.writeInt(mStackState);
        out.writeLong(mControllerTxTimeMs);
        out.writeLongArray(mControllerTxTimePerLevelMs);
        out.writeLong(mControllerRxTimeMs);
        out.writeLong(mControllerIdleTimeMs);
        out.writeLong(mControllerEnergyUsed);
@@ -127,6 +139,16 @@ public final class WifiActivityEnergyInfo implements Parcelable {
        return mControllerTxTimeMs;
    }

    /**
     * @return tx time at power level provided in ms
     */
    public long getControllerTxTimeMillisAtLevel(int level) {
        if (level < mControllerTxTimePerLevelMs.length) {
            return mControllerTxTimePerLevelMs[level];
        }
        return 0;
    }

    /**
     * @return rx time in ms
     */