Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +6 −3 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static com.android.systemui.statusbar.notification.NotificationAlertingMa import android.annotation.Nullable; import android.app.INotificationManager; import android.app.Notification; import android.app.NotificationChannel; import android.app.PendingIntent; import android.content.Context; import android.content.pm.ActivityInfo; Loading Loading @@ -414,7 +415,8 @@ public class BubbleController { /** * Whether the notification has been developer configured to bubble and is allowed by the user. */ private boolean shouldBubble(NotificationEntry entry) { @VisibleForTesting protected boolean shouldBubble(NotificationEntry entry) { StatusBarNotification n = entry.notification; boolean canAppOverlay = false; try { Loading @@ -424,8 +426,9 @@ public class BubbleController { Log.w(TAG, "Error calling NoMan to determine if app can overlay", e); } boolean canChannelOverlay = mNotificationEntryManager.getNotificationData().getChannel( entry.key).canBubble(); NotificationChannel channel = mNotificationEntryManager.getNotificationData().getChannel( entry.key); boolean canChannelOverlay = channel != null && channel.canBubble(); boolean hasOverlayIntent = n.getNotification().getBubbleMetadata() != null && n.getNotification().getBubbleMetadata().getIntent() != null; return DEBUG_ENABLE_AUTO_BUBBLE && hasOverlayIntent && canChannelOverlay && canAppOverlay; Loading packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ public class BubbleControllerTest extends SysuiTestCase { private NotificationTestHelper mNotificationTestHelper; private ExpandableNotificationRow mRow; private ExpandableNotificationRow mRow2; private ExpandableNotificationRow mNoChannelRow; @Mock private NotificationData mNotificationData; Loading @@ -92,10 +93,12 @@ public class BubbleControllerTest extends SysuiTestCase { mNotificationTestHelper = new NotificationTestHelper(mContext); mRow = mNotificationTestHelper.createBubble(); mRow2 = mNotificationTestHelper.createBubble(); mNoChannelRow = mNotificationTestHelper.createBubble(); // Return non-null notification data from the NEM when(mNotificationEntryManager.getNotificationData()).thenReturn(mNotificationData); when(mNotificationData.getChannel(mRow.getEntry().key)).thenReturn(mRow.getEntry().channel); when(mNotificationData.getChannel(mNoChannelRow.getEntry().key)).thenReturn(null); mBubbleController = new TestableBubbleController(mContext, mStatusBarWindowController); Loading Loading @@ -184,6 +187,11 @@ public class BubbleControllerTest extends SysuiTestCase { assertTrue(mRow.getEntry().showInShadeWhenBubble()); } @Test public void testNotificationWithoutChannel() { assertFalse(mBubbleController.shouldBubble(mNoChannelRow.getEntry())); } static class TestableBubbleController extends BubbleController { TestableBubbleController(Context context, Loading Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +6 −3 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import static com.android.systemui.statusbar.notification.NotificationAlertingMa import android.annotation.Nullable; import android.app.INotificationManager; import android.app.Notification; import android.app.NotificationChannel; import android.app.PendingIntent; import android.content.Context; import android.content.pm.ActivityInfo; Loading Loading @@ -414,7 +415,8 @@ public class BubbleController { /** * Whether the notification has been developer configured to bubble and is allowed by the user. */ private boolean shouldBubble(NotificationEntry entry) { @VisibleForTesting protected boolean shouldBubble(NotificationEntry entry) { StatusBarNotification n = entry.notification; boolean canAppOverlay = false; try { Loading @@ -424,8 +426,9 @@ public class BubbleController { Log.w(TAG, "Error calling NoMan to determine if app can overlay", e); } boolean canChannelOverlay = mNotificationEntryManager.getNotificationData().getChannel( entry.key).canBubble(); NotificationChannel channel = mNotificationEntryManager.getNotificationData().getChannel( entry.key); boolean canChannelOverlay = channel != null && channel.canBubble(); boolean hasOverlayIntent = n.getNotification().getBubbleMetadata() != null && n.getNotification().getBubbleMetadata().getIntent() != null; return DEBUG_ENABLE_AUTO_BUBBLE && hasOverlayIntent && canChannelOverlay && canAppOverlay; Loading
packages/SystemUI/tests/src/com/android/systemui/bubbles/BubbleControllerTest.java +8 −0 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ public class BubbleControllerTest extends SysuiTestCase { private NotificationTestHelper mNotificationTestHelper; private ExpandableNotificationRow mRow; private ExpandableNotificationRow mRow2; private ExpandableNotificationRow mNoChannelRow; @Mock private NotificationData mNotificationData; Loading @@ -92,10 +93,12 @@ public class BubbleControllerTest extends SysuiTestCase { mNotificationTestHelper = new NotificationTestHelper(mContext); mRow = mNotificationTestHelper.createBubble(); mRow2 = mNotificationTestHelper.createBubble(); mNoChannelRow = mNotificationTestHelper.createBubble(); // Return non-null notification data from the NEM when(mNotificationEntryManager.getNotificationData()).thenReturn(mNotificationData); when(mNotificationData.getChannel(mRow.getEntry().key)).thenReturn(mRow.getEntry().channel); when(mNotificationData.getChannel(mNoChannelRow.getEntry().key)).thenReturn(null); mBubbleController = new TestableBubbleController(mContext, mStatusBarWindowController); Loading Loading @@ -184,6 +187,11 @@ public class BubbleControllerTest extends SysuiTestCase { assertTrue(mRow.getEntry().showInShadeWhenBubble()); } @Test public void testNotificationWithoutChannel() { assertFalse(mBubbleController.shouldBubble(mNoChannelRow.getEntry())); } static class TestableBubbleController extends BubbleController { TestableBubbleController(Context context, Loading