diff options
| author | 2023-02-23 14:56:10 -0500 | |
|---|---|---|
| committer | 2023-02-27 15:00:33 -0500 | |
| commit | a0c9db17821a26d7798fe4acb79522ad5435e8b6 (patch) | |
| tree | 6c467a0ca40cfad24ae139b29d658af1a7638c22 | |
| parent | 648fed59562da3d77fbcc0ea4f2a6881720d06d5 (diff) | |
Update ZenModeHelper & Test for refactor of DND atoms out of atoms.proto.
Also updates the mirror at notification.proto to be more consistent with the refactor.
Bug: 259261349
Test: ZenModeHelperTest
Change-Id: Iede3c6076b32e36a6fba826dda8b9d2e9b599980
3 files changed, 43 insertions, 37 deletions
diff --git a/core/proto/android/service/notification.proto b/core/proto/android/service/notification.proto index e029af4f9819..f87d9109e7f8 100644 --- a/core/proto/android/service/notification.proto +++ b/core/proto/android/service/notification.proto @@ -285,22 +285,24 @@ message NotificationRemoteViewsProto { repeated PackageRemoteViewInfoProto package_remote_view_info = 1; } +// Enum used in DNDModeProto to specify the zen mode setting. +enum LoggedZenMode { + ROOT_CONFIG = -1; // Used to distinguish config (one per user) from the rules. + OFF = 0; + IMPORTANT_INTERRUPTIONS = 1; + NO_INTERRUPTIONS = 2; + ALARMS = 3; +} + /** * Atom that represents an item in the list of Do Not Disturb rules, pulled from * NotificationManagerService.java. */ message DNDModeProto { - enum Mode { - ROOT_CONFIG = -1; // Used to distinguish the config (one per user) from the rules. - ZEN_MODE_OFF = 0; - ZEN_MODE_IMPORTANT_INTERRUPTIONS = 1; - ZEN_MODE_NO_INTERRUPTIONS = 2; - ZEN_MODE_ALARMS = 3; - } optional int32 user = 1; // Android user ID (0, 1, 10, ...) optional bool enabled = 2; // true for ROOT_CONFIG if a manualRule is enabled optional bool channels_bypassing = 3; // only valid for ROOT_CONFIG - optional Mode zen_mode = 4; + optional LoggedZenMode zen_mode = 4; // id is one of the system default rule IDs, or empty // May also be "MANUAL_RULE" to indicate app-activation of the manual rule. optional string id = 5; @@ -308,15 +310,34 @@ message DNDModeProto { optional DNDPolicyProto policy = 7; } +// Enum used in DNDPolicyProto for a particular policy parameter's state. +enum State { + STATE_UNSET = 0; + STATE_ALLOW = 1; + STATE_DISALLOW = 2; +} + +// Enum used in DNDPolicyProto for which people are allowed to break through. +enum PeopleType { + PEOPLE_UNSET = 0; + PEOPLE_ANYONE = 1; + PEOPLE_CONTACTS = 2; + PEOPLE_STARRED = 3; + PEOPLE_NONE = 4; +} + +// Enum used in DNDPolicyProto for conversation types allowed to break through. +enum ConversationType { + CONV_UNSET = 0; + CONV_ANYONE = 1; + CONV_IMPORTANT = 2; + CONV_NONE = 3; +} + /** - * Atom that represents a Do Not Disturb policy, an optional detail proto for DNDModeProto. + * Message that represents a Do Not Disturb policy, an optional detail proto for DNDModeProto. */ message DNDPolicyProto { - enum State { - STATE_UNSET = 0; - STATE_ALLOW = 1; - STATE_DISALLOW = 2; - } optional State calls = 1; optional State repeat_callers = 2; optional State messages = 3; @@ -334,23 +355,8 @@ message DNDPolicyProto { optional State ambient = 15; optional State notification_list = 16; - enum PeopleType { - PEOPLE_UNSET = 0; - PEOPLE_ANYONE = 1; - PEOPLE_CONTACTS = 2; - PEOPLE_STARRED = 3; - PEOPLE_NONE = 4; - } - optional PeopleType allow_calls_from = 17; optional PeopleType allow_messages_from = 18; - enum ConversationType { - CONV_UNSET = 0; - CONV_ANYONE = 1; - CONV_IMPORTANT = 2; - CONV_NONE = 3; - } - optional ConversationType allow_conversations_from = 19; } diff --git a/services/core/java/com/android/server/notification/ZenModeHelper.java b/services/core/java/com/android/server/notification/ZenModeHelper.java index 4b2c88c2bf06..27744626385e 100644 --- a/services/core/java/com/android/server/notification/ZenModeHelper.java +++ b/services/core/java/com/android/server/notification/ZenModeHelper.java @@ -20,7 +20,7 @@ import static android.app.NotificationManager.AUTOMATIC_RULE_STATUS_DISABLED; import static android.app.NotificationManager.AUTOMATIC_RULE_STATUS_ENABLED; import static android.app.NotificationManager.AUTOMATIC_RULE_STATUS_REMOVED; import static android.app.NotificationManager.Policy.PRIORITY_SENDERS_ANY; -import static android.service.notification.DNDModeProto.ROOT_CONFIG; +import static android.service.notification.NotificationServiceProto.ROOT_CONFIG; import static android.util.StatsLog.ANNOTATION_ID_IS_UID; import static com.android.internal.util.FrameworkStatsLog.DND_MODE_RULE; diff --git a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java index 12f124e385f3..6f6e22428eb4 100644 --- a/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java +++ b/services/tests/uiservicestests/src/com/android/server/notification/ZenModeHelperTest.java @@ -38,11 +38,12 @@ import static android.service.notification.Condition.STATE_TRUE; import static android.util.StatsLog.ANNOTATION_ID_IS_UID; import static com.android.internal.util.FrameworkStatsLog.DND_MODE_RULE; -import static com.android.os.AtomsProto.DNDModeProto.CHANNELS_BYPASSING_FIELD_NUMBER; -import static com.android.os.AtomsProto.DNDModeProto.ENABLED_FIELD_NUMBER; -import static com.android.os.AtomsProto.DNDModeProto.ID_FIELD_NUMBER; -import static com.android.os.AtomsProto.DNDModeProto.UID_FIELD_NUMBER; -import static com.android.os.AtomsProto.DNDModeProto.ZEN_MODE_FIELD_NUMBER; +import static com.android.os.dnd.DNDModeProto.CHANNELS_BYPASSING_FIELD_NUMBER; +import static com.android.os.dnd.DNDModeProto.ENABLED_FIELD_NUMBER; +import static com.android.os.dnd.DNDModeProto.ID_FIELD_NUMBER; +import static com.android.os.dnd.DNDModeProto.UID_FIELD_NUMBER; +import static com.android.os.dnd.DNDModeProto.ZEN_MODE_FIELD_NUMBER; +import static com.android.os.dnd.DNDProtoEnums.ROOT_CONFIG; import static com.android.server.notification.ZenModeHelper.RULE_LIMIT_PER_PACKAGE; import static junit.framework.Assert.assertEquals; @@ -95,7 +96,6 @@ import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings.Global; import android.service.notification.Condition; -import android.service.notification.DNDModeProto; import android.service.notification.ZenModeConfig; import android.service.notification.ZenModeConfig.ScheduleInfo; import android.service.notification.ZenPolicy; @@ -898,7 +898,7 @@ public class ZenModeHelperTest extends UiServiceTestCase { assertEquals(n + 1, events.size()); for (WrappedSysUiStatsEvent.WrappedBuilder builder : mStatsEventBuilderFactory.builders) { if (builder.getAtomId() == DND_MODE_RULE) { - if (builder.getInt(ZEN_MODE_FIELD_NUMBER) == DNDModeProto.ROOT_CONFIG) { + if (builder.getInt(ZEN_MODE_FIELD_NUMBER) == ROOT_CONFIG) { assertTrue(builder.getBoolean(ENABLED_FIELD_NUMBER)); assertFalse(builder.getBoolean(CHANNELS_BYPASSING_FIELD_NUMBER)); } |