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

Commit 21e06482 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Rename getTopActivity to getTopNonFinishingActivity (69/n)

Avoid name conflict with a method that will be introduced in
WindowContainer later on.

Bug: 80414790
Test: Existing tests pass
Change-Id: I299bb67d24fe581e14937079a071e13af9c693d2
parent 3a6d75b3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4358,7 +4358,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        final boolean isDisplaySleeping = getDisplay().isSleeping()
                && getDisplayId() != DEFAULT_DISPLAY;
        // Whether this activity is the top activity of this stack.
        final boolean isTop = this == stack.getTopActivity();
        final boolean isTop = this == stack.getTopNonFinishingActivity();
        // Exclude the case where this is the top activity in a pinned stack.
        final boolean isTopNotPinnedStack = stack.isAttached()
                && stack.getDisplay().isTopNotPinnedStack(stack);
+11 −10
Original line number Diff line number Diff line
@@ -794,7 +794,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
            return;
        }

        final ActivityRecord topActivity = getTopActivity();
        final ActivityRecord topActivity = getTopNonFinishingActivity();

        // For now, assume that the Stack's windowing mode is what will actually be used
        // by it's activities. In the future, there may be situations where this doesn't
@@ -1041,9 +1041,9 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
        return null;
    }

    ActivityRecord getTopActivity() {
    ActivityRecord getTopNonFinishingActivity() {
        for (int taskNdx = getChildCount() - 1; taskNdx >= 0; --taskNdx) {
            final ActivityRecord r = getChildAt(taskNdx).getTopActivity();
            final ActivityRecord r = getChildAt(taskNdx).getTopNonFinishingActivity();
            if (r != null) {
                return r;
            }
@@ -1264,7 +1264,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
            }

            // Overlays should not be considered as the task's logical top activity.
            final ActivityRecord r = task.getTopActivity(false /* includeOverlays */);
            final ActivityRecord r = task.getTopNonFinishingActivity(false /* includeOverlays */);
            if (r == null || r.finishing || r.mUserId != userId ||
                    r.launchMode == ActivityInfo.LAUNCH_SINGLE_INSTANCE) {
                if (DEBUG_TASKS) Slog.d(TAG_TASKS, "Skipping " + task + ": mismatch root " + r);
@@ -1823,7 +1823,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
    }

    boolean isTopActivityVisible() {
        final ActivityRecord topActivity = getTopActivity();
        final ActivityRecord topActivity = getTopNonFinishingActivity();
        return topActivity != null && topActivity.visible;
    }

@@ -2899,7 +2899,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
            boolean startIt = true;
            for (int taskNdx = getChildCount() - 1; taskNdx >= 0; --taskNdx) {
                task = getChildAt(taskNdx);
                if (task.getTopActivity() == null) {
                if (task.getTopNonFinishingActivity() == null) {
                    // All activities in task are finishing.
                    continue;
                }
@@ -3380,7 +3380,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg

        int taskNdx = mChildren.indexOf(task);
        if (taskNdx >= 0) {
            ActivityRecord newTop = getChildAt(taskNdx).getTopActivity();
            ActivityRecord newTop = getChildAt(taskNdx).getTopNonFinishingActivity();
            if (newTop != null) {
                taskTop = newTop;
            }
@@ -4002,7 +4002,8 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
        if (DEBUG_SWITCH) Slog.v(TAG_SWITCH, "moveTaskToFront: " + tr);

        final ActivityStack topStack = getDisplay().getTopStack();
        final ActivityRecord topActivity = topStack != null ? topStack.getTopActivity() : null;
        final ActivityRecord topActivity = topStack != null
                ? topStack.getTopNonFinishingActivity() : null;
        final int numTasks = getChildCount();
        final int index = mChildren.indexOf(tr);
        if (numTasks == 0 || index < 0)  {
@@ -4033,7 +4034,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
            positionChildAtTop(tr);

            // Don't refocus if invisible to current user
            final ActivityRecord top = tr.getTopActivity();
            final ActivityRecord top = tr.getTopNonFinishingActivity();
            if (top == null || !top.okToShowLocked()) {
                if (top != null) {
                    mStackSupervisor.mRecentTasks.add(top.getTask());
@@ -4352,7 +4353,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
        int userId = UserHandle.getUserId(callingUid);
        for (int taskNdx = getChildCount() - 1; taskNdx >= 0; --taskNdx) {
            final Task task = getChildAt(taskNdx);
            if (task.getTopActivity() == null) {
            if (task.getTopNonFinishingActivity() == null) {
                // Skip if there are no activities in the task
                continue;
            }
+5 −5
Original line number Diff line number Diff line
@@ -1428,7 +1428,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
            moveHomeStackToFrontIfNeeded(flags, currentStack.getDisplay(), reason);
        }

        final ActivityRecord r = task.getTopActivity();
        final ActivityRecord r = task.getTopNonFinishingActivity();
        currentStack.moveTaskToFrontLocked(task, false /* noAnimation */, options,
                r == null ? null : r.appTimeTracker, reason);

@@ -2077,7 +2077,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {

        // When launching tasks behind, update the last active time of the top task after the new
        // task has been shown briefly
        final ActivityRecord top = stack.getTopActivity();
        final ActivityRecord top = stack.getTopNonFinishingActivity();
        if (top != null) {
            top.getTask().touchActiveTime();
        }
@@ -2458,7 +2458,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {

    /** Notifies that the top activity of the task is forced to be resizeable. */
    private void handleForcedResizableTaskIfNeeded(Task task, int reason) {
        final ActivityRecord topActivity = task.getTopActivity();
        final ActivityRecord topActivity = task.getTopNonFinishingActivity();
        if (topActivity == null || topActivity.noDisplay
                || !topActivity.isNonResizableOrForcedResizable(task.getWindowingMode())) {
            return;
@@ -2750,7 +2750,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
            // Work Challenge is present) let startActivityInPackage handle the intercepting.
            if (!mService.mAmInternal.shouldConfirmCredentials(task.mUserId)
                    && task.getRootActivity() != null) {
                final ActivityRecord targetActivity = task.getTopActivity();
                final ActivityRecord targetActivity = task.getTopNonFinishingActivity();

                mRootActivityContainer.sendPowerHintForLaunchStartIfNeeded(
                        true /* forceSend */, targetActivity);
@@ -2767,7 +2767,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
                }

                mService.getActivityStartController().postStartActivityProcessingForLastStarter(
                        task.getTopActivity(), ActivityManager.START_TASK_TO_FRONT,
                        task.getTopNonFinishingActivity(), ActivityManager.START_TASK_TO_FRONT,
                        task.getStack());
                return ActivityManager.START_TASK_TO_FRONT;
            }
+13 −10
Original line number Diff line number Diff line
@@ -1502,7 +1502,8 @@ class ActivityStarter {
            return startResult;
        }

        final ActivityRecord targetTaskTop = newTask ? null : targetTask.getTopActivity();
        final ActivityRecord targetTaskTop = newTask
                ? null : targetTask.getTopNonFinishingActivity();
        if (targetTaskTop != null) {
            // Recycle the target task for this launch.
            startResult = recycleTask(targetTask, targetTaskTop, reusedTask);
@@ -1559,8 +1560,8 @@ class ActivityStarter {
        mRootActivityContainer.sendPowerHintForLaunchStartIfNeeded(
                false /* forceSend */, mStartActivity);

        mTargetStack.startActivityLocked(mStartActivity, topStack.getTopActivity(), newTask,
                mKeepCurTransition, mOptions);
        mTargetStack.startActivityLocked(mStartActivity, topStack.getTopNonFinishingActivity(),
                newTask, mKeepCurTransition, mOptions);
        if (mDoResume) {
            final ActivityRecord topTaskActivity =
                    mStartActivity.getTask().topRunningActivityLocked();
@@ -1612,7 +1613,7 @@ class ActivityStarter {
            return mInTask;
        } else {
            final ActivityRecord top = computeStackFocus(mStartActivity, false /* newTask */,
                    mLaunchFlags, mOptions).getTopActivity();
                    mLaunchFlags, mOptions).getTopNonFinishingActivity();
            if (top != null) {
                return top.getTask();
            }
@@ -1727,7 +1728,8 @@ class ActivityStarter {
            return START_RETURN_INTENT_TO_CALLER;
        }

        complyActivityFlags(targetTask, reusedTask != null ? reusedTask.getTopActivity() : null);
        complyActivityFlags(targetTask,
                reusedTask != null ? reusedTask.getTopNonFinishingActivity() : null);

        if (clearTaskForReuse) {
            // Clear task for re-use so later code to methods
@@ -1755,7 +1757,7 @@ class ActivityStarter {
        // FLAG_ACTIVITY_CLEAR_TOP flag. In that case, return the top running activity in the
        // task instead.
        mLastStartActivityRecord =
                targetTaskTop.finishing ? targetTask.getTopActivity() : targetTaskTop;
                targetTaskTop.finishing ? targetTask.getTopNonFinishingActivity() : targetTaskTop;
        return mMovedToFront ? START_TASK_TO_FRONT : START_DELIVERED_TO_TOP;
    }

@@ -1806,7 +1808,7 @@ class ActivityStarter {
     * task.
     */
    private void complyActivityFlags(Task targetTask, ActivityRecord reusedActivity) {
        ActivityRecord targetTaskTop = targetTask.getTopActivity();
        ActivityRecord targetTaskTop = targetTask.getTopNonFinishingActivity();
        final boolean resetTask =
                reusedActivity != null && (mLaunchFlags & FLAG_ACTIVITY_RESET_TASK_IF_NEEDED) != 0;
        if (resetTask) {
@@ -2037,7 +2039,8 @@ class ActivityStarter {
                if (!mOptions.canTaskOverlayResume()) {
                    final Task task = mRootActivityContainer.anyTaskForId(
                            mOptions.getLaunchTaskId());
                    final ActivityRecord top = task != null ? task.getTopActivity() : null;
                    final ActivityRecord top = task != null
                            ? task.getTopNonFinishingActivity() : null;
                    if (top != null && !top.isState(RESUMED)) {

                        // The caller specifies that we'd like to be avoided to be moved to the
@@ -2295,8 +2298,8 @@ class ActivityStarter {

        if (differentTopTask && !mAvoidMoveToFront) {
            mStartActivity.intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
            if (mSourceRecord == null || (mSourceStack.getTopActivity() != null &&
                    mSourceStack.getTopActivity().getTask()
            if (mSourceRecord == null || (mSourceStack.getTopNonFinishingActivity() != null &&
                    mSourceStack.getTopNonFinishingActivity().getTask()
                            == mSourceRecord.getTask())) {
                // We really do want to push this one into the user's face, right now.
                if (mLaunchTaskBehind && mSourceRecord != null) {
+7 −7
Original line number Diff line number Diff line
@@ -2410,7 +2410,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            mStackSupervisor.findTaskToMoveToFront(task, flags, realOptions, "moveTaskToFront",
                    false /* forceNonResizable */);

            final ActivityRecord topActivity = task.getTopActivity();
            final ActivityRecord topActivity = task.getTopNonFinishingActivity();
            if (topActivity != null) {

                // We are reshowing a task, use a starting window to hide the initial draw delay
@@ -2999,7 +2999,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    public boolean isTopOfTask(IBinder token) {
        synchronized (mGlobalLock) {
            ActivityRecord r = ActivityRecord.isInStackLocked(token);
            return r != null && r.getTask().getTopActivity() == r;
            return r != null && r.getTask().getTopNonFinishingActivity() == r;
        }
    }

@@ -3589,7 +3589,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                "enqueueAssistContext()");

        synchronized (mGlobalLock) {
            ActivityRecord activity = getTopDisplayFocusedStack().getTopActivity();
            ActivityRecord activity = getTopDisplayFocusedStack().getTopNonFinishingActivity();
            if (activity == null) {
                Slog.w(TAG, "getAssistContextExtras failed: no top activity");
                return null;
@@ -3722,7 +3722,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                return false;
            }

            final ActivityRecord activity = focusedStack.getTopActivity();
            final ActivityRecord activity = focusedStack.getTopNonFinishingActivity();
            if (activity == null) {
                return false;
            }
@@ -3737,7 +3737,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
        try {
            synchronized (mGlobalLock) {
                ActivityRecord caller = ActivityRecord.forTokenLocked(token);
                ActivityRecord top = getTopDisplayFocusedStack().getTopActivity();
                ActivityRecord top = getTopDisplayFocusedStack().getTopNonFinishingActivity();
                if (top != caller) {
                    Slog.w(TAG, "showAssistFromActivity failed: caller " + caller
                            + " is not current top " + top);
@@ -4355,7 +4355,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    public void startLocalVoiceInteraction(IBinder callingActivity, Bundle options) {
        Slog.i(TAG, "Activity tried to startLocalVoiceInteraction");
        synchronized (mGlobalLock) {
            ActivityRecord activity = getTopDisplayFocusedStack().getTopActivity();
            ActivityRecord activity = getTopDisplayFocusedStack().getTopNonFinishingActivity();
            if (ActivityRecord.forTokenLocked(callingActivity) != activity) {
                throw new SecurityException("Only focused activity can call startVoiceInteraction");
            }
@@ -6576,7 +6576,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
                            + " Requested task not found");
                    return null;
                }
                final ActivityRecord activity = task.getTopActivity();
                final ActivityRecord activity = task.getTopNonFinishingActivity();
                if (activity == null) {
                    Slog.w(TAG, "getApplicationThreadForTopActivity failed:"
                            + " Requested activity not found");
Loading