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

Commit 86d676c8 authored by Andrii Kulian's avatar Andrii Kulian
Browse files

3/n Refactor TaskContainers to TaskDisplayArea

Renamed TaskContainers to TaskDisplayArea and added getDisplayArea()
method to WindowContainer that finds the first display area in the
hierarchy above the node. ActivityRecord and Task override it to
return the TaskDisplayArea class.

Bug: 152116619
Test: WM CTS and unit tests
Change-Id: I4525afbcd794848e1020213cdca04d89a646dd55
parent b51f33f4
Loading
Loading
Loading
Loading
+18 −30
Original line number Diff line number Diff line
@@ -301,12 +301,6 @@
      "group": "WM_DEBUG_ADD_REMOVE",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "-1455600136": {
      "message": "Attempted to add Dream window with unknown token %s.  Aborting.",
      "level": "WARN",
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-1443029505": {
      "message": "SAFE MODE ENABLED (menu=%d s=%d dpad=%d trackball=%d)",
      "level": "INFO",
@@ -385,12 +379,6 @@
      "group": "WM_DEBUG_RESIZE",
      "at": "com\/android\/server\/wm\/WindowState.java"
    },
    "-1263554915": {
      "message": "Attempted to add Dream window with bad token %s.  Aborting.",
      "level": "WARN",
      "group": "WM_ERROR",
      "at": "com\/android\/server\/wm\/WindowManagerService.java"
    },
    "-1263316010": {
      "message": "Computed rotation=%s (%d) for display id=%d based on lastOrientation=%s (%d) and oldRotation=%s (%d)",
      "level": "VERBOSE",
@@ -541,12 +529,6 @@
      "group": "WM_DEBUG_APP_TRANSITIONS",
      "at": "com\/android\/server\/wm\/AppTransitionController.java"
    },
    "-993446393": {
      "message": "App is requesting an orientation, return %d for display id=%d",
      "level": "VERBOSE",
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/TaskContainers.java"
    },
    "-993378225": {
      "message": "finishDrawingLocked: mDrawState=COMMIT_DRAW_PENDING %s in %s",
      "level": "VERBOSE",
@@ -967,6 +949,12 @@
      "group": "WM_SHOW_TRANSACTIONS",
      "at": "com\/android\/server\/wm\/Session.java"
    },
    "-49129622": {
      "message": "performLayout: Activity exiting now removed %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_ADD_REMOVE",
      "at": "com\/android\/server\/wm\/TaskDisplayArea.java"
    },
    "-33096143": {
      "message": "applyAnimation: transition animation is disabled or skipped. container=%s",
      "level": "VERBOSE",
@@ -1075,12 +1063,6 @@
      "group": "WM_SHOW_TRANSACTIONS",
      "at": "com\/android\/server\/wm\/WindowSurfaceController.java"
    },
    "137835146": {
      "message": "No app is requesting an orientation, return %d for display id=%d",
      "level": "VERBOSE",
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/TaskContainers.java"
    },
    "140319294": {
      "message": "IME target changed within ActivityRecord",
      "level": "DEBUG",
@@ -1723,6 +1705,12 @@
      "group": "WM_DEBUG_IME",
      "at": "com\/android\/server\/wm\/ImeInsetsSourceProvider.java"
    },
    "1381227466": {
      "message": "App is requesting an orientation, return %d for display id=%d",
      "level": "VERBOSE",
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/TaskDisplayArea.java"
    },
    "1389009035": {
      "message": "NonAppWindowContainer cannot set orientation: %s",
      "level": "WARN",
@@ -1891,6 +1879,12 @@
      "group": "WM_DEBUG_RESIZE",
      "at": "com\/android\/server\/wm\/WindowState.java"
    },
    "1640436199": {
      "message": "No app is requesting an orientation, return %d for display id=%d",
      "level": "VERBOSE",
      "group": "WM_DEBUG_ORIENTATION",
      "at": "com\/android\/server\/wm\/TaskDisplayArea.java"
    },
    "1653210583": {
      "message": "Removing app %s delayed=%b animation=%s animating=%b",
      "level": "VERBOSE",
@@ -1915,12 +1909,6 @@
      "group": "WM_DEBUG_STARTING_WINDOW",
      "at": "com\/android\/server\/wm\/ActivityRecord.java"
    },
    "1685441447": {
      "message": "performLayout: Activity exiting now removed %s",
      "level": "VERBOSE",
      "group": "WM_DEBUG_ADD_REMOVE",
      "at": "com\/android\/server\/wm\/TaskContainers.java"
    },
    "1720229827": {
      "message": "Creating animation bounds layer",
      "level": "INFO",
+18 −12
Original line number Diff line number Diff line
@@ -2078,6 +2078,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        return stack != null ? stack.getDisplay() : null;
    }

    @Override
    @Nullable
    TaskDisplayArea getDisplayArea() {
        return (TaskDisplayArea) super.getDisplayArea();
    }

    @Override
    boolean fillsParent() {
        return occludesParent();
@@ -2232,8 +2238,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        boolean isKeyguardLocked = mAtmService.isKeyguardLocked();
        boolean isCurrentAppLocked =
                mAtmService.getLockTaskModeState() != LOCK_TASK_MODE_NONE;
        final DisplayContent display = getDisplay();
        boolean hasPinnedStack = display != null && display.hasPinnedTask();
        final TaskDisplayArea taskDisplayArea = getDisplayArea();
        boolean hasPinnedStack = taskDisplayArea != null && taskDisplayArea.hasPinnedTask();
        // Don't return early if !isNotLocked, since we want to throw an exception if the activity
        // is in an incorrect state
        boolean isNotLockedOrOnKeyguard = !isKeyguardLocked && !isCurrentAppLocked;
@@ -2500,11 +2506,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
                    // and focused application if needed.
                    stack.adjustFocusToNextFocusableStack("finish-top");
                } else {
                    // Only move the next stack to top in its display.
                    final DisplayContent display = stack.getDisplay();
                    next = display.topRunningActivity();
                    // Only move the next stack to top in its task container.
                    final TaskDisplayArea taskDisplayArea = stack.getDisplayArea();
                    next = taskDisplayArea.topRunningActivity();
                    if (next != null) {
                        display.mTaskContainers.positionStackAtTop(next.getRootTask(),
                        taskDisplayArea.positionStackAtTop(next.getRootTask(),
                                false /* includingParents */, "finish-display-top");
                    }
                }
@@ -2634,7 +2640,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // Note that if this finishing activity is floating task, we don't need to wait the
        // next activity resume and can destroy it directly.
        // TODO(b/137329632): find the next activity directly underneath this one, not just anywhere
        final ActivityRecord next = getDisplay().topRunningActivity(
        final ActivityRecord next = getDisplayArea().topRunningActivity(
                true /* considerKeyguardState */);
        // isNextNotYetVisible is to check if the next activity is invisible, or it has been
        // requested to be invisible but its windows haven't reported as invisible.  If so, it
@@ -2673,13 +2679,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        mStackSupervisor.mStoppingActivities.remove(this);

        final ActivityStack stack = getRootTask();
        final DisplayContent display = getDisplay();
        final TaskDisplayArea taskDisplayArea = getDisplayArea();
        // TODO(b/137329632): Exclude current activity when looking for the next one with
        // DisplayContent#topRunningActivity().
        final ActivityRecord next = display.topRunningActivity();
        final ActivityRecord next = taskDisplayArea.topRunningActivity();
        final boolean isLastStackOverEmptyHome =
                next == null && stack.isFocusedStackOnDisplay()
                        && display.mTaskContainers.getOrCreateRootHomeTask() != null;
                        && taskDisplayArea.getOrCreateRootHomeTask() != null;
        if (isLastStackOverEmptyHome) {
            // Don't destroy activity immediately if this is the last activity on the display and
            // the display contains home stack. Although there is no next activity at the moment,
@@ -4477,7 +4483,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // case where this is the top activity in a pinned stack.
        final boolean isTop = this == stack.getTopNonFinishingActivity();
        final boolean isTopNotPinnedStack = stack.isAttached()
                && stack.getDisplay().mTaskContainers.isTopNotPinnedStack(stack);
                && stack.getDisplayArea().isTopNotPinnedStack(stack);
        final boolean visibleIgnoringDisplayStatus = stack.checkKeyguardVisibility(this,
                visibleIgnoringKeyguard, isTop && isTopNotPinnedStack);

@@ -5194,7 +5200,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // The activity may have been requested to be invisible (another activity has been launched)
        // so there is no valid info. But if it is the current top activity (e.g. sleeping), the
        // invalid state is still reported to make sure the waiting result is notified.
        if (validInfo || this == mDisplayContent.topRunningActivity()) {
        if (validInfo || this == getDisplayArea().topRunningActivity()) {
            mStackSupervisor.reportActivityLaunchedLocked(false /* timeout */, this,
                    windowsDrawnDelayMs, launchState);
            mStackSupervisor.stopWaitingForActivityVisible(this, windowsDrawnDelayMs);
+50 −67

File changed.

Preview size limit exceeded, changes collapsed.

+7 −7
Original line number Diff line number Diff line
@@ -1788,7 +1788,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
            if (prevStack != null) {
                return prevStack;
            }
            stack = stack.getDisplay().createStack(
            stack = stack.getDisplayArea().createStack(
                    WINDOWING_MODE_FULLSCREEN, stack.getActivityType(), toTop);
        }
        return stack;
@@ -1878,7 +1878,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
        mStoppingActivities.remove(r);

        final ActivityStack stack = r.getRootTask();
        if (stack.getDisplay().mTaskContainers.allResumedActivitiesComplete()) {
        if (stack.getDisplayArea().allResumedActivitiesComplete()) {
            mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
            // Make sure activity & window visibility should be identical
            // for all displays in this stage.
@@ -2242,7 +2242,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
        final boolean isSecondaryDisplayPreferred =
                (preferredDisplayId != DEFAULT_DISPLAY && preferredDisplayId != INVALID_DISPLAY);
        final boolean inSplitScreenMode = actualStack != null
                && actualStack.getDisplay().mTaskContainers.isSplitScreenModeActivated();
                && actualStack.getDisplayArea().isSplitScreenModeActivated();
        if (((!inSplitScreenMode && preferredWindowingMode != WINDOWING_MODE_SPLIT_SCREEN_PRIMARY)
                && !isSecondaryDisplayPreferred) || !task.isActivityTypeStandardOrUndefined()) {
            return;
@@ -2289,14 +2289,14 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {
        if (!task.supportsSplitScreenWindowingMode() || forceNonResizable) {
            // Dismiss docked stack. If task appeared to be in docked stack but is not resizable -
            // we need to move it to top of fullscreen stack, otherwise it will be covered.
            final DisplayContent display = task.getStack().getDisplay();
            if (display.mTaskContainers.isSplitScreenModeActivated()) {
            final TaskDisplayArea taskDisplayArea = task.getDisplayArea();
            if (taskDisplayArea.isSplitScreenModeActivated()) {
                // Display a warning toast that we tried to put an app that doesn't support
                // split-screen in split-screen.
                mService.getTaskChangeNotificationController()
                        .notifyActivityDismissingDockedStack();
                display.mTaskContainers.onSplitScreenModeDismissed();
                display.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS,
                taskDisplayArea.onSplitScreenModeDismissed();
                taskDisplayArea.mDisplayContent.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS,
                        true /* notifyClients */);
            }
            return;
+1 −1
Original line number Diff line number Diff line
@@ -1390,7 +1390,7 @@ class ActivityStarter {
            // The activity was already running so it wasn't started, but either brought to the
            // front or the new intent was delivered to it since it was already in front. Notify
            // anyone interested in this piece of information.
            final ActivityStack homeStack = targetTask.getDisplayContent().getRootHomeTask();
            final ActivityStack homeStack = targetTask.getDisplayArea().getRootHomeTask();
            final boolean homeTaskVisible = homeStack != null && homeStack.shouldBeVisible(null);
            mService.getTaskChangeNotificationController().notifyActivityRestartAttempt(
                    targetTask.getTaskInfo(), homeTaskVisible, clearedTask);
Loading