Loading libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java +1 −1 Original line number Diff line number Diff line Loading @@ -297,7 +297,7 @@ public class Bubble implements BubbleViewProvider { public BubbleInfo asBubbleBarBubble() { return new BubbleInfo(getKey(), getFlags(), getShortcutInfo().getId(), getShortcutId(), getIcon(), getUser().getIdentifier(), getPackageName()); Loading libs/WindowManager/Shell/src/com/android/wm/shell/common/bubbles/BubbleInfo.java +4 −1 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ public class BubbleInfo implements Parcelable { private String mKey; // Same key as the Notification private int mFlags; // Flags from BubbleMetadata @Nullable private String mShortcutId; private int mUserId; private String mPackageName; Loading @@ -46,7 +47,7 @@ public class BubbleInfo implements Parcelable { @Nullable private Icon mIcon; public BubbleInfo(String key, int flags, String shortcutId, @Nullable Icon icon, public BubbleInfo(String key, int flags, @Nullable String shortcutId, @Nullable Icon icon, int userId, String packageName) { mKey = key; mFlags = flags; Loading @@ -69,10 +70,12 @@ public class BubbleInfo implements Parcelable { return mKey; } @Nullable public String getShortcutId() { return mShortcutId; } @Nullable public Icon getIcon() { return mIcon; } Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubbleTest.java +31 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.content.pm.ShortcutInfo; import android.content.res.Resources; import android.graphics.drawable.Icon; import android.os.Bundle; import android.os.UserHandle; import android.service.notification.StatusBarNotification; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; Loading @@ -42,6 +43,7 @@ import androidx.test.filters.SmallTest; import com.android.wm.shell.R; import com.android.wm.shell.ShellTestCase; import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.bubbles.BubbleInfo; import org.junit.Before; import org.junit.Test; Loading Loading @@ -179,6 +181,34 @@ public class BubbleTest extends ShellTestCase { assertThat(bubble.isConversation()).isFalse(); } @Test public void testBubbleAsBubbleBarBubble_withShortcut() { Bubble bubble = createBubbleWithShortcut(); BubbleInfo bubbleInfo = bubble.asBubbleBarBubble(); assertThat(bubble.getShortcutInfo()).isNotNull(); assertThat(bubbleInfo.getShortcutId()).isNotNull(); assertThat(bubbleInfo.getShortcutId()).isEqualTo(bubble.getShortcutId()); assertThat(bubbleInfo.getKey()).isEqualTo(bubble.getKey()); assertThat(bubbleInfo.getUserId()).isEqualTo(bubble.getUser().getIdentifier()); assertThat(bubbleInfo.getPackageName()).isEqualTo(bubble.getPackageName()); } @Test public void testBubbleAsBubbleBarBubble_withoutShortcut() { Intent intent = new Intent(mContext, BubblesTestActivity.class); intent.setPackage(mContext.getPackageName()); Bubble bubble = Bubble.createAppBubble(intent, new UserHandle(1 /* userId */), null /* icon */, mMainExecutor); BubbleInfo bubbleInfo = bubble.asBubbleBarBubble(); assertThat(bubble.getShortcutInfo()).isNull(); assertThat(bubbleInfo.getShortcutId()).isNull(); assertThat(bubbleInfo.getKey()).isEqualTo(bubble.getKey()); assertThat(bubbleInfo.getUserId()).isEqualTo(bubble.getUser().getIdentifier()); assertThat(bubbleInfo.getPackageName()).isEqualTo(bubble.getPackageName()); } private Bubble createBubbleWithShortcut() { ShortcutInfo shortcutInfo = new ShortcutInfo.Builder(mContext) .setId("mockShortcutId") Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/Bubble.java +1 −1 Original line number Diff line number Diff line Loading @@ -297,7 +297,7 @@ public class Bubble implements BubbleViewProvider { public BubbleInfo asBubbleBarBubble() { return new BubbleInfo(getKey(), getFlags(), getShortcutInfo().getId(), getShortcutId(), getIcon(), getUser().getIdentifier(), getPackageName()); Loading
libs/WindowManager/Shell/src/com/android/wm/shell/common/bubbles/BubbleInfo.java +4 −1 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ public class BubbleInfo implements Parcelable { private String mKey; // Same key as the Notification private int mFlags; // Flags from BubbleMetadata @Nullable private String mShortcutId; private int mUserId; private String mPackageName; Loading @@ -46,7 +47,7 @@ public class BubbleInfo implements Parcelable { @Nullable private Icon mIcon; public BubbleInfo(String key, int flags, String shortcutId, @Nullable Icon icon, public BubbleInfo(String key, int flags, @Nullable String shortcutId, @Nullable Icon icon, int userId, String packageName) { mKey = key; mFlags = flags; Loading @@ -69,10 +70,12 @@ public class BubbleInfo implements Parcelable { return mKey; } @Nullable public String getShortcutId() { return mShortcutId; } @Nullable public Icon getIcon() { return mIcon; } Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/bubbles/BubbleTest.java +31 −1 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ import android.content.pm.ShortcutInfo; import android.content.res.Resources; import android.graphics.drawable.Icon; import android.os.Bundle; import android.os.UserHandle; import android.service.notification.StatusBarNotification; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; Loading @@ -42,6 +43,7 @@ import androidx.test.filters.SmallTest; import com.android.wm.shell.R; import com.android.wm.shell.ShellTestCase; import com.android.wm.shell.common.ShellExecutor; import com.android.wm.shell.common.bubbles.BubbleInfo; import org.junit.Before; import org.junit.Test; Loading Loading @@ -179,6 +181,34 @@ public class BubbleTest extends ShellTestCase { assertThat(bubble.isConversation()).isFalse(); } @Test public void testBubbleAsBubbleBarBubble_withShortcut() { Bubble bubble = createBubbleWithShortcut(); BubbleInfo bubbleInfo = bubble.asBubbleBarBubble(); assertThat(bubble.getShortcutInfo()).isNotNull(); assertThat(bubbleInfo.getShortcutId()).isNotNull(); assertThat(bubbleInfo.getShortcutId()).isEqualTo(bubble.getShortcutId()); assertThat(bubbleInfo.getKey()).isEqualTo(bubble.getKey()); assertThat(bubbleInfo.getUserId()).isEqualTo(bubble.getUser().getIdentifier()); assertThat(bubbleInfo.getPackageName()).isEqualTo(bubble.getPackageName()); } @Test public void testBubbleAsBubbleBarBubble_withoutShortcut() { Intent intent = new Intent(mContext, BubblesTestActivity.class); intent.setPackage(mContext.getPackageName()); Bubble bubble = Bubble.createAppBubble(intent, new UserHandle(1 /* userId */), null /* icon */, mMainExecutor); BubbleInfo bubbleInfo = bubble.asBubbleBarBubble(); assertThat(bubble.getShortcutInfo()).isNull(); assertThat(bubbleInfo.getShortcutId()).isNull(); assertThat(bubbleInfo.getKey()).isEqualTo(bubble.getKey()); assertThat(bubbleInfo.getUserId()).isEqualTo(bubble.getUser().getIdentifier()); assertThat(bubbleInfo.getPackageName()).isEqualTo(bubble.getPackageName()); } private Bubble createBubbleWithShortcut() { ShortcutInfo shortcutInfo = new ShortcutInfo.Builder(mContext) .setId("mockShortcutId") Loading