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

Commit a89a47a5 authored by Toshiki Kikuchi's avatar Toshiki Kikuchi
Browse files

Allow WCT#setAlwaysOnTop to Task

This CL unlocks the capability to apply WCT#setAlwaysOnTop to Task.
Currently, WCT#setAlwaysOnTop is only applicable to DisplayArea but
ARC++ wants to set a task as always-on-top from Shell.

Bug: 286868077
Bug: 292437230
Test: atest WindowOrganizerTests
Change-Id: I08348e384725c24bd11221d4b9dff6fccef31acd
parent 2ef3c463
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -804,7 +804,7 @@ public final class WindowContainerTransaction implements Parcelable {
     * Sets/removes the always on top flag for this {@code windowContainer}. See
     * {@link com.android.server.wm.ConfigurationContainer#setAlwaysOnTop(boolean)}.
     * Please note that this method is only intended to be used for a
     * {@link com.android.server.wm.DisplayArea}.
     * {@link com.android.server.wm.Task} or {@link com.android.server.wm.DisplayArea}.
     *
     * <p>
     *     Setting always on top to {@code True} will also make the {@code windowContainer} to move
+7 −3
Original line number Diff line number Diff line
@@ -1159,9 +1159,13 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
            }
            case HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP: {
                final WindowContainer container = WindowContainer.fromBinder(hop.getContainer());
                if (container == null || container.asDisplayArea() == null
                        || !container.isAttached()) {
                    Slog.e(TAG, "Attempt to operate on unknown or detached display area: "
                if (container == null || !container.isAttached()) {
                    Slog.e(TAG, "Attempt to operate on unknown or detached container: "
                            + container);
                    break;
                }
                if (container.asTask() == null && container.asDisplayArea() == null) {
                    Slog.e(TAG, "Cannot set always-on-top on non-task or non-display area: "
                            + container);
                    break;
                }
+22 −0
Original line number Diff line number Diff line
@@ -1646,6 +1646,28 @@ public class WindowOrganizerTests extends WindowTestsBase {
        verify(mWm.mAtmService.mRootWindowContainer).resumeFocusedTasksTopActivities();
    }

    @Test
    public void testSetAlwaysOnTop() {
        final Task rootTask = new TaskBuilder(mSupervisor)
                .setWindowingMode(WINDOWING_MODE_FREEFORM).build();
        testSetAlwaysOnTop(rootTask);

        final DisplayArea displayArea = mDisplayContent.getDefaultTaskDisplayArea();
        displayArea.setWindowingMode(WINDOWING_MODE_FREEFORM);
        testSetAlwaysOnTop(displayArea);
    }

    private void testSetAlwaysOnTop(WindowContainer wc) {
        final WindowContainerTransaction t = new WindowContainerTransaction();
        t.setAlwaysOnTop(wc.mRemoteToken.toWindowContainerToken(), true);
        mWm.mAtmService.mWindowOrganizerController.applyTransaction(t);
        assertTrue(wc.isAlwaysOnTop());

        t.setAlwaysOnTop(wc.mRemoteToken.toWindowContainerToken(), false);
        mWm.mAtmService.mWindowOrganizerController.applyTransaction(t);
        assertFalse(wc.isAlwaysOnTop());
    }

    private ActivityRecord createActivityRecordAndDispatchPendingEvents(Task task) {
        final ActivityRecord record = createActivityRecord(task);
        // Flush EVENT_APPEARED.