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

Commit 1b4bf857 authored by Craig Mautner's avatar Craig Mautner
Browse files

Do not start tasks on ActivityViews unless explicit

New tasks were being started on ActivityViews because they
matched packages. This fix enforces a rule that new tasks
can only be started on ActivityViews if they are explicitly
targeted for that ActivityView.

Fixes bug 15162447.

Change-Id: I9ccb72171b5cda0897a0b9ffe4cbebfbb0d92c2c
parent e5c9c92c
Loading
Loading
Loading
Loading
+25 −9
Original line number Original line Diff line number Diff line
@@ -1194,8 +1194,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
            requestCode = sourceRecord.requestCode;
            requestCode = sourceRecord.requestCode;
            sourceRecord.resultTo = null;
            sourceRecord.resultTo = null;
            if (resultRecord != null) {
            if (resultRecord != null) {
                resultRecord.removeResultsLocked(
                resultRecord.removeResultsLocked(sourceRecord, resultWho, requestCode);
                    sourceRecord, resultWho, requestCode);
            }
            }
            if (sourceRecord.launchedFromUid == callingUid) {
            if (sourceRecord.launchedFromUid == callingUid) {
                // The new activity is being launched from the same uid as the previous
                // The new activity is being launched from the same uid as the previous
@@ -1334,7 +1333,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
        return err;
        return err;
    }
    }


    ActivityStack adjustStackFocus(ActivityRecord r) {
    ActivityStack adjustStackFocus(ActivityRecord r, boolean newTask) {
        final TaskRecord task = r.task;
        final TaskRecord task = r.task;
        if (r.isApplicationActivity() || (task != null && task.isApplicationTask())) {
        if (r.isApplicationActivity() || (task != null && task.isApplicationTask())) {
            if (task != null) {
            if (task != null) {
@@ -1359,7 +1358,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
                return container.mStack;
                return container.mStack;
            }
            }


            if (mFocusedStack != mHomeStack) {
            if (mFocusedStack != mHomeStack && (!newTask ||
                    mFocusedStack.mActivityContainer.isEligibleForNewTasks())) {
                if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG,
                if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG,
                        "adjustStackFocus: Have a focused stack=" + mFocusedStack);
                        "adjustStackFocus: Have a focused stack=" + mFocusedStack);
                return mFocusedStack;
                return mFocusedStack;
@@ -1727,7 +1727,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
        // Should this be considered a new task?
        // Should this be considered a new task?
        if (r.resultTo == null && !addingToTask
        if (r.resultTo == null && !addingToTask
                && (launchFlags&Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
                && (launchFlags&Intent.FLAG_ACTIVITY_NEW_TASK) != 0) {
            targetStack = adjustStackFocus(r);
            newTask = true;
            targetStack = adjustStackFocus(r, newTask);
            targetStack.moveToFront();
            targetStack.moveToFront();
            if (reuseTask == null) {
            if (reuseTask == null) {
                r.setTask(targetStack.createTaskRecord(getNextTaskId(),
                r.setTask(targetStack.createTaskRecord(getNextTaskId(),
@@ -1739,7 +1740,6 @@ public final class ActivityStackSupervisor implements DisplayListener {
            } else {
            } else {
                r.setTask(reuseTask, reuseTask, true);
                r.setTask(reuseTask, reuseTask, true);
            }
            }
            newTask = true;
            if (!movedHome) {
            if (!movedHome) {
                if ((launchFlags &
                if ((launchFlags &
                        (Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_TASK_ON_HOME))
                        (Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_TASK_ON_HOME))
@@ -1803,7 +1803,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
            // This not being started from an existing activity, and not part
            // This not being started from an existing activity, and not part
            // of a new task...  just put it in the top task, though these days
            // of a new task...  just put it in the top task, though these days
            // this case should never happen.
            // this case should never happen.
            targetStack = adjustStackFocus(r);
            targetStack = adjustStackFocus(r, newTask);
            targetStack.moveToFront();
            targetStack.moveToFront();
            ActivityRecord prev = targetStack.topActivity();
            ActivityRecord prev = targetStack.topActivity();
            r.setTask(prev != null ? prev.task
            r.setTask(prev != null ? prev.task
@@ -2235,7 +2235,12 @@ public final class ActivityStackSupervisor implements DisplayListener {
            for (int stackNdx = stacks.size() - 1; stackNdx >= 0; --stackNdx) {
            for (int stackNdx = stacks.size() - 1; stackNdx >= 0; --stackNdx) {
                final ActivityStack stack = stacks.get(stackNdx);
                final ActivityStack stack = stacks.get(stackNdx);
                if (!r.isApplicationActivity() && !stack.isHomeStack()) {
                if (!r.isApplicationActivity() && !stack.isHomeStack()) {
                    if (DEBUG_TASKS) Slog.d(TAG, "Skipping stack: " + stack);
                    if (DEBUG_TASKS) Slog.d(TAG, "Skipping stack: (home activity) " + stack);
                    continue;
                }
                if (!stack.mActivityContainer.isEligibleForNewTasks()) {
                    if (DEBUG_TASKS) Slog.d(TAG, "Skipping stack: (new task not allowed) " +
                            stack);
                    continue;
                    continue;
                }
                }
                final ActivityRecord ar = stack.findTaskLocked(r);
                final ActivityRecord ar = stack.findTaskLocked(r);
@@ -3131,6 +3136,11 @@ public final class ActivityStackSupervisor implements DisplayListener {
        void setDrawn() {
        void setDrawn() {
        }
        }


        // You can always start a new task on a regular ActivityStack.
        boolean isEligibleForNewTasks() {
            return true;
        }

        @Override
        @Override
        public String toString() {
        public String toString() {
            return mIdString + (mActivityDisplay == null ? "N" : "A");
            return mIdString + (mActivityDisplay == null ? "N" : "A");
@@ -3211,6 +3221,12 @@ public final class ActivityStackSupervisor implements DisplayListener {
            }
            }
        }
        }


        // Never start a new task on an ActivityView if it isn't explicitly specified.
        @Override
        boolean isEligibleForNewTasks() {
            return false;
        }

        private void setSurfaceIfReady() {
        private void setSurfaceIfReady() {
            if (DEBUG_STACK) Slog.v(TAG, "setSurfaceIfReady: mDrawn=" + mDrawn +
            if (DEBUG_STACK) Slog.v(TAG, "setSurfaceIfReady: mDrawn=" + mDrawn +
                    " mContainerState=" + mContainerState + " mSurface=" + mSurface);
                    " mContainerState=" + mContainerState + " mSurface=" + mSurface);