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

Commit cb308d9c authored by Blake Kragten's avatar Blake Kragten
Browse files

Power Monitor Addition framworks base:

Frameworks Base section of power monitor addition. Since IPowerStats
does not have a java interface, we needed to make a native interface
into the code. I followed how the LowPowerStats collection is being
done.

Native code is located in
com_android_server_am_BatteryStatsService.cpp. We are calling the
getEnergyData to get all rails energy data that has been collecting from
boot. This energy data is collected in uWs (microWatt seconds). After
the rail data is collected at each update in the RailStats class, the
wifi and cellular total energy values will contain the energy that all
rails associated with the specific subsystem will have.

We update and collect the energy data using battery stats and propagate
it to telephony metrics. When we collect the total energy for an update
we need to zero out the energy data so it can be accumulated correctly.

1/31: Added modemRailEnergy and wifiRailEnergy to Volta historian.

Bug: 115929961
Test: adb shell dumpsys activity service TelephonyDebugService --metrics
Results Examples:
	Energy consumed by modem (mAh): 2.41
	Energy Rails consumed by modem (mAh): 2.76
Dumpsys historian results:
	  +4m23s712ms (2) 100 cc511a18 modemRailChargemAh=0.34 wifiRailChargemAh=1.17 +wifi_scan stats=0:"dump"
         +10m24s089ms (2) 100 c4511a18 modemRailChargemAh=0.71 wifiRailChargemAh=1.77 stats=0:"write"
         +11m24s228ms (3) 100 c4511a19 volt=4315 charge=3988 modemRailChargemAh=0.77 wifiRailChargemAh=1.94 wifi_signal_strength=2 stats=0:"battery-state"

Change-Id: I97521a03204968079e61f3de86640d4f1a580255
parent 7b8b2c3e
Loading
Loading
Loading
Loading
+61 −4
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.internal.os.BatteryStatsHelper;

