summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Richard Gaywood <richardgaywood@google.com> 2020-02-18 15:59:06 +0000
committer Richard Gaywood <richardgaywood@google.com> 2020-02-20 16:09:20 +0000
commit3ee7557fb5007fedfd291a55b85afa8417a48ff9 (patch)
tree50336c05bbd00bd88bdb0ac5122878e9c5f41c0e
parentcce9df2afc3edc9a58a97dbd3746c5d2acb217a9 (diff)
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
-rw-r--r--core/java/com/android/internal/app/procstats/IProcessStats.aidl11
-rw-r--r--core/java/com/android/internal/app/procstats/ProcessStats.java9
-rw-r--r--services/core/java/com/android/server/am/ProcessStatsService.java18
3 files changed, 36 insertions, 2 deletions
diff --git a/core/java/com/android/internal/app/procstats/IProcessStats.aidl b/core/java/com/android/internal/app/procstats/IProcessStats.aidl
index 0c203ab76346..7a6301f6f180 100644
--- a/core/java/com/android/internal/app/procstats/IProcessStats.aidl
+++ b/core/java/com/android/internal/app/procstats/IProcessStats.aidl
@@ -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);
}
diff --git a/core/java/com/android/internal/app/procstats/ProcessStats.java b/core/java/com/android/internal/app/procstats/ProcessStats.java
index 3045410a2ca2..009b1e0fa829 100644
--- a/core/java/com/android/internal/app/procstats/ProcessStats.java
+++ b/core/java/com/android/internal/app/procstats/ProcessStats.java
@@ -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();
diff --git a/services/core/java/com/android/server/am/ProcessStatsService.java b/services/core/java/com/android/server/am/ProcessStatsService.java
index 3ada0c366758..5bf0ed6d2438 100644
--- a/services/core/java/com/android/server/am/ProcessStatsService.java
+++ b/services/core/java/com/android/server/am/ProcessStatsService.java
@@ -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 {