Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cf36be8a authored by Jeff Chang's avatar Jeff Chang Committed by android-build-team Robot
Browse files

[RESTRICT AUTOMERGE]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
(cherry picked from commit 59a51c6b)
parent e3e68f6a
Loading
Loading
Loading
Loading
+3 −2
Original line number Original line Diff line number Diff line
@@ -1704,8 +1704,9 @@ class ActivityStack extends Task {
        // If the most recent activity was noHistory but was only stopped rather
        // 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
        // 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.
        // sure to finish it as we're making a new activity topmost.
        if (shouldSleepActivities() && mLastNoHistoryActivity != null &&
        if (shouldSleepActivities() && mLastNoHistoryActivity != null
                !mLastNoHistoryActivity.finishing) {
                && !mLastNoHistoryActivity.finishing
                && mLastNoHistoryActivity != next) {
            if (DEBUG_STATES) Slog.d(TAG_STATES,
            if (DEBUG_STATES) Slog.d(TAG_STATES,
                    "no-history finish of " + mLastNoHistoryActivity + " on new resume");
                    "no-history finish of " + mLastNoHistoryActivity + " on new resume");
            mLastNoHistoryActivity.finishIfPossible("resume-no-history", false /* oomAdj */);
            mLastNoHistoryActivity.finishIfPossible("resume-no-history", false /* oomAdj */);
+3 −2
Original line number Original line Diff line number Diff line
@@ -1481,9 +1481,10 @@ class ActivityStarter {
            // anyone interested in this piece of information.
            // anyone interested in this piece of information.
            final ActivityStack homeStack = targetTask.getDisplayArea().getRootHomeTask();
            final ActivityStack homeStack = targetTask.getDisplayArea().getRootHomeTask();
            final boolean homeTaskVisible = homeStack != null && homeStack.shouldBeVisible(null);
            final boolean homeTaskVisible = homeStack != null && homeStack.shouldBeVisible(null);
            final ActivityRecord top = targetTask.getTopNonFinishingActivity();
            final boolean visible = top != null && top.isVisible();
            mService.getTaskChangeNotificationController().notifyActivityRestartAttempt(
            mService.getTaskChangeNotificationController().notifyActivityRestartAttempt(
                    targetTask.getTaskInfo(), homeTaskVisible, clearedTask,
                    targetTask.getTaskInfo(), homeTaskVisible, clearedTask, visible);
                    targetTask.getTopNonFinishingActivity().isVisible());
        }
        }
    }
    }