import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -262,6 +263,7 @@ public abstract class BatteryStats implements Parcelable {
    private static final long BYTES_PER_KB = 1024;
    private static final long BYTES_PER_MB = 1048576; // 1024^2
    private static final long BYTES_PER_GB = 1073741824; //1024^3
    public static final double MILLISECONDS_IN_HOUR = 3600 * 1000;

    private static final String VERSION_DATA = "vers";
    private static final String UID_DATA = "uid";
@@ -482,6 +484,13 @@ public abstract class BatteryStats implements Parcelable {
         * yield a value of 0 if the device doesn't support power calculations.
         */
        public abstract LongCounter getPowerCounter();

        /**
         * @return a non-null {@link LongCounter} representing total power monitored on the rails
         * in mAms (miliamps-milliseconds). The counter may always yield a value of 0 if the device
         * doesn't support power rail monitoring.
         */
        public abstract LongCounter getMonitoredRailChargeConsumedMaMs();
    }

    /**
@@ -1526,6 +1535,9 @@ public abstract class BatteryStats implements Parcelable {
        // The charge of the battery in micro-Ampere-hours.
        public int batteryChargeUAh;

        public double modemRailChargeMah;
        public double wifiRailChargeMah;

        // Constants from SCREEN_BRIGHTNESS_*
        public static final int STATE_BRIGHTNESS_SHIFT = 0;
        public static final int STATE_BRIGHTNESS_MASK = 0x7;
@@ -1738,6 +1750,8 @@ public abstract class BatteryStats implements Parcelable {
                    | ((((int)batteryVoltage)<<16)&0xffff0000);
            dest.writeInt(bat);
            dest.writeInt(batteryChargeUAh);
            dest.writeDouble(modemRailChargeMah);
            dest.writeDouble(wifiRailChargeMah);
            dest.writeInt(states);
            dest.writeInt(states2);
            if (wakelockTag != null) {
@@ -1767,6 +1781,8 @@ public abstract class BatteryStats implements Parcelable {
            batteryTemperature = (short)(bat2&0xffff);
            batteryVoltage = (char)((bat2>>16)&0xffff);
            batteryChargeUAh = src.readInt();
            modemRailChargeMah = src.readDouble();
            wifiRailChargeMah = src.readDouble();
            states = src.readInt();
            states2 = src.readInt();
            if ((bat&0x10000000) != 0) {
@@ -1807,6 +1823,8 @@ public abstract class BatteryStats implements Parcelable {
            batteryTemperature = 0;
            batteryVoltage = 0;
            batteryChargeUAh = 0;
            modemRailChargeMah = 0;
            wifiRailChargeMah = 0;
            states = 0;
            states2 = 0;
            wakelockTag = null;
@@ -1835,6 +1853,8 @@ public abstract class BatteryStats implements Parcelable {
            batteryTemperature = o.batteryTemperature;
            batteryVoltage = o.batteryVoltage;
            batteryChargeUAh = o.batteryChargeUAh;
            modemRailChargeMah = o.modemRailChargeMah;
            wifiRailChargeMah = o.wifiRailChargeMah;
            states = o.states;
            states2 = o.states2;
            if (o.wakelockTag != null) {
@@ -1867,6 +1887,8 @@ public abstract class BatteryStats implements Parcelable {
                    && batteryTemperature == o.batteryTemperature
                    && batteryVoltage == o.batteryVoltage
                    && batteryChargeUAh == o.batteryChargeUAh
                    && modemRailChargeMah == o.modemRailChargeMah
                    && wifiRailChargeMah == o.wifiRailChargeMah
                    && states == o.states
                    && states2 == o.states2
                    && currentTime == o.currentTime;
@@ -3311,7 +3333,8 @@ public abstract class BatteryStats implements Parcelable {

        if (counter.getIdleTimeCounter().getCountLocked(which) != 0
                || counter.getRxTimeCounter().getCountLocked(which) != 0
                || counter.getPowerCounter().getCountLocked(which) != 0) {
                || counter.getPowerCounter().getCountLocked(which) != 0
                || counter.getMonitoredRailChargeConsumedMaMs().getCountLocked(which) != 0) {
            return true;
        }

@@ -3345,7 +3368,10 @@ public abstract class BatteryStats implements Parcelable {
        pw.print(",");
        pw.print(counter.getRxTimeCounter().getCountLocked(which));
        pw.print(",");
        pw.print(counter.getPowerCounter().getCountLocked(which) / (1000 * 60 * 60));
        pw.print(counter.getPowerCounter().getCountLocked(which) / (MILLISECONDS_IN_HOUR));
        pw.print(",");
        pw.print(counter.getMonitoredRailChargeConsumedMaMs().getCountLocked(which)
                / (MILLISECONDS_IN_HOUR));
        for (LongCounter c : counter.getTxTimeCounters()) {
            pw.print(",");
            pw.print(c.getCountLocked(which));
@@ -3370,7 +3396,10 @@ public abstract class BatteryStats implements Parcelable {
        proto.write(ControllerActivityProto.RX_DURATION_MS,
                counter.getRxTimeCounter().getCountLocked(which));
        proto.write(ControllerActivityProto.POWER_MAH,
                counter.getPowerCounter().getCountLocked(which) / (1000 * 60 * 60));
                counter.getPowerCounter().getCountLocked(which) / (MILLISECONDS_IN_HOUR));
        proto.write(ControllerActivityProto.MONITORED_RAIL_CHARGE_MAH,
                counter.getMonitoredRailChargeConsumedMaMs().getCountLocked(which)
                        / (MILLISECONDS_IN_HOUR));

        long tToken;
        LongCounter[] txCounters = counter.getTxTimeCounters();
@@ -3400,6 +3429,8 @@ public abstract class BatteryStats implements Parcelable {
        final long idleTimeMs = counter.getIdleTimeCounter().getCountLocked(which);
        final long rxTimeMs = counter.getRxTimeCounter().getCountLocked(which);
        final long powerDrainMaMs = counter.getPowerCounter().getCountLocked(which);
        final long monitoredRailChargeConsumedMaMs =
                counter.getMonitoredRailChargeConsumedMaMs().getCountLocked(which);
        // Battery real time
        final long totalControllerActivityTimeMs
            = computeBatteryRealtime(SystemClock.elapsedRealtime() * 1000, which) / 1000;
@@ -3522,7 +3553,19 @@ public abstract class BatteryStats implements Parcelable {
            sb.append("     ");
            sb.append(controllerName);
            sb.append(" Battery drain: ").append(
                BatteryStatsHelper.makemAh(powerDrainMaMs / (double) (1000*60*60)));
                    BatteryStatsHelper.makemAh(powerDrainMaMs / MILLISECONDS_IN_HOUR));
            sb.append("mAh");
            pw.println(sb.toString());
        }

        if (monitoredRailChargeConsumedMaMs > 0) {
            sb.setLength(0);
            sb.append(prefix);
            sb.append("     ");
            sb.append(controllerName);
            sb.append(" Monitored rail energy drain: ").append(
                    new DecimalFormat("#.##").format(
                            monitoredRailChargeConsumedMaMs / MILLISECONDS_IN_HOUR));
            sb.append(" mAh");
            pw.println(sb.toString());
        }
@@ -6103,6 +6146,8 @@ public abstract class BatteryStats implements Parcelable {
        int oldTemp = -1;
        int oldVolt = -1;
        int oldChargeMAh = -1;
        double oldModemRailChargeMah = -1;
        double oldWifiRailChargeMah = -1;
        long lastTime = -1;

        void reset() {
@@ -6114,6 +6159,8 @@ public abstract class BatteryStats implements Parcelable {
            oldTemp = -1;
            oldVolt = -1;
            oldChargeMAh = -1;
            oldModemRailChargeMah = -1;
            oldWifiRailChargeMah = -1;
        }

        public void printNextItem(PrintWriter pw, HistoryItem rec, long baseTime, boolean checkin,
@@ -6299,6 +6346,16 @@ public abstract class BatteryStats implements Parcelable {
                    item.append(checkin ? ",Bcc=" : " charge=");
                    item.append(oldChargeMAh);
                }
                if (oldModemRailChargeMah != rec.modemRailChargeMah) {
                    oldModemRailChargeMah = rec.modemRailChargeMah;
                    item.append(checkin ? ",Mrc=" : " modemRailChargemAh=");
                    item.append(new DecimalFormat("#.##").format(oldModemRailChargeMah));
                }
                if (oldWifiRailChargeMah != rec.wifiRailChargeMah) {
                    oldWifiRailChargeMah = rec.wifiRailChargeMah;
                    item.append(checkin ? ",Wrc=" : " wifiRailChargemAh=");
                    item.append(new DecimalFormat("#.##").format(oldWifiRailChargeMah));
                }
                printBitDescriptions(item, oldState, rec.states, rec.wakelockTag,
                        HISTORY_STATE_DESCRIPTIONS, !checkin);
                printBitDescriptions(item, oldState2, rec.states2, null,
+13 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ public final class WifiBatteryStats implements Parcelable {
  private long[] mTimeInStateMs;
  private long[] mTimeInSupplicantStateMs;
  private long[] mTimeInRxSignalStrengthLevelMs;
  private long mMonitoredRailChargeConsumedMaMs;

  public static final Parcelable.Creator<WifiBatteryStats> CREATOR = new
      Parcelable.Creator<WifiBatteryStats>() {
@@ -77,6 +78,7 @@ public final class WifiBatteryStats implements Parcelable {
    out.writeLongArray(mTimeInStateMs);
    out.writeLongArray(mTimeInRxSignalStrengthLevelMs);
    out.writeLongArray(mTimeInSupplicantStateMs);
    out.writeLong(mMonitoredRailChargeConsumedMaMs);
  }

  public void readFromParcel(Parcel in) {
@@ -96,6 +98,7 @@ public final class WifiBatteryStats implements Parcelable {
    in.readLongArray(mTimeInStateMs);
    in.readLongArray(mTimeInRxSignalStrengthLevelMs);
    in.readLongArray(mTimeInSupplicantStateMs);
    mMonitoredRailChargeConsumedMaMs = in.readLong();
  }

  public long getLoggingDurationMs() {
@@ -162,6 +165,10 @@ public final class WifiBatteryStats implements Parcelable {
    return mTimeInSupplicantStateMs;
  }

  public long getMonitoredRailChargeConsumedMaMs() {
    return mMonitoredRailChargeConsumedMaMs;
  }

  public void setLoggingDurationMs(long t) {
    mLoggingDurationMs = t;
    return;
@@ -245,6 +252,11 @@ public final class WifiBatteryStats implements Parcelable {
    return;
  }

  public void setMonitoredRailChargeConsumedMaMs(long monitoredRailEnergyConsumedMaMs) {
    mMonitoredRailChargeConsumedMaMs = monitoredRailEnergyConsumedMaMs;
    return;
  }

  public int describeContents() {
    return 0;
  }
@@ -274,6 +286,7 @@ public final class WifiBatteryStats implements Parcelable {
    Arrays.fill(mTimeInRxSignalStrengthLevelMs, 0);
    mTimeInSupplicantStateMs = new long[BatteryStats.NUM_WIFI_SUPPL_STATES];
    Arrays.fill(mTimeInSupplicantStateMs, 0);
    mMonitoredRailChargeConsumedMaMs = 0;
    return;
  }
}
 No newline at end of file
+132 −53
Original line number Diff line number Diff line
@@ -187,6 +187,8 @@ public class BatteryStatsImpl extends BatteryStats {
    static final int MSG_REPORT_RESET_STATS = 4;
    static final long DELAY_UPDATE_WAKELOCKS = 5*1000;
    private static final double MILLISECONDS_IN_HOUR = 3600 * 1000;
    private final KernelWakelockReader mKernelWakelockReader = new KernelWakelockReader();
    private final KernelWakelockStats mTmpWakelockStats = new KernelWakelockStats();
@@ -252,6 +254,9 @@ public class BatteryStatsImpl extends BatteryStats {
    private static final long RPM_STATS_UPDATE_FREQ_MS = 1000;
    /** Last time that RPM stats were updated by updateRpmStatsLocked. */
    private long mLastRpmStatsUpdateTimeMs = -RPM_STATS_UPDATE_FREQ_MS;
    /** Container for Rail Energy Data stats. */
    private final RailStats mTmpRailStats = new RailStats();
    /**
     * Use a queue to delay removing UIDs from {@link KernelCpuUidUserSysTimeReader},
     * {@link KernelCpuUidActiveTimeReader}, {@link KernelCpuUidClusterTimeReader},
@@ -327,6 +332,15 @@ public class BatteryStatsImpl extends BatteryStats {
        public String getSubsystemLowPowerStats();
    }
    /** interface to update rail information for power monitor */
    public interface RailEnergyDataCallback {
        /** Function to fill the map for the rail data stats
         * Used for power monitoring feature
         * @param railStats
         */
        void fillRailDataStats(RailStats railStats);
    }
    public static abstract class UserInfoProvider {
        private int[] userIds;
        protected abstract @Nullable int[] getUserIds();
@@ -361,6 +375,8 @@ public class BatteryStatsImpl extends BatteryStats {
        }
    };
    public final RailEnergyDataCallback mRailEnergyDataCallback;
    /**
     * This handler is running on {@link BackgroundThread}.
     */
@@ -593,7 +609,9 @@ public class BatteryStatsImpl extends BatteryStats {
        int UPDATE_RADIO = 0x04;
        int UPDATE_BT = 0x08;
        int UPDATE_RPM = 0x10; // 16
        int UPDATE_ALL = UPDATE_CPU | UPDATE_WIFI | UPDATE_RADIO | UPDATE_BT | UPDATE_RPM;
        int UPDATE_RAIL = 0x20; // 32
        int UPDATE_ALL = UPDATE_CPU | UPDATE_WIFI | UPDATE_RADIO | UPDATE_BT | UPDATE_RPM
                | UPDATE_RAIL;
        Future<?> scheduleSync(String reason, int flags);
        Future<?> scheduleCpuSyncDueToRemovedUid(int uid);
@@ -1078,6 +1096,7 @@ public class BatteryStatsImpl extends BatteryStats {
        mBatteryStatsHistory = null;
        mHandler = null;
        mPlatformIdleStateCallback = null;
        mRailEnergyDataCallback = null;
        mUserInfoProvider = null;
        mConstants = new Constants(mHandler);
        clearHistoryLocked();
@@ -3005,6 +3024,7 @@ public class BatteryStatsImpl extends BatteryStats {
        private final LongSamplingCounter mRxTimeMillis;
        private final LongSamplingCounter[] mTxTimeMillis;
        private final LongSamplingCounter mPowerDrainMaMs;
        private final LongSamplingCounter mMonitoredRailChargeConsumedMaMs;
        public ControllerActivityCounterImpl(TimeBase timeBase, int numTxStates) {
            mIdleTimeMillis = new LongSamplingCounter(timeBase);
@@ -3016,6 +3036,7 @@ public class BatteryStatsImpl extends BatteryStats {
                mTxTimeMillis[i] = new LongSamplingCounter(timeBase);
            }
            mPowerDrainMaMs = new LongSamplingCounter(timeBase);
            mMonitoredRailChargeConsumedMaMs = new LongSamplingCounter(timeBase);
        }
        public ControllerActivityCounterImpl(TimeBase timeBase, int numTxStates, Parcel in) {
@@ -3033,6 +3054,7 @@ public class BatteryStatsImpl extends BatteryStats {
                mTxTimeMillis[i] = new LongSamplingCounter(timeBase, in);
            }
            mPowerDrainMaMs = new LongSamplingCounter(timeBase, in);
            mMonitoredRailChargeConsumedMaMs = new LongSamplingCounter(timeBase, in);
        }
        public void readSummaryFromParcel(Parcel in) {
@@ -3048,6 +3070,7 @@ public class BatteryStatsImpl extends BatteryStats {
                counter.readSummaryFromParcelLocked(in);
            }
            mPowerDrainMaMs.readSummaryFromParcelLocked(in);
            mMonitoredRailChargeConsumedMaMs.readSummaryFromParcelLocked(in);
        }
        @Override
@@ -3065,6 +3088,7 @@ public class BatteryStatsImpl extends BatteryStats {
                counter.writeSummaryFromParcelLocked(dest);
            }
            mPowerDrainMaMs.writeSummaryFromParcelLocked(dest);
            mMonitoredRailChargeConsumedMaMs.writeSummaryFromParcelLocked(dest);
        }
        @Override
@@ -3078,6 +3102,7 @@ public class BatteryStatsImpl extends BatteryStats {
                counter.writeToParcel(dest);
            }
            mPowerDrainMaMs.writeToParcel(dest);
            mMonitoredRailChargeConsumedMaMs.writeToParcel(dest);
        }
        public void reset(boolean detachIfReset) {
@@ -3089,6 +3114,7 @@ public class BatteryStatsImpl extends BatteryStats {
                counter.reset(detachIfReset);
            }
            mPowerDrainMaMs.reset(detachIfReset);
            mMonitoredRailChargeConsumedMaMs.reset(detachIfReset);
        }
        public void detach() {
@@ -3100,6 +3126,7 @@ public class BatteryStatsImpl extends BatteryStats {
                counter.detach();
            }
            mPowerDrainMaMs.detach();
            mMonitoredRailChargeConsumedMaMs.detach();
        }
        /**
@@ -3154,6 +3181,15 @@ public class BatteryStatsImpl extends BatteryStats {
        public LongSamplingCounter getPowerCounter() {
            return mPowerDrainMaMs;
        }
        /**
         * @return a LongSamplingCounter, measuring actual monitored rail energy consumed
         * milli-ampere milli-seconds (mAmS).
         */
        @Override
        public LongSamplingCounter getMonitoredRailChargeConsumedMaMs() {
            return mMonitoredRailChargeConsumedMaMs;
        }
    }
    /** Get Resource Power Manager stats. Create a new one if it doesn't already exist. */
@@ -3497,6 +3533,8 @@ public class BatteryStatsImpl extends BatteryStats {
            if (DEBUG) Slog.i(TAG, "WRITE DELTA: batteryChargeUAh=" + cur.batteryChargeUAh);
            dest.writeInt(cur.batteryChargeUAh);
        }
        dest.writeDouble(cur.modemRailChargeMah);
        dest.writeDouble(cur.wifiRailChargeMah);
    }
    private int buildBatteryLevelInt(HistoryItem h) {
@@ -3747,6 +3785,8 @@ public class BatteryStatsImpl extends BatteryStats {
        if ((firstToken&DELTA_BATTERY_CHARGE_FLAG) != 0) {
            cur.batteryChargeUAh = src.readInt();
        }
        cur.modemRailChargeMah = src.readDouble();
        cur.wifiRailChargeMah = src.readDouble();
    }
    @Override
@@ -10111,12 +10151,12 @@ public class BatteryStatsImpl extends BatteryStats {
    }
    public BatteryStatsImpl(File systemDir, Handler handler, PlatformIdleStateCallback cb,
            UserInfoProvider userInfoProvider) {
        this(new SystemClocks(), systemDir, handler, cb, userInfoProvider);
            RailEnergyDataCallback railStatsCb, UserInfoProvider userInfoProvider) {
        this(new SystemClocks(), systemDir, handler, cb, railStatsCb, userInfoProvider);
    }
    private BatteryStatsImpl(Clocks clocks, File systemDir, Handler handler,
            PlatformIdleStateCallback cb,
            PlatformIdleStateCallback cb, RailEnergyDataCallback railStatsCb,
            UserInfoProvider userInfoProvider) {
        init(clocks);
@@ -10218,6 +10258,7 @@ public class BatteryStatsImpl extends BatteryStats {
        clearHistoryLocked();
        updateDailyDeadlineLocked();
        mPlatformIdleStateCallback = cb;
        mRailEnergyDataCallback = railStatsCb;
        mUserInfoProvider = userInfoProvider;
    }
@@ -10238,6 +10279,7 @@ public class BatteryStatsImpl extends BatteryStats {
        mBatteryStatsHistory = new BatteryStatsHistory(this, mHistoryBuffer);
        readFromParcel(p);
        mPlatformIdleStateCallback = null;
        mRailEnergyDataCallback = null;
    }
    public void setPowerProfileLocked(PowerProfile profile) {
@@ -10934,6 +10976,8 @@ public class BatteryStatsImpl extends BatteryStats {
            mWakeupReasonStats.clear();
        }
        mTmpRailStats.reset();
        mLastHistoryStepDetails = null;
        mLastStepCpuUserTime = mLastStepCpuSystemTime = 0;
        mCurStepCpuUserTime = mCurStepCpuSystemTime = 0;
@@ -11321,6 +11365,16 @@ public class BatteryStatsImpl extends BatteryStats {
                    mWifiActivity.getPowerCounter().addCountLocked(
                            (long) (info.getControllerEnergyUsed() / opVolt));
                }
                // Converting uWs to mAms.
                // Conversion: (uWs * (1000ms / 1s) * (1mW / 1000uW)) / mV = mAms
                long monitoredRailChargeConsumedMaMs =
                        (long) (mTmpRailStats.getWifiTotalEnergyUseduWs() / opVolt);
                mWifiActivity.getMonitoredRailChargeConsumedMaMs().addCountLocked(
                        monitoredRailChargeConsumedMaMs);
                mHistoryCur.wifiRailChargeMah +=
                        (monitoredRailChargeConsumedMaMs / MILLISECONDS_IN_HOUR);
                addHistoryRecordLocked(mClocks.elapsedRealtime(), mClocks.uptimeMillis());
                mTmpRailStats.resetWifiTotalEnergyUsed();
            }
        }
    }
