Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a0a5e9e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Protect against null channel"

parents 2b55d1c8 c18ba96b
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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;
@@ -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 {
@@ -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;
+8 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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);

@@ -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,