From b7ef42dc956ffac37c6a5b183145afbeb5b3af7a Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Wed, 7 Apr 2021 11:08:04 -0400 Subject: [PATCH] Allow updates to DND configuration activities Package name needs to be frozen but the config activity doesn't need to be Test: NotificationManagerTest and test app that updates the config activity (DND can still be enabled and disabled and the links from settings worked) Fixes: 184191272 Change-Id: I1dd98e01ce0738dd176d0603dd07a3c3816f9f1a --- .../server/notification/ZenModeHelper.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java index 18c689f1973d8..fcee63c62ae80 100644 --- a/services/core/java/com/android/server/notification/ZenModeHelper.java +++ b/services/core/java/com/android/server/notification/ZenModeHelper.java @@ -586,19 +586,6 @@ public class ZenModeHelper { } private void populateZenRule(AutomaticZenRule automaticZenRule, ZenRule rule, boolean isNew) { - if (isNew) { - rule.id = ZenModeConfig.newRuleId(); - rule.creationTime = System.currentTimeMillis(); - rule.component = automaticZenRule.getOwner(); - rule.configurationActivity = automaticZenRule.getConfigurationActivity(); - rule.pkg = (rule.component != null) - ? rule.component.getPackageName() - : rule.configurationActivity.getPackageName(); - } - - if (rule.enabled != automaticZenRule.isEnabled()) { - rule.snoozing = false; - } rule.name = automaticZenRule.getName(); rule.condition = null; rule.conditionId = automaticZenRule.getConditionId(); @@ -607,6 +594,20 @@ public class ZenModeHelper { rule.zenPolicy = automaticZenRule.getZenPolicy(); rule.zenMode = NotificationManager.zenModeFromInterruptionFilter( automaticZenRule.getInterruptionFilter(), Global.ZEN_MODE_OFF); + rule.configurationActivity = automaticZenRule.getConfigurationActivity(); + + if (isNew) { + rule.id = ZenModeConfig.newRuleId(); + rule.creationTime = System.currentTimeMillis(); + rule.component = automaticZenRule.getOwner(); + rule.pkg = (rule.component != null) + ? rule.component.getPackageName() + : rule.configurationActivity.getPackageName(); + } + + if (rule.enabled != automaticZenRule.isEnabled()) { + rule.snoozing = false; + } } protected AutomaticZenRule createAutomaticZenRule(ZenRule rule) {