1 /*
2  * Copyright (c) 2021-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_CONSTANT_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_CONSTANT_H
18 
19 #include <string>
20 
21 namespace OHOS {
22 namespace Notification {
23 class NotificationConstant {
24 public:
25     enum InputEditType {
26         EDIT_AUTO,      // Indicates that the system determines whether to allow the user to edit the options before
27                         // they are sent to the application.
28         EDIT_DISABLED,  // Indicates that the user is not allowed to edit an option before the option is sent to the
29                         // application.
30         EDIT_ENABLED,   // Indicates that the user is allowed to edit an option before the option is sent to the
31                         // application.
32     };
33 
34     enum InputsSource {
35         FREE_FORM_INPUT,  // Indicates that the user manually input the content.
36         OPTION,           // Indicates that the user selected one of the provided options.
37     };
38 
39     enum SemanticActionButton {
40         NONE_ACTION_BUTTON,         // Indicates that no WantAgent is associated.
41         REPLY_ACTION_BUTTON,        // Indicates the action of replying to a conversation.
42         READ_ACTION_BUTTON,         // Indicates the action of marking the content as read.
43         UNREAD_ACTION_BUTTON,       // Indicates the action of marking the content as unread.
44         DELETE_ACTION_BUTTON,       // Indicates the action of deleting the content associated with the notification.
45         ARCHIVE_ACTION_BUTTON,      // Indicates the action of archiving the content associated with the notification.
46         MUTE_ACTION_BUTTON,         // Indicates the action of muting the content associated with the notification.
47         UNMUTE_ACTION_BUTTON,       // Indicates the action of unmuting the content associated with the notification.
48         THUMBS_UP_ACTION_BUTTON,    // Indicates the action of marking the content with a thumbs-up.
49         THUMBS_DOWN_ACTION_BUTTON,  // Indicates the action of marking the content with a thumbs-down.
50         CALL_ACTION_BUTTON,         // Indicates the action of making a call.
51     };
52 
53     enum SubscribeResult : uint32_t {
54         SUCCESS,
55         PREMISSION_FAIL,
56         RESOURCES_FAIL,
57     };
58 
59     enum SlotType {
60         SOCIAL_COMMUNICATION,   // the notification type is social communication
61         SERVICE_REMINDER,       // the notification type is service reminder
62         CONTENT_INFORMATION,    // the notificatin type is content information
63         OTHER,                  // the notificatin type is other
64         CUSTOM,                 // the notification type is custom
65         LIVE_VIEW,              // the notification type is live view
66         CUSTOMER_SERVICE,       // the notification type is customer service
67         EMERGENCY_INFORMATION,  // the notification type is emergency information
68         ILLEGAL_TYPE,           // invalid type,it is used as the upper limit of the enumerated value
69     };
70 
71     enum ReminderFlag {
72         SOUND_FLAG = 1 << 0,
73         LOCKSCREEN_FLAG = 1 << 1,
74         BANNER_FLAG = 1 << 2,
75         LIGHTSCREEN_FLAG = 1 << 3,
76         VIBRATION_FLAG = 1 << 4,
77         STATUSBAR_ICON_FLAG = 1 << 5,
78         SA_SELF_BANNER_FLAG = 1 << 9,
79     };
80 
81     enum class VisiblenessType {
82         /**
83          * the notification display effect has not been set by NotificationRequest::setVisibleness().
84          * This method is usually not used.
85          */
86         NO_OVERRIDE,
87         /**
88          * only the basic information, such as application icon and application name is displayed on the lock screen.
89          */
90         PRIVATE,
91         /**
92          * contents of a notification are displayed on the lock screen.
93          */
94         PUBLIC,
95         /**
96          * notifications are not displayed on the lock screen.
97          */
98         SECRET,
99         /**
100          * invalid type
101          * It is used as the upper limit of the enumerated value.
102          */
103         ILLEGAL_TYPE
104     };
105 
106     enum class DoNotDisturbType {
107         NONE    = 0,
108         ONCE    = 1,    // only once
109         DAILY   = 2,    // every day
110         CLEARLY = 3,    // time period
111     };
112 
113     enum class RemindType {
114         NONE                       = -1,
115         DEVICE_IDLE_DONOT_REMIND   = 0, // The device is not in use, no reminder
116         DEVICE_IDLE_REMIND         = 1, // The device is not in use, remind
117         DEVICE_ACTIVE_DONOT_REMIND = 2, // The device is in use, no reminder
118         DEVICE_ACTIVE_REMIND       = 3, // The device is in use, reminder
119     };
120 
121     enum class DistributedReminderPolicy {
122         DEFAULT,
123         ALWAYS_REMIND,
124         DO_NOT_REMIND,
125     };
126 
127     enum class SourceType {
128         /**
129          * general notification.
130          */
131         TYPE_NORMAL = 0x00000000,
132         /**
133          * long-term task notification.
134          */
135         TYPE_CONTINUOUS = 0x00000001,
136         /**
137          * timed notification.
138          */
139         TYPE_TIMER = 0x00000002
140     };
141 
142     enum class FlagStatus {
143         NONE,
144         OPEN,
145         CLOSE
146     };
147 
148     static const int32_t DEFAULT_REASON_DELETE = 0;
149 
150     /**
151      * Indicates that a notification is deleted because it is clicked.
152      */
153     static const int32_t CLICK_REASON_DELETE = 1;
154 
155     /**
156      * Indicates that a notification is deleted because the user clears it.
157      */
158     static const int32_t CANCEL_REASON_DELETE = 2;
159 
160     /**
161      * Indicates that a notification is deleted because the user clears all notifications.
162      */
163     static const int32_t CANCEL_ALL_REASON_DELETE = 3;
164 
165     /**
166      * Indicates that a notification is deleted because of a UI error.
167      */
168     static const int32_t ERROR_REASON_DELETE = 4;
169 
170     /**
171      * Indicates that a notification is deleted because a change has been made to the application.
172      */
173     static const int32_t PACKAGE_CHANGED_REASON_DELETE = 5;
174 
175     /**
176      * Indicates that a notification is deleted because the application context is stopped.
177      */
178     static const int32_t USER_STOPPED_REASON_DELETE = 6;
179 
180     /**
181      * Indicates that a notification is deleted because the application is banned from sending notifications.
182      */
183     static const int32_t PACKAGE_BANNED_REASON_DELETE = 7;
184 
185     /**
186      * Indicates that a notification is deleted because the application cancels it.
187      */
188     static const int32_t APP_CANCEL_REASON_DELETE = 8;
189 
190     /**
191      * Indicates that a notification is deleted because the application cancels all notifications.
192      */
193     static const int32_t APP_CANCEL_ALL_REASON_DELETE = 9;
194 
195     /**
196      * Indicates that a notification is deleted because this user is removed.
197      */
198     static const int32_t USER_REMOVED_REASON_DELETE = 10;
199 
200     /**
201      * Indicates that a notification is deleted because of flow control.
202      */
203     static const int32_t FLOW_CONTROL_REASON_DELETE = 11;
204 
205     /**
206      * Indicates that a notification is deleted because enable state is changed.
207      */
208     static const int32_t DISABLE_SLOT_REASON_DELETE = 12;
209 
210     /**
211      * Indicates that a notification is deleted because enable state is changed.
212      */
213     static const int32_t DISABLE_NOTIFICATION_REASON_DELETE = 13;
214 
215     /**
216      * Indicates that a notification is deleted by bundle because the application cancel it.
217      */
218     static const int32_t APP_CANCEL_AS_BUNELE_REASON_DELETE = 14;
219 
220     /**
221      * Indicates that a notification is deleted by agent because the application cancel it.
222      */
223     static const int32_t APP_CANCEL_AS_BUNELE_WITH_AGENT_REASON_DELETE = 15;
224 
225     /**
226      * Indicates that a notification is deleted because the reminder cancel it.
227      */
228     static const int32_t APP_CANCEL_REMINDER_REASON_DELETE = 16;
229 
230     /**
231      * Indicates that a notification is deleted because the application cancel it by group.
232      */
233     static const int32_t APP_CANCEL_GROPU_REASON_DELETE = 17;
234 
235     /**
236      * Indicates that a notification is deleted by group because the system cancel it.
237      */
238     static const int32_t APP_REMOVE_GROUP_REASON_DELETE = 18;
239 
240     /**
241      * Indicates that aLL notification is deleted because the system cancel it.
242      */
243     static const int32_t APP_REMOVE_ALL_REASON_DELETE = 19;
244 
245     /**
246      * Indicates that aLL notification is deleted by userId because the system cancel it.
247      */
248     static const int32_t APP_REMOVE_ALL_USER_REASON_DELETE = 20;
249 
250     /**
251      * Indicates that notification is deleted because eight-hour timer cancel it.
252      */
253     static const int32_t TRIGGER_EIGHT_HOUR_REASON_DELETE = 21;
254 
255     /**
256      * Indicates that notification is deleted because four-hour timer cancel it.
257      */
258     static const int32_t TRIGGER_FOUR_HOUR_REASON_DELETE = 22;
259 
260     /**
261      * Indicates that notification is deleted because ten-minutes timer cancel it.
262      */
263     static const int32_t TRIGGER_TEN_MINUTES_REASON_DELETE = 23;
264 
265     /**
266      * Indicates that notification is deleted because fifteen-minutes timer cancel it.
267      */
268     static const int32_t TRIGGER_FIFTEEN_MINUTES_REASON_DELETE = 24;
269 
270     /**
271      * Indicates that notification is deleted because thirty-minutes timer cancel it.
272      */
273     static const int32_t TRIGGER_THIRTY_MINUTES_REASON_DELETE = 25;
274 
275     /**
276      * Indicates that notification is deleted because startArchive timer cancel it.
277      */
278     static const int32_t TRIGGER_START_ARCHIVE_REASON_DELETE = 26;
279 
280     /**
281      * Indicates that notification is deleted because auto delete timer cancel it.
282      */
283     static const int32_t TRIGGER_AUTO_DELETE_REASON_DELETE = 27;
284 
285     /**
286      * Indicates that notification is deleted because auto packge remove cancel it.
287      */
288     static const int32_t PACKAGE_REMOVE_REASON_DELETE = 28;
289 
290     /**
291      * Indicates that notification is deleted because slot enabled close remove cancel it.
292      */
293     static const int32_t SLOT_ENABLED_REASON_DELETE = 29;
294 
295     /**
296      * Indicates that a notification is deleted because recover live live validated need delete.
297      */
298     static const int32_t RECOVER_LIVE_VIEW_DELETE = 30;
299 
300     /**
301      * Indicates that a notification is deleted for other reasons.
302      */
303     static const int32_t APP_CANCEL_REASON_OTHER = 100;
304 
305     /**
306      * The key indicates input source.
307      */
308     static const std::string EXTRA_INPUTS_SOURCE;
309 
310     static const int64_t HOUR_TO_MS = 3600000;
311 
312     static const int64_t SECOND_TO_MS = 1000;
313 
314     static const int64_t TEN_MINUTES = 600000;
315 
316     static const int64_t FIFTEEN_MINUTES = 900000;
317 
318     static const int64_t THIRTY_MINUTES = 1800000;
319 
320     static const int64_t FINISH_PER = 100;
321 
322     static const int64_t DEFAULT_FINISH_STATUS = -1;
323 
324     static const int64_t MAX_FINISH_TIME = 8 * HOUR_TO_MS;
325 
326     static const int64_t MAX_UPDATE_TIME = 4 * HOUR_TO_MS;
327 
328     static const int64_t INVALID_AUTO_DELETE_TIME = -1;
329 
330     /* one hour */
331     static const int64_t DEFAULT_AUTO_DELETE_TIME = 3600;
332 
333     static const int64_t NO_DELAY_DELETE_TIME = 0;
334 
335     static constexpr uint64_t INVALID_TIMER_ID = 0ULL;
336 
337     // live view max size is 512KB(extra size) + 8KB(base size) = 520KB
338     static constexpr uint64_t NOTIFICATION_MAX_LIVE_VIEW_SIZE = 520ULL * 1024ULL;
339 
340     // rdb
341     constexpr static const char* NOTIFICATION_RDB_NAME = "/notificationdb.db";
342     constexpr static const char* NOTIFICATION_RDB_TABLE_NAME = "notification_table";
343     constexpr static const char* NOTIFICATION_RDB_PATH = "/data/service/el1/public/database/notification_service";
344     constexpr static const char* NOTIFICATION_JOURNAL_MODE = "WAL";
345     constexpr static const char* NOTIFICATION_SYNC_MODE = "FULL";
346     constexpr static int32_t NOTIFICATION_RDB_VERSION = 1;
347     constexpr static const char* SLOTTYPECCMNAMES[] = {"Social_communication", "Service_reminder",
348         "Content_information", "Other", "Custom", "Live_view", "Custom_service", "Emergency_information"};
349     constexpr static const char* CURRENT_DEVICE_TYPE = "current";
350 };
351 }  // namespace Notification
352 }  // namespace OHOS
353 
354 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_CONSTANT_H
355