Loading core/java/android/util/proto/ProtoUtils.java +11 −1 Original line number Original line Diff line number Diff line Loading @@ -32,14 +32,24 @@ public class ProtoUtils { * Dump AggStats to ProtoOutputStream * Dump AggStats to ProtoOutputStream */ */ public static void toAggStatsProto(ProtoOutputStream proto, long fieldId, public static void toAggStatsProto(ProtoOutputStream proto, long fieldId, long min, long average, long max) { long min, long average, long max, int meanKb, int maxKb) { final long aggStatsToken = proto.start(fieldId); final long aggStatsToken = proto.start(fieldId); proto.write(AggStats.MIN, min); proto.write(AggStats.MIN, min); proto.write(AggStats.AVERAGE, average); proto.write(AggStats.AVERAGE, average); proto.write(AggStats.MAX, max); proto.write(AggStats.MAX, max); proto.write(AggStats.MEAN_KB, meanKb); proto.write(AggStats.MAX_KB, maxKb); proto.end(aggStatsToken); proto.end(aggStatsToken); } } /** * Dump AggStats to ProtoOutputStream */ public static void toAggStatsProto(ProtoOutputStream proto, long fieldId, long min, long average, long max) { toAggStatsProto(proto, fieldId, min, average, max, 0, 0); } /** /** * Dump Duration to ProtoOutputStream * Dump Duration to ProtoOutputStream */ */ Loading core/java/com/android/internal/app/procstats/DumpUtils.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -550,7 +550,7 @@ public final class DumpUtils { // screen state is in lowest 0xf bits, process state is in next 0xf bits up // screen state is in lowest 0xf bits, process state is in next 0xf bits up try { try { proto.write(stateId, STATE_PROTO_ENUMS[state >> 0xf]); proto.write(stateId, state >> 0xf); } catch (IndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) { proto.write(stateId, ProcessStatsEnums.PROCESS_STATE_UNKNOWN); proto.write(stateId, ProcessStatsEnums.PROCESS_STATE_UNKNOWN); } } Loading core/java/com/android/internal/app/procstats/ProcessState.java +11 −7 Original line number Original line Diff line number Diff line Loading @@ -1459,16 +1459,16 @@ public final class ProcessState { for (int i = 0; i < mPssTable.getKeyCount(); i++) { for (int i = 0; i < mPssTable.getKeyCount(); i++) { final int key = mPssTable.getKeyAt(i); final int key = mPssTable.getKeyAt(i); final int type = SparseMappingTable.getIdFromKey(key); final int type = SparseMappingTable.getIdFromKey(key); if (durationByState.indexOfKey(type) < 0) { final int aggregatedType = DumpUtils.aggregateCurrentProcessState(type); if (durationByState.indexOfKey(aggregatedType) < 0) { // state without duration should not have stats! // state without duration should not have stats! continue; continue; } } final int aggregatedType = DumpUtils.aggregateCurrentProcessState(type); long[] rssMeanAndMax = mPssTable.getRssMeanAndMax(key); long[] rssMeanAndMax = mPssTable.getRssMeanAndMax(key); // compute mean * duration, then store sum of that in meanRssByState // compute mean * duration, then store sum of that in meanRssByState long meanTimesDuration = rssMeanAndMax[0] * mDurations.getValue(key); long meanTimesDuration = rssMeanAndMax[0] * mDurations.getValueForId((byte) type); if (meanRssByState.indexOfKey(aggregatedType) >= 0) { if (meanRssByState.indexOfKey(aggregatedType) >= 0) { meanRssByState.put(aggregatedType, meanRssByState.put(aggregatedType, meanTimesDuration + meanRssByState.get(aggregatedType)); meanTimesDuration + meanRssByState.get(aggregatedType)); Loading @@ -1492,8 +1492,10 @@ public final class ProcessState { // these data structures should be consistent // these data structures should be consistent continue; continue; } } final long duration = durationByState.get(aggregatedKey); meanRssByState.put(aggregatedKey, meanRssByState.put(aggregatedKey, meanRssByState.get(aggregatedKey) / durationByState.get(aggregatedKey)); duration > 0 ? (meanRssByState.get(aggregatedKey) / duration) : meanRssByState.get(aggregatedKey)); } } // build the output // build the output Loading @@ -1508,14 +1510,16 @@ public final class ProcessState { DumpUtils.printAggregatedProcStateTagProto(proto, DumpUtils.printAggregatedProcStateTagProto(proto, ProcessStatsStateProto.SCREEN_STATE, ProcessStatsStateProto.SCREEN_STATE, ProcessStatsStateProto.PROCESS_STATE, ProcessStatsStateProto.PROCESS_STATE_AGGREGATED, aggregatedKey); aggregatedKey); proto.write(ProcessStatsStateProto.DURATION_MS, durationByState.get(aggregatedKey)); proto.write(ProcessStatsStateProto.DURATION_MS, durationByState.get(aggregatedKey)); ProtoUtils.toAggStatsProto(proto, ProcessStatsStateProto.RSS, ProtoUtils.toAggStatsProto(proto, ProcessStatsStateProto.RSS, 0, /* do not output a minimum value */ 0, /* do not output a minimum value */ meanRssByState.get(aggregatedKey), 0, /* do not output an average value */ maxRssByState.get(aggregatedKey)); 0, /* do not output a max value */ (int) meanRssByState.get(aggregatedKey), (int) maxRssByState.get(aggregatedKey)); proto.end(stateToken); proto.end(stateToken); } } Loading core/proto/android/service/procstats.proto +11 −4 Original line number Original line Diff line number Diff line Loading @@ -104,7 +104,7 @@ message ProcessStatsAvailablePagesProto { repeated int32 pages_per_order = 4; repeated int32 pages_per_order = 4; } } // Next Tag: 10 // Next Tag: 13 message ProcessStatsStateProto { message ProcessStatsStateProto { option (android.msg_privacy).dest = DEST_AUTOMATIC; option (android.msg_privacy).dest = DEST_AUTOMATIC; Loading @@ -114,13 +114,20 @@ message ProcessStatsStateProto { // this enum list is from frameworks/base/core/java/com/android/internal/app/procstats/ProcessStats.java // this enum list is from frameworks/base/core/java/com/android/internal/app/procstats/ProcessStats.java // and not frameworks/base/core/java/android/app/ActivityManager.java // and not frameworks/base/core/java/android/app/ActivityManager.java optional ProcessState process_state = 3; optional ProcessState process_state = 3 [deprecated = true]; // the AggregatedProcessState needs to keep sync with ProcessStateAggregated optional AggregatedProcessState process_state_aggregated = 10; // Millisecond uptime duration spent in this state // Millisecond uptime duration spent in this state optional int64 duration_ms = 4; optional int64 duration_ms = 4 [deprecated = true]; // Same as above, but with minute resolution so it fits into an int32. optional int32 duration_minutes = 11; // Millisecond elapsed realtime duration spent in this state // Millisecond elapsed realtime duration spent in this state optional int64 realtime_duration_ms = 9; optional int64 realtime_duration_ms = 9 [deprecated = true]; // Same as above, but with minute resolution so it fits into an int32. optional int32 realtime_duration_minutes = 12; // # of samples taken // # of samples taken optional int32 sample_size = 5; optional int32 sample_size = 5; Loading core/proto/android/util/common.proto +9 −4 Original line number Original line Diff line number Diff line Loading @@ -27,11 +27,16 @@ option java_multiple_files = true; message AggStats { message AggStats { option (android.msg_privacy).dest = DEST_AUTOMATIC; option (android.msg_privacy).dest = DEST_AUTOMATIC; optional int64 min = 1; optional int64 min = 1 [deprecated = true]; optional int64 average = 2; optional int64 average = 2 [deprecated = true]; optional int64 max = 3; optional int64 max = 3 [deprecated = true]; // These are all in kilobyte resolution. Can fit in int32, so smaller on the wire than the above // int64 fields. optional int32 mean_kb = 4; optional int32 max_kb = 5; } } /** /** Loading Loading
core/java/android/util/proto/ProtoUtils.java +11 −1 Original line number Original line Diff line number Diff line Loading @@ -32,14 +32,24 @@ public class ProtoUtils { * Dump AggStats to ProtoOutputStream * Dump AggStats to ProtoOutputStream */ */ public static void toAggStatsProto(ProtoOutputStream proto, long fieldId, public static void toAggStatsProto(ProtoOutputStream proto, long fieldId, long min, long average, long max) { long min, long average, long max, int meanKb, int maxKb) { final long aggStatsToken = proto.start(fieldId); final long aggStatsToken = proto.start(fieldId); proto.write(AggStats.MIN, min); proto.write(AggStats.MIN, min); proto.write(AggStats.AVERAGE, average); proto.write(AggStats.AVERAGE, average); proto.write(AggStats.MAX, max); proto.write(AggStats.MAX, max); proto.write(AggStats.MEAN_KB, meanKb); proto.write(AggStats.MAX_KB, maxKb); proto.end(aggStatsToken); proto.end(aggStatsToken); } } /** * Dump AggStats to ProtoOutputStream */ public static void toAggStatsProto(ProtoOutputStream proto, long fieldId, long min, long average, long max) { toAggStatsProto(proto, fieldId, min, average, max, 0, 0); } /** /** * Dump Duration to ProtoOutputStream * Dump Duration to ProtoOutputStream */ */ Loading
core/java/com/android/internal/app/procstats/DumpUtils.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -550,7 +550,7 @@ public final class DumpUtils { // screen state is in lowest 0xf bits, process state is in next 0xf bits up // screen state is in lowest 0xf bits, process state is in next 0xf bits up try { try { proto.write(stateId, STATE_PROTO_ENUMS[state >> 0xf]); proto.write(stateId, state >> 0xf); } catch (IndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) { proto.write(stateId, ProcessStatsEnums.PROCESS_STATE_UNKNOWN); proto.write(stateId, ProcessStatsEnums.PROCESS_STATE_UNKNOWN); } } Loading
core/java/com/android/internal/app/procstats/ProcessState.java +11 −7 Original line number Original line Diff line number Diff line Loading @@ -1459,16 +1459,16 @@ public final class ProcessState { for (int i = 0; i < mPssTable.getKeyCount(); i++) { for (int i = 0; i < mPssTable.getKeyCount(); i++) { final int key = mPssTable.getKeyAt(i); final int key = mPssTable.getKeyAt(i); final int type = SparseMappingTable.getIdFromKey(key); final int type = SparseMappingTable.getIdFromKey(key); if (durationByState.indexOfKey(type) < 0) { final int aggregatedType = DumpUtils.aggregateCurrentProcessState(type); if (durationByState.indexOfKey(aggregatedType) < 0) { // state without duration should not have stats! // state without duration should not have stats! continue; continue; } } final int aggregatedType = DumpUtils.aggregateCurrentProcessState(type); long[] rssMeanAndMax = mPssTable.getRssMeanAndMax(key); long[] rssMeanAndMax = mPssTable.getRssMeanAndMax(key); // compute mean * duration, then store sum of that in meanRssByState // compute mean * duration, then store sum of that in meanRssByState long meanTimesDuration = rssMeanAndMax[0] * mDurations.getValue(key); long meanTimesDuration = rssMeanAndMax[0] * mDurations.getValueForId((byte) type); if (meanRssByState.indexOfKey(aggregatedType) >= 0) { if (meanRssByState.indexOfKey(aggregatedType) >= 0) { meanRssByState.put(aggregatedType, meanRssByState.put(aggregatedType, meanTimesDuration + meanRssByState.get(aggregatedType)); meanTimesDuration + meanRssByState.get(aggregatedType)); Loading @@ -1492,8 +1492,10 @@ public final class ProcessState { // these data structures should be consistent // these data structures should be consistent continue; continue; } } final long duration = durationByState.get(aggregatedKey); meanRssByState.put(aggregatedKey, meanRssByState.put(aggregatedKey, meanRssByState.get(aggregatedKey) / durationByState.get(aggregatedKey)); duration > 0 ? (meanRssByState.get(aggregatedKey) / duration) : meanRssByState.get(aggregatedKey)); } } // build the output // build the output Loading @@ -1508,14 +1510,16 @@ public final class ProcessState { DumpUtils.printAggregatedProcStateTagProto(proto, DumpUtils.printAggregatedProcStateTagProto(proto, ProcessStatsStateProto.SCREEN_STATE, ProcessStatsStateProto.SCREEN_STATE, ProcessStatsStateProto.PROCESS_STATE, ProcessStatsStateProto.PROCESS_STATE_AGGREGATED, aggregatedKey); aggregatedKey); proto.write(ProcessStatsStateProto.DURATION_MS, durationByState.get(aggregatedKey)); proto.write(ProcessStatsStateProto.DURATION_MS, durationByState.get(aggregatedKey)); ProtoUtils.toAggStatsProto(proto, ProcessStatsStateProto.RSS, ProtoUtils.toAggStatsProto(proto, ProcessStatsStateProto.RSS, 0, /* do not output a minimum value */ 0, /* do not output a minimum value */ meanRssByState.get(aggregatedKey), 0, /* do not output an average value */ maxRssByState.get(aggregatedKey)); 0, /* do not output a max value */ (int) meanRssByState.get(aggregatedKey), (int) maxRssByState.get(aggregatedKey)); proto.end(stateToken); proto.end(stateToken); } } Loading
core/proto/android/service/procstats.proto +11 −4 Original line number Original line Diff line number Diff line Loading @@ -104,7 +104,7 @@ message ProcessStatsAvailablePagesProto { repeated int32 pages_per_order = 4; repeated int32 pages_per_order = 4; } } // Next Tag: 10 // Next Tag: 13 message ProcessStatsStateProto { message ProcessStatsStateProto { option (android.msg_privacy).dest = DEST_AUTOMATIC; option (android.msg_privacy).dest = DEST_AUTOMATIC; Loading @@ -114,13 +114,20 @@ message ProcessStatsStateProto { // this enum list is from frameworks/base/core/java/com/android/internal/app/procstats/ProcessStats.java // this enum list is from frameworks/base/core/java/com/android/internal/app/procstats/ProcessStats.java // and not frameworks/base/core/java/android/app/ActivityManager.java // and not frameworks/base/core/java/android/app/ActivityManager.java optional ProcessState process_state = 3; optional ProcessState process_state = 3 [deprecated = true]; // the AggregatedProcessState needs to keep sync with ProcessStateAggregated optional AggregatedProcessState process_state_aggregated = 10; // Millisecond uptime duration spent in this state // Millisecond uptime duration spent in this state optional int64 duration_ms = 4; optional int64 duration_ms = 4 [deprecated = true]; // Same as above, but with minute resolution so it fits into an int32. optional int32 duration_minutes = 11; // Millisecond elapsed realtime duration spent in this state // Millisecond elapsed realtime duration spent in this state optional int64 realtime_duration_ms = 9; optional int64 realtime_duration_ms = 9 [deprecated = true]; // Same as above, but with minute resolution so it fits into an int32. optional int32 realtime_duration_minutes = 12; // # of samples taken // # of samples taken optional int32 sample_size = 5; optional int32 sample_size = 5; Loading
core/proto/android/util/common.proto +9 −4 Original line number Original line Diff line number Diff line Loading @@ -27,11 +27,16 @@ option java_multiple_files = true; message AggStats { message AggStats { option (android.msg_privacy).dest = DEST_AUTOMATIC; option (android.msg_privacy).dest = DEST_AUTOMATIC; optional int64 min = 1; optional int64 min = 1 [deprecated = true]; optional int64 average = 2; optional int64 average = 2 [deprecated = true]; optional int64 max = 3; optional int64 max = 3 [deprecated = true]; // These are all in kilobyte resolution. Can fit in int32, so smaller on the wire than the above // int64 fields. optional int32 mean_kb = 4; optional int32 max_kb = 5; } } /** /** Loading