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

Commit 2e746df8 authored by Evan Rosky's avatar Evan Rosky
Browse files

Fix some bugs around stack parenting

1. Don't unfreeze/clear snapshot in onChildVisibilityRequested
   if its becoming visible... this situation means that the
   container changed via going invis + made vis again (which
   is a result of a single transaction reparenting + changing
   mode).

2. Fixed a crash in applyTransaction where if you tried to
   reparent a task that was already on the display to null,
   it would call reparent rather than re-order. DisplayArea
   reparent crashes if the task is already a child.

Bug: 151881448
Test: Added some tests
Change-Id: Ieb5794b365bc256ec02a95a4abbf16d9a28753bd
parent 61d85ada
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -995,12 +995,14 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
     * changes (eg. a transition animation might play out first).
     */
    void onChildVisibilityRequested(boolean visible) {
        // If we are changing visibility, then a snapshot isn't necessary and we are no-longer
        // If we are losing visibility, then a snapshot isn't necessary and we are no-longer
        // part of a change transition.
        if (!visible) {
            mSurfaceFreezer.unfreeze(getSyncTransaction());
            if (mDisplayContent != null) {
                mDisplayContent.mChangingContainers.remove(this);
            }
        }
        WindowContainer parent = getParent();
        if (parent != null) {
            parent.onChildVisibilityRequested(visible);
+9 −7
Original line number Diff line number Diff line
@@ -324,12 +324,13 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
                    (task.isRootTask() && !task.mCreatedByOrganizer)
                            || task.getParent().asTask().mCreatedByOrganizer;
            if (isNonOrganizedRootableTask) {
                Task newParent = hop.getNewParent() == null ? null
                        : WindowContainer.fromBinder(hop.getNewParent()).asTask();
                WindowContainer newParent = hop.getNewParent() == null
                        ? dc.getDefaultTaskDisplayArea()
                        : WindowContainer.fromBinder(hop.getNewParent());
                if (task.getParent() != newParent) {
                    if (newParent == null) {
                        // Re-parent task to display as a root task.
                        as.reparent(dc.getDefaultTaskDisplayArea(), hop.getToTop());
                    if (newParent instanceof TaskDisplayArea) {
                        // For now, reparenting to displayarea is different from other reparents...
                        as.reparent((TaskDisplayArea) newParent, hop.getToTop());
                    } else if (newParent.inMultiWindowMode() && !task.isResizeable()
                            && task.isLeafTask()) {
                        Slog.w(TAG, "Can't support task that doesn't support multi-window mode in"
@@ -341,8 +342,9 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
                                false /*moveParents*/, "sanitizeAndApplyHierarchyOp");
                    }
                } else {
                    final ActivityStack rootTask =
                            (ActivityStack) (newParent != null ? newParent : task.getRootTask());
                    final ActivityStack rootTask = (ActivityStack) (
                            (newParent != null && !(newParent instanceof TaskDisplayArea))
                                    ? newParent : task.getRootTask());
                    if (hop.getToTop()) {
                        as.getDisplayArea().positionStackAtTop(rootTask,
                                false /* includingParents */);
+8 −0
Original line number Diff line number Diff line
@@ -669,6 +669,14 @@ public class WindowOrganizerTests extends WindowTestsBase {
        assertEquals(1, lastReportedTiles.size());
        assertEquals(ACTIVITY_TYPE_HOME,
                lastReportedTiles.get(info1.token.asBinder()).topActivityType);

        // This just needs to not crash (ie. it should be possible to reparent to display twice)
        wct = new WindowContainerTransaction();
        wct.reparent(stack2.mRemoteToken.toWindowContainerToken(), null, true /* onTop */);
        mWm.mAtmService.mWindowOrganizerController.applyTransaction(wct);
        wct = new WindowContainerTransaction();
        wct.reparent(stack2.mRemoteToken.toWindowContainerToken(), null, true /* onTop */);
        mWm.mAtmService.mWindowOrganizerController.applyTransaction(wct);
    }

    private List<Task> getTasksCreatedByOrganizer(DisplayContent dc) {