Prevent NPE while finishing activity

Activity was finished and removed from history before entering
global lock and caused NPE when accessing its task.

Bug: 158299941
Test: existing tests
Change-Id: Iac49bb631653137785edff48c46e2263adbbda64
This commit is contained in:
Louis Chang
2020-06-09 16:02:42 +08:00
parent f04e437777
commit 7326979bcd

View File

@@ -1685,6 +1685,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
final NeededUriGrants resultGrants = collectGrants(resultData, r.resultTo);
synchronized (mGlobalLock) {
// Sanity check in case activity was removed before entering global lock.
if (!r.isInHistory()) {
return true;
}
// Keep track of the root activity of the task before we finish it
final Task tr = r.getTask();
final ActivityRecord rootR = tr.getRootActivity();