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

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

Merge "Prevent apps from creating blocked channel groups" into qt-qpr1-dev

parents c4ee9df9 450617d4
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -601,6 +601,9 @@ public class PreferencesHelper implements RankingConfig {
            if (r == null) {
                throw new IllegalArgumentException("Invalid package");
            }
            if (fromTargetApp) {
                group.setBlocked(false);
            }
            final NotificationChannelGroup oldGroup = r.groups.get(group.getId());
            if (!group.equals(oldGroup)) {
                // will log for new entries as well as name/description changes
+13 −0
Original line number Diff line number Diff line
@@ -2009,6 +2009,19 @@ public class PreferencesHelperTest extends UiServiceTestCase {
        assertTrue(mHelper.isGroupBlocked(PKG_N_MR1, UID_N_MR1, group.getId()));
    }

    @Test
    public void testIsGroupBlocked_appCannotCreateAsBlocked() throws Exception {
        NotificationChannelGroup group = new NotificationChannelGroup("id", "name");
        group.setBlocked(true);
        mHelper.createNotificationChannelGroup(PKG_N_MR1, UID_N_MR1, group, true);
        assertFalse(mHelper.isGroupBlocked(PKG_N_MR1, UID_N_MR1, group.getId()));

        NotificationChannelGroup group3 = group.clone();
        group3.setBlocked(false);
        mHelper.createNotificationChannelGroup(PKG_N_MR1, UID_N_MR1, group3, true);
        assertFalse(mHelper.isGroupBlocked(PKG_N_MR1, UID_N_MR1, group.getId()));
    }

    @Test
    public void testIsGroup_appCannotResetBlock() throws Exception {
        NotificationChannelGroup group = new NotificationChannelGroup("id", "name");