1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17syntax = "proto2";
18package android.service.notification;
19
20option java_multiple_files = true;
21option java_outer_classname = "NotificationServiceProto";
22
23import "frameworks/base/core/proto/android/app/notification_channel.proto";
24import "frameworks/base/core/proto/android/app/notification_channel_group.proto";
25import "frameworks/base/core/proto/android/app/notificationmanager.proto";
26import "frameworks/base/core/proto/android/content/component_name.proto";
27import "frameworks/base/core/proto/android/media/audioattributes.proto";
28import "frameworks/base/core/proto/android/privacy.proto";
29
30message NotificationServiceDumpProto {
31    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
32
33    repeated NotificationRecordProto records = 1;
34
35    optional ZenModeProto zen = 2;
36
37    optional ManagedServicesProto notification_listeners = 3;
38
39    optional int32 listener_hints = 4;
40
41    repeated ListenersDisablingEffectsProto listeners_disabling_effects = 5;
42
43    optional ManagedServicesProto notification_assistants = 6;
44
45    optional ManagedServicesProto condition_providers = 7;
46
47    optional RankingHelperProto ranking_config = 8;
48}
49
50message NotificationRecordProto {
51    option (.android.msg_privacy).dest = DEST_AUTOMATIC;
52
53    optional string key = 1;
54
55    enum State {
56        ENQUEUED = 0;
57        POSTED = 1;
58        SNOOZED = 2;
59    }
60    optional State state = 2;
61    optional int32 flags = 3;
62    optional string channel_id = 4 [ (.android.privacy).dest = DEST_EXPLICIT ];
63    optional string sound = 5 [ (.android.privacy).dest = DEST_EXPLICIT ];
64    optional .android.media.AudioAttributesProto audio_attributes = 6;
65    optional bool can_vibrate = 7;
66    optional bool can_show_light = 8;
67    optional string group_key = 9 [ (.android.privacy).dest = DEST_EXPLICIT ];
68    optional sint32 importance = 10;
69    // The package the notification was posted for.
70    optional string package = 11;
71    // The package that posted the notification. It might not be the same as package.
72    optional string delegate_package = 12;
73}
74
75message ListenersDisablingEffectsProto {
76    option (android.msg_privacy).dest = DEST_AUTOMATIC;
77
78    optional int32 hint = 1;
79    reserved 2; // ManagedServiceInfoProto listeners
80    repeated android.content.ComponentNameProto listener_components = 3;
81}
82
83message ManagedServiceInfoProto {
84    option (android.msg_privacy).dest = DEST_AUTOMATIC;
85
86    optional android.content.ComponentNameProto component = 1;
87    optional int32 user_id = 2;
88    optional string service = 3;
89    optional bool is_system = 4;
90    optional bool is_guest = 5;
91}
92
93message ManagedServicesProto {
94    option (android.msg_privacy).dest = DEST_AUTOMATIC;
95
96    // Hard-coded string identifying what the service config is for
97    // (eg: "notification assistant" or "notification listener").
98    optional string caption = 1;
99
100    message ServiceProto {
101        option (android.msg_privacy).dest = DEST_AUTOMATIC;
102
103        // Package or component name.
104        repeated string name = 1;
105        optional int32 user_id = 2;
106        optional bool is_primary = 3;
107    }
108    repeated ServiceProto approved = 2;
109
110    // All of this type/caption enabled for current profiles.
111    repeated android.content.ComponentNameProto enabled = 3;
112
113    repeated ManagedServiceInfoProto live_services = 4;
114
115    // Was: repeated ComponentNameProto, when snoozed services were not per-user-id.
116    reserved 5;
117
118    message SnoozedServices {
119        option (android.msg_privacy).dest = DEST_AUTOMATIC;
120
121        optional int32 user_id = 1;
122        repeated android.content.ComponentNameProto snoozed = 2;
123    }
124
125    // Snoozed for current profiles.
126    repeated SnoozedServices snoozed = 6;
127}
128
129message RankingHelperProto {
130    option (android.msg_privacy).dest = DEST_AUTOMATIC;
131
132    repeated string notification_signal_extractors = 1;
133
134    message RecordProto {
135        option (android.msg_privacy).dest = DEST_AUTOMATIC;
136
137        optional string package = 1;
138        // Default value is UNKNOWN_UID = USER_NULL = -10000.
139        optional int32 uid = 2;
140        // Default is IMPORTANCE_UNSPECIFIED (-1000).
141        optional sint32 importance = 3;
142        // Default is PRIORITY_DEFAULT (0).
143        optional int32 priority = 4;
144        // Default is VISIBILITY_NO_OVERRIDE (-1000).
145        optional sint32 visibility = 5;
146        // Default is true.
147        optional bool show_badge = 6;
148        repeated android.app.NotificationChannelProto channels = 7;
149        repeated android.app.NotificationChannelGroupProto channel_groups = 8;
150    }
151    repeated RecordProto records = 2;
152    repeated RecordProto records_restored_without_uid = 3;
153}
154
155enum ZenMode {
156    ZEN_MODE_OFF = 0;
157    ZEN_MODE_IMPORTANT_INTERRUPTIONS = 1;
158    ZEN_MODE_NO_INTERRUPTIONS = 2;
159    ZEN_MODE_ALARMS = 3;
160}
161
162// An android.service.notification.Condition object.
163message ConditionProto {
164    option (android.msg_privacy).dest = DEST_EXPLICIT;
165
166    // The URI representing the rule being updated.
167    optional string id = 1;
168    // A user visible description of the rule state.
169    optional string summary = 2;
170    // Android generated strings that detail when ZenMode will end.
171    optional string line_1 = 3;
172    optional string line_2 = 4;
173    optional int32 icon = 5 [ (android.privacy).dest = DEST_AUTOMATIC ];
174
175    enum State {
176        // Indicates that Do Not Disturb should be turned off.
177        STATE_FALSE = 0;
178        // Indicates that Do Not Disturb should be turned on.
179        STATE_TRUE = 1;
180        STATE_UNKNOWN = 2;
181        STATE_ERROR = 3;
182    }
183    optional State state = 6 [ (android.privacy).dest = DEST_AUTOMATIC ];
184
185    optional int32 flags = 7 [ (android.privacy).dest = DEST_AUTOMATIC ];
186}
187
188// An android.service.notification.ZenModeConfig.ZenRule object.
189message ZenRuleProto {
190    option (android.msg_privacy).dest = DEST_EXPLICIT;
191
192    // Required for automatic ZenRules (unique).
193    optional string id = 1;
194    // Required for automatic ZenRules.
195    optional string name = 2;
196    // Required for automatic ZenRules.
197    optional int64 creation_time_ms = 3 [
198        (android.privacy).dest = DEST_AUTOMATIC
199    ];
200    optional bool enabled = 4 [ (android.privacy).dest = DEST_AUTOMATIC ];
201    // Package name, only used for manual ZenRules.
202    optional string enabler = 5 [ (android.privacy).dest = DEST_AUTOMATIC ];
203    // User manually disabled this instance.
204    optional bool is_snoozing = 6 [
205        (android.privacy).dest = DEST_AUTOMATIC
206    ];
207    optional ZenMode zen_mode = 7 [
208        (android.privacy).dest = DEST_AUTOMATIC
209    ];
210
211    // Required for automatic ZenRules. The condition's ID, which is the URI
212    // representing the rule being updated.
213    optional string condition_id = 8;
214    optional ConditionProto condition = 9;
215    optional android.content.ComponentNameProto component = 10;
216    optional ZenPolicyProto zenPolicy = 11;
217
218    // Indicates whether this ZenRule has been modified after its initial creation
219    optional bool modified = 12 [ (android.privacy).dest = DEST_AUTOMATIC ];
220}
221
222// A dump from com.android.server.notification.ZenModeHelper.
223message ZenModeProto {
224    option (android.msg_privacy).dest = DEST_AUTOMATIC;
225
226    optional ZenMode zen_mode = 1;
227    repeated ZenRuleProto enabled_active_conditions = 2;
228    optional int32 suppressed_effects = 3;
229    repeated android.content.ComponentNameProto suppressors = 4;
230    optional android.app.PolicyProto policy = 5;
231}
232
233// An android.service.notification.ZenPolicy object
234message ZenPolicyProto {
235    option (android.msg_privacy).dest = DEST_AUTOMATIC;
236
237    enum State {
238        STATE_UNSET = 0;
239        STATE_ALLOW = 1;
240        STATE_DISALLOW = 2;
241    }
242
243    // Notifications and sounds allowed/disallowed when DND is active
244    optional State reminders = 1;
245    optional State events = 2;
246    optional State messages = 3;
247    optional State calls = 4;
248    optional State repeat_callers = 5;
249    optional State alarms = 6;
250    optional State media = 7;
251    optional State system = 8;
252
253    // Visual effects allowed/disallowed for intercepted notifications when DND is active
254    optional State full_screen_intent = 9;
255    optional State lights = 10;
256    optional State peek = 11;
257    optional State status_bar = 12;
258    optional State badge= 13;
259    optional State ambient = 14;
260    optional State notification_list = 15;
261
262    enum Sender {
263        SENDER_UNSET = 0;
264        // Any sender is prioritized.
265        SENDER_ANY = 1;
266        // Saved contacts are prioritized.
267        SENDER_CONTACTS = 2;
268        // Only starred contacts are prioritized.
269        SENDER_STARRED = 3;
270        // No calls/messages are prioritized.
271        SENDER_NONE = 4;
272    }
273    optional Sender priority_calls = 16;
274    optional Sender priority_messages = 17;
275}
276
277// Next Tag: 2
278message PackageRemoteViewInfoProto {
279    optional string package_name = 1;
280    // add per-package additional info here (like channels)
281}
282
283// Next Tag: 2
284message NotificationRemoteViewsProto {
285    repeated PackageRemoteViewInfoProto package_remote_view_info = 1;
286}
287
288// Enum used in DNDModeProto to specify the zen mode setting.
289enum LoggedZenMode {
290    ROOT_CONFIG = -1;  // Used to distinguish config (one per user) from the rules.
291    OFF = 0;
292    IMPORTANT_INTERRUPTIONS = 1;
293    NO_INTERRUPTIONS = 2;
294    ALARMS = 3;
295}
296
297/**
298 * Atom that represents an item in the list of Do Not Disturb rules, pulled from
299 * NotificationManagerService.java.
300 */
301message DNDModeProto {
302    optional int32 user = 1;  // Android user ID (0, 1, 10, ...)
303    optional bool enabled = 2;  // true for ROOT_CONFIG if a manualRule is enabled
304    optional bool channels_bypassing = 3; // only valid for ROOT_CONFIG
305    optional LoggedZenMode zen_mode = 4;
306    // id is one of the system default rule IDs, or empty
307    // May also be "MANUAL_RULE" to indicate app-activation of the manual rule.
308    optional string id = 5;
309    optional int32 uid = 6; // currently only SYSTEM_UID or 0 for other
310    optional DNDPolicyProto policy = 7;
311}
312
313// Enum used in DNDPolicyProto for a particular policy parameter's state.
314enum State {
315    STATE_UNSET = 0;
316    STATE_ALLOW = 1;
317    STATE_DISALLOW = 2;
318}
319
320// Enum used in DNDPolicyProto for which people are allowed to break through.
321enum PeopleType {
322    PEOPLE_UNSET = 0;
323    PEOPLE_ANYONE = 1;
324    PEOPLE_CONTACTS = 2;
325    PEOPLE_STARRED = 3;
326    PEOPLE_NONE = 4;
327}
328
329// Enum used in DNDPolicyProto for conversation types allowed to break through.
330enum ConversationType {
331    CONV_UNSET = 0;
332    CONV_ANYONE = 1;
333    CONV_IMPORTANT = 2;
334    CONV_NONE = 3;
335}
336
337/**
338 * Message that represents a Do Not Disturb policy, an optional detail proto for DNDModeProto.
339 */
340message DNDPolicyProto {
341    optional State calls = 1;
342    optional State repeat_callers = 2;
343    optional State messages = 3;
344    optional State conversations = 4;
345    optional State reminders = 5;
346    optional State events = 6;
347    optional State alarms = 7;
348    optional State media = 8;
349    optional State system = 9;
350    optional State fullscreen = 10;
351    optional State lights = 11;
352    optional State peek = 12;
353    optional State status_bar = 13;
354    optional State badge = 14;
355    optional State ambient = 15;
356    optional State notification_list = 16;
357
358    optional PeopleType allow_calls_from = 17;
359    optional PeopleType allow_messages_from = 18;
360
361    optional ConversationType allow_conversations_from = 19;
362
363    optional ChannelPolicy allow_channels = 20;
364}
365
366// Enum identifying the type of rule that changed; values set to match ones used in the
367// DNDStateChanged proto.
368enum RuleType {
369    RULE_TYPE_UNKNOWN = 0;
370    RULE_TYPE_MANUAL = 1;
371    RULE_TYPE_AUTOMATIC = 2;
372}
373
374// Enum used in DNDPolicyProto to indicate the type of channels permitted to
375// break through DND. Mirrors values in ZenPolicy.
376enum ChannelPolicy {
377    CHANNEL_POLICY_UNSET = 0;
378    CHANNEL_POLICY_PRIORITY = 1;
379    CHANNEL_POLICY_NONE = 2;
380}
381