From 0ce93167c8ed30dd9d192945a446026a7a46d3b6 Mon Sep 17 00:00:00 2001 From: Yuri Lin Date: Tue, 4 Apr 2023 16:00:29 -0400 Subject: [PATCH] Don't convert conversation senders to the wrong enum Bug: 276950971 Test: ZenModeConfigTest Change-Id: I7efb90982dbc8102552abd8244c0ec06fff6601e --- .../android/service/notification/ZenModeConfig.java | 5 ++--- .../server/notification/ZenModeConfigTest.java | 12 ++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/core/java/android/service/notification/ZenModeConfig.java b/core/java/android/service/notification/ZenModeConfig.java index 5c2b38963005c..402da28b3c5cb 100644 --- a/core/java/android/service/notification/ZenModeConfig.java +++ b/core/java/android/service/notification/ZenModeConfig.java @@ -1008,9 +1008,8 @@ public class ZenModeConfig implements Parcelable { .allowAlarms(allowAlarms) .allowMedia(allowMedia) .allowSystem(allowSystem) - .allowConversations(allowConversations - ? ZenModeConfig.getZenPolicySenders(allowConversationsFrom) - : ZenPolicy.PEOPLE_TYPE_NONE); + .allowConversations(allowConversations ? allowConversationsFrom + : ZenPolicy.CONVERSATION_SENDERS_NONE); if (suppressedVisualEffects == 0) { builder.showAllVisualEffects(); } else { diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeConfigTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeConfigTest.java index 893f53825bbb1..3ba94000d4a56 100644 --- a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeConfigTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeConfigTest.java @@ -120,12 +120,20 @@ public class ZenModeConfigTest extends UiServiceTestCase { .showLights(false) .showBadges(false) .showInAmbientDisplay(false) + .allowCalls(ZenPolicy.PEOPLE_TYPE_CONTACTS) + .allowMessages(ZenPolicy.PEOPLE_TYPE_STARRED) + .allowConversations(ZenPolicy.CONVERSATION_SENDERS_NONE) .build(); ZenModeConfig config = getMutedAllConfig(); config.allowAlarms = true; config.allowReminders = true; config.allowEvents = true; + config.allowCalls = true; + config.allowCallsFrom = Policy.PRIORITY_SENDERS_CONTACTS; + config.allowMessages = true; + config.allowMessagesFrom = Policy.PRIORITY_SENDERS_STARRED; + config.allowConversations = false; config.suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_BADGE; config.suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_LIGHTS; config.suppressedVisualEffects |= Policy.SUPPRESSED_EFFECT_AMBIENT; @@ -138,6 +146,10 @@ public class ZenModeConfigTest extends UiServiceTestCase { assertEquals(expected.getPriorityCategoryEvents(), actual.getPriorityCategoryEvents()); assertEquals(expected.getVisualEffectLights(), actual.getVisualEffectLights()); assertEquals(expected.getVisualEffectAmbient(), actual.getVisualEffectAmbient()); + assertEquals(expected.getPriorityConversationSenders(), + actual.getPriorityConversationSenders()); + assertEquals(expected.getPriorityCallSenders(), actual.getPriorityCallSenders()); + assertEquals(expected.getPriorityMessageSenders(), actual.getPriorityMessageSenders()); } @Test