Construct the UidState in case of not found during unparceling

Bug: 232966772
Test: atest ProcStatsValidationTests
Test: atest ProcessStatsDumpsysTest
Test: atest CtsIncidentHostTestCases:ProcStatsProtoTest
Change-Id: Id3b22522d407074fe1758c3ef43cd2f5e163cfdc
This commit is contained in:
Jing Ji
2022-05-23 13:03:33 -07:00
parent 7316c95946
commit c76ca4f2f6

View File

@@ -1183,7 +1183,16 @@ public final class ProcessStats implements Parcelable {
+ " " + proc);
mProcesses.put(procName, uid, proc);
mUidStates.get(uid).addProcess(proc);
UidState uidState = mUidStates.get(uid);
if (uidState == null) {
// This is not expected, log a warning and construct a new UID state.
if (DEBUG_PARCEL) {
Slog.w(TAG, "Couldn't find the common UID " + uid + " for " + proc);
}
uidState = new UidState(this, uid);
mUidStates.put(uid, uidState);
}
uidState.addProcess(proc);
}
}