Loading core/java/com/android/internal/app/procstats/IProcessStats.aidl +10 −0 Original line number Diff line number Diff line Loading @@ -24,4 +24,14 @@ interface IProcessStats { byte[] getCurrentStats(out List<ParcelFileDescriptor> historic); ParcelFileDescriptor getStatsOverTime(long minTime); int getCurrentMemoryState(); /** * 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. */ long getCommittedStats(long highWaterMarkMs, int section, boolean doAggregate, out List<ParcelFileDescriptor> committedStats); } core/java/com/android/internal/app/procstats/ProcessStats.java +308 −234 Original line number Diff line number Diff line Loading @@ -158,6 +158,25 @@ public final class ProcessStats implements Parcelable { STATE_CACHED_ACTIVITY_CLIENT, STATE_CACHED_EMPTY }; // Should report process stats. public static final int REPORT_PROC_STATS = 0x01; // Should report package process stats. public static final int REPORT_PKG_PROC_STATS = 0x02; // Should report package service stats. public static final int REPORT_PKG_SVC_STATS = 0x04; // Should report package association stats. public static final int REPORT_PKG_ASC_STATS = 0x08; // Should report package stats. public static final int REPORT_PKG_STATS = 0x0E; // Should report all stats. public static final int REPORT_ALL = 0x0F; public static final int[] OPTIONS = {REPORT_PROC_STATS, REPORT_PKG_PROC_STATS, REPORT_PKG_SVC_STATS, REPORT_PKG_ASC_STATS, REPORT_PKG_STATS, REPORT_ALL}; public static final String[] OPTIONS_STR = {"proc", "pkg-proc", "pkg-svc", "pkg-asc", "pkg-all", "all"}; // Current version of the parcel format. private static final int PARCEL_VERSION = 34; // In-memory Parcel magic number, used to detect attempts to unmarshall bad data Loading Loading @@ -1412,7 +1431,7 @@ public final class ProcessStats implements Parcelable { } public void dumpLocked(PrintWriter pw, String reqPackage, long now, boolean dumpSummary, boolean dumpDetails, boolean dumpAll, boolean activeOnly) { boolean dumpDetails, boolean dumpAll, boolean activeOnly, int section) { long totalTime = DumpUtils.dumpSingleTime(null, null, mMemFactorDurations, mMemFactor, mStartTime, now); boolean sepNeeded = false; Loading @@ -1421,8 +1440,10 @@ public final class ProcessStats implements Parcelable { mSysMemUsage.dump(pw, " ", ALL_SCREEN_ADJ, ALL_MEM_ADJ); sepNeeded = true; } ArrayMap<String, SparseArray<LongSparseArray<PackageState>>> pkgMap = mPackages.getMap(); boolean printedHeader = false; if ((section & REPORT_PKG_STATS) != 0) { ArrayMap<String, SparseArray<LongSparseArray<PackageState>>> pkgMap = mPackages.getMap(); for (int ip = 0; ip < pkgMap.size(); ip++) { final String pkgName = pkgMap.keyAt(ip); final SparseArray<LongSparseArray<PackageState>> uids = pkgMap.valueAt(ip); Loading Loading @@ -1456,10 +1477,15 @@ public final class ProcessStats implements Parcelable { printedHeader = true; sepNeeded = true; } pw.print(" * "); pw.print(pkgName); pw.print(" / "); UserHandle.formatUid(pw, uid); pw.print(" / v"); pw.print(vers); pw.println(":"); pw.print(" * "); pw.print(pkgName); pw.print(" / "); UserHandle.formatUid(pw, uid); pw.print(" / v"); pw.print(vers); pw.println(":"); } if ((section & REPORT_PKG_PROC_STATS) != 0) { if (!dumpSummary || dumpAll) { for (int iproc = 0; iproc < NPROCS; iproc++) { ProcessState proc = pkgState.mProcesses.valueAt(iproc); Loading @@ -1468,7 +1494,8 @@ public final class ProcessStats implements Parcelable { } if (activeOnly && !proc.isInUse()) { pw.print(" (Not active: "); pw.print(pkgState.mProcesses.keyAt(iproc)); pw.println(")"); pw.print(pkgState.mProcesses.keyAt(iproc)); pw.println(")"); continue; } pw.print(" Process "); Loading @@ -1481,7 +1508,8 @@ public final class ProcessStats implements Parcelable { pw.print(proc.getDurationsBucketCount()); pw.print(" entries)"); pw.println(":"); proc.dumpProcessState(pw, " ", ALL_SCREEN_ADJ, ALL_MEM_ADJ, proc.dumpProcessState(pw, " ", ALL_SCREEN_ADJ, ALL_MEM_ADJ, ALL_PROC_STATES, now); proc.dumpPss(pw, " ", ALL_SCREEN_ADJ, ALL_MEM_ADJ, ALL_PROC_STATES, now); Loading @@ -1503,6 +1531,8 @@ public final class ProcessStats implements Parcelable { ALL_SCREEN_ADJ, ALL_MEM_ADJ, NON_CACHED_PROC_STATES, now, totalTime); } } if ((section & REPORT_PKG_SVC_STATS) != 0) { for (int isvc = 0; isvc < NSRVS; isvc++) { ServiceState svc = pkgState.mServices.valueAt(isvc); if (!pkgMatch && !reqPackage.equals(svc.getProcessName())) { Loading @@ -1510,7 +1540,8 @@ public final class ProcessStats implements Parcelable { } if (activeOnly && !svc.isInUse()) { pw.print(" (Not active service: "); pw.print(pkgState.mServices.keyAt(isvc)); pw.println(")"); pw.print(pkgState.mServices.keyAt(isvc)); pw.println(")"); continue; } if (dumpAll) { Loading @@ -1520,10 +1551,13 @@ public final class ProcessStats implements Parcelable { } pw.print(pkgState.mServices.keyAt(isvc)); pw.println(":"); pw.print(" Process: "); pw.println(svc.getProcessName()); pw.print(" Process: "); pw.println(svc.getProcessName()); svc.dumpStats(pw, " ", " ", " ", now, totalTime, dumpSummary, dumpAll); } } if ((section & REPORT_PKG_ASC_STATS) != 0) { for (int iasc = 0; iasc < NASCS; iasc++) { AssociationState asc = pkgState.mAssociations.valueAt(iasc); if (!pkgMatch && !reqPackage.equals(asc.getProcessName())) { Loading @@ -1531,7 +1565,8 @@ public final class ProcessStats implements Parcelable { } if (activeOnly && !asc.isInUse()) { pw.print(" (Not active association: "); pw.print(pkgState.mAssociations.keyAt(iasc)); pw.println(")"); pw.print(pkgState.mAssociations.keyAt(iasc)); pw.println(")"); continue; } if (dumpAll) { Loading @@ -1541,14 +1576,18 @@ public final class ProcessStats implements Parcelable { } pw.print(pkgState.mAssociations.keyAt(iasc)); pw.println(":"); pw.print(" Process: "); pw.println(asc.getProcessName()); pw.print(" Process: "); pw.println(asc.getProcessName()); asc.dumpStats(pw, " ", " ", " ", now, totalTime, dumpDetails, dumpAll); } } } } } } if ((section & REPORT_PROC_STATS) != 0) { ArrayMap<String, SparseArray<ProcessState>> procMap = mProcesses.getMap(); printedHeader = false; int numShownProcs = 0, numTotalProcs = 0; Loading Loading @@ -1579,27 +1618,35 @@ public final class ProcessStats implements Parcelable { printedHeader = true; } if (activeOnly && !proc.isInUse()) { pw.print(" (Not active: "); pw.print(procName); pw.println(")"); pw.print(" (Not active: "); pw.print(procName); pw.println(")"); continue; } pw.print(" * "); pw.print(procName); pw.print(" / "); pw.print(" * "); pw.print(procName); pw.print(" / "); UserHandle.formatUid(pw, uid); pw.print(" ("); pw.print(proc.getDurationsBucketCount()); pw.print(" entries)"); pw.println(":"); pw.print(" ("); pw.print(proc.getDurationsBucketCount()); pw.print(" entries)"); pw.println(":"); proc.dumpProcessState(pw, " ", ALL_SCREEN_ADJ, ALL_MEM_ADJ, ALL_PROC_STATES, now); proc.dumpPss(pw, " ", ALL_SCREEN_ADJ, ALL_MEM_ADJ, ALL_PROC_STATES, now); proc.dumpInternalLocked(pw, " ", dumpAll); } } pw.print(" Total procs: "); pw.print(numShownProcs); pw.print(" shown of "); pw.print(numTotalProcs); pw.println(" total"); } if (dumpAll) { if (sepNeeded) { pw.println(); } sepNeeded = true; pw.print(" Total procs: "); pw.print(numShownProcs); pw.print(" shown of "); pw.print(numTotalProcs); pw.println(" total"); if (mTrackingAssociations.size() > 0) { pw.println(); pw.println("Tracking associations:"); Loading Loading @@ -1866,7 +1913,10 @@ public final class ProcessStats implements Parcelable { return outProcs; } public void dumpCheckinLocked(PrintWriter pw, String reqPackage) { /** * Prints checkin style stats dump. */ public void dumpCheckinLocked(PrintWriter pw, String reqPackage, int section) { final long now = SystemClock.uptimeMillis(); final ArrayMap<String, SparseArray<LongSparseArray<PackageState>>> pkgMap = mPackages.getMap(); Loading Loading @@ -1895,6 +1945,8 @@ public final class ProcessStats implements Parcelable { } pw.println(); pw.print("config,"); pw.println(mRuntime); if ((section & REPORT_PKG_STATS) != 0) { for (int ip = 0; ip < pkgMap.size(); ip++) { final String pkgName = pkgMap.keyAt(ip); if (reqPackage != null && !reqPackage.equals(pkgName)) { Loading @@ -1910,17 +1962,22 @@ public final class ProcessStats implements Parcelable { final int NPROCS = pkgState.mProcesses.size(); final int NSRVS = pkgState.mServices.size(); final int NASCS = pkgState.mAssociations.size(); if ((section & REPORT_PKG_PROC_STATS) != 0) { for (int iproc = 0; iproc < NPROCS; iproc++) { ProcessState proc = pkgState.mProcesses.valueAt(iproc); proc.dumpPackageProcCheckin(pw, pkgName, uid, vers, pkgState.mProcesses.keyAt(iproc), now); } } if ((section & REPORT_PKG_SVC_STATS) != 0) { for (int isvc = 0; isvc < NSRVS; isvc++) { final String serviceName = DumpUtils.collapseString(pkgName, pkgState.mServices.keyAt(isvc)); final ServiceState svc = pkgState.mServices.valueAt(isvc); svc.dumpTimesCheckin(pw, pkgName, uid, vers, serviceName, now); } } if ((section & REPORT_PKG_ASC_STATS) != 0) { for (int iasc = 0; iasc < NASCS; iasc++) { final String associationName = DumpUtils.collapseString(pkgName, pkgState.mAssociations.keyAt(iasc)); Loading @@ -1930,7 +1987,10 @@ public final class ProcessStats implements Parcelable { } } } } } if ((section & REPORT_PROC_STATS) != 0) { ArrayMap<String, SparseArray<ProcessState>> procMap = mProcesses.getMap(); for (int ip = 0; ip < procMap.size(); ip++) { String procName = procMap.keyAt(ip); Loading @@ -1941,6 +2001,7 @@ public final class ProcessStats implements Parcelable { procState.dumpProcCheckin(pw, procName, uid, now); } } } pw.print("total"); DumpUtils.dumpAdjTimesCheckin(pw, ",", mMemFactorDurations, mMemFactor, mStartTime, now); pw.println(); Loading Loading @@ -2013,9 +2074,10 @@ public final class ProcessStats implements Parcelable { } } public void writeToProto(ProtoOutputStream proto, long fieldId, long now) { final long token = proto.start(fieldId); /** * Writes to ProtoOutputStream. */ public void writeToProto(ProtoOutputStream proto, long now, int section) { proto.write(ProcessStatsSectionProto.START_REALTIME_MS, mTimePeriodStartRealtime); proto.write(ProcessStatsSectionProto.END_REALTIME_MS, mRunning ? SystemClock.elapsedRealtime() : mTimePeriodEndRealtime); Loading @@ -2041,6 +2103,7 @@ public final class ProcessStats implements Parcelable { } final ArrayMap<String, SparseArray<ProcessState>> procMap = mProcesses.getMap(); if ((section & REPORT_PROC_STATS) != 0) { for (int ip = 0; ip < procMap.size(); ip++) { final String procName = procMap.keyAt(ip); final SparseArray<ProcessState> uids = procMap.valueAt(ip); Loading @@ -2051,7 +2114,9 @@ public final class ProcessStats implements Parcelable { uid, now); } } } if ((section & REPORT_PKG_STATS) != 0) { final ArrayMap<String, SparseArray<LongSparseArray<PackageState>>> pkgMap = mPackages.getMap(); for (int ip = 0; ip < pkgMap.size(); ip++) { Loading @@ -2060,12 +2125,12 @@ public final class ProcessStats implements Parcelable { final LongSparseArray<PackageState> vers = uids.valueAt(iu); for (int iv = 0; iv < vers.size(); iv++) { final PackageState pkgState = vers.valueAt(iv); pkgState.writeToProto(proto, ProcessStatsSectionProto.PACKAGE_STATS, now); pkgState.writeToProto(proto, ProcessStatsSectionProto.PACKAGE_STATS, now, section); } } } } proto.end(token); } final public static class ProcessStateHolder { Loading Loading @@ -2110,31 +2175,40 @@ public final class ProcessStats implements Parcelable { return as; } public void writeToProto(ProtoOutputStream proto, long fieldId, long now) { /** * Writes the containing stats into proto, with options to choose smaller sections. */ public void writeToProto(ProtoOutputStream proto, long fieldId, long now, int section) { final long token = proto.start(fieldId); proto.write(ProcessStatsPackageProto.PACKAGE, mPackageName); proto.write(ProcessStatsPackageProto.UID, mUid); proto.write(ProcessStatsPackageProto.VERSION, mVersionCode); if ((section & ProcessStats.REPORT_PKG_PROC_STATS) != 0) { for (int ip = 0; ip < mProcesses.size(); ip++) { final String procName = mProcesses.keyAt(ip); final ProcessState procState = mProcesses.valueAt(ip); procState.writeToProto(proto, ProcessStatsPackageProto.PROCESS_STATS, procName, mUid, now); } } if ((section & ProcessStats.REPORT_PKG_SVC_STATS) != 0) { for (int is = 0; is < mServices.size(); is++) { final ServiceState serviceState = mServices.valueAt(is); serviceState.writeToProto(proto, ProcessStatsPackageProto.SERVICE_STATS, now); } } if ((section & ProcessStats.REPORT_PKG_ASC_STATS) != 0) { for (int ia = 0; ia < mAssociations.size(); ia++) { final AssociationState ascState = mAssociations.valueAt(ia); ascState.writeToProto(proto, ProcessStatsPackageProto.ASSOCIATION_STATS, now); } } proto.end(token); } Loading services/core/java/com/android/server/am/ProcessStatsService.java +137 −20 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
core/java/com/android/internal/app/procstats/IProcessStats.aidl +10 −0 Original line number Diff line number Diff line Loading @@ -24,4 +24,14 @@ interface IProcessStats { byte[] getCurrentStats(out List<ParcelFileDescriptor> historic); ParcelFileDescriptor getStatsOverTime(long minTime); int getCurrentMemoryState(); /** * 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. */ long getCommittedStats(long highWaterMarkMs, int section, boolean doAggregate, out List<ParcelFileDescriptor> committedStats); }
core/java/com/android/internal/app/procstats/ProcessStats.java +308 −234 Original line number Diff line number Diff line Loading @@ -158,6 +158,25 @@ public final class ProcessStats implements Parcelable { STATE_CACHED_ACTIVITY_CLIENT, STATE_CACHED_EMPTY }; // Should report process stats. public static final int REPORT_PROC_STATS = 0x01; // Should report package process stats. public static final int REPORT_PKG_PROC_STATS = 0x02; // Should report package service stats. public static final int REPORT_PKG_SVC_STATS = 0x04; // Should report package association stats. public static final int REPORT_PKG_ASC_STATS = 0x08; // Should report package stats. public static final int REPORT_PKG_STATS = 0x0E; // Should report all stats. public static final int REPORT_ALL = 0x0F; public static final int[] OPTIONS = {REPORT_PROC_STATS, REPORT_PKG_PROC_STATS, REPORT_PKG_SVC_STATS, REPORT_PKG_ASC_STATS, REPORT_PKG_STATS, REPORT_ALL}; public static final String[] OPTIONS_STR = {"proc", "pkg-proc", "pkg-svc", "pkg-asc", "pkg-all", "all"}; // Current version of the parcel format. private static final int PARCEL_VERSION = 34; // In-memory Parcel magic number, used to detect attempts to unmarshall bad data Loading Loading @@ -1412,7 +1431,7 @@ public final class ProcessStats implements Parcelable { } public void dumpLocked(PrintWriter pw, String reqPackage, long now, boolean dumpSummary, boolean dumpDetails, boolean dumpAll, boolean activeOnly) { boolean dumpDetails, boolean dumpAll, boolean activeOnly, int section) { long totalTime = DumpUtils.dumpSingleTime(null, null, mMemFactorDurations, mMemFactor, mStartTime, now); boolean sepNeeded = false; Loading @@ -1421,8 +1440,10 @@ public final class ProcessStats implements Parcelable { mSysMemUsage.dump(pw, " ", ALL_SCREEN_ADJ, ALL_MEM_ADJ); sepNeeded = true; } ArrayMap<String, SparseArray<LongSparseArray<PackageState>>> pkgMap = mPackages.getMap(); boolean printedHeader = false; if ((section & REPORT_PKG_STATS) != 0) { ArrayMap<String, SparseArray<LongSparseArray<PackageState>>> pkgMap = mPackages.getMap(); for (int ip = 0; ip < pkgMap.size(); ip++) { final String pkgName = pkgMap.keyAt(ip); final SparseArray<LongSparseArray<PackageState>> uids = pkgMap.valueAt(ip); Loading Loading @@ -1456,10 +1477,15 @@ public final class ProcessStats implements Parcelable { printedHeader = true; sepNeeded = true; } pw.print(" * "); pw.print(pkgName); pw.print(" / "); UserHandle.formatUid(pw, uid); pw.print(" / v"); pw.print(vers); pw.println(":"); pw.print(" * "); pw.print(pkgName); pw.print(" / "); UserHandle.formatUid(pw, uid); pw.print(" / v"); pw.print(vers); pw.println(":"); } if ((section & REPORT_PKG_PROC_STATS) != 0) { if (!dumpSummary || dumpAll) { for (int iproc = 0; iproc < NPROCS; iproc++) { ProcessState proc = pkgState.mProcesses.valueAt(iproc); Loading @@ -1468,7 +1494,8 @@ public final class ProcessStats implements Parcelable { } if (activeOnly && !proc.isInUse()) { pw.print(" (Not active: "); pw.print(pkgState.mProcesses.keyAt(iproc)); pw.println(")"); pw.print(pkgState.mProcesses.keyAt(iproc)); pw.println(")"); continue; } pw.print(" Process "); Loading @@ -1481,7 +1508,8 @@ public final class ProcessStats implements Parcelable { pw.print(proc.getDurationsBucketCount()); pw.print(" entries)"); pw.println(":"); proc.dumpProcessState(pw, " ", ALL_SCREEN_ADJ, ALL_MEM_ADJ, proc.dumpProcessState(pw, " ", ALL_SCREEN_ADJ, ALL_MEM_ADJ, ALL_PROC_STATES, now); proc.dumpPss(pw, " ", ALL_SCREEN_ADJ, ALL_MEM_ADJ, ALL_PROC_STATES, now); Loading @@ -1503,6 +1531,8 @@ public final class ProcessStats implements Parcelable { ALL_SCREEN_ADJ, ALL_MEM_ADJ, NON_CACHED_PROC_STATES, now, totalTime); } } if ((section & REPORT_PKG_SVC_STATS) != 0) { for (int isvc = 0; isvc < NSRVS; isvc++) { ServiceState svc = pkgState.mServices.valueAt(isvc); if (!pkgMatch && !reqPackage.equals(svc.getProcessName())) { Loading @@ -1510,7 +1540,8 @@ public final class ProcessStats implements Parcelable { } if (activeOnly && !svc.isInUse()) { pw.print(" (Not active service: "); pw.print(pkgState.mServices.keyAt(isvc)); pw.println(")"); pw.print(pkgState.mServices.keyAt(isvc)); pw.println(")"); continue; } if (dumpAll) { Loading @@ -1520,10 +1551,13 @@ public final class ProcessStats implements Parcelable { } pw.print(pkgState.mServices.keyAt(isvc)); pw.println(":"); pw.print(" Process: "); pw.println(svc.getProcessName()); pw.print(" Process: "); pw.println(svc.getProcessName()); svc.dumpStats(pw, " ", " ", " ", now, totalTime, dumpSummary, dumpAll); } } if ((section & REPORT_PKG_ASC_STATS) != 0) { for (int iasc = 0; iasc < NASCS; iasc++) { AssociationState asc = pkgState.mAssociations.valueAt(iasc); if (!pkgMatch && !reqPackage.equals(asc.getProcessName())) { Loading @@ -1531,7 +1565,8 @@ public final class ProcessStats implements Parcelable { } if (activeOnly && !asc.isInUse()) { pw.print(" (Not active association: "); pw.print(pkgState.mAssociations.keyAt(iasc)); pw.println(")"); pw.print(pkgState.mAssociations.keyAt(iasc)); pw.println(")"); continue; } if (dumpAll) { Loading @@ -1541,14 +1576,18 @@ public final class ProcessStats implements Parcelable { } pw.print(pkgState.mAssociations.keyAt(iasc)); pw.println(":"); pw.print(" Process: "); pw.println(asc.getProcessName()); pw.print(" Process: "); pw.println(asc.getProcessName()); asc.dumpStats(pw, " ", " ", " ", now, totalTime, dumpDetails, dumpAll); } } } } } } if ((section & REPORT_PROC_STATS) != 0) { ArrayMap<String, SparseArray<ProcessState>> procMap = mProcesses.getMap(); printedHeader = false; int numShownProcs = 0, numTotalProcs = 0; Loading Loading @@ -1579,27 +1618,35 @@ public final class ProcessStats implements Parcelable { printedHeader = true; } if (activeOnly && !proc.isInUse()) { pw.print(" (Not active: "); pw.print(procName); pw.println(")"); pw.print(" (Not active: "); pw.print(procName); pw.println(")"); continue; } pw.print(" * "); pw.print(procName); pw.print(" / "); pw.print(" * "); pw.print(procName); pw.print(" / "); UserHandle.formatUid(pw, uid); pw.print(" ("); pw.print(proc.getDurationsBucketCount()); pw.print(" entries)"); pw.println(":"); pw.print(" ("); pw.print(proc.getDurationsBucketCount()); pw.print(" entries)"); pw.println(":"); proc.dumpProcessState(pw, " ", ALL_SCREEN_ADJ, ALL_MEM_ADJ, ALL_PROC_STATES, now); proc.dumpPss(pw, " ", ALL_SCREEN_ADJ, ALL_MEM_ADJ, ALL_PROC_STATES, now); proc.dumpInternalLocked(pw, " ", dumpAll); } } pw.print(" Total procs: "); pw.print(numShownProcs); pw.print(" shown of "); pw.print(numTotalProcs); pw.println(" total"); } if (dumpAll) { if (sepNeeded) { pw.println(); } sepNeeded = true; pw.print(" Total procs: "); pw.print(numShownProcs); pw.print(" shown of "); pw.print(numTotalProcs); pw.println(" total"); if (mTrackingAssociations.size() > 0) { pw.println(); pw.println("Tracking associations:"); Loading Loading @@ -1866,7 +1913,10 @@ public final class ProcessStats implements Parcelable { return outProcs; } public void dumpCheckinLocked(PrintWriter pw, String reqPackage) { /** * Prints checkin style stats dump. */ public void dumpCheckinLocked(PrintWriter pw, String reqPackage, int section) { final long now = SystemClock.uptimeMillis(); final ArrayMap<String, SparseArray<LongSparseArray<PackageState>>> pkgMap = mPackages.getMap(); Loading Loading @@ -1895,6 +1945,8 @@ public final class ProcessStats implements Parcelable { } pw.println(); pw.print("config,"); pw.println(mRuntime); if ((section & REPORT_PKG_STATS) != 0) { for (int ip = 0; ip < pkgMap.size(); ip++) { final String pkgName = pkgMap.keyAt(ip); if (reqPackage != null && !reqPackage.equals(pkgName)) { Loading @@ -1910,17 +1962,22 @@ public final class ProcessStats implements Parcelable { final int NPROCS = pkgState.mProcesses.size(); final int NSRVS = pkgState.mServices.size(); final int NASCS = pkgState.mAssociations.size(); if ((section & REPORT_PKG_PROC_STATS) != 0) { for (int iproc = 0; iproc < NPROCS; iproc++) { ProcessState proc = pkgState.mProcesses.valueAt(iproc); proc.dumpPackageProcCheckin(pw, pkgName, uid, vers, pkgState.mProcesses.keyAt(iproc), now); } } if ((section & REPORT_PKG_SVC_STATS) != 0) { for (int isvc = 0; isvc < NSRVS; isvc++) { final String serviceName = DumpUtils.collapseString(pkgName, pkgState.mServices.keyAt(isvc)); final ServiceState svc = pkgState.mServices.valueAt(isvc); svc.dumpTimesCheckin(pw, pkgName, uid, vers, serviceName, now); } } if ((section & REPORT_PKG_ASC_STATS) != 0) { for (int iasc = 0; iasc < NASCS; iasc++) { final String associationName = DumpUtils.collapseString(pkgName, pkgState.mAssociations.keyAt(iasc)); Loading @@ -1930,7 +1987,10 @@ public final class ProcessStats implements Parcelable { } } } } } if ((section & REPORT_PROC_STATS) != 0) { ArrayMap<String, SparseArray<ProcessState>> procMap = mProcesses.getMap(); for (int ip = 0; ip < procMap.size(); ip++) { String procName = procMap.keyAt(ip); Loading @@ -1941,6 +2001,7 @@ public final class ProcessStats implements Parcelable { procState.dumpProcCheckin(pw, procName, uid, now); } } } pw.print("total"); DumpUtils.dumpAdjTimesCheckin(pw, ",", mMemFactorDurations, mMemFactor, mStartTime, now); pw.println(); Loading Loading @@ -2013,9 +2074,10 @@ public final class ProcessStats implements Parcelable { } } public void writeToProto(ProtoOutputStream proto, long fieldId, long now) { final long token = proto.start(fieldId); /** * Writes to ProtoOutputStream. */ public void writeToProto(ProtoOutputStream proto, long now, int section) { proto.write(ProcessStatsSectionProto.START_REALTIME_MS, mTimePeriodStartRealtime); proto.write(ProcessStatsSectionProto.END_REALTIME_MS, mRunning ? SystemClock.elapsedRealtime() : mTimePeriodEndRealtime); Loading @@ -2041,6 +2103,7 @@ public final class ProcessStats implements Parcelable { } final ArrayMap<String, SparseArray<ProcessState>> procMap = mProcesses.getMap(); if ((section & REPORT_PROC_STATS) != 0) { for (int ip = 0; ip < procMap.size(); ip++) { final String procName = procMap.keyAt(ip); final SparseArray<ProcessState> uids = procMap.valueAt(ip); Loading @@ -2051,7 +2114,9 @@ public final class ProcessStats implements Parcelable { uid, now); } } } if ((section & REPORT_PKG_STATS) != 0) { final ArrayMap<String, SparseArray<LongSparseArray<PackageState>>> pkgMap = mPackages.getMap(); for (int ip = 0; ip < pkgMap.size(); ip++) { Loading @@ -2060,12 +2125,12 @@ public final class ProcessStats implements Parcelable { final LongSparseArray<PackageState> vers = uids.valueAt(iu); for (int iv = 0; iv < vers.size(); iv++) { final PackageState pkgState = vers.valueAt(iv); pkgState.writeToProto(proto, ProcessStatsSectionProto.PACKAGE_STATS, now); pkgState.writeToProto(proto, ProcessStatsSectionProto.PACKAGE_STATS, now, section); } } } } proto.end(token); } final public static class ProcessStateHolder { Loading Loading @@ -2110,31 +2175,40 @@ public final class ProcessStats implements Parcelable { return as; } public void writeToProto(ProtoOutputStream proto, long fieldId, long now) { /** * Writes the containing stats into proto, with options to choose smaller sections. */ public void writeToProto(ProtoOutputStream proto, long fieldId, long now, int section) { final long token = proto.start(fieldId); proto.write(ProcessStatsPackageProto.PACKAGE, mPackageName); proto.write(ProcessStatsPackageProto.UID, mUid); proto.write(ProcessStatsPackageProto.VERSION, mVersionCode); if ((section & ProcessStats.REPORT_PKG_PROC_STATS) != 0) { for (int ip = 0; ip < mProcesses.size(); ip++) { final String procName = mProcesses.keyAt(ip); final ProcessState procState = mProcesses.valueAt(ip); procState.writeToProto(proto, ProcessStatsPackageProto.PROCESS_STATS, procName, mUid, now); } } if ((section & ProcessStats.REPORT_PKG_SVC_STATS) != 0) { for (int is = 0; is < mServices.size(); is++) { final ServiceState serviceState = mServices.valueAt(is); serviceState.writeToProto(proto, ProcessStatsPackageProto.SERVICE_STATS, now); } } if ((section & ProcessStats.REPORT_PKG_ASC_STATS) != 0) { for (int ia = 0; ia < mAssociations.size(); ia++) { final AssociationState ascState = mAssociations.valueAt(ia); ascState.writeToProto(proto, ProcessStatsPackageProto.ASSOCIATION_STATS, now); } } proto.end(token); } Loading
services/core/java/com/android/server/am/ProcessStatsService.java +137 −20 File changed.Preview size limit exceeded, changes collapsed. Show changes