Fix NPE when dragging an app to bubble from taskbar
I shouldn't have removed the use of component utils to look
up the package name. I've added that back and modified the
test to work with it.
Flag: com.android.wm.shell.enable_bubble_anything
Test: atest WMShellRobolectricTests:BubbleTaskViewListenerTest
Test: manual - open an app, bring taskbar up, drag an app from taskbar
to the bubble drop zone => observe that it works
Bug: 398847805
Change-Id: I4eff1faf4c49fd21538b0e77472416c83a04c765
diff --git a/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubbleTaskViewListenerTest.kt b/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubbleTaskViewListenerTest.kt
index 3aefcd5..9087da3 100644
--- a/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubbleTaskViewListenerTest.kt
+++ b/libs/WindowManager/Shell/multivalentTests/src/com/android/wm/shell/bubbles/BubbleTaskViewListenerTest.kt
@@ -552,7 +552,9 @@
private fun createAppBubble(usePendingIntent: Boolean = false): Bubble {
val target = Intent(context, TestActivity::class.java)
+ val component = ComponentName(context, TestActivity::class.java)
target.setPackage(context.packageName)
+ target.setComponent(component)
if (usePendingIntent) {
// Robolectric doesn't seem to play nice with PendingIntents, have to mock it.
val pendingIntent = mock<PendingIntent>()
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java
index 313d151..d948928 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java
@@ -364,7 +364,7 @@
@ShellMainThread Executor mainExecutor, @ShellBackgroundThread Executor bgExecutor) {
return new Bubble(intent,
user,
- /* key= */ getAppBubbleKeyForApp(intent.getIntent().getPackage(), user),
+ /* key= */ getAppBubbleKeyForApp(ComponentUtils.getPackageName(intent), user),
mainExecutor, bgExecutor);
}