Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java +4 −4 Original line number Original line Diff line number Diff line Loading @@ -165,6 +165,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G mIsForeground = mIsForeground = (mSbn.getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE) != 0; (mSbn.getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE) != 0; mIsForBlockingHelper = isForBlockingHelper; mIsForBlockingHelper = isForBlockingHelper; mAppUid = mSbn.getUid(); int numTotalChannels = mINotificationManager.getNumNotificationChannelsForPackage( int numTotalChannels = mINotificationManager.getNumNotificationChannelsForPackage( pkg, mAppUid, false /* includeDeleted */); pkg, mAppUid, false /* includeDeleted */); Loading @@ -173,9 +174,9 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G } else { } else { // Special behavior for the Default channel if no other channels have been defined. // Special behavior for the Default channel if no other channels have been defined. mIsSingleDefaultChannel = mNumNotificationChannels == 1 mIsSingleDefaultChannel = mNumNotificationChannels == 1 && mSingleNotificationChannel.getId() && mSingleNotificationChannel.getId().equals( .equals(NotificationChannel.DEFAULT_CHANNEL_ID) NotificationChannel.DEFAULT_CHANNEL_ID) && numTotalChannels <= 1; && numTotalChannels == 1; } } try { try { Loading Loading @@ -210,7 +211,6 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G | PackageManager.MATCH_DIRECT_BOOT_UNAWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE | PackageManager.MATCH_DIRECT_BOOT_AWARE); | PackageManager.MATCH_DIRECT_BOOT_AWARE); if (info != null) { if (info != null) { mAppUid = mSbn.getUid(); mAppName = String.valueOf(mPm.getApplicationLabel(info)); mAppName = String.valueOf(mPm.getApplicationLabel(info)); pkgicon = mPm.getApplicationIcon(info); pkgicon = mPm.getApplicationIcon(info); } } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java +12 −0 Original line number Original line Diff line number Diff line Loading @@ -217,6 +217,18 @@ public class NotificationInfoTest extends SysuiTestCase { assertEquals(GONE, textView.getVisibility()); assertEquals(GONE, textView.getVisibility()); } } @Test public void testBindNotification_DefaultChannelUsesChannelNameIfMoreChannelsExist() throws Exception { // Package has one channel by default. when(mMockINotificationManager.getNumNotificationChannelsForPackage( eq(TEST_PACKAGE_NAME), eq(TEST_UID), anyBoolean())).thenReturn(10); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, TEST_PACKAGE_NAME, mDefaultNotificationChannel, 1, mSbn, null, null, null, null); final TextView textView = mNotificationInfo.findViewById(R.id.channel_name); assertEquals(VISIBLE, textView.getVisibility()); } @Test @Test public void testBindNotification_UnblockablePackageUsesChannelName() throws Exception { public void testBindNotification_UnblockablePackageUsesChannelName() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationInfo.java +4 −4 Original line number Original line Diff line number Diff line Loading @@ -165,6 +165,7 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G mIsForeground = mIsForeground = (mSbn.getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE) != 0; (mSbn.getNotification().flags & Notification.FLAG_FOREGROUND_SERVICE) != 0; mIsForBlockingHelper = isForBlockingHelper; mIsForBlockingHelper = isForBlockingHelper; mAppUid = mSbn.getUid(); int numTotalChannels = mINotificationManager.getNumNotificationChannelsForPackage( int numTotalChannels = mINotificationManager.getNumNotificationChannelsForPackage( pkg, mAppUid, false /* includeDeleted */); pkg, mAppUid, false /* includeDeleted */); Loading @@ -173,9 +174,9 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G } else { } else { // Special behavior for the Default channel if no other channels have been defined. // Special behavior for the Default channel if no other channels have been defined. mIsSingleDefaultChannel = mNumNotificationChannels == 1 mIsSingleDefaultChannel = mNumNotificationChannels == 1 && mSingleNotificationChannel.getId() && mSingleNotificationChannel.getId().equals( .equals(NotificationChannel.DEFAULT_CHANNEL_ID) NotificationChannel.DEFAULT_CHANNEL_ID) && numTotalChannels <= 1; && numTotalChannels == 1; } } try { try { Loading Loading @@ -210,7 +211,6 @@ public class NotificationInfo extends LinearLayout implements NotificationGuts.G | PackageManager.MATCH_DIRECT_BOOT_UNAWARE | PackageManager.MATCH_DIRECT_BOOT_UNAWARE | PackageManager.MATCH_DIRECT_BOOT_AWARE); | PackageManager.MATCH_DIRECT_BOOT_AWARE); if (info != null) { if (info != null) { mAppUid = mSbn.getUid(); mAppName = String.valueOf(mPm.getApplicationLabel(info)); mAppName = String.valueOf(mPm.getApplicationLabel(info)); pkgicon = mPm.getApplicationIcon(info); pkgicon = mPm.getApplicationIcon(info); } } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationInfoTest.java +12 −0 Original line number Original line Diff line number Diff line Loading @@ -217,6 +217,18 @@ public class NotificationInfoTest extends SysuiTestCase { assertEquals(GONE, textView.getVisibility()); assertEquals(GONE, textView.getVisibility()); } } @Test public void testBindNotification_DefaultChannelUsesChannelNameIfMoreChannelsExist() throws Exception { // Package has one channel by default. when(mMockINotificationManager.getNumNotificationChannelsForPackage( eq(TEST_PACKAGE_NAME), eq(TEST_UID), anyBoolean())).thenReturn(10); mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, TEST_PACKAGE_NAME, mDefaultNotificationChannel, 1, mSbn, null, null, null, null); final TextView textView = mNotificationInfo.findViewById(R.id.channel_name); assertEquals(VISIBLE, textView.getVisibility()); } @Test @Test public void testBindNotification_UnblockablePackageUsesChannelName() throws Exception { public void testBindNotification_UnblockablePackageUsesChannelName() throws Exception { mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, mNotificationInfo.bindNotification(mMockPackageManager, mMockINotificationManager, Loading