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

Commit aac5fb73 authored by Evan Rosky's avatar Evan Rosky
Browse files

Consider "similar" change modes the same for promotion purposes

If all the siblings of a change are changing in a similar way
(ie. all ending-up visible or non-visible) then they can be
considered the same mode for promotion (ie. if one child is hide
while the other is close, it is valid to promote).

Bug: 250012839
Test: atest TransitionTests
Change-Id: Iedd12ee0ca6c026848c6c4d3259fef541609f724
parent 576b93c7
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -1331,7 +1331,7 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
            ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS,
                    "        sibling is a participant with mode %s",
                    TransitionInfo.modeToString(siblingMode));
            if (mode != siblingMode) {
            if (reduceMode(mode) != reduceMode(siblingMode)) {
                ProtoLog.v(ProtoLogGroup.WM_DEBUG_WINDOW_TRANSITIONS,
                        "          SKIP: common mode mismatch. was %s",
                        TransitionInfo.modeToString(mode));
@@ -1341,6 +1341,16 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
        return true;
    }

    /** "reduces" a mode into a smaller set of modes that uniquely represents visibility change. */
    @TransitionInfo.TransitionMode
    private static int reduceMode(@TransitionInfo.TransitionMode int mode) {
        switch (mode) {
            case TRANSIT_TO_BACK: return TRANSIT_CLOSE;
            case TRANSIT_TO_FRONT: return TRANSIT_OPEN;
            default: return mode;
        }
    }

    /**
     * Go through topTargets and try to promote (see {@link #canPromote}) one of them.
     *
@@ -1842,7 +1852,7 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
        @TransitionInfo.TransitionMode
        int getTransitMode(@NonNull WindowContainer wc) {
            if ((mFlags & ChangeInfo.FLAG_ABOVE_TRANSIENT_LAUNCH) != 0) {
                return TRANSIT_CLOSE;
                return mExistenceChanged ? TRANSIT_CLOSE : TRANSIT_TO_BACK;
            }
            final boolean nowVisible = wc.isVisibleRequested();
            if (nowVisible == mVisible) {
+64 −0
Original line number Diff line number Diff line
@@ -392,6 +392,70 @@ public class TransitionTests extends WindowTestsBase {
                tasks[showWallpaperTask].mRemoteToken.toWindowContainerToken()).getFlags());
    }

    @Test
    public void testCreateInfo_PromoteSimilarClose() {
        final Transition transition = createTestTransition(TRANSIT_CLOSE);
        ArrayMap<WindowContainer, Transition.ChangeInfo> changes = transition.mChanges;
        ArraySet<WindowContainer> participants = transition.mParticipants;

        final Task topTask = createTask(mDisplayContent);
        final Task belowTask = createTask(mDisplayContent);
        final ActivityRecord showing = createActivityRecord(belowTask);
        final ActivityRecord hiding = createActivityRecord(topTask);
        final ActivityRecord closing = createActivityRecord(topTask);
        // Start states.
        changes.put(topTask, new Transition.ChangeInfo(true /* vis */, false /* exChg */));
        changes.put(belowTask, new Transition.ChangeInfo(false /* vis */, false /* exChg */));
        changes.put(showing, new Transition.ChangeInfo(false /* vis */, false /* exChg */));
        changes.put(hiding, new Transition.ChangeInfo(true /* vis */, false /* exChg */));
        changes.put(closing, new Transition.ChangeInfo(true /* vis */, true /* exChg */));
        fillChangeMap(changes, topTask);
        // End states.
        showing.mVisibleRequested = true;
        closing.mVisibleRequested = false;
        hiding.mVisibleRequested = false;

        participants.add(belowTask);
        participants.add(hiding);
        participants.add(closing);
        ArrayList<WindowContainer> targets = Transition.calculateTargets(participants, changes);
        assertEquals(2, targets.size());
        assertTrue(targets.contains(belowTask));
        assertTrue(targets.contains(topTask));
    }

    @Test
    public void testCreateInfo_PromoteSimilarOpen() {
        final Transition transition = createTestTransition(TRANSIT_OPEN);
        ArrayMap<WindowContainer, Transition.ChangeInfo> changes = transition.mChanges;
        ArraySet<WindowContainer> participants = transition.mParticipants;

        final Task topTask = createTask(mDisplayContent);
        final Task belowTask = createTask(mDisplayContent);
        final ActivityRecord showing = createActivityRecord(topTask);
        final ActivityRecord opening = createActivityRecord(topTask);
        final ActivityRecord closing = createActivityRecord(belowTask);
        // Start states.
        changes.put(topTask, new Transition.ChangeInfo(false /* vis */, false /* exChg */));
        changes.put(belowTask, new Transition.ChangeInfo(true /* vis */, false /* exChg */));
        changes.put(showing, new Transition.ChangeInfo(false /* vis */, false /* exChg */));
        changes.put(opening, new Transition.ChangeInfo(false /* vis */, true /* exChg */));
        changes.put(closing, new Transition.ChangeInfo(true /* vis */, false /* exChg */));
        fillChangeMap(changes, topTask);
        // End states.
        showing.mVisibleRequested = true;
        opening.mVisibleRequested = true;
        closing.mVisibleRequested = false;

        participants.add(belowTask);
        participants.add(showing);
        participants.add(opening);
        ArrayList<WindowContainer> targets = Transition.calculateTargets(participants, changes);
        assertEquals(2, targets.size());
        assertTrue(targets.contains(belowTask));
        assertTrue(targets.contains(topTask));
    }

    @Test
    public void testTargets_noIntermediatesToWallpaper() {
        final Transition transition = createTestTransition(TRANSIT_OPEN);