Skip STATE_SERVICE_RESTARTING while dumping procstats to statsd

Because it's not a real process state.

Bug: 186438656
Test: atest ProcStatsValidationTests
Test: atest ProcessStatsDumpsysTest
Test: atest CtsIncidentHostTestCases:ProcStatsProtoTest
Test: atest CtsStatsdHostTestCases
Test: atest CtsAppTestCases:ActivityManagerProcessStateTest
Change-Id: I26d170f5acac8434548aa62b439c26141ad99c3e
This commit is contained in:
Jing Ji
2021-05-04 18:02:56 -07:00
parent 5f1fac6a58
commit ec65308e4b
2 changed files with 7 additions and 2 deletions

View File

@@ -93,7 +93,6 @@ public final class DumpUtils {
STATE_LABELS[STATE_BOUND_TOP_OR_FGS] = "Bnd TopFgs";
STATE_LABELS[STATE_FGS] = " Fgs";
STATE_LABELS[STATE_IMPORTANT_FOREGROUND] = " Imp Fg";
STATE_LABELS[STATE_IMPORTANT_FOREGROUND] = " Imp Fg";
STATE_LABELS[STATE_IMPORTANT_BACKGROUND] = " Imp Bg";
STATE_LABELS[STATE_BACKUP] = " Backup";
STATE_LABELS[STATE_SERVICE] = " Service";

View File

@@ -1550,6 +1550,10 @@ public final class ProcessState {
final int key = mDurations.getKeyAt(i);
final int type = SparseMappingTable.getIdFromKey(key);
final int aggregatedType = DumpUtils.aggregateCurrentProcessState(type);
if ((type % STATE_COUNT) == STATE_SERVICE_RESTARTING) {
// Skip restarting service state -- that is not actually a running process.
continue;
}
long time = mDurations.getValue(key);
if (mCurCombinedState == type) {
@@ -1563,7 +1567,9 @@ public final class ProcessState {
durationByState.put(aggregatedType, time);
}
}
if (!didCurState && mCurCombinedState != STATE_NOTHING) {
if (!didCurState && mCurCombinedState != STATE_NOTHING
&& (mCurCombinedState % STATE_COUNT) != STATE_SERVICE_RESTARTING) {
// Skip restarting service state -- that is not actually a running process.
final int aggregatedType = DumpUtils.aggregateCurrentProcessState(mCurCombinedState);
int index = durationByState.indexOfKey(aggregatedType);
if (index >= 0) {