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

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

Merge "Fix visibility of settings on channel page" into qt-dev

parents 62e5be97 2290e284
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -50,12 +50,18 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
        if (mAppRow == null) {
            return false;
        }
        if (mAppRow.banned) {
            return false;
        }
        if (mChannel == null) {
            return false;
        }
        if (isDefaultChannel()) {
            return false;
        }
        if (mChannelGroup != null && mChannelGroup.isBlocked()) {
            return false;
        }
        return true;
    }

+3 −3
Original line number Diff line number Diff line
@@ -73,12 +73,12 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
        if (mAppRow.banned) {
            return false;
        }
        if (mChannel != null) {
            return mChannel.getImportance() != IMPORTANCE_NONE;
        }
        if (mChannelGroup != null) {
            return !mChannelGroup.isBlocked();
        }
        if (mChannel != null) {
            return mChannel.getImportance() != IMPORTANCE_NONE;
        }
        return true;
    }

+14 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.settings.notification;

import static android.app.NotificationChannel.DEFAULT_CHANNEL_ID;
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;
@@ -36,6 +37,7 @@ import static org.mockito.Mockito.when;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationChannelGroup;
import android.app.NotificationManager;
import android.content.Context;
import android.os.UserManager;
@@ -100,7 +102,18 @@ public class ImportancePreferenceControllerTest {
        NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
        appRow.banned = true;
        mController.onResume(appRow, mock(NotificationChannel.class), null, null);
        assertTrue(mController.isAvailable());
        assertFalse(mController.isAvailable());
    }

    @Test
    public void testIsAvailable_isGroupBlocked() {
        NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
        NotificationChannel channel = mock(NotificationChannel.class);
        when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
        NotificationChannelGroup group = mock(NotificationChannelGroup.class);
        when(group.isBlocked()).thenReturn(true);
        mController.onResume(appRow, channel, group, null);
        assertFalse(mController.isAvailable());
    }

    @Test
+1 −0
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ public class NotificationPreferenceControllerTest {
    public void isAvailable_notIfChannelGroupBlocked() {
        NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
        NotificationChannel channel = mock(NotificationChannel.class);
        when(channel.getImportance()).thenReturn(IMPORTANCE_DEFAULT);
        NotificationChannelGroup group = mock(NotificationChannelGroup.class);

        mController.onResume(appRow, channel, group, null);