Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +18 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -2631,6 +2632,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 Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblesTransitionObserver.java +9 −2 Original line number Diff line number Diff line Loading @@ -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); } } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubblesTransitionObserverTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -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); Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +18 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -2631,6 +2632,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 Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblesTransitionObserver.java +9 −2 Original line number Diff line number Diff line Loading @@ -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); } } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubblesTransitionObserverTest.java +16 −0 Original line number Diff line number Diff line Loading @@ -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); Loading