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

Commit 9497e65d authored by Jing Ji's avatar Jing Ji Committed by Automerger Merge Worker
Browse files

Merge "Fix test failure in testProcessStateByPulling" into rvc-dev am: b344e0ac am: 9ef42068

Change-Id: Iff48c0bdf77059d96b440c6b9e05ffb2ef668d93
parents 507ffb8b 9ef42068
Loading
Loading
Loading
Loading
+11 −1
Original line number Original line Diff line number Diff line
@@ -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
     */
     */
+1 −1
Original line number Original line Diff line number Diff line
@@ -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);
        }
        }
+11 −7
Original line number Original line Diff line number Diff line
@@ -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));
@@ -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
@@ -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);
        }
        }
+11 −4
Original line number Original line Diff line number Diff line
@@ -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;


@@ -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;
+9 −4
Original line number Original line Diff line number Diff line
@@ -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