@@ -11411,9 +11465,18 @@ public class BatteryStatsImpl extends BatteryStats {
                    // We store the power drain as mAms.
                    mModemActivity.getPowerCounter().addCountLocked((long) energyUsed);
                    // Converting uWs to mAms.
                    // Conversion: (uWs * (1000ms / 1s) * (1mW / 1000uW)) / mV = mAms
                    long monitoredRailChargeConsumedMaMs =
                            (long) (mTmpRailStats.getCellularTotalEnergyUseduWs() / opVolt);
                    mModemActivity.getMonitoredRailChargeConsumedMaMs().addCountLocked(
                            monitoredRailChargeConsumedMaMs);
                    mHistoryCur.modemRailChargeMah +=
                            (monitoredRailChargeConsumedMaMs / MILLISECONDS_IN_HOUR);
                    addHistoryRecordLocked(mClocks.elapsedRealtime(), mClocks.uptimeMillis());
                    mTmpRailStats.resetCellularTotalEnergyUsed();
                }
            }
            final long elapsedRealtimeMs = mClocks.elapsedRealtime();
            long radioTime = mMobileRadioActivePerAppTimer.getTimeSinceMarkLocked(
                    elapsedRealtimeMs * 1000);
@@ -11811,6 +11874,16 @@ public class BatteryStatsImpl extends BatteryStats {
        }
    }
    /**
     * Read and record Rail Energy data.
     */
    public void updateRailStatsLocked() {
        if (mRailEnergyDataCallback == null || !mTmpRailStats.isRailStatsAvailable()) {
            return;
        }
        mRailEnergyDataCallback.fillRailDataStats(mTmpRailStats);
    }
    /**
     * Read and distribute kernel wake lock use across apps.
     */
