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

Commit 2791092c authored by Louis Chang's avatar Louis Chang Committed by Android (Google) Code Review
Browse files

Merge "Do not reuse organized task as leaf task" into sc-dev

parents 66c9982c 825afdd3
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -908,7 +908,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                        pw.print(Integer.toHexString(taskDescription.getStatusBarColor()));
                        pw.print(Integer.toHexString(taskDescription.getStatusBarColor()));
                        pw.print(" navigationBarColor=");
                        pw.print(" navigationBarColor=");
                        pw.println(Integer.toHexString(taskDescription.getNavigationBarColor()));
                        pw.println(Integer.toHexString(taskDescription.getNavigationBarColor()));
                        pw.print(" backgroundColorFloating=");
                        pw.print(prefix); pw.print(" backgroundColorFloating=");
                        pw.println(Integer.toHexString(
                        pw.println(Integer.toHexString(
                                taskDescription.getBackgroundColorFloating()));
                                taskDescription.getBackgroundColorFloating()));
            }
            }
+0 −7
Original line number Original line Diff line number Diff line
@@ -5262,13 +5262,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                || windowingMode == WINDOWING_MODE_MULTI_WINDOW);
                || windowingMode == WINDOWING_MODE_MULTI_WINDOW);
    }
    }


    static boolean canReuseExistingTask(int windowingMode, int activityType) {
        // Existing Tasks can be reused if a new root task will be created anyway, or for the
        // Dream - because there can only ever be one DreamActivity.
        return alwaysCreateRootTask(windowingMode, activityType)
                || activityType == ACTIVITY_TYPE_DREAM;
    }

    @Nullable
    @Nullable
    Task getFocusedRootTask() {
    Task getFocusedRootTask() {
        return getItemFromTaskDisplayAreas(TaskDisplayArea::getFocusedRootTask);
        return getItemFromTaskDisplayAreas(TaskDisplayArea::getFocusedRootTask);
+18 −2
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.app.ActivityTaskManager.RESIZE_MODE_FORCED;
import static android.app.ActivityTaskManager.RESIZE_MODE_SYSTEM_SCREEN_ROTATION;
import static android.app.ActivityTaskManager.RESIZE_MODE_SYSTEM_SCREEN_ROTATION;
import static android.app.ITaskStackListener.FORCED_RESIZEABLE_REASON_SPLIT_SCREEN;
import static android.app.ITaskStackListener.FORCED_RESIZEABLE_REASON_SPLIT_SCREEN;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_DREAM;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
@@ -7349,6 +7350,7 @@ class Task extends WindowContainer<WindowContainer> {
        return reuseOrCreateTask(info, intent, null /*voiceSession*/, null /*voiceInteractor*/,
        return reuseOrCreateTask(info, intent, null /*voiceSession*/, null /*voiceInteractor*/,
                toTop, null /*activity*/, null /*source*/, null /*options*/);
                toTop, null /*activity*/, null /*source*/, null /*options*/);
    }
    }

    // TODO: Can be removed once we change callpoints creating root tasks to be creating tasks.
    // TODO: Can be removed once we change callpoints creating root tasks to be creating tasks.
    /** Either returns this current task to be re-used or creates a new child task. */
    /** Either returns this current task to be re-used or creates a new child task. */
    Task reuseOrCreateTask(ActivityInfo info, Intent intent, IVoiceInteractionSession voiceSession,
    Task reuseOrCreateTask(ActivityInfo info, Intent intent, IVoiceInteractionSession voiceSession,
@@ -7356,7 +7358,7 @@ class Task extends WindowContainer<WindowContainer> {
            ActivityRecord source, ActivityOptions options) {
            ActivityRecord source, ActivityOptions options) {


        Task task;
        Task task;
        if (DisplayContent.canReuseExistingTask(getWindowingMode(), getActivityType())) {
        if (canReuseAsLeafTask()) {
            // This root task will only contain one task, so just return itself since all root
            // This root task will only contain one task, so just return itself since all root
            // tasks ara now tasks and all tasks are now root tasks.
            // tasks ara now tasks and all tasks are now root tasks.
            task = reuseAsLeafTask(voiceSession, voiceInteractor, intent, info, activity);
            task = reuseAsLeafTask(voiceSession, voiceInteractor, intent, info, activity);
@@ -7391,10 +7393,24 @@ class Task extends WindowContainer<WindowContainer> {
        return task;
        return task;
    }
    }


    /** Return {@code true} if this task can be reused as leaf task. */
    private boolean canReuseAsLeafTask() {
        // Cannot be reused as leaf task if this task is created by organizer or having child tasks.
        if (mCreatedByOrganizer || !isLeafTask()) {
            return false;
        }

        // Existing Tasks can be reused if a new root task will be created anyway, or for the
        // Dream - because there can only ever be one DreamActivity.
        final int windowingMode = getWindowingMode();
        final int activityType = getActivityType();
        return DisplayContent.alwaysCreateRootTask(windowingMode, activityType)
                || activityType == ACTIVITY_TYPE_DREAM;
    }

    void addChild(WindowContainer child, final boolean toTop, boolean showForAllUsers) {
    void addChild(WindowContainer child, final boolean toTop, boolean showForAllUsers) {
        Task task = child.asTask();
        Task task = child.asTask();
        try {
        try {

            if (task != null) {
            if (task != null) {
                task.setForceShowForAllUsers(showForAllUsers);
                task.setForceShowForAllUsers(showForAllUsers);
            }
            }