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

Commit f29257fb authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Remove confusing WindowState#getRootTask" into main

parents 1798b05a 79aedcff
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -8977,9 +8977,8 @@ public class WindowManagerService extends IWindowManager.Stub
    }

    private boolean shouldDelayTouchOutside(InputTarget t) {
        final WindowState w = t.getWindowState();
        final ActivityRecord activity = w != null ? w.getActivityRecord() : null;
        final Task task = w != null ? w.getRootTask() : null;
        final ActivityRecord activity = t.getActivityRecord();
        final Task task = activity != null ? activity.getTask() : null;

        final boolean isInputTargetNotFocused =
                mFocusedInputTarget != t && mFocusedInputTarget != null;
+14 −31
Original line number Diff line number Diff line
@@ -1704,18 +1704,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        return mActivityRecord != null ? mActivityRecord.getTaskFragment() : null;
    }

    @Nullable Task getRootTask() {
        final Task task = getTask();
        if (task != null) {
            return task.getRootTask();
        }
        // Some system windows (e.g. "Power off" dialog) don't have a task, but we would still
        // associate them with some root task to enable dimming.
        final DisplayContent dc = getDisplayContent();
        return mAttrs.type >= FIRST_SYSTEM_WINDOW
                && dc != null ? dc.getDefaultTaskDisplayArea().getRootHomeTask() : null;
    }

    /**
     * Retrieves the visible bounds of the window.
     * @param bounds The rect which gets the bounds.
@@ -2570,10 +2558,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
            return false;
        }

        final Task rootTask = getRootTask();
        if (rootTask != null && !rootTask.isFocusable()) {
            // Ignore when the root task shouldn't receive input event.
            // (i.e. the minimized root task in split screen mode.)
        final Task task = getTask();
        if (task != null && !task.isFocusable()) {
            // The task can be set as non-focusable, e.g. swapping split-screen sides.
            return false;
        }

@@ -2599,7 +2586,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        }

        // Don't allow transient-launch activities to take IME.
        if (rootTask != null && mActivityRecord != null
        if (task != null && mActivityRecord != null
                && mTransitionController.isTransientLaunch(mActivityRecord)) {
            return false;
        }
@@ -2785,11 +2772,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
                // means we need to intercept touches outside of that window. The dim layer
                // user associated with the window (task or root task) will give us the good
                // bounds, as they would be used to display the dim layer.
                final TaskFragment taskFragment = getTaskFragment();
                final TaskFragment taskFragment = mActivityRecord.getTaskFragment();
                if (taskFragment != null) {
                    taskFragment.getDimBounds(mTmpRect);
                } else if (getRootTask() != null) {
                    getRootTask().getDimBounds(mTmpRect);
                }
            }
        }
@@ -3934,14 +3919,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        }
    }

    private int getRootTaskId() {
        final Task rootTask = getRootTask();
        if (rootTask == null) {
            return INVALID_TASK_ID;
        }
        return rootTask.mTaskId;
    }

    public void registerFocusObserver(IWindowFocusObserver observer) {
        synchronized (mWmService.mGlobalLock) {
            if (mFocusCallbacks == null) {
@@ -4077,7 +4054,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
        final long token = proto.start(fieldId);
        super.dumpDebug(proto, WINDOW_CONTAINER, logLevel);
        proto.write(DISPLAY_ID, getDisplayId());
        proto.write(STACK_ID, getRootTaskId());
        int rootTaskId = INVALID_TASK_ID;
        final Task task = getTask();
        if (task != null) {
            rootTaskId = task.getRootTaskId();
        }
        proto.write(STACK_ID, rootTaskId);
        mAttrs.dumpDebug(proto, ATTRIBUTES);
        mGivenContentInsets.dumpDebug(proto, GIVEN_CONTENT_INSETS);
        mWindowFrames.dumpDebug(proto, WINDOW_FRAMES);
@@ -4135,8 +4117,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
    @Override
    void dump(PrintWriter pw, String prefix, boolean dumpAll) {
        pw.print(prefix + "mDisplayId=" + getDisplayId());
        if (getRootTask() != null) {
            pw.print(" rootTaskId=" + getRootTaskId());
        final Task task = getTask();
        if (task != null) {
            pw.print(" taskId=" + task.mTaskId);
        }
        pw.println(" mSession=" + mSession
                + " mClient=" + mClient.asBinder());
+0 −16
Original line number Diff line number Diff line
@@ -1420,20 +1420,4 @@ public class RootTaskTests extends WindowTestsBase {
        verify(mSupervisor).startSpecificActivity(any(), eq(false) /* andResume */,
                anyBoolean());
    }

    private void verifyShouldSleepActivities(boolean focusedRootTask,
            boolean keyguardGoingAway, boolean displaySleeping, boolean isDefaultDisplay,
            boolean expected) {
        final Task task = new TaskBuilder(mSupervisor).build();
        final DisplayContent display = mock(DisplayContent.class);
        final KeyguardController keyguardController = mSupervisor.getKeyguardController();
        display.isDefaultDisplay = isDefaultDisplay;

        task.mDisplayContent = display;
        doReturn(keyguardGoingAway).when(display).isKeyguardGoingAway();
        doReturn(displaySleeping).when(display).isSleeping();
        doReturn(focusedRootTask).when(task).isFocusedRootTaskOnDisplay();

        assertEquals(expected, task.shouldSleepActivities());
    }
}
+2 −4
Original line number Diff line number Diff line
@@ -310,10 +310,8 @@ public class WindowStateTests extends WindowTestsBase {
        // Simulate the window is in split screen root task.
        final Task rootTask = createTask(mDisplayContent,
                WINDOWING_MODE_MULTI_WINDOW, ACTIVITY_TYPE_STANDARD);
        spyOn(appWindow);
        spyOn(rootTask);
        rootTask.setFocusable(false);
        doReturn(rootTask).when(appWindow).getRootTask();
        appWindow.mActivityRecord.reparent(rootTask, 0 /* position */, "test");

        // Make sure canBeImeTarget is false;
        assertFalse(appWindow.canBeImeTarget());
@@ -1035,7 +1033,7 @@ public class WindowStateTests extends WindowTestsBase {
                mDisplayContent,
                "SystemDialog", true);
        mDisplayContent.setImeLayeringTarget(mAppWindow);
        mAppWindow.getRootTask().setWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
        mAppWindow.getTask().setWindowingMode(WINDOWING_MODE_MULTI_WINDOW);
        makeWindowVisible(mImeWindow);
        systemDialogWindow.mAttrs.flags |= FLAG_ALT_FOCUSABLE_IM;
        assertTrue(systemDialogWindow.needsRelativeLayeringToIme());