Fix NullPointerException in ActiveServices

The ProcessRecord field of a ServiceRecord could be null.

Bug: 190634592
Test: atest CtsAppTestCases:ServiceTest
Change-Id: I63abf5be600991a94e6ad4eb26786450cea1e242
This commit is contained in:
Jing Ji
2021-06-09 16:40:26 -07:00
parent ad82033c4a
commit 827ebe7f15

View File

@@ -4865,7 +4865,8 @@ public final class ActiveServices {
Slog.w(TAG, "Service crashed " + sr.crashCount
+ " times, stopping: " + sr);
EventLog.writeEvent(EventLogTags.AM_SERVICE_CRASHED_TOO_MUCH,
sr.userId, sr.crashCount, sr.shortInstanceName, sr.app.getPid());
sr.userId, sr.crashCount, sr.shortInstanceName,
sr.app != null ? sr.app.getPid() : -1);
bringDownServiceLocked(sr, true);
} else if (!allowRestart
|| !mAm.mUserController.isUserRunning(sr.userId, 0)) {