diff options
18 files changed, 143 insertions, 147 deletions
diff --git a/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubbleControllerTest.kt b/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubbleControllerTest.kt index 55830afaab36..64f5170dfd9d 100644 --- a/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubbleControllerTest.kt +++ b/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubbleControllerTest.kt @@ -128,14 +128,14 @@ class BubbleControllerTest { } @Test - fun showOrHideAppBubble_createsNoteBubble() { + fun showOrHideNotesBubble_createsNoteBubble() { val intent = Intent(context, TestActivity::class.java) intent.setPackage(context.packageName) val user = UserHandle.of(0) val expectedKey = Bubble.getNoteBubbleKeyForApp(intent.getPackage(), user) getInstrumentation().runOnMainSync { - bubbleController.showOrHideAppBubble(intent, user, mock<Icon>()) + bubbleController.showOrHideNotesBubble(intent, user, mock<Icon>()) } getInstrumentation().waitForIdleSync() diff --git a/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubblePositionerTest.kt b/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubblePositionerTest.kt index 1d0c5057c77f..9711889ad028 100644 --- a/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubblePositionerTest.kt +++ b/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubblePositionerTest.kt @@ -154,19 +154,19 @@ class BubblePositionerTest { /** Test that the default resting position on tablet is middle right. */ @Test - fun testGetDefaultPosition_appBubble_onTablet() { + fun testGetDefaultPosition_noteBubble_onTablet() { positioner.update(defaultDeviceConfig.copy(isLargeScreen = true)) val allowableStackRegion = positioner.getAllowableStackPositionRegion(1 /* bubbleCount */) - val startPosition = positioner.getDefaultStartPosition(true /* isAppBubble */) + val startPosition = positioner.getDefaultStartPosition(true /* isNoteBubble */) assertThat(startPosition.x).isEqualTo(allowableStackRegion.right) assertThat(startPosition.y).isEqualTo(defaultYPosition) } @Test - fun testGetRestingPosition_appBubble_onTablet_RTL() { + fun testGetRestingPosition_noteBubble_onTablet_RTL() { positioner.update(defaultDeviceConfig.copy(isLargeScreen = true, isRtl = true)) val allowableStackRegion = positioner.getAllowableStackPositionRegion(1 /* bubbleCount */) - val startPosition = positioner.getDefaultStartPosition(true /* isAppBubble */) + val startPosition = positioner.getDefaultStartPosition(true /* isNoteBubble */) assertThat(startPosition.x).isEqualTo(allowableStackRegion.left) assertThat(startPosition.y).isEqualTo(defaultYPosition) } diff --git a/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/FakeBubbleExpandedViewManager.kt b/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/FakeBubbleExpandedViewManager.kt index 3c013d3636e8..adcd835d72be 100644 --- a/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/FakeBubbleExpandedViewManager.kt +++ b/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/FakeBubbleExpandedViewManager.kt @@ -38,7 +38,7 @@ class FakeBubbleExpandedViewManager(var bubbleBar: Boolean = false, var expanded override fun dismissBubble(bubble: Bubble, reason: Int) {} - override fun setAppBubbleTaskId(key: String, taskId: Int) {} + override fun setNoteBubbleTaskId(key: String, taskId: Int) {} override fun isStackExpanded(): Boolean { return expanded diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java index 234474057e5d..4b5aa19c6595 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java @@ -1562,74 +1562,72 @@ public class BubbleController implements ConfigurationChangeListener, /** * This method has different behavior depending on: - * - if an app bubble exists - * - if an app bubble is expanded + * - if a notes bubble exists + * - if a notes bubble is expanded * - * If no app bubble exists, this will add and expand a bubble with the provided intent. The + * If no notes bubble exists, this will add and expand a bubble with the provided intent. The * intent must be explicit (i.e. include a package name or fully qualified component class name) * and the activity for it should be resizable. * - * If an app bubble exists, this will toggle the visibility of it, i.e. if the app bubble is - * expanded, calling this method will collapse it. If the app bubble is not expanded, calling + * If a notes bubble exists, this will toggle the visibility of it, i.e. if the notes bubble is + * expanded, calling this method will collapse it. If the notes bubble is not expanded, calling * this method will expand it. * * These bubbles are <b>not</b> backed by a notification and remain until the user dismisses * the bubble or bubble stack. * - * Some notes: - * - Only one app bubble is supported at a time, regardless of users. Multi-users support is - * tracked in b/273533235. - * - Calling this method with a different intent than the existing app bubble will do nothing + * Some details: + * - Calling this method with a different intent than the existing bubble will do nothing * * @param intent the intent to display in the bubble expanded view. * @param user the {@link UserHandle} of the user to start this activity for. * @param icon the {@link Icon} to use for the bubble view. */ - public void showOrHideAppBubble(Intent intent, UserHandle user, @Nullable Icon icon) { + public void showOrHideNotesBubble(Intent intent, UserHandle user, @Nullable Icon icon) { if (intent == null || intent.getPackage() == null) { - Log.w(TAG, "App bubble failed to show, invalid intent: " + intent + Log.w(TAG, "Notes bubble failed to show, invalid intent: " + intent + ((intent != null) ? " with package: " + intent.getPackage() : " ")); return; } - String appBubbleKey = Bubble.getNoteBubbleKeyForApp(intent.getPackage(), user); + String noteBubbleKey = Bubble.getNoteBubbleKeyForApp(intent.getPackage(), user); PackageManager packageManager = getPackageManagerForUser(mContext, user.getIdentifier()); - if (!mResizabilityChecker.isResizableActivity(intent, packageManager, appBubbleKey)) { + if (!mResizabilityChecker.isResizableActivity(intent, packageManager, noteBubbleKey)) { // resize check logs any errors return; } - Bubble existingAppBubble = mBubbleData.getBubbleInStackWithKey(appBubbleKey); + Bubble existingNotebubble = mBubbleData.getBubbleInStackWithKey(noteBubbleKey); ProtoLog.d(WM_SHELL_BUBBLES, - "showOrHideAppBubble, key=%s existingAppBubble=%s stackVisibility=%s " + "showOrHideNotesBubble, key=%s existingAppBubble=%s stackVisibility=%s " + "statusBarShade=%s", - appBubbleKey, existingAppBubble, + noteBubbleKey, existingNotebubble, (mStackView != null ? mStackView.getVisibility() : "null"), mIsStatusBarShade); - if (existingAppBubble != null) { + if (existingNotebubble != null) { BubbleViewProvider selectedBubble = mBubbleData.getSelectedBubble(); if (isStackExpanded()) { - if (selectedBubble != null && appBubbleKey.equals(selectedBubble.getKey())) { - ProtoLog.d(WM_SHELL_BUBBLES, "collapseStack for %s", appBubbleKey); - // App bubble is expanded, lets collapse + if (selectedBubble != null && noteBubbleKey.equals(selectedBubble.getKey())) { + ProtoLog.d(WM_SHELL_BUBBLES, "collapseStack for %s", noteBubbleKey); + // Notes bubble is expanded, lets collapse collapseStack(); } else { - ProtoLog.d(WM_SHELL_BUBBLES, "setSelected for %s", appBubbleKey); - // App bubble is not selected, select it - mBubbleData.setSelectedBubble(existingAppBubble); + ProtoLog.d(WM_SHELL_BUBBLES, "setSelected for %s", noteBubbleKey); + // Notes bubble is not selected, select it + mBubbleData.setSelectedBubble(existingNotebubble); } } else { - ProtoLog.d(WM_SHELL_BUBBLES, "setSelectedBubbleAndExpandStack %s", appBubbleKey); - // App bubble is not selected, select it & expand - mBubbleData.setSelectedBubbleAndExpandStack(existingAppBubble); + ProtoLog.d(WM_SHELL_BUBBLES, "setSelectedBubbleAndExpandStack %s", noteBubbleKey); + // Notes bubble is not selected, select it & expand + mBubbleData.setSelectedBubbleAndExpandStack(existingNotebubble); } } else { // Check if it exists in the overflow - Bubble b = mBubbleData.getOverflowBubbleWithKey(appBubbleKey); + Bubble b = mBubbleData.getOverflowBubbleWithKey(noteBubbleKey); if (b != null) { // It's in the overflow, so remove it & reinflate - mBubbleData.dismissBubbleWithKey(appBubbleKey, Bubbles.DISMISS_NOTIF_CANCEL); + mBubbleData.dismissBubbleWithKey(noteBubbleKey, Bubbles.DISMISS_NOTIF_CANCEL); // Update the bubble entry in the overflow with the latest intent. b.setAppBubbleIntent(intent); } else { @@ -1637,7 +1635,7 @@ public class BubbleController implements ConfigurationChangeListener, b = Bubble.createNotesBubble(intent, user, icon, mMainExecutor, mBackgroundExecutor); } - ProtoLog.d(WM_SHELL_BUBBLES, "inflateAndAdd %s", appBubbleKey); + ProtoLog.d(WM_SHELL_BUBBLES, "inflateAndAdd %s", noteBubbleKey); b.setShouldAutoExpand(true); inflateAndAdd(b, /* suppressFlyout= */ true, /* showInShade= */ false); } @@ -1685,9 +1683,9 @@ public class BubbleController implements ConfigurationChangeListener, } } - /** Sets the app bubble's taskId which is cached for SysUI. */ - public void setAppBubbleTaskId(String key, int taskId) { - mImpl.mCachedState.setAppBubbleTaskId(key, taskId); + /** Sets the note bubble's taskId which is cached for SysUI. */ + public void setNoteBubbleTaskId(String key, int taskId) { + mImpl.mCachedState.setNoteBubbleTaskId(key, taskId); } /** @@ -2793,7 +2791,7 @@ public class BubbleController implements ConfigurationChangeListener, private HashMap<String, String> mSuppressedGroupToNotifKeys = new HashMap<>(); private HashMap<String, Bubble> mShortcutIdToBubble = new HashMap<>(); - private HashMap<String, Integer> mAppBubbleTaskIds = new HashMap(); + private HashMap<String, Integer> mNoteBubbleTaskIds = new HashMap(); private ArrayList<Bubble> mTmpBubbles = new ArrayList<>(); @@ -2825,20 +2823,20 @@ public class BubbleController implements ConfigurationChangeListener, mSuppressedBubbleKeys.clear(); mShortcutIdToBubble.clear(); - mAppBubbleTaskIds.clear(); + mNoteBubbleTaskIds.clear(); for (Bubble b : mTmpBubbles) { mShortcutIdToBubble.put(b.getShortcutId(), b); updateBubbleSuppressedState(b); - if (b.isAppBubble()) { - mAppBubbleTaskIds.put(b.getKey(), b.getTaskId()); + if (b.isNoteBubble()) { + mNoteBubbleTaskIds.put(b.getKey(), b.getTaskId()); } } } - /** Sets the app bubble's taskId which is cached for SysUI. */ - synchronized void setAppBubbleTaskId(String key, int taskId) { - mAppBubbleTaskIds.put(key, taskId); + /** Sets the note bubble's taskId which is cached for SysUI. */ + synchronized void setNoteBubbleTaskId(String key, int taskId) { + mNoteBubbleTaskIds.put(key, taskId); } /** @@ -2890,7 +2888,7 @@ public class BubbleController implements ConfigurationChangeListener, pw.println(" suppressing: " + key); } - pw.println("mAppBubbleTaskIds: " + mAppBubbleTaskIds.values()); + pw.println("mNoteBubbleTaskIds: " + mNoteBubbleTaskIds.values()); } } @@ -2941,14 +2939,14 @@ public class BubbleController implements ConfigurationChangeListener, } @Override - public void showOrHideAppBubble(Intent intent, UserHandle user, @Nullable Icon icon) { + public void showOrHideNoteBubble(Intent intent, UserHandle user, @Nullable Icon icon) { mMainExecutor.execute( - () -> BubbleController.this.showOrHideAppBubble(intent, user, icon)); + () -> BubbleController.this.showOrHideNotesBubble(intent, user, icon)); } @Override - public boolean isAppBubbleTaskId(int taskId) { - return mCachedState.mAppBubbleTaskIds.values().contains(taskId); + public boolean isNoteBubbleTaskId(int taskId) { + return mCachedState.mNoteBubbleTaskIds.values().contains(taskId); } @Override diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java index 2fbecd2cbb0b..ac74a42d1359 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedView.java @@ -287,7 +287,7 @@ public class BubbleExpandedView extends LinearLayout { if (mBubble != null && mBubble.isNoteBubble()) { // Let the controller know sooner what the taskId is. - mManager.setAppBubbleTaskId(mBubble.getKey(), mTaskId); + mManager.setNoteBubbleTaskId(mBubble.getKey(), mTaskId); } // With the task org, the taskAppeared callback will only happen once the task has diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedViewManager.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedViewManager.kt index a02623138f1e..6be49ddc549a 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedViewManager.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleExpandedViewManager.kt @@ -28,7 +28,7 @@ interface BubbleExpandedViewManager { fun promoteBubbleFromOverflow(bubble: Bubble) fun removeBubble(key: String, reason: Int) fun dismissBubble(bubble: Bubble, reason: Int) - fun setAppBubbleTaskId(key: String, taskId: Int) + fun setNoteBubbleTaskId(key: String, taskId: Int) fun isStackExpanded(): Boolean fun isShowingAsBubbleBar(): Boolean fun hideCurrentInputMethod() @@ -73,8 +73,8 @@ interface BubbleExpandedViewManager { controller.dismissBubble(bubble, reason) } - override fun setAppBubbleTaskId(key: String, taskId: Int) { - controller.setAppBubbleTaskId(key, taskId) + override fun setNoteBubbleTaskId(key: String, taskId: Int) { + controller.setNoteBubbleTaskId(key, taskId) } override fun isStackExpanded(): Boolean = controller.isStackExpanded diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java index a725e04d3f8a..0e2fc3a77c6d 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubblePositioner.java @@ -758,20 +758,20 @@ public class BubblePositioner { * is being shown, for a normal bubble. */ public PointF getDefaultStartPosition() { - return getDefaultStartPosition(false /* isAppBubble */); + return getDefaultStartPosition(false /* isNoteBubble */); } /** * The stack position to use if we don't have a saved location or if user education * is being shown. * - * @param isAppBubble whether this start position is for an app bubble or not. + * @param isNoteBubble whether this start position is for a note bubble or not. */ - public PointF getDefaultStartPosition(boolean isAppBubble) { + public PointF getDefaultStartPosition(boolean isNoteBubble) { // Normal bubbles start on the left if we're in LTR, right otherwise. // TODO (b/294284894): update language around "app bubble" here // App bubbles start on the right in RTL, left otherwise. - final boolean startOnLeft = isAppBubble ? mDeviceConfig.isRtl() : !mDeviceConfig.isRtl(); + final boolean startOnLeft = isNoteBubble ? mDeviceConfig.isRtl() : !mDeviceConfig.isRtl(); return getStartPosition(startOnLeft ? StackPinnedEdge.LEFT : StackPinnedEdge.RIGHT); } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTaskViewHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTaskViewHelper.java index ca9390613621..83d311ed6cd9 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTaskViewHelper.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleTaskViewHelper.java @@ -169,7 +169,7 @@ public class BubbleTaskViewHelper { if (mBubble != null && mBubble.isNoteBubble()) { // Let the controller know sooner what the taskId is. - mExpandedViewManager.setAppBubbleTaskId(mBubble.getKey(), mTaskId); + mExpandedViewManager.setNoteBubbleTaskId(mBubble.getKey(), mTaskId); } // With the task org, the taskAppeared callback will only happen once the task has diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubbles.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubbles.java index 4297fac0f6a8..44ae74479949 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubbles.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubbles.java @@ -135,33 +135,31 @@ public interface Bubbles { /** * This method has different behavior depending on: - * - if an app bubble exists - * - if an app bubble is expanded + * - if a notes bubble exists + * - if a notes bubble is expanded * - * If no app bubble exists, this will add and expand a bubble with the provided intent. The + * If no notes bubble exists, this will add and expand a bubble with the provided intent. The * intent must be explicit (i.e. include a package name or fully qualified component class name) * and the activity for it should be resizable. * - * If an app bubble exists, this will toggle the visibility of it, i.e. if the app bubble is - * expanded, calling this method will collapse it. If the app bubble is not expanded, calling + * If a notes bubble exists, this will toggle the visibility of it, i.e. if the notes bubble is + * expanded, calling this method will collapse it. If the notes bubble is not expanded, calling * this method will expand it. * * These bubbles are <b>not</b> backed by a notification and remain until the user dismisses * the bubble or bubble stack. * - * Some notes: - * - Only one app bubble is supported at a time, regardless of users. Multi-users support is - * tracked in b/273533235. - * - Calling this method with a different intent than the existing app bubble will do nothing + * Some details: + * - Calling this method with a different intent than the existing bubble will do nothing * * @param intent the intent to display in the bubble expanded view. - * @param user the {@link UserHandle} of the user to start this activity for. - * @param icon the {@link Icon} to use for the bubble view. + * @param user the {@link UserHandle} of the user to start this activity for. + * @param icon the {@link Icon} to use for the bubble view. */ - void showOrHideAppBubble(Intent intent, UserHandle user, @Nullable Icon icon); + void showOrHideNoteBubble(Intent intent, UserHandle user, @Nullable Icon icon); /** @return true if the specified {@code taskId} corresponds to app bubble's taskId. */ - boolean isAppBubbleTaskId(int taskId); + boolean isNoteBubbleTaskId(int taskId); /** ` * @return a {@link SynchronousScreenCaptureListener} after performing a screenshot that may diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/notetask/FakeNoteTaskBubbleController.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/notetask/FakeNoteTaskBubbleController.kt index 032eef0ad936..9283455d3e54 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/notetask/FakeNoteTaskBubbleController.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/notetask/FakeNoteTaskBubbleController.kt @@ -38,7 +38,7 @@ class FakeNoteTaskBubbleController( ) : NoteTaskBubblesController(unUsed1, unsUsed2) { override suspend fun areBubblesAvailable() = optionalBubbles.isPresent - override suspend fun showOrHideAppBubble( + override suspend fun showOrHideNoteBubble( intent: Intent, userHandle: UserHandle, icon: Icon, @@ -54,7 +54,7 @@ class FakeNoteTaskBubbleController( ) { return@ifPresentOrElse } - bubbles.showOrHideAppBubble(intent, userHandle, icon) + bubbles.showOrHideNoteBubble(intent, userHandle, icon) }, { throw IllegalAccessException() }, ) diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/notetask/NoteTaskBubblesServiceTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/notetask/NoteTaskBubblesServiceTest.kt index e55d6ad6c5a0..7b9af90ff228 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/notetask/NoteTaskBubblesServiceTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/notetask/NoteTaskBubblesServiceTest.kt @@ -64,41 +64,41 @@ internal class NoteTaskBubblesServiceTest : SysuiTestCase() { } @Test - fun showOrHideAppBubble_defaultExpandBehavior_shouldCallBubblesApi() { + fun showOrHideNoteBubble_defaultExpandBehavior_shouldCallBubblesApi() { val intent = Intent() val user = UserHandle.SYSTEM val icon = Icon.createWithResource(context, R.drawable.ic_note_task_shortcut_widget) val bubbleExpandBehavior = NoteTaskBubbleExpandBehavior.DEFAULT whenever(bubbles.isBubbleExpanded(any())).thenReturn(false) - createServiceBinder().showOrHideAppBubble(intent, user, icon, bubbleExpandBehavior) + createServiceBinder().showOrHideNoteBubble(intent, user, icon, bubbleExpandBehavior) - verify(bubbles).showOrHideAppBubble(intent, user, icon) + verify(bubbles).showOrHideNoteBubble(intent, user, icon) } @Test - fun showOrHideAppBubble_keepIfExpanded_bubbleShown_shouldNotCallBubblesApi() { + fun showOrHideNoteBubble_keepIfExpanded_bubbleShown_shouldNotCallBubblesApi() { val intent = Intent().apply { setPackage("test") } val user = UserHandle.SYSTEM val icon = Icon.createWithResource(context, R.drawable.ic_note_task_shortcut_widget) val bubbleExpandBehavior = NoteTaskBubbleExpandBehavior.KEEP_IF_EXPANDED whenever(bubbles.isBubbleExpanded(any())).thenReturn(true) - createServiceBinder().showOrHideAppBubble(intent, user, icon, bubbleExpandBehavior) + createServiceBinder().showOrHideNoteBubble(intent, user, icon, bubbleExpandBehavior) - verify(bubbles, never()).showOrHideAppBubble(intent, user, icon) + verify(bubbles, never()).showOrHideNoteBubble(intent, user, icon) } @Test - fun showOrHideAppBubble_keepIfExpanded_bubbleNotShown_shouldCallBubblesApi() { + fun showOrHideNoteBubble_keepIfExpanded_bubbleNotShown_shouldCallBubblesApi() { val intent = Intent().apply { setPackage("test") } val user = UserHandle.SYSTEM val icon = Icon.createWithResource(context, R.drawable.ic_note_task_shortcut_widget) val bubbleExpandBehavior = NoteTaskBubbleExpandBehavior.KEEP_IF_EXPANDED whenever(bubbles.isBubbleExpanded(any())).thenReturn(false) - createServiceBinder().showOrHideAppBubble(intent, user, icon, bubbleExpandBehavior) + createServiceBinder().showOrHideNoteBubble(intent, user, icon, bubbleExpandBehavior) - verify(bubbles).showOrHideAppBubble(intent, user, icon) + verify(bubbles).showOrHideNoteBubble(intent, user, icon) } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/screenshot/appclips/AppClipsServiceTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/screenshot/appclips/AppClipsServiceTest.java index d8897e9048c3..81301b3886f1 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/screenshot/appclips/AppClipsServiceTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/screenshot/appclips/AppClipsServiceTest.java @@ -183,14 +183,14 @@ public final class AppClipsServiceTest extends SysuiTestCase { when(mFeatureFlags.isEnabled(SCREENSHOT_APP_CLIPS)).thenReturn(true); when(mOptionalBubbles.isEmpty()).thenReturn(false); when(mOptionalBubbles.get()).thenReturn(mBubbles); - when(mBubbles.isAppBubbleTaskId(eq((FAKE_TASK_ID)))).thenReturn(false); + when(mBubbles.isNoteBubbleTaskId(eq((FAKE_TASK_ID)))).thenReturn(false); } private void mockForScreenshotBlocked() { when(mFeatureFlags.isEnabled(SCREENSHOT_APP_CLIPS)).thenReturn(true); when(mOptionalBubbles.isEmpty()).thenReturn(false); when(mOptionalBubbles.get()).thenReturn(mBubbles); - when(mBubbles.isAppBubbleTaskId(eq((FAKE_TASK_ID)))).thenReturn(true); + when(mBubbles.isNoteBubbleTaskId(eq((FAKE_TASK_ID)))).thenReturn(true); when(mDevicePolicyManager.getScreenCaptureDisabled(eq(null))).thenReturn(true); } @@ -199,7 +199,7 @@ public final class AppClipsServiceTest extends SysuiTestCase { when(mFeatureFlags.isEnabled(SCREENSHOT_APP_CLIPS)).thenReturn(true); when(mOptionalBubbles.isEmpty()).thenReturn(false); when(mOptionalBubbles.get()).thenReturn(mBubbles); - when(mBubbles.isAppBubbleTaskId(eq((FAKE_TASK_ID)))).thenReturn(true); + when(mBubbles.isNoteBubbleTaskId(eq((FAKE_TASK_ID)))).thenReturn(true); when(mDevicePolicyManager.getScreenCaptureDisabled(eq(null))).thenReturn(false); } @@ -208,7 +208,7 @@ public final class AppClipsServiceTest extends SysuiTestCase { when(mFeatureFlags.isEnabled(SCREENSHOT_APP_CLIPS)).thenReturn(true); when(mOptionalBubbles.isEmpty()).thenReturn(false); when(mOptionalBubbles.get()).thenReturn(mBubbles); - when(mBubbles.isAppBubbleTaskId(eq((FAKE_TASK_ID)))).thenReturn(true); + when(mBubbles.isNoteBubbleTaskId(eq((FAKE_TASK_ID)))).thenReturn(true); when(mDevicePolicyManager.getScreenCaptureDisabled(eq(null))).thenReturn(false); } diff --git a/packages/SystemUI/src/com/android/systemui/notetask/INoteTaskBubblesService.aidl b/packages/SystemUI/src/com/android/systemui/notetask/INoteTaskBubblesService.aidl index 7803f229dda7..d803ebed94e3 100644 --- a/packages/SystemUI/src/com/android/systemui/notetask/INoteTaskBubblesService.aidl +++ b/packages/SystemUI/src/com/android/systemui/notetask/INoteTaskBubblesService.aidl @@ -26,6 +26,6 @@ interface INoteTaskBubblesService { boolean areBubblesAvailable(); - void showOrHideAppBubble(in Intent intent, in UserHandle userHandle, in Icon icon, + void showOrHideNoteBubble(in Intent intent, in UserHandle userHandle, in Icon icon, in NoteTaskBubbleExpandBehavior bubbleExpandBehavior); } diff --git a/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskBubblesController.kt b/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskBubblesController.kt index 9214d88c4e27..e20ccfa13e17 100644 --- a/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskBubblesController.kt +++ b/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskBubblesController.kt @@ -76,8 +76,8 @@ constructor( } } - /** Calls the [Bubbles.showOrHideAppBubble] API as [UserHandle.USER_SYSTEM]. */ - open suspend fun showOrHideAppBubble( + /** Calls the [Bubbles.showOrHideNoteBubble] API as [UserHandle.USER_SYSTEM]. */ + open suspend fun showOrHideNoteBubble( intent: Intent, userHandle: UserHandle, icon: Icon, @@ -85,7 +85,7 @@ constructor( ) { withContext(bgDispatcher) { serviceConnector - .post { it.showOrHideAppBubble(intent, userHandle, icon, bubbleExpandBehavior) } + .post { it.showOrHideNoteBubble(intent, userHandle, icon, bubbleExpandBehavior) } .whenComplete { _, error -> if (error != null) { debugLog(error = error) { @@ -119,7 +119,7 @@ constructor( return object : INoteTaskBubblesService.Stub() { override fun areBubblesAvailable() = mOptionalBubbles.isPresent - override fun showOrHideAppBubble( + override fun showOrHideNoteBubble( intent: Intent, userHandle: UserHandle, icon: Icon, @@ -136,7 +136,7 @@ constructor( ) { return@ifPresentOrElse } - bubbles.showOrHideAppBubble(intent, userHandle, icon) + bubbles.showOrHideNoteBubble(intent, userHandle, icon) }, { debugLog { diff --git a/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt b/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt index 32a4579c78fa..7e0128ab8f13 100644 --- a/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt +++ b/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt @@ -219,7 +219,7 @@ constructor( val intent = createNoteTaskIntent(info, useStylusMode) val icon = Icon.createWithResource(context, R.drawable.ic_note_task_shortcut_widget) - noteTaskBubblesController.showOrHideAppBubble( + noteTaskBubblesController.showOrHideNoteBubble( intent, user, icon, diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/appclips/AppClipsService.java b/packages/SystemUI/src/com/android/systemui/screenshot/appclips/AppClipsService.java index 3bca4e421cbd..1a91afcf6cac 100644 --- a/packages/SystemUI/src/com/android/systemui/screenshot/appclips/AppClipsService.java +++ b/packages/SystemUI/src/com/android/systemui/screenshot/appclips/AppClipsService.java @@ -152,8 +152,8 @@ public class AppClipsService extends Service { return CAPTURE_CONTENT_FOR_NOTE_FAILED; } - if (!mOptionalBubbles.get().isAppBubbleTaskId(taskId)) { - Log.d(TAG, String.format("Taskid %d is not app bubble task", taskId)); + if (!mOptionalBubbles.get().isNoteBubbleTaskId(taskId)) { + Log.d(TAG, String.format("Taskid %d is not note bubble task", taskId)); return CAPTURE_CONTENT_FOR_NOTE_WINDOW_MODE_UNSUPPORTED; } diff --git a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskControllerTest.kt index 141791a94381..69539743f96f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskControllerTest.kt @@ -230,7 +230,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() { } @Test - fun onBubbleExpandChanged_notKeyAppBubble_shouldDoNothing() { + fun onBubbleExpandChanged_notKeyNoteBubble_shouldDoNothing() { createNoteTaskController().onBubbleExpandChanged(isExpanding = true, key = "any other key") verifyNoMoreInteractions(bubbles, keyguardManager, userManager, eventLogger) @@ -740,7 +740,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() { val intentCaptor = argumentCaptor<Intent>() val iconCaptor = argumentCaptor<Icon>() verify(bubbles) - .showOrHideAppBubble(capture(intentCaptor), eq(userHandle), capture(iconCaptor)) + .showOrHideNoteBubble(capture(intentCaptor), eq(userHandle), capture(iconCaptor)) assertThat(intentCaptor.value).run { hasAction(ACTION_CREATE_NOTE) hasPackage(NOTE_TASK_PACKAGE_NAME) diff --git a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java index 293f5c961890..9ceda0e33b44 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/wmshell/BubblesTest.java @@ -26,8 +26,6 @@ import static android.service.notification.NotificationListenerService.REASON_AP import static android.service.notification.NotificationListenerService.REASON_GROUP_SUMMARY_CANCELED; import static android.service.notification.NotificationListenerService.REASON_PACKAGE_BANNED; -import static androidx.test.ext.truth.content.IntentSubject.assertThat; - 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; @@ -298,7 +296,7 @@ public class BubblesTest extends SysuiTestCase { private BubbleEntry mBubbleEntryUser11; private BubbleEntry mBubbleEntry2User11; - private Intent mAppBubbleIntent; + private Intent mNotesBubbleIntent; @Mock private ShellInit mShellInit; @@ -355,7 +353,7 @@ public class BubblesTest extends SysuiTestCase { @Mock private NotifPipelineFlags mNotifPipelineFlags; @Mock - private Icon mAppBubbleIcon; + private Icon mNotesBubbleIcon; @Mock private Display mDefaultDisplay; @Mock @@ -458,8 +456,8 @@ public class BubblesTest extends SysuiTestCase { mNotificationShadeWindowController.fetchWindowRootView(); mNotificationShadeWindowController.attach(); - mAppBubbleIntent = new Intent(mContext, BubblesTestActivity.class); - mAppBubbleIntent.setPackage(mContext.getPackageName()); + mNotesBubbleIntent = new Intent(mContext, BubblesTestActivity.class); + mNotesBubbleIntent.setPackage(mContext.getPackageName()); mZenModeConfig.suppressedVisualEffects = 0; when(mZenModeController.getConfig()).thenReturn(mZenModeConfig); @@ -1480,8 +1478,8 @@ public class BubblesTest extends SysuiTestCase { } @Test - public void testShowManageMenuChangesSysuiState_appBubble() { - mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon); + public void testShowManageMenuChangesSysuiState_notesBubble() { + mBubbleController.showOrHideNotesBubble(mNotesBubbleIntent, mUser0, mNotesBubbleIcon); assertTrue(mBubbleController.hasBubbles()); // Expand the stack @@ -1981,10 +1979,10 @@ public class BubblesTest extends SysuiTestCase { } @Test - public void testShowOrHideAppBubble_addsAndExpand() { + public void testShowOrHideNotesBubble_addsAndExpand() { assertThat(mBubbleController.isStackExpanded()).isFalse(); - mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon); + mBubbleController.showOrHideNotesBubble(mNotesBubbleIntent, mUser0, mNotesBubbleIcon); verify(mBubbleController).inflateAndAdd(any(Bubble.class), /* suppressFlyout= */ eq(true), /* showInShade= */ eq(false)); @@ -1994,14 +1992,14 @@ public class BubblesTest extends SysuiTestCase { } @Test - public void testShowOrHideAppBubble_expandIfCollapsed() { - mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon); + public void testShowOrHideNotesBubble_expandIfCollapsed() { + mBubbleController.showOrHideNotesBubble(mNotesBubbleIntent, mUser0, mNotesBubbleIcon); mBubbleController.updateBubble(mBubbleEntry); mBubbleController.collapseStack(); assertThat(mBubbleController.isStackExpanded()).isFalse(); // Calling this while collapsed will expand the app bubble - mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon); + mBubbleController.showOrHideNotesBubble(mNotesBubbleIntent, mUser0, mNotesBubbleIcon); assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo( Bubble.getNoteBubbleKeyForApp(mContext.getPackageName(), mUser0)); @@ -2010,14 +2008,14 @@ public class BubblesTest extends SysuiTestCase { } @Test - public void testShowOrHideAppBubble_collapseIfSelected() { - mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon); + public void testShowOrHideNotesBubble_collapseIfSelected() { + mBubbleController.showOrHideNotesBubble(mNotesBubbleIntent, mUser0, mNotesBubbleIcon); assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo( Bubble.getNoteBubbleKeyForApp(mContext.getPackageName(), mUser0)); assertThat(mBubbleController.isStackExpanded()).isTrue(); // Calling this while the app bubble is expanded should collapse the stack - mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon); + mBubbleController.showOrHideNotesBubble(mNotesBubbleIntent, mUser0, mNotesBubbleIcon); assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo( Bubble.getNoteBubbleKeyForApp(mContext.getPackageName(), mUser0)); @@ -2027,33 +2025,34 @@ public class BubblesTest extends SysuiTestCase { } @Test - public void testShowOrHideAppBubbleWithNonPrimaryUser_bubbleCollapsedWithExpectedUser() { + public void testShowOrHideNotesBubbleWithNonPrimaryUser_bubbleCollapsedWithExpectedUser() { UserHandle user10 = createUserHandle(/* userId = */ 10); - String appBubbleKey = Bubble.getNoteBubbleKeyForApp(mContext.getPackageName(), user10); - mBubbleController.showOrHideAppBubble(mAppBubbleIntent, user10, mAppBubbleIcon); - assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(appBubbleKey); + String notesKey = Bubble.getNoteBubbleKeyForApp(mContext.getPackageName(), user10); + mBubbleController.showOrHideNotesBubble(mNotesBubbleIntent, user10, mNotesBubbleIcon); + assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(notesKey); assertThat(mBubbleController.isStackExpanded()).isTrue(); assertThat(mBubbleData.getBubbles().size()).isEqualTo(1); assertThat(mBubbleData.getBubbles().get(0).getUser()).isEqualTo(user10); // Calling this while the app bubble is expanded should collapse the stack - mBubbleController.showOrHideAppBubble(mAppBubbleIntent, user10, mAppBubbleIcon); + mBubbleController.showOrHideNotesBubble(mNotesBubbleIntent, user10, mNotesBubbleIcon); - assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(appBubbleKey); + assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(notesKey); assertThat(mBubbleController.isStackExpanded()).isFalse(); assertThat(mBubbleData.getBubbles().size()).isEqualTo(1); assertThat(mBubbleData.getBubbles().get(0).getUser()).isEqualTo(user10); } @Test - public void testShowOrHideAppBubbleOnUser10AndThenUser0_user0BubbleExpanded() { + public void testShowOrHideNotesBubbleOnUser10AndThenUser0_user0BubbleExpanded() { UserHandle user10 = createUserHandle(/* userId = */ 10); - mBubbleController.showOrHideAppBubble(mAppBubbleIntent, user10, mAppBubbleIcon); + mBubbleController.showOrHideNotesBubble(mNotesBubbleIntent, user10, mNotesBubbleIcon); - String appBubbleUser0Key = Bubble.getNoteBubbleKeyForApp(mContext.getPackageName(), mUser0); - mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon); + String notesBubbleUser0Key = Bubble.getNoteBubbleKeyForApp(mContext.getPackageName(), + mUser0); + mBubbleController.showOrHideNotesBubble(mNotesBubbleIntent, mUser0, mNotesBubbleIcon); - assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(appBubbleUser0Key); + assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(notesBubbleUser0Key); assertThat(mBubbleController.isStackExpanded()).isTrue(); assertThat(mBubbleData.getBubbles()).hasSize(2); assertThat(mBubbleData.getBubbles().get(0).getUser()).isEqualTo(mUser0); @@ -2061,14 +2060,14 @@ public class BubblesTest extends SysuiTestCase { } @Test - public void testShowOrHideAppBubble_selectIfNotSelected() { - mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon); + public void testShowOrHideNotesBubble_selectIfNotSelected() { + mBubbleController.showOrHideNotesBubble(mNotesBubbleIntent, mUser0, mNotesBubbleIcon); mBubbleController.updateBubble(mBubbleEntry); mBubbleController.expandStackAndSelectBubble(mBubbleEntry); assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(mBubbleEntry.getKey()); assertThat(mBubbleController.isStackExpanded()).isTrue(); - mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon); + mBubbleController.showOrHideNotesBubble(mNotesBubbleIntent, mUser0, mNotesBubbleIcon); assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo( Bubble.getNoteBubbleKeyForApp(mContext.getPackageName(), mUser0)); assertThat(mBubbleController.isStackExpanded()).isTrue(); @@ -2076,48 +2075,49 @@ public class BubblesTest extends SysuiTestCase { } @Test - public void testShowOrHideAppBubble_addsFromOverflow() { - String appBubbleKey = Bubble.getNoteBubbleKeyForApp(mAppBubbleIntent.getPackage(), mUser0); - mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon); - + public void testShowOrHideNotesBubble_addsFromOverflow() { + String noteBubbleKey = Bubble.getNoteBubbleKeyForApp(mNotesBubbleIntent.getPackage(), + mUser0); + mBubbleController.showOrHideNotesBubble(mNotesBubbleIntent, mUser0, mNotesBubbleIcon); // Collapse the stack so we don't need to wait for the dismiss animation in the test mBubbleController.collapseStack(); // Dismiss the app bubble so it's in the overflow - mBubbleController.dismissBubble(appBubbleKey, Bubbles.DISMISS_USER_GESTURE); - assertThat(mBubbleData.getOverflowBubbleWithKey(appBubbleKey)).isNotNull(); + mBubbleController.dismissBubble(noteBubbleKey, Bubbles.DISMISS_USER_GESTURE); + assertThat(mBubbleData.getOverflowBubbleWithKey(noteBubbleKey)).isNotNull(); // Calling this while collapsed will re-add and expand the app bubble - mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon); - assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(appBubbleKey); + mBubbleController.showOrHideNotesBubble(mNotesBubbleIntent, mUser0, mNotesBubbleIcon); + assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(noteBubbleKey); assertThat(mBubbleController.isStackExpanded()).isTrue(); assertThat(mBubbleData.getBubbles().size()).isEqualTo(1); - assertThat(mBubbleData.getOverflowBubbleWithKey(appBubbleKey)).isNull(); + assertThat(mBubbleData.getOverflowBubbleWithKey(noteBubbleKey)).isNull(); } @Test - public void testShowOrHideAppBubble_updateExistedBubbleInOverflow_updateIntentInBubble() { - String appBubbleKey = Bubble.getNoteBubbleKeyForApp(mAppBubbleIntent.getPackage(), mUser0); - mBubbleController.showOrHideAppBubble(mAppBubbleIntent, mUser0, mAppBubbleIcon); + public void testShowOrHideNotesBubble_updateExistedBubbleInOverflow_updateIntentInBubble() { + String noteBubbleKey = Bubble.getNoteBubbleKeyForApp(mNotesBubbleIntent.getPackage(), + mUser0); + mBubbleController.showOrHideNotesBubble(mNotesBubbleIntent, mUser0, mNotesBubbleIcon); // Collapse the stack so we don't need to wait for the dismiss animation in the test mBubbleController.collapseStack(); // Dismiss the app bubble so it's in the overflow - mBubbleController.dismissBubble(appBubbleKey, Bubbles.DISMISS_USER_GESTURE); - assertThat(mBubbleData.getOverflowBubbleWithKey(appBubbleKey)).isNotNull(); + mBubbleController.dismissBubble(noteBubbleKey, Bubbles.DISMISS_USER_GESTURE); + assertThat(mBubbleData.getOverflowBubbleWithKey(noteBubbleKey)).isNotNull(); // Modify the intent to include new extras. - Intent newAppBubbleIntent = new Intent(mContext, BubblesTestActivity.class) + Intent newIntent = new Intent(mContext, BubblesTestActivity.class) .setPackage(mContext.getPackageName()) .putExtra("hello", "world"); // Calling this while collapsed will re-add and expand the app bubble - mBubbleController.showOrHideAppBubble(newAppBubbleIntent, mUser0, mAppBubbleIcon); - assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(appBubbleKey); + mBubbleController.showOrHideNotesBubble(newIntent, mUser0, mNotesBubbleIcon); + assertThat(mBubbleData.getSelectedBubble().getKey()).isEqualTo(noteBubbleKey); assertThat(mBubbleController.isStackExpanded()).isTrue(); assertThat(mBubbleData.getBubbles().size()).isEqualTo(1); assertThat(mBubbleData.getBubbles().get(0).getAppBubbleIntent() .getStringExtra("hello")).isEqualTo("world"); - assertThat(mBubbleData.getOverflowBubbleWithKey(appBubbleKey)).isNull(); + assertThat(mBubbleData.getOverflowBubbleWithKey(noteBubbleKey)).isNull(); } @Test |