Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +26 −19 Original line number Diff line number Diff line Loading @@ -1170,7 +1170,9 @@ public class BubbleController implements ConfigurationChangeListener, * @param bubbleKey key of the bubble being dragged */ public void startBubbleDrag(String bubbleKey) { onBubbleDrag(bubbleKey, true /* isBeingDragged */); if (mBubbleData.getSelectedBubble() != null) { mBubbleBarViewCallback.expansionChanged(/* isExpanded = */ false); } if (mBubbleStateListener != null) { boolean overflow = BubbleOverflow.KEY.equals(bubbleKey); Rect rect = new Rect(); Loading @@ -1183,23 +1185,29 @@ public class BubbleController implements ConfigurationChangeListener, } /** * A bubble is no longer being dragged in Launcher. As was released in given location. * A bubble is no longer being dragged in Launcher. And was released in given location. * Will be called only when bubble bar is expanded. * * @param bubbleKey key of the bubble being dragged * @param location location where bubble was released */ public void stopBubbleDrag(String bubbleKey, BubbleBarLocation location) { public void stopBubbleDrag(BubbleBarLocation location) { mBubblePositioner.setBubbleBarLocation(location); onBubbleDrag(bubbleKey, false /* isBeingDragged */); if (mBubbleData.getSelectedBubble() != null) { mBubbleBarViewCallback.expansionChanged(/* isExpanded = */ true); } } private void onBubbleDrag(String bubbleKey, boolean isBeingDragged) { // TODO(b/330585402): collapse stack if any bubble is dragged if (mBubbleData.getSelectedBubble() != null && mBubbleData.getSelectedBubble().getKey().equals(bubbleKey)) { // Should collapse/expand only if equals to selected bubble. mBubbleBarViewCallback.expansionChanged(/* isExpanded = */ !isBeingDragged); /** * A bubble was dragged and is released in dismiss target in Launcher. * * @param bubbleKey key of the bubble being dragged to dismiss target */ public void dragBubbleToDismiss(String bubbleKey) { String selectedBubbleKey = mBubbleData.getSelectedBubbleKey(); removeBubble(bubbleKey, Bubbles.DISMISS_USER_GESTURE); if (selectedBubbleKey != null && !selectedBubbleKey.equals(bubbleKey)) { // We did not remove the selected bubble. Expand it again mBubbleBarViewCallback.expansionChanged(/* isExpanded = */ true); } } Loading Loading @@ -2357,12 +2365,6 @@ public class BubbleController implements ConfigurationChangeListener, key, bubbleBarBounds)); } @Override public void removeBubble(String key) { mMainExecutor.execute( () -> mController.removeBubble(key, Bubbles.DISMISS_USER_GESTURE)); } @Override public void removeAllBubbles() { mMainExecutor.execute(() -> mController.removeAllBubbles(Bubbles.DISMISS_USER_GESTURE)); Loading @@ -2379,8 +2381,13 @@ public class BubbleController implements ConfigurationChangeListener, } @Override public void stopBubbleDrag(String bubbleKey, BubbleBarLocation location) { mMainExecutor.execute(() -> mController.stopBubbleDrag(bubbleKey, location)); public void stopBubbleDrag(BubbleBarLocation location) { mMainExecutor.execute(() -> mController.stopBubbleDrag(location)); } @Override public void dragBubbleToDismiss(String key) { mMainExecutor.execute(() -> mController.dragBubbleToDismiss(key)); } @Override Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java +9 −3 Original line number Diff line number Diff line Loading @@ -327,6 +327,14 @@ public class BubbleData { return mSelectedBubble; } /** * Returns the key of the selected bubble, or null if no bubble is selected. */ @Nullable public String getSelectedBubbleKey() { return mSelectedBubble != null ? mSelectedBubble.getKey() : null; } public BubbleOverflow getOverflow() { return mOverflow; } Loading Loading @@ -1228,9 +1236,7 @@ public class BubbleData { public void dump(PrintWriter pw) { pw.println("BubbleData state:"); pw.print(" selected: "); pw.println(mSelectedBubble != null ? mSelectedBubble.getKey() : "null"); pw.println(getSelectedBubbleKey()); pw.print(" expanded: "); pw.println(mExpanded); Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ interface IBubbles { oneway void showBubble(in String key, in Rect bubbleBarBounds) = 3; oneway void removeBubble(in String key) = 4; oneway void dragBubbleToDismiss(in String key) = 4; oneway void removeAllBubbles() = 5; Loading @@ -47,5 +47,5 @@ interface IBubbles { oneway void setBubbleBarBounds(in Rect bubbleBarBounds) = 10; oneway void stopBubbleDrag(in String key, in BubbleBarLocation location) = 11; oneway void stopBubbleDrag(in BubbleBarLocation location) = 11; } No newline at end of file packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +107 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import static android.service.notification.NotificationListenerService.REASON_GR import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static com.android.server.notification.Flags.FLAG_SCREENSHARE_NOTIFICATION_HIDING; import static com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_BAR; import static com.google.common.truth.Truth.assertThat; Loading Loading @@ -2141,6 +2142,112 @@ public class BubblesTest extends SysuiTestCase { assertThat(mBubbleController.getLayerView().isExpanded()).isFalse(); } @EnableFlags(FLAG_ENABLE_BUBBLE_BAR) @Test public void dragBubbleBarBubble_selectedBubble_expandedViewCollapsesDuringDrag() { mBubbleProperties.mIsBubbleBarEnabled = true; mPositioner.setIsLargeScreen(true); FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener(); mBubbleController.registerBubbleStateListener(bubbleStateListener); // Add 2 bubbles mEntryListener.onEntryAdded(mRow); mEntryListener.onEntryAdded(mRow2); mBubbleController.updateBubble(mBubbleEntry); mBubbleController.updateBubble(mBubbleEntry2); // Select first bubble mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), new Rect()); assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry.getKey()); assertThat(mBubbleController.getLayerView().isExpanded()).isTrue(); // Drag first bubble, bubble should collapse mBubbleController.startBubbleDrag(mBubbleEntry.getKey()); assertThat(mBubbleController.getLayerView().isExpanded()).isFalse(); // Stop dragging, first bubble should be expanded mBubbleController.stopBubbleDrag(BubbleBarLocation.LEFT); assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry.getKey()); assertThat(mBubbleController.getLayerView().isExpanded()).isTrue(); } @EnableFlags(FLAG_ENABLE_BUBBLE_BAR) @Test public void dragBubbleBarBubble_unselectedBubble_expandedViewCollapsesDuringDrag() { mBubbleProperties.mIsBubbleBarEnabled = true; mPositioner.setIsLargeScreen(true); FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener(); mBubbleController.registerBubbleStateListener(bubbleStateListener); // Add 2 bubbles mEntryListener.onEntryAdded(mRow); mEntryListener.onEntryAdded(mRow2); mBubbleController.updateBubble(mBubbleEntry); mBubbleController.updateBubble(mBubbleEntry2); // Select first bubble mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), new Rect()); assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry.getKey()); assertThat(mBubbleController.getLayerView().isExpanded()).isTrue(); // Drag second bubble, bubble should collapse mBubbleController.startBubbleDrag(mBubbleEntry2.getKey()); assertThat(mBubbleController.getLayerView().isExpanded()).isFalse(); // Stop dragging, first bubble should be expanded mBubbleController.stopBubbleDrag(BubbleBarLocation.LEFT); assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry.getKey()); assertThat(mBubbleController.getLayerView().isExpanded()).isTrue(); } @EnableFlags(FLAG_ENABLE_BUBBLE_BAR) @Test public void dismissBubbleBarBubble_selected_selectsAndExpandsNext() { mBubbleProperties.mIsBubbleBarEnabled = true; mPositioner.setIsLargeScreen(true); FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener(); mBubbleController.registerBubbleStateListener(bubbleStateListener); // Add 2 bubbles mEntryListener.onEntryAdded(mRow); mEntryListener.onEntryAdded(mRow2); mBubbleController.updateBubble(mBubbleEntry); mBubbleController.updateBubble(mBubbleEntry2); // Select first bubble mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), new Rect()); // Drag first bubble to dismiss mBubbleController.startBubbleDrag(mBubbleEntry.getKey()); mBubbleController.dragBubbleToDismiss(mBubbleEntry.getKey()); // Second bubble is selected and expanded assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry2.getKey()); assertThat(mBubbleController.getLayerView().isExpanded()).isTrue(); } @EnableFlags(FLAG_ENABLE_BUBBLE_BAR) @Test public void dismissBubbleBarBubble_unselected_selectionDoesNotChange() { mBubbleProperties.mIsBubbleBarEnabled = true; mPositioner.setIsLargeScreen(true); FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener(); mBubbleController.registerBubbleStateListener(bubbleStateListener); // Add 2 bubbles mEntryListener.onEntryAdded(mRow); mEntryListener.onEntryAdded(mRow2); mBubbleController.updateBubble(mBubbleEntry); mBubbleController.updateBubble(mBubbleEntry2); // Select first bubble mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), new Rect()); // Drag second bubble to dismiss mBubbleController.startBubbleDrag(mBubbleEntry2.getKey()); mBubbleController.dragBubbleToDismiss(mBubbleEntry2.getKey()); // First bubble remains selected and expanded assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry.getKey()); assertThat(mBubbleController.getLayerView().isExpanded()).isTrue(); } @DisableFlags(FLAG_SCREENSHARE_NOTIFICATION_HIDING) @Test public void doesNotRegisterSensitiveStateListener() { Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +26 −19 Original line number Diff line number Diff line Loading @@ -1170,7 +1170,9 @@ public class BubbleController implements ConfigurationChangeListener, * @param bubbleKey key of the bubble being dragged */ public void startBubbleDrag(String bubbleKey) { onBubbleDrag(bubbleKey, true /* isBeingDragged */); if (mBubbleData.getSelectedBubble() != null) { mBubbleBarViewCallback.expansionChanged(/* isExpanded = */ false); } if (mBubbleStateListener != null) { boolean overflow = BubbleOverflow.KEY.equals(bubbleKey); Rect rect = new Rect(); Loading @@ -1183,23 +1185,29 @@ public class BubbleController implements ConfigurationChangeListener, } /** * A bubble is no longer being dragged in Launcher. As was released in given location. * A bubble is no longer being dragged in Launcher. And was released in given location. * Will be called only when bubble bar is expanded. * * @param bubbleKey key of the bubble being dragged * @param location location where bubble was released */ public void stopBubbleDrag(String bubbleKey, BubbleBarLocation location) { public void stopBubbleDrag(BubbleBarLocation location) { mBubblePositioner.setBubbleBarLocation(location); onBubbleDrag(bubbleKey, false /* isBeingDragged */); if (mBubbleData.getSelectedBubble() != null) { mBubbleBarViewCallback.expansionChanged(/* isExpanded = */ true); } } private void onBubbleDrag(String bubbleKey, boolean isBeingDragged) { // TODO(b/330585402): collapse stack if any bubble is dragged if (mBubbleData.getSelectedBubble() != null && mBubbleData.getSelectedBubble().getKey().equals(bubbleKey)) { // Should collapse/expand only if equals to selected bubble. mBubbleBarViewCallback.expansionChanged(/* isExpanded = */ !isBeingDragged); /** * A bubble was dragged and is released in dismiss target in Launcher. * * @param bubbleKey key of the bubble being dragged to dismiss target */ public void dragBubbleToDismiss(String bubbleKey) { String selectedBubbleKey = mBubbleData.getSelectedBubbleKey(); removeBubble(bubbleKey, Bubbles.DISMISS_USER_GESTURE); if (selectedBubbleKey != null && !selectedBubbleKey.equals(bubbleKey)) { // We did not remove the selected bubble. Expand it again mBubbleBarViewCallback.expansionChanged(/* isExpanded = */ true); } } Loading Loading @@ -2357,12 +2365,6 @@ public class BubbleController implements ConfigurationChangeListener, key, bubbleBarBounds)); } @Override public void removeBubble(String key) { mMainExecutor.execute( () -> mController.removeBubble(key, Bubbles.DISMISS_USER_GESTURE)); } @Override public void removeAllBubbles() { mMainExecutor.execute(() -> mController.removeAllBubbles(Bubbles.DISMISS_USER_GESTURE)); Loading @@ -2379,8 +2381,13 @@ public class BubbleController implements ConfigurationChangeListener, } @Override public void stopBubbleDrag(String bubbleKey, BubbleBarLocation location) { mMainExecutor.execute(() -> mController.stopBubbleDrag(bubbleKey, location)); public void stopBubbleDrag(BubbleBarLocation location) { mMainExecutor.execute(() -> mController.stopBubbleDrag(location)); } @Override public void dragBubbleToDismiss(String key) { mMainExecutor.execute(() -> mController.dragBubbleToDismiss(key)); } @Override Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleData.java +9 −3 Original line number Diff line number Diff line Loading @@ -327,6 +327,14 @@ public class BubbleData { return mSelectedBubble; } /** * Returns the key of the selected bubble, or null if no bubble is selected. */ @Nullable public String getSelectedBubbleKey() { return mSelectedBubble != null ? mSelectedBubble.getKey() : null; } public BubbleOverflow getOverflow() { return mOverflow; } Loading Loading @@ -1228,9 +1236,7 @@ public class BubbleData { public void dump(PrintWriter pw) { pw.println("BubbleData state:"); pw.print(" selected: "); pw.println(mSelectedBubble != null ? mSelectedBubble.getKey() : "null"); pw.println(getSelectedBubbleKey()); pw.print(" expanded: "); pw.println(mExpanded); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -33,7 +33,7 @@ interface IBubbles { oneway void showBubble(in String key, in Rect bubbleBarBounds) = 3; oneway void removeBubble(in String key) = 4; oneway void dragBubbleToDismiss(in String key) = 4; oneway void removeAllBubbles() = 5; Loading @@ -47,5 +47,5 @@ interface IBubbles { oneway void setBubbleBarBounds(in Rect bubbleBarBounds) = 10; oneway void stopBubbleDrag(in String key, in BubbleBarLocation location) = 11; oneway void stopBubbleDrag(in BubbleBarLocation location) = 11; } No newline at end of file
packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +107 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import static android.service.notification.NotificationListenerService.REASON_GR import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static com.android.server.notification.Flags.FLAG_SCREENSHARE_NOTIFICATION_HIDING; import static com.android.wm.shell.Flags.FLAG_ENABLE_BUBBLE_BAR; import static com.google.common.truth.Truth.assertThat; Loading Loading @@ -2141,6 +2142,112 @@ public class BubblesTest extends SysuiTestCase { assertThat(mBubbleController.getLayerView().isExpanded()).isFalse(); } @EnableFlags(FLAG_ENABLE_BUBBLE_BAR) @Test public void dragBubbleBarBubble_selectedBubble_expandedViewCollapsesDuringDrag() { mBubbleProperties.mIsBubbleBarEnabled = true; mPositioner.setIsLargeScreen(true); FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener(); mBubbleController.registerBubbleStateListener(bubbleStateListener); // Add 2 bubbles mEntryListener.onEntryAdded(mRow); mEntryListener.onEntryAdded(mRow2); mBubbleController.updateBubble(mBubbleEntry); mBubbleController.updateBubble(mBubbleEntry2); // Select first bubble mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), new Rect()); assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry.getKey()); assertThat(mBubbleController.getLayerView().isExpanded()).isTrue(); // Drag first bubble, bubble should collapse mBubbleController.startBubbleDrag(mBubbleEntry.getKey()); assertThat(mBubbleController.getLayerView().isExpanded()).isFalse(); // Stop dragging, first bubble should be expanded mBubbleController.stopBubbleDrag(BubbleBarLocation.LEFT); assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry.getKey()); assertThat(mBubbleController.getLayerView().isExpanded()).isTrue(); } @EnableFlags(FLAG_ENABLE_BUBBLE_BAR) @Test public void dragBubbleBarBubble_unselectedBubble_expandedViewCollapsesDuringDrag() { mBubbleProperties.mIsBubbleBarEnabled = true; mPositioner.setIsLargeScreen(true); FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener(); mBubbleController.registerBubbleStateListener(bubbleStateListener); // Add 2 bubbles mEntryListener.onEntryAdded(mRow); mEntryListener.onEntryAdded(mRow2); mBubbleController.updateBubble(mBubbleEntry); mBubbleController.updateBubble(mBubbleEntry2); // Select first bubble mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), new Rect()); assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry.getKey()); assertThat(mBubbleController.getLayerView().isExpanded()).isTrue(); // Drag second bubble, bubble should collapse mBubbleController.startBubbleDrag(mBubbleEntry2.getKey()); assertThat(mBubbleController.getLayerView().isExpanded()).isFalse(); // Stop dragging, first bubble should be expanded mBubbleController.stopBubbleDrag(BubbleBarLocation.LEFT); assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry.getKey()); assertThat(mBubbleController.getLayerView().isExpanded()).isTrue(); } @EnableFlags(FLAG_ENABLE_BUBBLE_BAR) @Test public void dismissBubbleBarBubble_selected_selectsAndExpandsNext() { mBubbleProperties.mIsBubbleBarEnabled = true; mPositioner.setIsLargeScreen(true); FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener(); mBubbleController.registerBubbleStateListener(bubbleStateListener); // Add 2 bubbles mEntryListener.onEntryAdded(mRow); mEntryListener.onEntryAdded(mRow2); mBubbleController.updateBubble(mBubbleEntry); mBubbleController.updateBubble(mBubbleEntry2); // Select first bubble mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), new Rect()); // Drag first bubble to dismiss mBubbleController.startBubbleDrag(mBubbleEntry.getKey()); mBubbleController.dragBubbleToDismiss(mBubbleEntry.getKey()); // Second bubble is selected and expanded assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry2.getKey()); assertThat(mBubbleController.getLayerView().isExpanded()).isTrue(); } @EnableFlags(FLAG_ENABLE_BUBBLE_BAR) @Test public void dismissBubbleBarBubble_unselected_selectionDoesNotChange() { mBubbleProperties.mIsBubbleBarEnabled = true; mPositioner.setIsLargeScreen(true); FakeBubbleStateListener bubbleStateListener = new FakeBubbleStateListener(); mBubbleController.registerBubbleStateListener(bubbleStateListener); // Add 2 bubbles mEntryListener.onEntryAdded(mRow); mEntryListener.onEntryAdded(mRow2); mBubbleController.updateBubble(mBubbleEntry); mBubbleController.updateBubble(mBubbleEntry2); // Select first bubble mBubbleController.expandStackAndSelectBubbleFromLauncher(mBubbleEntry.getKey(), new Rect()); // Drag second bubble to dismiss mBubbleController.startBubbleDrag(mBubbleEntry2.getKey()); mBubbleController.dragBubbleToDismiss(mBubbleEntry2.getKey()); // First bubble remains selected and expanded assertThat(mBubbleData.getSelectedBubbleKey()).isEqualTo(mBubbleEntry.getKey()); assertThat(mBubbleController.getLayerView().isExpanded()).isTrue(); } @DisableFlags(FLAG_SCREENSHARE_NOTIFICATION_HIDING) @Test public void doesNotRegisterSensitiveStateListener() { Loading