Merge "Fix channel configurability check"

This commit is contained in:
TreeHugger Robot
2019-03-15 21:57:23 +00:00
committed by Android (Google) Code Review
2 changed files with 17 additions and 0 deletions

View File

@@ -111,6 +111,9 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
} }
protected boolean isChannelConfigurable() { protected boolean isChannelConfigurable() {
if (mAppRow != null && mAppRow.lockedImportance) {
return false;
}
if (mChannel != null && mAppRow != null) { if (mChannel != null && mAppRow != null) {
return !Objects.equals(mChannel.getId(), mAppRow.lockedChannelId); return !Objects.equals(mChannel.getId(), mAppRow.lockedChannelId);
} }

View File

@@ -218,6 +218,20 @@ public class NotificationPreferenceControllerTest {
assertTrue(mController.isChannelConfigurable()); assertTrue(mController.isChannelConfigurable());
} }
@Test
public void testIsConfigurable_appLevel() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
appRow.lockedChannelId = "something";
appRow.lockedImportance = true;
mController.onResume(appRow, mock(NotificationChannel.class), null, null);
assertFalse(mController.isChannelConfigurable());
appRow.lockedImportance = false;
mController.onResume(appRow, mock(NotificationChannel.class), null, null);
assertTrue(mController.isChannelConfigurable());
}
@Test @Test
public void testIsChannelBlockable_nonSystemAppsBlockable() { public void testIsChannelBlockable_nonSystemAppsBlockable() {
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow(); NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();