Merge "Add a title to BubbleInfo." into udc-dev
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 24fd86b..e396ba1 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
@@ -300,7 +300,8 @@
                 getShortcutId(),
                 getIcon(),
                 getUser().getIdentifier(),
-                getPackageName());
+                getPackageName(),
+                getTitle());
     }
 
     @Override
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/bubbles/BubbleInfo.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/bubbles/BubbleInfo.java
index d27d05b..baa23e3 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/bubbles/BubbleInfo.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/bubbles/BubbleInfo.java
@@ -30,7 +30,6 @@
  */
 public class BubbleInfo implements Parcelable {
 
-    // TODO(b/269672147): needs a title string for a11y & that comes from notification
     // TODO(b/269671451): needs whether the bubble is an 'important person' or not
 
     private String mKey; // Same key as the Notification
@@ -46,24 +45,28 @@
      */
     @Nullable
     private Icon mIcon;
+    @Nullable
+    private String mTitle;
 
     public BubbleInfo(String key, int flags, @Nullable String shortcutId, @Nullable Icon icon,
-            int userId, String packageName) {
+            int userId, String packageName, @Nullable String title) {
         mKey = key;
         mFlags = flags;
         mShortcutId = shortcutId;
         mIcon = icon;
         mUserId = userId;
         mPackageName = packageName;
+        mTitle = title;
     }
 
-    public BubbleInfo(Parcel source) {
+    private BubbleInfo(Parcel source) {
         mKey = source.readString();
         mFlags = source.readInt();
         mShortcutId = source.readString();
         mIcon = source.readTypedObject(Icon.CREATOR);
         mUserId = source.readInt();
         mPackageName = source.readString();
+        mTitle = source.readString();
     }
 
     public String getKey() {
@@ -92,6 +95,11 @@
         return mPackageName;
     }
 
+    @Nullable
+    public String getTitle() {
+        return mTitle;
+    }
+
     /**
      * Whether this bubble is currently being hidden from the stack.
      */
@@ -141,11 +149,12 @@
         parcel.writeTypedObject(mIcon, flags);
         parcel.writeInt(mUserId);
         parcel.writeString(mPackageName);
+        parcel.writeString(mTitle);
     }
 
     @NonNull
     public static final Creator<BubbleInfo> CREATOR =
-            new Creator<BubbleInfo>() {
+            new Creator<>() {
                 public BubbleInfo createFromParcel(Parcel source) {
                     return new BubbleInfo(source);
                 }
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/bubbles/BubbleInfoTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/bubbles/BubbleInfoTest.kt
new file mode 100644
index 0000000..8fbac1d
--- /dev/null
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/bubbles/BubbleInfoTest.kt
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2023 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.common.bubbles
+
+import android.os.Parcel
+import android.os.Parcelable.PARCELABLE_WRITE_RETURN_VALUE
+import android.testing.AndroidTestingRunner
+import androidx.test.filters.SmallTest
+import com.android.wm.shell.ShellTestCase
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@SmallTest
+@RunWith(AndroidTestingRunner::class)
+class BubbleInfoTest : ShellTestCase() {
+
+    @Test
+    fun bubbleInfo() {
+        val bubbleInfo = BubbleInfo("key", 0, "shortcut id", null, 6, "com.some.package", "title")
+        val parcel = Parcel.obtain()
+        bubbleInfo.writeToParcel(parcel, PARCELABLE_WRITE_RETURN_VALUE)
+        parcel.setDataPosition(0)
+
+        val bubbleInfoFromParcel = BubbleInfo.CREATOR.createFromParcel(parcel)
+
+        assertThat(bubbleInfo.key).isEqualTo(bubbleInfoFromParcel.key)
+        assertThat(bubbleInfo.flags).isEqualTo(bubbleInfoFromParcel.flags)
+        assertThat(bubbleInfo.shortcutId).isEqualTo(bubbleInfoFromParcel.shortcutId)
+        assertThat(bubbleInfo.icon).isEqualTo(bubbleInfoFromParcel.icon)
+        assertThat(bubbleInfo.userId).isEqualTo(bubbleInfoFromParcel.userId)
+        assertThat(bubbleInfo.packageName).isEqualTo(bubbleInfoFromParcel.packageName)
+        assertThat(bubbleInfo.title).isEqualTo(bubbleInfoFromParcel.title)
+    }
+}