diff --git a/packages/SystemUI/res/layout/partial_conversation_info.xml b/packages/SystemUI/res/layout/partial_conversation_info.xml index 803b0c61e6da7..ecc3118934970 100644 --- a/packages/SystemUI/res/layout/partial_conversation_info.xml +++ b/packages/SystemUI/res/layout/partial_conversation_info.xml @@ -35,7 +35,7 @@ android:clipChildren="false" android:clipToPadding="false"> - - messages = - Notification.MessagingStyle.Message.getMessagesFromBundleArray( - (Parcelable[]) mSbn.getNotification().extras.get( - Notification.EXTRA_MESSAGES)); - - final Notification.MessagingStyle.Message latestMessage = - Notification.MessagingStyle.findLatestIncomingMessage(messages); - Icon personIcon = null; - if (latestMessage != null && latestMessage.getSenderPerson() != null) { - personIcon = latestMessage.getSenderPerson().getIcon(); - } - if (personIcon != null) { - image.setImageIcon(latestMessage.getSenderPerson().getIcon()); - } else { - image.setImageDrawable(mPkgIcon); - } - } - } - private void bindPackage() { ApplicationInfo info; try { @@ -241,6 +195,10 @@ public class PartialConversationInfo extends LinearLayout implements } catch (PackageManager.NameNotFoundException e) { mPkgIcon = mPm.getDefaultActivityIcon(); } + TextView name = findViewById(R.id.name); + name.setText(mAppName); + ImageView image = findViewById(R.id.icon); + image.setImageDrawable(mPkgIcon); } private void bindDelegate() { diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java index f327967ebd73e..43aa8fef76a90 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/PartialConversationInfoTest.java @@ -25,6 +25,7 @@ import static android.view.View.VISIBLE; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.anyObject; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyBoolean; import static org.mockito.Mockito.anyInt; @@ -162,6 +163,7 @@ public class PartialConversationInfoTest extends SysuiTestCase { @Test public void testBindNotification_SetsName() { + when(mMockPackageManager.getApplicationLabel(any())).thenReturn("Package"); mInfo.bindNotification( mMockPackageManager, mMockINotificationManager, @@ -174,15 +176,13 @@ public class PartialConversationInfoTest extends SysuiTestCase { true, false); final TextView textView = mInfo.findViewById(R.id.name); - assertTrue(textView.getText().toString().contains("title")); + assertTrue(textView.getText().toString().equals("Package")); } + @Test - public void testBindNotification_groupSetsPackageIcon() { - mEntry.getSbn().getNotification().extras.putBoolean(EXTRA_IS_GROUP_CONVERSATION, true); - final Drawable iconDrawable = mock(Drawable.class); - when(mMockPackageManager.getApplicationIcon(any(ApplicationInfo.class))) - .thenReturn(iconDrawable); + public void testBindNotification_setsIcon() { + when(mMockPackageManager.getApplicationIcon((ApplicationInfo) any())).thenReturn(mDrawable); mInfo.bindNotification( mMockPackageManager, mMockINotificationManager, @@ -194,34 +194,7 @@ public class PartialConversationInfoTest extends SysuiTestCase { null, true, false); - final ImageView iconView = mInfo.findViewById(R.id.conversation_icon); - assertEquals(iconDrawable, iconView.getDrawable()); - } - - @Test - public void testBindNotification_notGroupSetsMessageIcon() { - Notification n = new Notification.Builder(mContext, TEST_CHANNEL_NAME) - .setStyle(new Notification.MessagingStyle( - new Person.Builder().setName("me").build()) - .addMessage(new Notification.MessagingStyle.Message("hello", 0, - new Person.Builder().setName("friend").setIcon(mIcon).build()))) - .build(); - mSbn = new StatusBarNotification(TEST_PACKAGE_NAME, TEST_PACKAGE_NAME, 0, null, TEST_UID, 0, - n, UserHandle.CURRENT, null, 0); - mEntry.setSbn(mSbn); - mEntry.getSbn().getNotification().extras.putBoolean(EXTRA_IS_GROUP_CONVERSATION, false); - mInfo.bindNotification( - mMockPackageManager, - mMockINotificationManager, - mChannelEditorDialogController, - TEST_PACKAGE_NAME, - mNotificationChannel, - mNotificationChannelSet, - mEntry, - null, - true, - false); - final ImageView iconView = mInfo.findViewById(R.id.conversation_icon); + final ImageView iconView = mInfo.findViewById(R.id.icon); assertEquals(mDrawable.hashCode() + "", mDrawable, iconView.getDrawable()); } @@ -269,64 +242,6 @@ public class PartialConversationInfoTest extends SysuiTestCase { assertTrue(nameView.getText().toString().contains("Proxied")); } - @Test - public void testBindNotification_GroupNameHiddenIfNoGroup() throws Exception { - mInfo.bindNotification( - mMockPackageManager, - mMockINotificationManager, - mChannelEditorDialogController, - TEST_PACKAGE_NAME, - mNotificationChannel, - mNotificationChannelSet, - mEntry, - null, - true, - false); - final TextView groupNameView = mInfo.findViewById(R.id.group_name); - assertEquals(GONE, groupNameView.getVisibility()); - } - - @Test - public void testBindNotification_SetsGroupNameIfNonNull() throws Exception { - mNotificationChannel.setGroup("test_group_id"); - final NotificationChannelGroup notificationChannelGroup = - new NotificationChannelGroup("test_group_id", "Test Group Name"); - when(mMockINotificationManager.getNotificationChannelGroupForPackage( - eq("test_group_id"), eq(TEST_PACKAGE_NAME), eq(TEST_UID))) - .thenReturn(notificationChannelGroup); - mInfo.bindNotification( - mMockPackageManager, - mMockINotificationManager, - mChannelEditorDialogController, - TEST_PACKAGE_NAME, - mNotificationChannel, - mNotificationChannelSet, - mEntry, - null, - true, - false); - final TextView groupNameView = mInfo.findViewById(R.id.group_name); - assertEquals(View.VISIBLE, groupNameView.getVisibility()); - assertEquals("Test Group Name", groupNameView.getText()); - } - - @Test - public void testBindNotification_SetsTextChannelName() { - mInfo.bindNotification( - mMockPackageManager, - mMockINotificationManager, - mChannelEditorDialogController, - TEST_PACKAGE_NAME, - mNotificationChannel, - mNotificationChannelSet, - mEntry, - null, - true, - false); - final TextView textView = mInfo.findViewById(R.id.parent_channel_name); - assertEquals(TEST_CHANNEL_NAME, textView.getText()); - } - @Test public void testBindNotification_SetsOnClickListenerForSettings() { final CountDownLatch latch = new CountDownLatch(1);