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

Commit 10e72759 authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Don't allow devs to create blocked channels" into oc-dev

parents db5f5c3a d8c0ac42
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -561,7 +561,7 @@ public class RankingHelper implements RankingConfig {
            updateConfig();
            return;
        }
        if (channel.getImportance() < NotificationManager.IMPORTANCE_NONE
        if (channel.getImportance() < NotificationManager.IMPORTANCE_MIN
                || channel.getImportance() > NotificationManager.IMPORTANCE_MAX) {
            throw new IllegalArgumentException("Invalid importance level");
        }
+13 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.server.notification;
import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
import static android.app.NotificationManager.IMPORTANCE_HIGH;
import static android.app.NotificationManager.IMPORTANCE_LOW;
import static android.app.NotificationManager.IMPORTANCE_NONE;

import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.fail;
@@ -504,12 +505,23 @@ public class RankingHelperTest {

    @Test
    public void testCreateChannel_blocked() throws Exception {
        mHelper.setImportance(PKG, UID, NotificationManager.IMPORTANCE_NONE);
        mHelper.setImportance(PKG, UID, IMPORTANCE_NONE);

        mHelper.createNotificationChannel(PKG, UID,
                new NotificationChannel("bananas", "bananas", IMPORTANCE_LOW), true);
    }

    @Test
    public void testCreateChannel_ImportanceNone() throws Exception {
        try {
            mHelper.createNotificationChannel(PKG, UID,
                    new NotificationChannel("bananas", "bananas", IMPORTANCE_NONE), true);
            fail("Was allowed to create a blocked channel");
        } catch (IllegalArgumentException e) {
            // yay
        }
    }


    @Test
    public void testUpdate() throws Exception {