@@ -12950,6 +13023,8 @@ public class BatteryStatsImpl extends BatteryStats {
        final long idleTimeMs = counter.getIdleTimeCounter().getCountLocked(which);
        final long rxTimeMs = counter.getRxTimeCounter().getCountLocked(which);
        final long energyConsumedMaMs = counter.getPowerCounter().getCountLocked(which);
        final long monitoredRailChargeConsumedMaMs =
                counter.getMonitoredRailChargeConsumedMaMs().getCountLocked(which);
        long[] timeInRatMs = new long[BatteryStats.NUM_DATA_CONNECTION_TYPES];
        for (int i = 0; i < timeInRatMs.length; i++) {
           timeInRatMs[i] = getPhoneDataConnectionTime(i, rawRealTime, which) / 1000;
@@ -12979,6 +13054,7 @@ public class BatteryStatsImpl extends BatteryStats {
        s.setTimeInRatMs(timeInRatMs);
        s.setTimeInRxSignalStrengthLevelMs(timeInRxSignalStrengthLevelMs);
        s.setTxTimeMs(txTimeMs);
        s.setMonitoredRailChargeConsumedMaMs(monitoredRailChargeConsumedMaMs);
        return s;
    }
@@ -12997,6 +13073,8 @@ public class BatteryStatsImpl extends BatteryStats {
        final long sleepTimeMs
                = totalControllerActivityTimeMs - (idleTimeMs + rxTimeMs + txTimeMs);
        final long energyConsumedMaMs = counter.getPowerCounter().getCountLocked(which);
        final long monitoredRailChargeConsumedMaMs =
                counter.getMonitoredRailChargeConsumedMaMs().getCountLocked(which);
        long numAppScanRequest = 0;
        for (int i = 0; i < mUidStats.size(); i++) {
            numAppScanRequest += mUidStats.valueAt(i).mWifiScanTimer.getCountLocked(which);
@@ -13029,6 +13107,7 @@ public class BatteryStatsImpl extends BatteryStats {
        s.setTimeInStateMs(timeInStateMs);
        s.setTimeInSupplicantStateMs(timeInSupplStateMs);
        s.setTimeInRxSignalStrengthLevelMs(timeSignalStrengthTimeMs);
        s.setMonitoredRailChargeConsumedMaMs(monitoredRailChargeConsumedMaMs);
        return s;
    }
+147 −0

File added.

Preview size limit exceeded, changes collapsed.

+4 −0
Original line number Diff line number Diff line
@@ -58,6 +58,10 @@ message ControllerActivityProto {
        optional int64 duration_ms = 2;
    }
    repeated TxLevel tx = 4;

    // Total rail charge consumed by the monitored rails by the controller. The value may
    // always be 0 if the device doesn't support monitored rail calculations.
    optional double monitored_rail_charge_mah = 5;
}

message SystemProto {
Loading