Don't finish noHistory activity while it is on the topmost.

There was no top running activity in the target task result in the
NPE.

The CL makes sure the top running noHistory activity is not finished
when launched again and have protection for getTopNonFinishingActivity.

Bug: 159507052
Test: atest testNoHistoryActivityNotFinished
Change-Id: Id582f28d79bec052115e07d98c097c7d50c11609
This commit is contained in:
Jeff Chang
2020-09-04 12:07:58 +08:00
parent fc0321b167
commit 963d1880ca
2 changed files with 6 additions and 4 deletions

View File

@@ -1493,9 +1493,10 @@ class ActivityStarter {
// anyone interested in this piece of information.
final Task homeStack = targetTask.getDisplayArea().getRootHomeTask();
final boolean homeTaskVisible = homeStack != null && homeStack.shouldBeVisible(null);
final ActivityRecord top = targetTask.getTopNonFinishingActivity();
final boolean visible = top != null && top.isVisible();
mService.getTaskChangeNotificationController().notifyActivityRestartAttempt(
targetTask.getTaskInfo(), homeTaskVisible, clearedTask,
targetTask.getTopNonFinishingActivity().isVisible());
targetTask.getTaskInfo(), homeTaskVisible, clearedTask, visible);
}
}

View File

@@ -6036,8 +6036,9 @@ class Task extends WindowContainer<WindowContainer> {
// If the most recent activity was noHistory but was only stopped rather
// than stopped+finished because the device went to sleep, we need to make
// sure to finish it as we're making a new activity topmost.
if (shouldSleepActivities() && mLastNoHistoryActivity != null &&
!mLastNoHistoryActivity.finishing) {
if (shouldSleepActivities() && mLastNoHistoryActivity != null
&& !mLastNoHistoryActivity.finishing
&& mLastNoHistoryActivity != next) {
if (DEBUG_STATES) Slog.d(TAG_STATES,
"no-history finish of " + mLastNoHistoryActivity + " on new resume");
mLastNoHistoryActivity.finishIfPossible("resume-no-history", false /* oomAdj */);