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

Commit 3ee7557f authored by Richard Gaywood's avatar Richard Gaywood
Browse files

Add method to return merged stats to AIDL

For procstats aggregated stats collection, we need to expose the
aggregated ProcessStats object back to the caller.

Change-Id: Ifb52f813d679e3e0a1e061f983d8b4f539d6d72a
Test: nothing yet
parent cce9df2a
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -34,4 +34,15 @@ interface IProcessStats {
     */
     long getCommittedStats(long highWaterMarkMs, int section, boolean doAggregate,
        out List<ParcelFileDescriptor> committedStats);

    /**
     * Get stats committed after highWaterMarkMs
     * @param highWaterMarkMs Report stats committed after this time.
     * @param section Integer mask to indicate which sections to include in the stats.
     * @param doAggregate Whether to aggregate the stats or keep them separated.
     * @param List of Files of individual commits in protobuf binary or one that is merged from them.
     * @param ProcessStats object that will be used to return the full set of merged stats.
     */
     long getCommittedStatsMerged(long highWaterMarkMs, int section, boolean doAggregate,
        out List<ParcelFileDescriptor> committedStats, out ProcessStats mergedStats);
}
+9 −0
Original line number Diff line number Diff line
@@ -266,6 +266,15 @@ public final class ProcessStats implements Parcelable {
        readFromParcel(in);
    }

    /**
     * No-arg constructor is for use in AIDL-derived stubs.
     *
     * <p>This defaults to the non-running state, so is equivalent to ProcessStats(false).
     */
    public ProcessStats() {
        this(false);
    }

    public void add(ProcessStats other) {
        ArrayMap<String, SparseArray<LongSparseArray<PackageState>>> pkgMap =
                other.mPackages.getMap();
+16 −2
Original line number Diff line number Diff line
@@ -539,15 +539,29 @@ public final class ProcessStatsService extends IProcessStats.Stub {
     * @param highWaterMarkMs Report stats committed after this time.
     * @param section Integer mask to indicage which sections to include in the stats.
     * @param doAggregate Whether to aggregate the stats or keep them separated.
     * @return List of proto binary of individual commit files or one that is merged from them.
     * @return List of proto binary of individual commit files or one that is merged from them
     */
    @Override
    public long getCommittedStats(long highWaterMarkMs, int section, boolean doAggregate,
            List<ParcelFileDescriptor> committedStats) {
        return getCommittedStatsMerged(highWaterMarkMs, section, doAggregate, committedStats,
                new ProcessStats(false));
    }

    /**
     * Get stats committed after highWaterMarkMs
     * @param highWaterMarkMs Report stats committed after this time.
     * @param section Integer mask to indicage which sections to include in the stats.
     * @param doAggregate Whether to aggregate the stats or keep them separated.
     * @return List of proto binary of individual commit files or one that is merged from them;
     *         the merged, final ProcessStats object.
     */
    @Override
    public long getCommittedStatsMerged(long highWaterMarkMs, int section, boolean doAggregate,
            List<ParcelFileDescriptor> committedStats, ProcessStats mergedStats) {
        mAm.mContext.enforceCallingOrSelfPermission(
                android.Manifest.permission.PACKAGE_USAGE_STATS, null);

        ProcessStats mergedStats = new ProcessStats(false);
        long newHighWaterMark = highWaterMarkMs;
        mWriteLock.lock();
        try {