Loading src/com/android/settings/notification/ImportancePreferenceController.java +6 −0 Original line number Diff line number Diff line Loading @@ -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; } Loading src/com/android/settings/notification/NotificationPreferenceController.java +3 −3 Original line number Diff line number Diff line Loading @@ -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; } Loading tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java +14 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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 Loading tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -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); Loading Loading
src/com/android/settings/notification/ImportancePreferenceController.java +6 −0 Original line number Diff line number Diff line Loading @@ -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; } Loading
src/com/android/settings/notification/NotificationPreferenceController.java +3 −3 Original line number Diff line number Diff line Loading @@ -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; } Loading
tests/robotests/src/com/android/settings/notification/ImportancePreferenceControllerTest.java +14 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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 Loading
tests/robotests/src/com/android/settings/notification/NotificationPreferenceControllerTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -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); Loading