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

Commit 67cd5fef authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Generate a root for wallpaper-only transitions" into main

parents f40b620d 58b62b2e
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -3088,8 +3088,6 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        // There needs to be a root on each display.
        for (int i = 0; i < sortedTargets.size(); ++i) {
            final WindowContainer<?> wc = sortedTargets.get(i).mContainer;
            // Don't include wallpapers since they are in a different DA.
            if (isWallpaper(wc)) continue;
            final DisplayContent dc = wc.getDisplayContent();
            if (dc == null) continue;
            final int endDisplayId = dc.getDisplayId();
@@ -3329,7 +3327,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
            topApp = sortedTargets.get(i).mContainer;
            break;
        }
        if (topApp.asActivityRecord() != null) {
        if (topApp instanceof ActivityRecord) {
            final ActivityRecord topActivity = topApp.asActivityRecord();
            animOptions = addCustomActivityTransition(topActivity, true/* open */,
                    null /* animOptions */);
@@ -3446,16 +3444,20 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
    @NonNull
    static WindowContainer<?> findCommonAncestor(
            @NonNull ArrayList<ChangeInfo> targets,
            @NonNull WindowContainer<?> topApp) {
        final int displayId = getDisplayId(topApp);
        WindowContainer<?> ancestor = topApp.getParent();
            @NonNull WindowContainer<?> topWc) {
        final int displayId = getDisplayId(topWc);
        WindowContainer<?> ancestor = topWc.getParent();
        // Go up ancestor parent chain until all targets are descendants. Ancestor should never be
        // null because all targets are attached.
        for (int i = targets.size() - 1; i >= 0; i--) {
            final ChangeInfo change = targets.get(i);
            final WindowContainer wc = change.mContainer;
            if (isWallpaper(wc) || getDisplayId(wc) != displayId) {
                // Skip the non-app window or windows on a different display
            if (getDisplayId(wc) != displayId) {
                // Skip windows on a different display
                continue;
            }
            if (isWallpaper(wc) != isWallpaper(topWc)) {
                // Skip windows in a different DisplayArea.
                continue;
            }
            // Skip order-only display-level changes since the display itself isn't changing.
+46 −0
Original line number Diff line number Diff line
@@ -648,6 +648,52 @@ public class TransitionTests extends WindowTestsBase {
                info.getRoot(info.findRootIndex(otherDisplay.getDisplayId())).getDisplayId());
    }

    @Test
    public void testCreateInfo_OnlyWallpapersOnSecondaryDisplay() {
        DisplayContent otherDisplay = createNewDisplay();
        final Transition transition = createTestTransition(TRANSIT_CHANGE);
        ArrayMap<WindowContainer, Transition.ChangeInfo> changes = transition.mChanges;
        ArraySet<WindowContainer> participants = transition.mParticipants;

        final WallpaperWindowToken wallpaper1 =  new WallpaperWindowToken(mWm,
                mock(IBinder.class), true, otherDisplay, true /* ownerCanManageAppTokens */);
        final WindowState wallpaperWindow1 = newWindowBuilder("closing",
                TYPE_WALLPAPER).setWindowToken(wallpaper1).build();

        final WallpaperWindowToken wallpaper2 =  new WallpaperWindowToken(mWm,
                mock(IBinder.class), true, otherDisplay, true /* ownerCanManageAppTokens */);
        final WindowState wallpaperWindow2 = newWindowBuilder("opening",
                TYPE_WALLPAPER).setWindowToken(wallpaper2).build();

        changes.put(wallpaper1,
                new Transition.ChangeInfo(wallpaper1, /* vis= */ false, /* exChg= */ true));
        fillChangeMap(changes, wallpaper1);

        changes.put(wallpaper2,
                new Transition.ChangeInfo(wallpaper2, /* vis= */ false, /* exChg= */ true));
        fillChangeMap(changes, wallpaper2);

        // End states.
        wallpaper1.setVisibleRequested(false);
        wallpaper2.setVisibleRequested(true);
        wallpaperWindow1.mHasSurface = true;
        wallpaperWindow2.mHasSurface = true;

        final int transit = transition.mType;
        int flags = 0;

        participants.add(wallpaper1);
        participants.add(wallpaper2);
        ArrayList<Transition.ChangeInfo> targets =
                Transition.calculateTargets(participants, changes);
        TransitionInfo info = Transition.calculateTransitionInfo(transit, flags, targets, mMockT);

        // Check that root can be found by display and has the correct display
        assertEquals(1, info.getRootCount());
        assertEquals(otherDisplay.getDisplayId(),
                info.getRoot(info.findRootIndex(otherDisplay.getDisplayId())).getDisplayId());
    }

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