Protect against assumptions of a top focused stack.

Ibefc3a80, Do the protect against when get top focused stack. Here
are some cases also need to do same thing to guards against the
assumptions that a top focused stack exists.

Bug: 153607881
Test: ActivityStarterTests ActivityRecordTest
Change-Id: I004bdb97ce4c1199b37625ba18bea35ac478f81c
This commit is contained in:
Jeff Chang
2020-04-29 16:14:31 +08:00
parent 32729dacab
commit 51de04a67d
2 changed files with 4 additions and 1 deletions

View File

@@ -5536,6 +5536,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
// timeout should not be caused by this.
if (stopped) {
final ActivityStack stack = mRootWindowContainer.getTopDisplayFocusedStack();
if (stack == null) {
return this;
}
// Try to use the one which is closest to top.
ActivityRecord r = stack.getResumedActivity();
if (r == null) {

View File

@@ -1123,7 +1123,7 @@ class ActivityStarter {
// If we are starting an activity that is not from the same uid as the currently resumed
// one, check whether app switches are allowed.
if (voiceSession == null && (stack.getResumedActivity() == null
if (voiceSession == null && stack != null && (stack.getResumedActivity() == null
|| stack.getResumedActivity().info.applicationInfo.uid != realCallingUid)) {
if (!mService.checkAppSwitchAllowedLocked(callingPid, callingUid,
realCallingPid, realCallingUid, "Activity start")) {