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

Commit d397669a authored by Andrii Kulian's avatar Andrii Kulian
Browse files

Don't collapse Bubbles when task opens on a different display

The current implementation collapses bubbles when any task opening
transition is detected outside of a bubble. This leads to also
collapsing the bubbles even when the user starts an app on a
different display, and there is no overlap or visual relation
between the bubbles stack and the new task.

This change adds a check on which display the task is opening,
and skips collapsing if it is not where the bubbles are currently
showing.

Bug: 408249958
Test: atest com.android.wm.shell.bubbles.BubblesTransitionObserverTest
Flag: EXEMPT bugfix
Change-Id: I05c7acea928143e45bbf9d00698c82485726ba85
parent 6649bbc5
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.wm.shell.bubbles;
import static android.service.notification.NotificationListenerService.NOTIFICATION_CHANNEL_OR_GROUP_DELETED;
import static android.service.notification.NotificationListenerService.NOTIFICATION_CHANNEL_OR_GROUP_UPDATED;
import static android.service.notification.NotificationListenerService.REASON_CANCEL;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
@@ -2601,6 +2602,23 @@ public class BubbleController implements ConfigurationChangeListener,
        return mLayerView;
    }

    /**
     * Returns the id of the display to which the current Bubble view is attached if it is currently
     * showing, {@link INVALID_DISPLAY} otherwise.
     */
    @VisibleForTesting
    public int getCurrentViewDisplayId() {
        if (isShowingAsBubbleBar() && mLayerView != null && mLayerView.getDisplay() != null) {
            return mLayerView.getDisplay().getDisplayId();
        }

        if (!isShowingAsBubbleBar() && mStackView != null && mStackView.getDisplay() != null) {
            return mStackView.getDisplay().getDisplayId();
        }

        return INVALID_DISPLAY;
    }

    /**
     * Check if notification panel is in an expanded state.
     * Makes a call to System UI process and delivers the result via {@code callback} on the
+9 −2
Original line number Diff line number Diff line
@@ -62,9 +62,16 @@ public class BubblesTransitionObserver implements Transitions.TransitionObserver
            final int expandedId = mBubbleData.getSelectedBubble().getTaskId();
            // If the task id that's opening is the same as the expanded bubble, skip collapsing
            // because it is our bubble that is opening.
            if (expandedId != INVALID_TASK_ID && expandedId != taskInfo.taskId) {
                mBubbleData.setExpanded(false);
            if (expandedId == INVALID_TASK_ID || expandedId == taskInfo.taskId) {
                continue;
            }
            // If the task is opening on a different display, skip collapsing because the task
            // opening does not visually overlap with the bubbles.
            final int bubbleViewDisplayId = mBubbleController.getCurrentViewDisplayId();
            if (taskInfo.displayId != bubbleViewDisplayId) {
                continue;
            }
            mBubbleData.setExpanded(false);
        }
    }

+16 −0
Original line number Diff line number Diff line
@@ -91,6 +91,22 @@ public class BubblesTransitionObserverTest extends ShellTestCase {
        verify(mBubbleData).setExpanded(eq(false));
    }

    @Test
    public void testOnTransitionReady_openOnAnotherDisplay_doesNotCollapseStack() {
        when(mBubbleData.isExpanded()).thenReturn(true);
        when(mBubbleData.getSelectedBubble()).thenReturn(mBubble);
        when(mBubble.getTaskId()).thenReturn(1);
        when(mBubbleController.isStackAnimating()).thenReturn(false);

        ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(2);
        taskInfo.displayId = 1; // not DEFAULT_DISPLAY
        TransitionInfo info = createTransitionInfo(TRANSIT_OPEN, taskInfo);

        mTransitionObserver.onTransitionReady(mTransition, info, mStartT, mFinishT);

        verify(mBubbleData, never()).setExpanded(eq(false));
    }

    @Test
    public void testOnTransitionReady_toFront_collapsesStack() {
        when(mBubbleData.isExpanded()).thenReturn(true);