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

Commit 9e2ec5fa authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Hide block pref on non-configurable channels

Test: robotests
Bug: 109875297
Change-Id: I164ae2e07d178db9e84746e5c59f0968e6c77eae
parent 90c77027
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -138,11 +138,11 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc

    protected boolean isChannelBlockable() {
        if (mChannel != null && mAppRow != null) {
            if (!mAppRow.systemApp) {
                return true;
            if (!isChannelConfigurable()) {
                return mChannel.getImportance() == IMPORTANCE_NONE;
            }

            return mChannel.isBlockableSystem()
            return mChannel.isBlockableSystem() || !mAppRow.systemApp
                    || mChannel.getImportance() == IMPORTANCE_NONE;
        }
        return false;
+1 −0
Original line number Diff line number Diff line
@@ -138,6 +138,7 @@ public class BlockPreferenceControllerTest {
    public void testIsAvailable_nonSystemApp() {
        NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
        appRow.systemApp = false;
        appRow.lockedChannelId = "not this";
        NotificationChannel channel = mock(NotificationChannel.class);
        when(channel.getImportance()).thenReturn(IMPORTANCE_HIGH);
        mController.onResume(appRow, channel, null, null);
+28 −0
Original line number Diff line number Diff line
@@ -261,6 +261,34 @@ public class NotificationPreferenceControllerTest {
        assertTrue(mController.isChannelBlockable());
    }

    @Test
    public void testIsChannelBlockable_notConfigurable() {
        String sameId = "apples";
        NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
        appRow.systemApp = false;
        appRow.lockedChannelId = sameId;
        NotificationChannel channel = mock(NotificationChannel.class);
        when(channel.getId()).thenReturn(sameId);
        when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);

        mController.onResume(appRow, channel, null, null);
        assertFalse(mController.isChannelBlockable());
    }

    @Test
    public void testIsChannelBlockable_notConfigurableButBlocked() {
        String sameId = "apples";
        NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
        appRow.systemApp = false;
        appRow.lockedChannelId = sameId;
        NotificationChannel channel = mock(NotificationChannel.class);
        when(channel.getId()).thenReturn(sameId);
        when(channel.getImportance()).thenReturn(IMPORTANCE_NONE);

        mController.onResume(appRow, channel, null, null);
        assertTrue(mController.isChannelBlockable());
    }

    @Test
    public void testIsChannelGroupBlockable_nonSystemBlockable() {
        NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();