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

Commit a52182c3 authored by Andrii Kulian's avatar Andrii Kulian Committed by Automerger Merge Worker
Browse files

Merge "7/n Use display area instead of display id in ATM methods" into rvc-dev...

Merge "7/n Use display area instead of display id in ATM methods" into rvc-dev am: bba1891e am: 248a3e7c am: 8a8456aa am: 7d72f771

Change-Id: Ic126a68f3a801f1ae303c49e4546edf8cd4b0005
parents dda480d8 7d72f771
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -2272,7 +2272,7 @@ class ActivityStack extends Task {
        ActivityOptions.abort(options);
        ActivityOptions.abort(options);
        if (DEBUG_STATES) Slog.d(TAG_STATES,
        if (DEBUG_STATES) Slog.d(TAG_STATES,
                "resumeNextFocusableActivityWhenStackIsEmpty: " + reason + ", go home");
                "resumeNextFocusableActivityWhenStackIsEmpty: " + reason + ", go home");
        return mRootWindowContainer.resumeHomeActivity(prev, reason, getDisplayId());
        return mRootWindowContainer.resumeHomeActivity(prev, reason, getDisplayArea());
    }
    }


    void startActivityLocked(ActivityRecord r, ActivityRecord focusedTopActivity,
    void startActivityLocked(ActivityRecord r, ActivityRecord focusedTopActivity,
+25 −15
Original line number Original line Diff line number Diff line
@@ -44,7 +44,6 @@ import static android.os.Process.INVALID_UID;
import static android.os.Process.SYSTEM_UID;
import static android.os.Process.SYSTEM_UID;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.Display.TYPE_VIRTUAL;
import static android.view.Display.TYPE_VIRTUAL;
import static android.view.WindowManager.TRANSIT_DOCK_TASK_FROM_RECENTS;
import static android.view.WindowManager.TRANSIT_DOCK_TASK_FROM_RECENTS;


@@ -1378,8 +1377,8 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
        if (DEBUG_STACK) Slog.d(TAG_STACK,
        if (DEBUG_STACK) Slog.d(TAG_STACK,
                "findTaskToMoveToFront: moved to front of stack=" + currentStack);
                "findTaskToMoveToFront: moved to front of stack=" + currentStack);


        handleNonResizableTaskIfNeeded(task, WINDOWING_MODE_UNDEFINED, DEFAULT_DISPLAY,
        handleNonResizableTaskIfNeeded(task, WINDOWING_MODE_UNDEFINED,
                currentStack, forceNonResizeable);
                mRootWindowContainer.getDefaultTaskDisplayArea(), currentStack, forceNonResizeable);
    }
    }


    private void moveHomeStackToFrontIfNeeded(int flags, TaskDisplayArea taskDisplayArea,
    private void moveHomeStackToFrontIfNeeded(int flags, TaskDisplayArea taskDisplayArea,
@@ -2134,16 +2133,29 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
                WindowManagerService.WINDOW_FREEZE_TIMEOUT_DURATION);
                WindowManagerService.WINDOW_FREEZE_TIMEOUT_DURATION);
    }
    }


    // TODO(b/152116619): Remove after complete switch to TaskDisplayArea
    void handleNonResizableTaskIfNeeded(Task task, int preferredWindowingMode,
    void handleNonResizableTaskIfNeeded(Task task, int preferredWindowingMode,
            int preferredDisplayId, ActivityStack actualStack) {
            int preferredDisplayId, ActivityStack actualStack) {
        handleNonResizableTaskIfNeeded(task, preferredWindowingMode, preferredDisplayId,
        final DisplayContent preferredDisplayContent = mRootWindowContainer
                .getDisplayContent(preferredDisplayId);
        final TaskDisplayArea preferredDisplayArea = preferredDisplayContent != null
                ? preferredDisplayContent.getDefaultTaskDisplayArea()
                : null;
        handleNonResizableTaskIfNeeded(task, preferredWindowingMode, preferredDisplayArea,
                actualStack);
    }

    void handleNonResizableTaskIfNeeded(Task task, int preferredWindowingMode,
            TaskDisplayArea preferredTaskDisplayArea, ActivityStack actualStack) {
        handleNonResizableTaskIfNeeded(task, preferredWindowingMode, preferredTaskDisplayArea,
                actualStack, false /* forceNonResizable */);
                actualStack, false /* forceNonResizable */);
    }
    }


    void handleNonResizableTaskIfNeeded(Task task, int preferredWindowingMode,
    void handleNonResizableTaskIfNeeded(Task task, int preferredWindowingMode,
            int preferredDisplayId, ActivityStack actualStack, boolean forceNonResizable) {
            TaskDisplayArea preferredTaskDisplayArea, ActivityStack actualStack,
        final boolean isSecondaryDisplayPreferred =
            boolean forceNonResizable) {
                (preferredDisplayId != DEFAULT_DISPLAY && preferredDisplayId != INVALID_DISPLAY);
        final boolean isSecondaryDisplayPreferred = preferredTaskDisplayArea != null
                && preferredTaskDisplayArea.getDisplayId() != DEFAULT_DISPLAY;
        final boolean inSplitScreenMode = actualStack != null
        final boolean inSplitScreenMode = actualStack != null
                && actualStack.getDisplayArea().isSplitScreenModeActivated();
                && actualStack.getDisplayArea().isSplitScreenModeActivated();
        if (((!inSplitScreenMode && preferredWindowingMode != WINDOWING_MODE_SPLIT_SCREEN_PRIMARY)
        if (((!inSplitScreenMode && preferredWindowingMode != WINDOWING_MODE_SPLIT_SCREEN_PRIMARY)
@@ -2153,33 +2165,31 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {


        // Handle incorrect launch/move to secondary display if needed.
        // Handle incorrect launch/move to secondary display if needed.
        if (isSecondaryDisplayPreferred) {
        if (isSecondaryDisplayPreferred) {
            final int actualDisplayId = task.getDisplayId();
            if (!task.canBeLaunchedOnDisplay(task.getDisplayId())) {
            if (!task.canBeLaunchedOnDisplay(actualDisplayId)) {
                throw new IllegalStateException("Task resolved to incompatible display");
                throw new IllegalStateException("Task resolved to incompatible display");
            }
            }


            final DisplayContent preferredDisplay =
            final DisplayContent preferredDisplay = preferredTaskDisplayArea.mDisplayContent;
                    mRootWindowContainer.getDisplayContent(preferredDisplayId);


            final boolean singleTaskInstance = preferredDisplay != null
            final boolean singleTaskInstance = preferredDisplay != null
                    && preferredDisplay.isSingleTaskInstance();
                    && preferredDisplay.isSingleTaskInstance();


            if (preferredDisplayId != actualDisplayId) {
            if (preferredDisplay != task.getDisplayContent()) {
                // Suppress the warning toast if the preferredDisplay was set to singleTask.
                // Suppress the warning toast if the preferredDisplay was set to singleTask.
                // The singleTaskInstance displays will only contain one task and any attempt to
                // The singleTaskInstance displays will only contain one task and any attempt to
                // launch new task will re-route to the default display.
                // launch new task will re-route to the default display.
                if (singleTaskInstance) {
                if (singleTaskInstance) {
                    mService.getTaskChangeNotificationController()
                    mService.getTaskChangeNotificationController()
                            .notifyActivityLaunchOnSecondaryDisplayRerouted(task.getTaskInfo(),
                            .notifyActivityLaunchOnSecondaryDisplayRerouted(task.getTaskInfo(),
                                    preferredDisplayId);
                                    preferredDisplay.mDisplayId);
                    return;
                    return;
                }
                }


                Slog.w(TAG, "Failed to put " + task + " on display " + preferredDisplayId);
                Slog.w(TAG, "Failed to put " + task + " on display " + preferredDisplay.mDisplayId);
                // Display a warning toast that we failed to put a task on a secondary display.
                // Display a warning toast that we failed to put a task on a secondary display.
                mService.getTaskChangeNotificationController()
                mService.getTaskChangeNotificationController()
                        .notifyActivityLaunchOnSecondaryDisplayFailed(task.getTaskInfo(),
                        .notifyActivityLaunchOnSecondaryDisplayFailed(task.getTaskInfo(),
                                preferredDisplayId);
                                preferredDisplay.mDisplayId);
            } else if (!forceNonResizable) {
            } else if (!forceNonResizable) {
                handleForcedResizableTaskIfNeeded(task, FORCED_RESIZEABLE_REASON_SECONDARY_DISPLAY);
                handleForcedResizableTaskIfNeeded(task, FORCED_RESIZEABLE_REASON_SECONDARY_DISPLAY);
            }
            }
+8 −7
Original line number Original line Diff line number Diff line
@@ -172,7 +172,8 @@ public class ActivityStartController {
        mLastStarter.postStartActivityProcessing(r, result, targetStack);
        mLastStarter.postStartActivityProcessing(r, result, targetStack);
    }
    }


    void startHomeActivity(Intent intent, ActivityInfo aInfo, String reason, int displayId) {
    void startHomeActivity(Intent intent, ActivityInfo aInfo, String reason,
            TaskDisplayArea taskDisplayArea) {
        final ActivityOptions options = ActivityOptions.makeBasic();
        final ActivityOptions options = ActivityOptions.makeBasic();
        options.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN);
        options.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN);
        if (!ActivityRecord.isResolverActivity(aInfo.name)) {
        if (!ActivityRecord.isResolverActivity(aInfo.name)) {
@@ -181,20 +182,20 @@ public class ActivityStartController {
            // foreground instead of bring home stack to front.
            // foreground instead of bring home stack to front.
            options.setLaunchActivityType(ACTIVITY_TYPE_HOME);
            options.setLaunchActivityType(ACTIVITY_TYPE_HOME);
        }
        }
        final int displayId = taskDisplayArea.getDisplayId();
        options.setLaunchDisplayId(displayId);
        options.setLaunchDisplayId(displayId);
        // TODO(b/152116619): Enable after complete switch to WindowContainerToken
        //options.setLaunchWindowContainerToken(taskDisplayArea.getWindowContainerToken());


        final DisplayContent display =
                mService.mRootWindowContainer.getDisplayContent(displayId);
        // The home activity will be started later, defer resuming to avoid unneccerary operations
        // The home activity will be started later, defer resuming to avoid unneccerary operations
        // (e.g. start home recursively) when creating home stack.
        // (e.g. start home recursively) when creating home stack.
        mSupervisor.beginDeferResume();
        mSupervisor.beginDeferResume();
        final ActivityStack homeStack;
        final ActivityStack homeStack;
        try {
        try {
            // TODO(multi-display-area): Support starting home in a task display area
            // Make sure home stack exists on display area.
            // Make sure home stack exist on display.
            // TODO(b/153624902): Replace with TaskDisplayArea#getOrCreateRootHomeTask()
            // TODO(b/153624902): Replace with TaskDisplayArea#getOrCreateRootHomeTask()
            homeStack = display.getDefaultTaskDisplayArea().getOrCreateStack(
            homeStack = taskDisplayArea.getOrCreateStack(WINDOWING_MODE_UNDEFINED,
                    WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_HOME, ON_TOP);
                    ACTIVITY_TYPE_HOME, ON_TOP);
        } finally {
        } finally {
            mSupervisor.endDeferResume();
            mSupervisor.endDeferResume();
        }
        }
+1 −1
Original line number Original line Diff line number Diff line
@@ -2422,7 +2422,7 @@ class ActivityStarter {
        // be destroyed.
        // be destroyed.
        mTargetStack = intentActivity.getRootTask();
        mTargetStack = intentActivity.getRootTask();
        mSupervisor.handleNonResizableTaskIfNeeded(intentTask, WINDOWING_MODE_UNDEFINED,
        mSupervisor.handleNonResizableTaskIfNeeded(intentTask, WINDOWING_MODE_UNDEFINED,
                DEFAULT_DISPLAY, mTargetStack);
                mRootWindowContainer.getDefaultTaskDisplayArea(), mTargetStack);
    }
    }


    private void resumeTargetStackIfNeeded() {
    private void resumeTargetStackIfNeeded() {
+2 −2
Original line number Original line Diff line number Diff line
@@ -28,7 +28,6 @@ import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_NEVER;
import static android.os.UserHandle.USER_ALL;
import static android.os.UserHandle.USER_ALL;
import static android.os.UserHandle.USER_CURRENT;
import static android.os.UserHandle.USER_CURRENT;
import static android.telecom.TelecomManager.EMERGENCY_DIALER_COMPONENT;
import static android.telecom.TelecomManager.EMERGENCY_DIALER_COMPONENT;
import static android.view.Display.DEFAULT_DISPLAY;


import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_LOCKTASK;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_LOCKTASK;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_LOCKTASK;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_LOCKTASK;
@@ -619,7 +618,8 @@ public class LockTaskController {
            }
            }
        } else if (lockTaskModeState != LOCK_TASK_MODE_NONE) {
        } else if (lockTaskModeState != LOCK_TASK_MODE_NONE) {
            mSupervisor.handleNonResizableTaskIfNeeded(task, WINDOWING_MODE_UNDEFINED,
            mSupervisor.handleNonResizableTaskIfNeeded(task, WINDOWING_MODE_UNDEFINED,
                    DEFAULT_DISPLAY, task.getStack(), true /* forceNonResizable */);
                    mSupervisor.mRootWindowContainer.getDefaultTaskDisplayArea(),
                    task.getStack(), true /* forceNonResizable */);
        }
        }
    }
    }


Loading