Loading core/java/android/service/notification/ZenModeConfig.java +8 −5 Original line number Diff line number Diff line Loading @@ -958,13 +958,15 @@ public class ZenModeConfig implements Parcelable { if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_MESSAGES, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_MESSAGES, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_MESSAGES; messageSenders = getNotificationPolicySenders(zenPolicy.getPriorityMessageSenders()); messageSenders = getNotificationPolicySenders(zenPolicy.getPriorityMessageSenders(), messageSenders); } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_CALLS, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_CALLS, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_CALLS; callSenders = getNotificationPolicySenders(zenPolicy.getPriorityCallSenders()); callSenders = getNotificationPolicySenders(zenPolicy.getPriorityCallSenders(), callSenders); } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_REPEAT_CALLERS, Loading Loading @@ -1056,16 +1058,17 @@ public class ZenModeConfig implements Parcelable { return (policy.suppressedVisualEffects & visualEffect) == 0; } private int getNotificationPolicySenders(@ZenPolicy.PeopleType int senders) { private int getNotificationPolicySenders(@ZenPolicy.PeopleType int senders, int defaultPolicySender) { switch (senders) { case ZenPolicy.PEOPLE_TYPE_ANYONE: return Policy.PRIORITY_SENDERS_ANY; case ZenPolicy.PEOPLE_TYPE_CONTACTS: return Policy.PRIORITY_SENDERS_CONTACTS; case ZenPolicy.PEOPLE_TYPE_STARRED: default: return Policy.PRIORITY_SENDERS_STARRED; default: return defaultPolicySender; } } Loading services/tests/uiservicestests/src/com/android/server/notification/ZenModeConfigTest.java +20 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ public class ZenModeConfigTest extends UiServiceTestCase { @Test public void testZenPolicyNothingSetToNotificationPolicy() { ZenModeConfig config = getMutedAllConfig(); ZenModeConfig config = getCustomConfig(); ZenPolicy zenPolicy = new ZenPolicy.Builder().build(); assertEquals(config.toNotificationPolicy(), config.toNotificationPolicy(zenPolicy)); } Loading Loading @@ -219,6 +219,25 @@ public class ZenModeConfigTest extends UiServiceTestCase { return config; } private ZenModeConfig getCustomConfig() { ZenModeConfig config = new ZenModeConfig(); // Some sounds allowed config.allowAlarms = true; config.allowMedia = false; config.allowSystem = false; config.allowCalls = true; config.allowRepeatCallers = true; config.allowMessages = false; config.allowReminders = false; config.allowEvents = false; config.areChannelsBypassingDnd = false; config.allowCallsFrom = ZenModeConfig.SOURCE_ANYONE; config.allowMessagesFrom = ZenModeConfig.SOURCE_ANYONE; config.suppressedVisualEffects = 0; return config; } private ZenModeConfig getMutedAllConfig() { ZenModeConfig config = new ZenModeConfig(); // No sounds allowed Loading Loading
core/java/android/service/notification/ZenModeConfig.java +8 −5 Original line number Diff line number Diff line Loading @@ -958,13 +958,15 @@ public class ZenModeConfig implements Parcelable { if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_MESSAGES, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_MESSAGES, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_MESSAGES; messageSenders = getNotificationPolicySenders(zenPolicy.getPriorityMessageSenders()); messageSenders = getNotificationPolicySenders(zenPolicy.getPriorityMessageSenders(), messageSenders); } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_CALLS, isPriorityCategoryEnabled(Policy.PRIORITY_CATEGORY_CALLS, defaultPolicy))) { priorityCategories |= Policy.PRIORITY_CATEGORY_CALLS; callSenders = getNotificationPolicySenders(zenPolicy.getPriorityCallSenders()); callSenders = getNotificationPolicySenders(zenPolicy.getPriorityCallSenders(), callSenders); } if (zenPolicy.isCategoryAllowed(ZenPolicy.PRIORITY_CATEGORY_REPEAT_CALLERS, Loading Loading @@ -1056,16 +1058,17 @@ public class ZenModeConfig implements Parcelable { return (policy.suppressedVisualEffects & visualEffect) == 0; } private int getNotificationPolicySenders(@ZenPolicy.PeopleType int senders) { private int getNotificationPolicySenders(@ZenPolicy.PeopleType int senders, int defaultPolicySender) { switch (senders) { case ZenPolicy.PEOPLE_TYPE_ANYONE: return Policy.PRIORITY_SENDERS_ANY; case ZenPolicy.PEOPLE_TYPE_CONTACTS: return Policy.PRIORITY_SENDERS_CONTACTS; case ZenPolicy.PEOPLE_TYPE_STARRED: default: return Policy.PRIORITY_SENDERS_STARRED; default: return defaultPolicySender; } } Loading
services/tests/uiservicestests/src/com/android/server/notification/ZenModeConfigTest.java +20 −1 Original line number Diff line number Diff line Loading @@ -67,7 +67,7 @@ public class ZenModeConfigTest extends UiServiceTestCase { @Test public void testZenPolicyNothingSetToNotificationPolicy() { ZenModeConfig config = getMutedAllConfig(); ZenModeConfig config = getCustomConfig(); ZenPolicy zenPolicy = new ZenPolicy.Builder().build(); assertEquals(config.toNotificationPolicy(), config.toNotificationPolicy(zenPolicy)); } Loading Loading @@ -219,6 +219,25 @@ public class ZenModeConfigTest extends UiServiceTestCase { return config; } private ZenModeConfig getCustomConfig() { ZenModeConfig config = new ZenModeConfig(); // Some sounds allowed config.allowAlarms = true; config.allowMedia = false; config.allowSystem = false; config.allowCalls = true; config.allowRepeatCallers = true; config.allowMessages = false; config.allowReminders = false; config.allowEvents = false; config.areChannelsBypassingDnd = false; config.allowCallsFrom = ZenModeConfig.SOURCE_ANYONE; config.allowMessagesFrom = ZenModeConfig.SOURCE_ANYONE; config.suppressedVisualEffects = 0; return config; } private ZenModeConfig getMutedAllConfig() { ZenModeConfig config = new ZenModeConfig(); // No sounds allowed Loading