summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/BubbleInfo.java32
-rw-r--r--libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/ParcelableFlyoutMessage.kt55
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java18
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleViewInfoTask.java6
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleViewInfoTaskLegacy.java6
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/bubbles/BubbleInfoTest.kt14
6 files changed, 117 insertions, 14 deletions
diff --git a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/BubbleInfo.java b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/BubbleInfo.java
index 58766826bd3b..85dabce8ac20 100644
--- a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/BubbleInfo.java
+++ b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/BubbleInfo.java
@@ -30,29 +30,32 @@ import java.util.Objects;
*/
public class BubbleInfo implements Parcelable {
- private String mKey; // Same key as the Notification
+ private final String mKey; // Same key as the Notification
private int mFlags; // Flags from BubbleMetadata
@Nullable
- private String mShortcutId;
- private int mUserId;
- private String mPackageName;
+ private final String mShortcutId;
+ private final int mUserId;
+ private final String mPackageName;
/**
* All notification bubbles require a shortcut to be set on the notification, however, the
* app could still specify an Icon and PendingIntent to use for the bubble. In that case
* this icon will be populated. If the bubble is entirely shortcut based, this will be null.
*/
@Nullable
- private Icon mIcon;
+ private final Icon mIcon;
@Nullable
- private String mTitle;
+ private final String mTitle;
@Nullable
- private String mAppName;
- private boolean mIsImportantConversation;
- private boolean mShowAppBadge;
+ private final String mAppName;
+ private final boolean mIsImportantConversation;
+ private final boolean mShowAppBadge;
+ @Nullable
+ private final ParcelableFlyoutMessage mParcelableFlyoutMessage;
public BubbleInfo(String key, int flags, @Nullable String shortcutId, @Nullable Icon icon,
int userId, String packageName, @Nullable String title, @Nullable String appName,
- boolean isImportantConversation, boolean showAppBadge) {
+ boolean isImportantConversation, boolean showAppBadge,
+ @Nullable ParcelableFlyoutMessage flyoutMessage) {
mKey = key;
mFlags = flags;
mShortcutId = shortcutId;
@@ -63,6 +66,7 @@ public class BubbleInfo implements Parcelable {
mAppName = appName;
mIsImportantConversation = isImportantConversation;
mShowAppBadge = showAppBadge;
+ mParcelableFlyoutMessage = flyoutMessage;
}
private BubbleInfo(Parcel source) {
@@ -76,6 +80,8 @@ public class BubbleInfo implements Parcelable {
mAppName = source.readString();
mIsImportantConversation = source.readBoolean();
mShowAppBadge = source.readBoolean();
+ mParcelableFlyoutMessage = source.readParcelable(
+ ParcelableFlyoutMessage.class.getClassLoader(), ParcelableFlyoutMessage.class);
}
public String getKey() {
@@ -122,6 +128,11 @@ public class BubbleInfo implements Parcelable {
return mShowAppBadge;
}
+ @Nullable
+ public ParcelableFlyoutMessage getParcelableFlyoutMessage() {
+ return mParcelableFlyoutMessage;
+ }
+
/**
* Whether this bubble is currently being hidden from the stack.
*/
@@ -180,6 +191,7 @@ public class BubbleInfo implements Parcelable {
parcel.writeString(mAppName);
parcel.writeBoolean(mIsImportantConversation);
parcel.writeBoolean(mShowAppBadge);
+ parcel.writeParcelable(mParcelableFlyoutMessage, flags);
}
@NonNull
diff --git a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/ParcelableFlyoutMessage.kt b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/ParcelableFlyoutMessage.kt
new file mode 100644
index 000000000000..294d5e552684
--- /dev/null
+++ b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/bubbles/ParcelableFlyoutMessage.kt
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.wm.shell.shared.bubbles
+
+import android.graphics.drawable.Icon
+import android.os.Parcel
+import android.os.Parcelable
+
+/** The contents of the flyout message to be passed to launcher for rendering in the bubble bar. */
+class ParcelableFlyoutMessage(
+ val icon: Icon?,
+ val title: String?,
+ val message: String?,
+) : Parcelable {
+
+ constructor(
+ parcel: Parcel
+ ) : this(
+ icon = parcel.readParcelable(Icon::class.java.classLoader),
+ title = parcel.readString(),
+ message = parcel.readString(),
+ )
+
+ override fun writeToParcel(parcel: Parcel, flags: Int) {
+ parcel.writeParcelable(icon, flags)
+ parcel.writeString(title)
+ parcel.writeString(message)
+ }
+
+ override fun describeContents() = 0
+
+ companion object {
+ @JvmField
+ val CREATOR =
+ object : Parcelable.Creator<ParcelableFlyoutMessage> {
+ override fun createFromParcel(parcel: Parcel) = ParcelableFlyoutMessage(parcel)
+
+ override fun newArray(size: Int) = arrayOfNulls<ParcelableFlyoutMessage>(size)
+ }
+ }
+}
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 169361ad5f6b..e3fc5c2273e2 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
@@ -56,6 +56,7 @@ import com.android.wm.shell.bubbles.bar.BubbleBarLayerView;
import com.android.wm.shell.shared.annotations.ShellBackgroundThread;
import com.android.wm.shell.shared.annotations.ShellMainThread;
import com.android.wm.shell.shared.bubbles.BubbleInfo;
+import com.android.wm.shell.shared.bubbles.ParcelableFlyoutMessage;
import java.io.PrintWriter;
import java.util.List;
@@ -350,7 +351,22 @@ public class Bubble implements BubbleViewProvider {
getTitle(),
getAppName(),
isImportantConversation(),
- !isAppLaunchIntent());
+ !isAppLaunchIntent(),
+ getParcelableFlyoutMessage());
+ }
+
+ /** Creates a parcelable flyout message to send to launcher. */
+ @Nullable
+ private ParcelableFlyoutMessage getParcelableFlyoutMessage() {
+ if (mFlyoutMessage == null) {
+ return null;
+ }
+ // the icon is only used in group chats
+ Icon icon = mFlyoutMessage.isGroupChat ? mFlyoutMessage.senderIcon : null;
+ String title =
+ mFlyoutMessage.senderName == null ? null : mFlyoutMessage.senderName.toString();
+ String message = mFlyoutMessage.message == null ? null : mFlyoutMessage.message.toString();
+ return new ParcelableFlyoutMessage(icon, title, message);
}
@Override
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleViewInfoTask.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleViewInfoTask.java
index 3982a237dd3b..c5e3afda34dd 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleViewInfoTask.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleViewInfoTask.java
@@ -274,7 +274,7 @@ public class BubbleViewInfoTask {
@Nullable BubbleExpandedView expandedView;
int dotColor;
Path dotPath;
- @Nullable Bubble.FlyoutMessage flyoutMessage;
+ Bubble.FlyoutMessage flyoutMessage;
Bitmap bubbleBitmap;
Bitmap badgeBitmap;
@@ -300,6 +300,10 @@ public class BubbleViewInfoTask {
return null;
}
+ // set the flyout message but don't load the avatar because we can't pass it on the
+ // binder to launcher
+ info.flyoutMessage = b.getFlyoutMessage();
+
return info;
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleViewInfoTaskLegacy.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleViewInfoTaskLegacy.java
index 1b7bb0db6516..c12822a27662 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleViewInfoTaskLegacy.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleViewInfoTaskLegacy.java
@@ -181,7 +181,7 @@ public class BubbleViewInfoTaskLegacy extends
@Nullable BubbleExpandedView expandedView;
int dotColor;
Path dotPath;
- @Nullable Bubble.FlyoutMessage flyoutMessage;
+ Bubble.FlyoutMessage flyoutMessage;
Bitmap bubbleBitmap;
Bitmap badgeBitmap;
@@ -221,6 +221,10 @@ public class BubbleViewInfoTaskLegacy extends
return null;
}
+ // set the flyout message but don't load the avatar because we can't pass it on the
+ // binder to launcher
+ info.flyoutMessage = b.getFlyoutMessage();
+
return info;
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/bubbles/BubbleInfoTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/bubbles/BubbleInfoTest.kt
index 641063c27076..205defef5dd5 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/bubbles/BubbleInfoTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/shared/bubbles/BubbleInfoTest.kt
@@ -16,6 +16,8 @@
package com.android.wm.shell.shared.bubbles
+import android.graphics.drawable.Icon
+import android.net.Uri
import android.os.Parcel
import android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE
import android.testing.AndroidTestingRunner
@@ -42,7 +44,12 @@ class BubbleInfoTest : ShellTestCase() {
"title",
"Some app",
true,
- true
+ true,
+ ParcelableFlyoutMessage(
+ Icon.createWithContentUri(Uri.parse("content://image/123")),
+ "sender",
+ "message"
+ )
)
val parcel = Parcel.obtain()
bubbleInfo.writeToParcel(parcel, PARCELABLE_WRITE_RETURN_VALUE)
@@ -60,5 +67,10 @@ class BubbleInfoTest : ShellTestCase() {
assertThat(bubbleInfo.appName).isEqualTo(bubbleInfoFromParcel.appName)
assertThat(bubbleInfo.isImportantConversation)
.isEqualTo(bubbleInfoFromParcel.isImportantConversation)
+ with(bubbleInfo.parcelableFlyoutMessage!!) {
+ assertThat(icon!!.uri.toString()).isEqualTo("content://image/123")
+ assertThat(title).isEqualTo("sender")
+ assertThat(message).isEqualTo("message")
+ }
}
}