Non-blockable whitelist should only control importance fields
Sounds, etc. should still be modifiable Test: robotests Fixes: 130086523 Change-Id: I1a95a73b299bb3afd169b249a3dabae3583a448a
This commit is contained in:
@@ -62,7 +62,7 @@ public class AllowSoundPreferenceController extends NotificationPreferenceContro
|
||||
if (mChannel != null) {
|
||||
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
|
||||
pref.setDisabledByAdmin(mAdmin);
|
||||
pref.setEnabled(isChannelConfigurable() && !pref.isDisabledByAdmin());
|
||||
pref.setEnabled(!pref.isDisabledByAdmin());
|
||||
pref.setChecked(mChannel.getImportance() >= IMPORTANCE_DEFAULT
|
||||
|| mChannel.getImportance() == IMPORTANCE_UNSPECIFIED);
|
||||
} else { Log.i(TAG, "tried to updatestate on a null channel?!"); }
|
||||
|
@@ -72,7 +72,7 @@ public class BadgePreferenceController extends NotificationPreferenceController
|
||||
pref.setDisabledByAdmin(mAdmin);
|
||||
if (mChannel != null) {
|
||||
pref.setChecked(mChannel.canShowBadge());
|
||||
pref.setEnabled(isChannelConfigurable() && !pref.isDisabledByAdmin());
|
||||
pref.setEnabled(!pref.isDisabledByAdmin());
|
||||
} else {
|
||||
pref.setChecked(mAppRow.showBadge);
|
||||
}
|
||||
|
@@ -81,7 +81,7 @@ public class BubblePreferenceController extends NotificationPreferenceController
|
||||
pref.setDisabledByAdmin(mAdmin);
|
||||
if (mChannel != null) {
|
||||
pref.setChecked(mChannel.canBubble());
|
||||
pref.setEnabled(isChannelConfigurable() && !pref.isDisabledByAdmin());
|
||||
pref.setEnabled(!pref.isDisabledByAdmin());
|
||||
} else {
|
||||
pref.setChecked(mAppRow.allowBubbles
|
||||
&& Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
|
@@ -50,7 +50,7 @@ public class DndPreferenceController extends NotificationPreferenceController
|
||||
if (mChannel != null) {
|
||||
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
|
||||
pref.setDisabledByAdmin(mAdmin);
|
||||
pref.setEnabled(isChannelConfigurable() && !pref.isDisabledByAdmin());
|
||||
pref.setEnabled(!pref.isDisabledByAdmin());
|
||||
pref.setChecked(mChannel.canBypassDnd());
|
||||
}
|
||||
}
|
||||
|
@@ -61,8 +61,8 @@ public class HighImportancePreferenceController extends NotificationPreferenceCo
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
if (mAppRow!= null && mChannel != null) {
|
||||
preference.setEnabled(mAdmin == null && isChannelConfigurable());
|
||||
if (mAppRow != null && mChannel != null) {
|
||||
preference.setEnabled(mAdmin == null && isChannelBlockable());
|
||||
|
||||
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
|
||||
pref.setChecked(mChannel.getImportance() >= IMPORTANCE_HIGH);
|
||||
|
@@ -59,9 +59,9 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
if (mAppRow!= null && mChannel != null) {
|
||||
preference.setEnabled(mAdmin == null && isChannelConfigurable());
|
||||
preference.setEnabled(mAdmin == null && isChannelBlockable());
|
||||
ImportancePreference pref = (ImportancePreference) preference;
|
||||
pref.setConfigurable(isChannelConfigurable());
|
||||
pref.setConfigurable(isChannelBlockable());
|
||||
pref.setImportance(mChannel.getImportance());
|
||||
pref.setDisplayInStatusBar(mBackend.showSilentInStatusBar(mContext.getPackageName()));
|
||||
// TODO: b/128445911 pass along lock screen setting
|
||||
|
@@ -56,7 +56,7 @@ public class LightsPreferenceController extends NotificationPreferenceController
|
||||
if (mChannel != null) {
|
||||
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
|
||||
pref.setDisabledByAdmin(mAdmin);
|
||||
pref.setEnabled(isChannelConfigurable() && !pref.isDisabledByAdmin());
|
||||
pref.setEnabled(!pref.isDisabledByAdmin());
|
||||
pref.setChecked(mChannel.shouldShowLights());
|
||||
}
|
||||
}
|
||||
|
@@ -61,8 +61,8 @@ public class MinImportancePreferenceController extends NotificationPreferenceCon
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
if (mAppRow!= null && mChannel != null) {
|
||||
preference.setEnabled(mAdmin == null && isChannelConfigurable());
|
||||
if (mAppRow != null && mChannel != null) {
|
||||
preference.setEnabled(mAdmin == null && isChannelBlockable());
|
||||
|
||||
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
|
||||
pref.setChecked(mChannel.getImportance() == IMPORTANCE_MIN);
|
||||
|
@@ -110,7 +110,7 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean isChannelConfigurable() {
|
||||
private boolean isChannelConfigurable() {
|
||||
if (mAppRow != null && mAppRow.lockedImportance) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -77,7 +77,7 @@ public class SoundPreferenceController extends NotificationPreferenceController
|
||||
public void updateState(Preference preference) {
|
||||
if (mAppRow!= null && mChannel != null) {
|
||||
NotificationSoundPreference pref = (NotificationSoundPreference) preference;
|
||||
pref.setEnabled(mAdmin == null && isChannelConfigurable());
|
||||
pref.setEnabled(mAdmin == null);
|
||||
pref.setRingtone(mChannel.getSound());
|
||||
}
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ public class VibrationPreferenceController extends NotificationPreferenceControl
|
||||
if (mChannel != null) {
|
||||
RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
|
||||
pref.setDisabledByAdmin(mAdmin);
|
||||
pref.setEnabled(!pref.isDisabledByAdmin() && isChannelConfigurable());
|
||||
pref.setEnabled(!pref.isDisabledByAdmin());
|
||||
pref.setChecked(mChannel.shouldVibrate());
|
||||
}
|
||||
}
|
||||
|
@@ -83,7 +83,6 @@ public class NotificationPreferenceControllerTest {
|
||||
mController.updateState(mock(Preference.class));
|
||||
assertFalse(mController.checkCanBeVisible(IMPORTANCE_UNSPECIFIED));
|
||||
mController.saveChannel();
|
||||
assertFalse(mController.isChannelConfigurable());
|
||||
assertFalse(mController.isChannelBlockable());
|
||||
assertFalse(mController.isChannelGroupBlockable());
|
||||
}
|
||||
@@ -204,7 +203,7 @@ public class NotificationPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsConfigurable() {
|
||||
public void testIsBlockable_channelLevelWhitelist() {
|
||||
String sameId = "bananas";
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedChannelId = sameId;
|
||||
@@ -212,25 +211,25 @@ public class NotificationPreferenceControllerTest {
|
||||
when(channel.getId()).thenReturn(sameId);
|
||||
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
assertFalse(mController.isChannelConfigurable());
|
||||
assertFalse(mController.isChannelBlockable());
|
||||
|
||||
when(channel.getId()).thenReturn("something new");
|
||||
mController.onResume(appRow, channel, null, null);
|
||||
assertTrue(mController.isChannelConfigurable());
|
||||
assertTrue(mController.isChannelBlockable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsConfigurable_appLevel() {
|
||||
public void testIsBlockable_appLevelWhitelist() {
|
||||
NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
|
||||
appRow.lockedChannelId = "something";
|
||||
appRow.lockedImportance = true;
|
||||
|
||||
mController.onResume(appRow, mock(NotificationChannel.class), null, null);
|
||||
assertFalse(mController.isChannelConfigurable());
|
||||
assertFalse(mController.isChannelBlockable());
|
||||
|
||||
appRow.lockedImportance = false;
|
||||
mController.onResume(appRow, mock(NotificationChannel.class), null, null);
|
||||
assertTrue(mController.isChannelConfigurable());
|
||||
assertTrue(mController.isChannelBlockable());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user