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 #include "notification_helper.h"
17 #include "ans_notification.h"
18 #include "singleton.h"
19 #include <memory>
20
21 namespace OHOS {
22 namespace Notification {
AddNotificationSlot(const NotificationSlot & slot)23 ErrCode NotificationHelper::AddNotificationSlot(const NotificationSlot &slot)
24 {
25 return DelayedSingleton<AnsNotification>::GetInstance()->AddNotificationSlot(slot);
26 }
27
AddSlotByType(const NotificationConstant::SlotType & slotType)28 ErrCode NotificationHelper::AddSlotByType(const NotificationConstant::SlotType &slotType)
29 {
30 return DelayedSingleton<AnsNotification>::GetInstance()->AddSlotByType(slotType);
31 }
32
AddNotificationSlots(const std::vector<NotificationSlot> & slots)33 ErrCode NotificationHelper::AddNotificationSlots(const std::vector<NotificationSlot> &slots)
34 {
35 return DelayedSingleton<AnsNotification>::GetInstance()->AddNotificationSlots(slots);
36 }
37
RemoveNotificationSlot(const NotificationConstant::SlotType & slotType)38 ErrCode NotificationHelper::RemoveNotificationSlot(const NotificationConstant::SlotType &slotType)
39 {
40 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveNotificationSlot(slotType);
41 }
42
RemoveAllSlots()43 ErrCode NotificationHelper::RemoveAllSlots()
44 {
45 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveAllSlots();
46 }
47
GetNotificationSlot(const NotificationConstant::SlotType & slotType,sptr<NotificationSlot> & slot)48 ErrCode NotificationHelper::GetNotificationSlot(
49 const NotificationConstant::SlotType &slotType, sptr<NotificationSlot> &slot)
50 {
51 return DelayedSingleton<AnsNotification>::GetInstance()->GetNotificationSlot(slotType, slot);
52 }
53
GetNotificationSlots(std::vector<sptr<NotificationSlot>> & slots)54 ErrCode NotificationHelper::GetNotificationSlots(std::vector<sptr<NotificationSlot>> &slots)
55 {
56 return DelayedSingleton<AnsNotification>::GetInstance()->GetNotificationSlots(slots);
57 }
58
GetNotificationSlotNumAsBundle(const NotificationBundleOption & bundleOption,uint64_t & num)59 ErrCode NotificationHelper::GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, uint64_t &num)
60 {
61 return DelayedSingleton<AnsNotification>::GetInstance()->GetNotificationSlotNumAsBundle(bundleOption, num);
62 }
63
GetNotificationSlotFlagsAsBundle(const NotificationBundleOption & bundleOption,uint32_t & slotFlags)64 ErrCode NotificationHelper::GetNotificationSlotFlagsAsBundle(const NotificationBundleOption &bundleOption,
65 uint32_t &slotFlags)
66 {
67 return DelayedSingleton<AnsNotification>::GetInstance()->GetNotificationSlotFlagsAsBundle(bundleOption, slotFlags);
68 }
69
SetNotificationSlotFlagsAsBundle(const NotificationBundleOption & bundleOption,uint32_t slotFlags)70 ErrCode NotificationHelper::SetNotificationSlotFlagsAsBundle(const NotificationBundleOption &bundleOption,
71 uint32_t slotFlags)
72 {
73 return DelayedSingleton<AnsNotification>::GetInstance()->SetNotificationSlotFlagsAsBundle(bundleOption, slotFlags);
74 }
75
PublishNotification(const NotificationRequest & request)76 ErrCode NotificationHelper::PublishNotification(const NotificationRequest &request)
77 {
78 return DelayedSingleton<AnsNotification>::GetInstance()->PublishNotification(request);
79 }
80
PublishNotification(const std::string & label,const NotificationRequest & request)81 ErrCode NotificationHelper::PublishNotification(const std::string &label, const NotificationRequest &request)
82 {
83 return DelayedSingleton<AnsNotification>::GetInstance()->PublishNotification(label, request);
84 }
85
PublishNotificationForIndirectProxy(const NotificationRequest & request)86 ErrCode NotificationHelper::PublishNotificationForIndirectProxy(const NotificationRequest &request)
87 {
88 return DelayedSingleton<AnsNotification>::GetInstance()->PublishNotificationForIndirectProxy(request);
89 }
90
CancelNotification(int32_t notificationId)91 ErrCode NotificationHelper::CancelNotification(int32_t notificationId)
92 {
93 return DelayedSingleton<AnsNotification>::GetInstance()->CancelNotification(notificationId);
94 }
95
CancelNotification(const std::string & label,int32_t notificationId)96 ErrCode NotificationHelper::CancelNotification(const std::string &label, int32_t notificationId)
97 {
98 return DelayedSingleton<AnsNotification>::GetInstance()->CancelNotification(label, notificationId);
99 }
100
CancelAllNotifications()101 ErrCode NotificationHelper::CancelAllNotifications()
102 {
103 return DelayedSingleton<AnsNotification>::GetInstance()->CancelAllNotifications();
104 }
105
CancelAsBundle(int32_t notificationId,const std::string & representativeBundle,int32_t userId)106 ErrCode NotificationHelper::CancelAsBundle(
107 int32_t notificationId, const std::string &representativeBundle, int32_t userId)
108 {
109 return DelayedSingleton<AnsNotification>::GetInstance()->CancelAsBundle(
110 notificationId, representativeBundle, userId);
111 }
112
CancelAsBundle(const NotificationBundleOption & bundleOption,int32_t notificationId)113 ErrCode NotificationHelper::CancelAsBundle(
114 const NotificationBundleOption &bundleOption, int32_t notificationId)
115 {
116 return DelayedSingleton<AnsNotification>::GetInstance()->CancelAsBundle(
117 bundleOption, notificationId);
118 }
119
GetActiveNotificationNums(uint64_t & num)120 ErrCode NotificationHelper::GetActiveNotificationNums(uint64_t &num)
121 {
122 return DelayedSingleton<AnsNotification>::GetInstance()->GetActiveNotificationNums(num);
123 }
124
GetActiveNotifications(std::vector<sptr<NotificationRequest>> & request)125 ErrCode NotificationHelper::GetActiveNotifications(std::vector<sptr<NotificationRequest>> &request)
126 {
127 return DelayedSingleton<AnsNotification>::GetInstance()->GetActiveNotifications(request);
128 }
129
SetNotificationAgent(const std::string & agent)130 ErrCode NotificationHelper::SetNotificationAgent(const std::string &agent)
131 {
132 return DelayedSingleton<AnsNotification>::GetInstance()->SetNotificationAgent(agent);
133 }
134
GetNotificationAgent(std::string & agent)135 ErrCode NotificationHelper::GetNotificationAgent(std::string &agent)
136 {
137 return DelayedSingleton<AnsNotification>::GetInstance()->GetNotificationAgent(agent);
138 }
139
CanPublishNotificationAsBundle(const std::string & representativeBundle,bool & canPublish)140 ErrCode NotificationHelper::CanPublishNotificationAsBundle(const std::string &representativeBundle, bool &canPublish)
141 {
142 return DelayedSingleton<AnsNotification>::GetInstance()->CanPublishNotificationAsBundle(
143 representativeBundle, canPublish);
144 }
145
PublishNotificationAsBundle(const std::string & representativeBundle,const NotificationRequest & request)146 ErrCode NotificationHelper::PublishNotificationAsBundle(
147 const std::string &representativeBundle, const NotificationRequest &request)
148 {
149 return DelayedSingleton<AnsNotification>::GetInstance()->PublishNotificationAsBundle(representativeBundle, request);
150 }
151
SetNotificationBadgeNum()152 ErrCode NotificationHelper::SetNotificationBadgeNum()
153 {
154 return DelayedSingleton<AnsNotification>::GetInstance()->SetNotificationBadgeNum();
155 }
156
SetNotificationBadgeNum(int32_t num)157 ErrCode NotificationHelper::SetNotificationBadgeNum(int32_t num)
158 {
159 return DelayedSingleton<AnsNotification>::GetInstance()->SetNotificationBadgeNum(num);
160 }
161
IsAllowedNotify(bool & allowed)162 ErrCode NotificationHelper::IsAllowedNotify(bool &allowed)
163 {
164 return DelayedSingleton<AnsNotification>::GetInstance()->IsAllowedNotify(allowed);
165 }
166
IsAllowedNotifySelf(bool & allowed)167 ErrCode NotificationHelper::IsAllowedNotifySelf(bool &allowed)
168 {
169 return DelayedSingleton<AnsNotification>::GetInstance()->IsAllowedNotifySelf(allowed);
170 }
171
CanPopEnableNotificationDialog(sptr<AnsDialogHostClient> & hostClient,bool & canPop,std::string & bundleName)172 ErrCode NotificationHelper::CanPopEnableNotificationDialog(sptr<AnsDialogHostClient> &hostClient,
173 bool &canPop, std::string &bundleName)
174 {
175 return DelayedSingleton<AnsNotification>::GetInstance()->CanPopEnableNotificationDialog(
176 hostClient, canPop, bundleName);
177 }
178
RemoveEnableNotificationDialog()179 ErrCode NotificationHelper::RemoveEnableNotificationDialog()
180 {
181 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveEnableNotificationDialog();
182 }
183
RequestEnableNotification(std::string & deviceId,sptr<AnsDialogHostClient> & hostClient,sptr<IRemoteObject> & callerToken)184 ErrCode NotificationHelper::RequestEnableNotification(std::string &deviceId,
185 sptr<AnsDialogHostClient> &hostClient,
186 sptr<IRemoteObject> &callerToken)
187 {
188 return DelayedSingleton<AnsNotification>::GetInstance()->RequestEnableNotification(
189 deviceId, hostClient, callerToken);
190 }
191
HasNotificationPolicyAccessPermission(bool & hasPermission)192 ErrCode NotificationHelper::HasNotificationPolicyAccessPermission(bool &hasPermission)
193 {
194 return DelayedSingleton<AnsNotification>::GetInstance()->HasNotificationPolicyAccessPermission(hasPermission);
195 }
196
GetBundleImportance(NotificationSlot::NotificationLevel & importance)197 ErrCode NotificationHelper::GetBundleImportance(NotificationSlot::NotificationLevel &importance)
198 {
199 return DelayedSingleton<AnsNotification>::GetInstance()->GetBundleImportance(importance);
200 }
201
SubscribeNotification(const NotificationSubscriber & subscriber)202 ErrCode NotificationHelper::SubscribeNotification(const NotificationSubscriber &subscriber)
203 {
204 return DelayedSingleton<AnsNotification>::GetInstance()->SubscribeNotification(subscriber);
205 }
206
SubscribeNotification(const std::shared_ptr<NotificationSubscriber> & subscriber)207 ErrCode NotificationHelper::SubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber)
208 {
209 return DelayedSingleton<AnsNotification>::GetInstance()->SubscribeNotification(subscriber, nullptr);
210 }
211
SubscribeNotificationSelf(const NotificationSubscriber & subscriber)212 ErrCode NotificationHelper::SubscribeNotificationSelf(const NotificationSubscriber &subscriber)
213 {
214 return DelayedSingleton<AnsNotification>::GetInstance()->SubscribeNotificationSelf(subscriber);
215 }
216
SubscribeNotificationSelf(const std::shared_ptr<NotificationSubscriber> & subscriber)217 ErrCode NotificationHelper::SubscribeNotificationSelf(const std::shared_ptr<NotificationSubscriber> &subscriber)
218 {
219 return DelayedSingleton<AnsNotification>::GetInstance()->SubscribeNotificationSelf(subscriber);
220 }
221
SubscribeLocalLiveViewNotification(const NotificationLocalLiveViewSubscriber & subscriber,const bool isNative)222 ErrCode NotificationHelper::SubscribeLocalLiveViewNotification(const NotificationLocalLiveViewSubscriber &subscriber,
223 const bool isNative)
224 {
225 return DelayedSingleton<AnsNotification>::GetInstance()->SubscribeLocalLiveViewNotification(subscriber, isNative);
226 }
227
SubscribeNotification(const NotificationSubscriber & subscriber,const NotificationSubscribeInfo & subscribeInfo)228 ErrCode NotificationHelper::SubscribeNotification(
229 const NotificationSubscriber &subscriber, const NotificationSubscribeInfo &subscribeInfo)
230 {
231 return DelayedSingleton<AnsNotification>::GetInstance()->SubscribeNotification(subscriber, subscribeInfo);
232 }
233
SubscribeNotification(const std::shared_ptr<NotificationSubscriber> & subscriber,const sptr<NotificationSubscribeInfo> & subscribeInfo)234 ErrCode NotificationHelper::SubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber,
235 const sptr<NotificationSubscribeInfo> &subscribeInfo)
236 {
237 return DelayedSingleton<AnsNotification>::GetInstance()->SubscribeNotification(subscriber, subscribeInfo);
238 }
239
UnSubscribeNotification(NotificationSubscriber & subscriber)240 ErrCode NotificationHelper::UnSubscribeNotification(NotificationSubscriber &subscriber)
241 {
242 return DelayedSingleton<AnsNotification>::GetInstance()->UnSubscribeNotification(subscriber);
243 }
244
UnSubscribeNotification(const std::shared_ptr<NotificationSubscriber> & subscriber)245 ErrCode NotificationHelper::UnSubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber)
246 {
247 return DelayedSingleton<AnsNotification>::GetInstance()->UnSubscribeNotification(subscriber);
248 }
249
UnSubscribeNotification(NotificationSubscriber & subscriber,NotificationSubscribeInfo subscribeInfo)250 ErrCode NotificationHelper::UnSubscribeNotification(
251 NotificationSubscriber &subscriber, NotificationSubscribeInfo subscribeInfo)
252 {
253 return DelayedSingleton<AnsNotification>::GetInstance()->UnSubscribeNotification(subscriber, subscribeInfo);
254 }
255
UnSubscribeNotification(const std::shared_ptr<NotificationSubscriber> & subscriber,const sptr<NotificationSubscribeInfo> & subscribeInfo)256 ErrCode NotificationHelper::UnSubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber,
257 const sptr<NotificationSubscribeInfo> &subscribeInfo)
258 {
259 return DelayedSingleton<AnsNotification>::GetInstance()->UnSubscribeNotification(subscriber, subscribeInfo);
260 }
261
TriggerLocalLiveView(const NotificationBundleOption & bundleOption,const int32_t notificationId,const NotificationButtonOption & buttonOption)262 ErrCode NotificationHelper::TriggerLocalLiveView(const NotificationBundleOption &bundleOption,
263 const int32_t notificationId, const NotificationButtonOption &buttonOption)
264 {
265 return DelayedSingleton<AnsNotification>::GetInstance()->TriggerLocalLiveView(
266 bundleOption, notificationId, buttonOption);
267 }
268
RemoveNotification(const std::string & key,int32_t removeReason)269 ErrCode NotificationHelper::RemoveNotification(const std::string &key, int32_t removeReason)
270 {
271 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveNotification(key, removeReason);
272 }
273
RemoveNotification(const NotificationBundleOption & bundleOption,const int32_t notificationId,const std::string & label,int32_t removeReason)274 ErrCode NotificationHelper::RemoveNotification(const NotificationBundleOption &bundleOption,
275 const int32_t notificationId, const std::string &label, int32_t removeReason)
276 {
277 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveNotification(bundleOption,
278 notificationId, label, removeReason);
279 }
280
RemoveAllNotifications(const NotificationBundleOption & bundleOption)281 ErrCode NotificationHelper::RemoveAllNotifications(const NotificationBundleOption &bundleOption)
282 {
283 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveAllNotifications(bundleOption);
284 }
285
RemoveNotifications(const std::vector<std::string> hashcodes,int32_t removeReason)286 ErrCode NotificationHelper::RemoveNotifications(const std::vector<std::string> hashcodes, int32_t removeReason)
287 {
288 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveNotifications(hashcodes, removeReason);
289 }
290
RemoveNotificationsByBundle(const NotificationBundleOption & bundleOption)291 ErrCode NotificationHelper::RemoveNotificationsByBundle(const NotificationBundleOption &bundleOption)
292 {
293 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveNotificationsByBundle(bundleOption);
294 }
295
RemoveNotifications()296 ErrCode NotificationHelper::RemoveNotifications()
297 {
298 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveNotifications();
299 }
300
GetNotificationSlotsForBundle(const NotificationBundleOption & bundleOption,std::vector<sptr<NotificationSlot>> & slots)301 ErrCode NotificationHelper::GetNotificationSlotsForBundle(
302 const NotificationBundleOption &bundleOption, std::vector<sptr<NotificationSlot>> &slots)
303 {
304 return DelayedSingleton<AnsNotification>::GetInstance()->GetNotificationSlotsForBundle(bundleOption, slots);
305 }
306
GetNotificationSlotForBundle(const NotificationBundleOption & bundleOption,const NotificationConstant::SlotType & slotType,sptr<NotificationSlot> & slot)307 ErrCode NotificationHelper::GetNotificationSlotForBundle(
308 const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType,
309 sptr<NotificationSlot> &slot)
310 {
311 return DelayedSingleton<AnsNotification>::GetInstance()->GetNotificationSlotForBundle(bundleOption, slotType, slot);
312 }
313
UpdateNotificationSlots(const NotificationBundleOption & bundleOption,const std::vector<sptr<NotificationSlot>> & slots)314 ErrCode NotificationHelper::UpdateNotificationSlots(
315 const NotificationBundleOption &bundleOption, const std::vector<sptr<NotificationSlot>> &slots)
316 {
317 return DelayedSingleton<AnsNotification>::GetInstance()->UpdateNotificationSlots(bundleOption, slots);
318 }
319
GetAllActiveNotifications(std::vector<sptr<Notification>> & notification)320 ErrCode NotificationHelper::GetAllActiveNotifications(std::vector<sptr<Notification>> ¬ification)
321 {
322 return DelayedSingleton<AnsNotification>::GetInstance()->GetAllActiveNotifications(notification);
323 }
324
GetAllActiveNotifications(const std::vector<std::string> key,std::vector<sptr<Notification>> & notification)325 ErrCode NotificationHelper::GetAllActiveNotifications(
326 const std::vector<std::string> key, std::vector<sptr<Notification>> ¬ification)
327 {
328 return DelayedSingleton<AnsNotification>::GetInstance()->GetAllActiveNotifications(key, notification);
329 }
330
GetActiveNotificationByFilter(const LiveViewFilter & filter,sptr<NotificationRequest> & request)331 ErrCode NotificationHelper::GetActiveNotificationByFilter(
332 const LiveViewFilter &filter, sptr<NotificationRequest> &request)
333 {
334 return DelayedSingleton<AnsNotification>::GetInstance()->GetActiveNotificationByFilter(filter, request);
335 }
336
IsAllowedNotify(const NotificationBundleOption & bundleOption,bool & allowed)337 ErrCode NotificationHelper::IsAllowedNotify(const NotificationBundleOption &bundleOption, bool &allowed)
338 {
339 return DelayedSingleton<AnsNotification>::GetInstance()->IsAllowedNotify(bundleOption, allowed);
340 }
341
SetNotificationsEnabledForAllBundles(const std::string & deviceId,bool enabled)342 ErrCode NotificationHelper::SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled)
343 {
344 return DelayedSingleton<AnsNotification>::GetInstance()->SetNotificationsEnabledForAllBundles(deviceId, enabled);
345 }
346
SetNotificationsEnabledForDefaultBundle(const std::string & deviceId,bool enabled)347 ErrCode NotificationHelper::SetNotificationsEnabledForDefaultBundle(const std::string &deviceId, bool enabled)
348 {
349 return DelayedSingleton<AnsNotification>::GetInstance()->SetNotificationsEnabledForDefaultBundle(deviceId, enabled);
350 }
351
SetNotificationsEnabledForSpecifiedBundle(const NotificationBundleOption & bundleOption,std::string & deviceId,bool enabled)352 ErrCode NotificationHelper::SetNotificationsEnabledForSpecifiedBundle(
353 const NotificationBundleOption &bundleOption, std::string &deviceId, bool enabled)
354 {
355 return DelayedSingleton<AnsNotification>::GetInstance()->SetNotificationsEnabledForSpecifiedBundle(
356 bundleOption, deviceId, enabled);
357 }
358
SetShowBadgeEnabledForBundle(const NotificationBundleOption & bundleOption,bool enabled)359 ErrCode NotificationHelper::SetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool enabled)
360 {
361 return DelayedSingleton<AnsNotification>::GetInstance()->SetShowBadgeEnabledForBundle(bundleOption, enabled);
362 }
363
GetShowBadgeEnabledForBundle(const NotificationBundleOption & bundleOption,bool & enabled)364 ErrCode NotificationHelper::GetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool &enabled)
365 {
366 return DelayedSingleton<AnsNotification>::GetInstance()->GetShowBadgeEnabledForBundle(bundleOption, enabled);
367 }
368
GetShowBadgeEnabled(bool & enabled)369 ErrCode NotificationHelper::GetShowBadgeEnabled(bool &enabled)
370 {
371 return DelayedSingleton<AnsNotification>::GetInstance()->GetShowBadgeEnabled(enabled);
372 }
373
CancelGroup(const std::string & groupName)374 ErrCode NotificationHelper::CancelGroup(const std::string &groupName)
375 {
376 return DelayedSingleton<AnsNotification>::GetInstance()->CancelGroup(groupName);
377 }
378
RemoveGroupByBundle(const NotificationBundleOption & bundleOption,const std::string & groupName)379 ErrCode NotificationHelper::RemoveGroupByBundle(
380 const NotificationBundleOption &bundleOption, const std::string &groupName)
381 {
382 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveGroupByBundle(bundleOption, groupName);
383 }
384
SetDoNotDisturbDate(const NotificationDoNotDisturbDate & doNotDisturbDate)385 ErrCode NotificationHelper::SetDoNotDisturbDate(const NotificationDoNotDisturbDate &doNotDisturbDate)
386 {
387 return DelayedSingleton<AnsNotification>::GetInstance()->SetDoNotDisturbDate(doNotDisturbDate);
388 }
389
GetDoNotDisturbDate(NotificationDoNotDisturbDate & doNotDisturbDate)390 ErrCode NotificationHelper::GetDoNotDisturbDate(NotificationDoNotDisturbDate &doNotDisturbDate)
391 {
392 return DelayedSingleton<AnsNotification>::GetInstance()->GetDoNotDisturbDate(doNotDisturbDate);
393 }
394
AddDoNotDisturbProfiles(const std::vector<sptr<NotificationDoNotDisturbProfile>> & profiles)395 ErrCode NotificationHelper::AddDoNotDisturbProfiles(const std::vector<sptr<NotificationDoNotDisturbProfile>> &profiles)
396 {
397 return DelayedSingleton<AnsNotification>::GetInstance()->AddDoNotDisturbProfiles(profiles);
398 }
399
RemoveDoNotDisturbProfiles(const std::vector<sptr<NotificationDoNotDisturbProfile>> & profiles)400 ErrCode NotificationHelper::RemoveDoNotDisturbProfiles(
401 const std::vector<sptr<NotificationDoNotDisturbProfile>> &profiles)
402 {
403 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveDoNotDisturbProfiles(profiles);
404 }
405
DoesSupportDoNotDisturbMode(bool & doesSupport)406 ErrCode NotificationHelper::DoesSupportDoNotDisturbMode(bool &doesSupport)
407 {
408 return DelayedSingleton<AnsNotification>::GetInstance()->DoesSupportDoNotDisturbMode(doesSupport);
409 }
410
IsNeedSilentInDoNotDisturbMode(const std::string & phoneNumber,int32_t callerType)411 ErrCode NotificationHelper::IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType)
412 {
413 return DelayedSingleton<AnsNotification>::GetInstance()->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType);
414 }
415
IsDistributedEnabled(bool & enabled)416 ErrCode NotificationHelper::IsDistributedEnabled(bool &enabled)
417 {
418 return DelayedSingleton<AnsNotification>::GetInstance()->IsDistributedEnabled(enabled);
419 }
420
EnableDistributed(const bool enabled)421 ErrCode NotificationHelper::EnableDistributed(const bool enabled)
422 {
423 return DelayedSingleton<AnsNotification>::GetInstance()->EnableDistributed(enabled);
424 }
425
EnableDistributedByBundle(const NotificationBundleOption & bundleOption,const bool enabled)426 ErrCode NotificationHelper::EnableDistributedByBundle(const NotificationBundleOption &bundleOption, const bool enabled)
427 {
428 return DelayedSingleton<AnsNotification>::GetInstance()->EnableDistributedByBundle(bundleOption, enabled);
429 }
430
EnableDistributedSelf(const bool enabled)431 ErrCode NotificationHelper::EnableDistributedSelf(const bool enabled)
432 {
433 return DelayedSingleton<AnsNotification>::GetInstance()->EnableDistributedSelf(enabled);
434 }
435
IsDistributedEnableByBundle(const NotificationBundleOption & bundleOption,bool & enabled)436 ErrCode NotificationHelper::IsDistributedEnableByBundle(const NotificationBundleOption &bundleOption, bool &enabled)
437 {
438 return DelayedSingleton<AnsNotification>::GetInstance()->IsDistributedEnableByBundle(bundleOption, enabled);
439 }
440
GetDeviceRemindType(NotificationConstant::RemindType & remindType)441 ErrCode NotificationHelper::GetDeviceRemindType(NotificationConstant::RemindType &remindType)
442 {
443 return DelayedSingleton<AnsNotification>::GetInstance()->GetDeviceRemindType(remindType);
444 }
445
PublishContinuousTaskNotification(const NotificationRequest & request)446 ErrCode NotificationHelper::PublishContinuousTaskNotification(const NotificationRequest &request)
447 {
448 return DelayedSingleton<AnsNotification>::GetInstance()->PublishContinuousTaskNotification(request);
449 }
450
CancelContinuousTaskNotification(const std::string & label,int32_t notificationId)451 ErrCode NotificationHelper::CancelContinuousTaskNotification(const std::string &label, int32_t notificationId)
452 {
453 return DelayedSingleton<AnsNotification>::GetInstance()->CancelContinuousTaskNotification(label, notificationId);
454 }
455
IsSupportTemplate(const std::string & templateName,bool & support)456 ErrCode NotificationHelper::IsSupportTemplate(const std::string &templateName, bool &support)
457 {
458 return DelayedSingleton<AnsNotification>::GetInstance()->IsSupportTemplate(templateName, support);
459 }
460
IsAllowedNotify(const int32_t & userId,bool & allowed)461 ErrCode NotificationHelper::IsAllowedNotify(const int32_t &userId, bool &allowed)
462 {
463 return DelayedSingleton<AnsNotification>::GetInstance()->IsAllowedNotify(userId, allowed);
464 }
465
SetNotificationsEnabledForAllBundles(const int32_t & userId,bool enabled)466 ErrCode NotificationHelper::SetNotificationsEnabledForAllBundles(const int32_t &userId, bool enabled)
467 {
468 return DelayedSingleton<AnsNotification>::GetInstance()->SetNotificationsEnabledForAllBundles(
469 userId, enabled);
470 }
471
RemoveNotifications(const int32_t & userId)472 ErrCode NotificationHelper::RemoveNotifications(const int32_t &userId)
473 {
474 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveNotifications(userId);
475 }
476
SetDoNotDisturbDate(const int32_t & userId,const NotificationDoNotDisturbDate & doNotDisturbDate)477 ErrCode NotificationHelper::SetDoNotDisturbDate(const int32_t &userId,
478 const NotificationDoNotDisturbDate &doNotDisturbDate)
479 {
480 return DelayedSingleton<AnsNotification>::GetInstance()->SetDoNotDisturbDate(userId, doNotDisturbDate);
481 }
482
GetDoNotDisturbDate(const int32_t & userId,NotificationDoNotDisturbDate & doNotDisturbDate)483 ErrCode NotificationHelper::GetDoNotDisturbDate(const int32_t &userId, NotificationDoNotDisturbDate &doNotDisturbDate)
484 {
485 return DelayedSingleton<AnsNotification>::GetInstance()->GetDoNotDisturbDate(userId, doNotDisturbDate);
486 }
487
SetEnabledForBundleSlot(const NotificationBundleOption & bundleOption,const NotificationConstant::SlotType & slotType,bool enabled,bool isForceControl)488 ErrCode NotificationHelper::SetEnabledForBundleSlot(const NotificationBundleOption &bundleOption,
489 const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl)
490 {
491 return DelayedSingleton<AnsNotification>::GetInstance()->SetEnabledForBundleSlot(bundleOption,
492 slotType, enabled, isForceControl);
493 }
494
GetEnabledForBundleSlot(const NotificationBundleOption & bundleOption,const NotificationConstant::SlotType & slotType,bool & enabled)495 ErrCode NotificationHelper::GetEnabledForBundleSlot(
496 const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType, bool &enabled)
497 {
498 return DelayedSingleton<AnsNotification>::GetInstance()->GetEnabledForBundleSlot(bundleOption, slotType, enabled);
499 }
500
GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType & slotType,bool & enabled)501 ErrCode NotificationHelper::GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled)
502 {
503 return DelayedSingleton<AnsNotification>::GetInstance()->GetEnabledForBundleSlotSelf(slotType, enabled);
504 }
505
SetSyncNotificationEnabledWithoutApp(const int32_t userId,const bool enabled)506 ErrCode NotificationHelper::SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled)
507 {
508 return DelayedSingleton<AnsNotification>::GetInstance()->SetSyncNotificationEnabledWithoutApp(
509 userId, enabled);
510 }
511
GetSyncNotificationEnabledWithoutApp(const int32_t userId,bool & enabled)512 ErrCode NotificationHelper::GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled)
513 {
514 return DelayedSingleton<AnsNotification>::GetInstance()->GetSyncNotificationEnabledWithoutApp(
515 userId, enabled);
516 }
517
SetBadgeNumber(int32_t badgeNumber)518 ErrCode NotificationHelper::SetBadgeNumber(int32_t badgeNumber)
519 {
520 return DelayedSingleton<AnsNotification>::GetInstance()->SetBadgeNumber(badgeNumber);
521 }
522
SetBadgeNumberByBundle(const NotificationBundleOption & bundleOption,int32_t badgeNumber)523 ErrCode NotificationHelper::SetBadgeNumberByBundle(const NotificationBundleOption &bundleOption, int32_t badgeNumber)
524 {
525 return DelayedSingleton<AnsNotification>::GetInstance()->SetBadgeNumberByBundle(bundleOption, badgeNumber);
526 }
527
GetAllNotificationEnabledBundles(std::vector<NotificationBundleOption> & bundleOption)528 ErrCode NotificationHelper::GetAllNotificationEnabledBundles(std::vector<NotificationBundleOption> &bundleOption)
529 {
530 return DelayedSingleton<AnsNotification>::GetInstance()->GetAllNotificationEnabledBundles(bundleOption);
531 }
532
RegisterPushCallback(const sptr<IRemoteObject> & pushCallback,const sptr<NotificationCheckRequest> & notificationCheckRequest)533 ErrCode NotificationHelper::RegisterPushCallback(const sptr<IRemoteObject> &pushCallback,
534 const sptr<NotificationCheckRequest> ¬ificationCheckRequest)
535 {
536 return DelayedSingleton<AnsNotification>::GetInstance()->RegisterPushCallback(pushCallback,
537 notificationCheckRequest);
538 }
539
UnregisterPushCallback()540 ErrCode NotificationHelper::UnregisterPushCallback()
541 {
542 return DelayedSingleton<AnsNotification>::GetInstance()->UnregisterPushCallback();
543 }
544
SetDistributedEnabledByBundle(const NotificationBundleOption & bundleOption,const std::string & deviceType,const bool enabled)545 ErrCode NotificationHelper::SetDistributedEnabledByBundle(const NotificationBundleOption &bundleOption,
546 const std::string &deviceType, const bool enabled)
547 {
548 return DelayedSingleton<AnsNotification>::GetInstance()->SetDistributedEnabledByBundle(bundleOption,
549 deviceType, enabled);
550 }
551
IsDistributedEnabledByBundle(const NotificationBundleOption & bundleOption,const std::string & deviceType,bool & enabled)552 ErrCode NotificationHelper::IsDistributedEnabledByBundle(const NotificationBundleOption &bundleOption,
553 const std::string &deviceType, bool &enabled)
554 {
555 return DelayedSingleton<AnsNotification>::GetInstance()->IsDistributedEnabledByBundle(bundleOption,
556 deviceType, enabled);
557 }
558
SetSmartReminderEnabled(const std::string & deviceType,const bool enabled)559 ErrCode NotificationHelper::SetSmartReminderEnabled(const std::string &deviceType, const bool enabled)
560 {
561 return DelayedSingleton<AnsNotification>::GetInstance()->SetSmartReminderEnabled(deviceType, enabled);
562 }
563
IsSmartReminderEnabled(const std::string & deviceType,bool & enabled)564 ErrCode NotificationHelper::IsSmartReminderEnabled(const std::string &deviceType, bool &enabled)
565 {
566 return DelayedSingleton<AnsNotification>::GetInstance()->IsSmartReminderEnabled(deviceType, enabled);
567 }
568
CancelAsBundleWithAgent(const NotificationBundleOption & bundleOption,const int32_t id)569 ErrCode NotificationHelper::CancelAsBundleWithAgent(const NotificationBundleOption &bundleOption, const int32_t id)
570 {
571 return DelayedSingleton<AnsNotification>::GetInstance()->CancelAsBundleWithAgent(bundleOption, id);
572 }
573
SetAdditionConfig(const std::string & key,const std::string & value)574 ErrCode NotificationHelper::SetAdditionConfig(const std::string &key, const std::string &value)
575 {
576 return DelayedSingleton<AnsNotification>::GetInstance()->SetAdditionConfig(key, value);
577 }
578
SetTargetDeviceStatus(const std::string & deviceType,const uint32_t status)579 ErrCode NotificationHelper::SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status)
580 {
581 return DelayedSingleton<AnsNotification>::GetInstance()->SetTargetDeviceStatus(deviceType, status);
582 }
RegisterSwingCallback(const std::function<void (bool,int)> swingCbFunc)583 ErrCode NotificationHelper::RegisterSwingCallback(const std::function<void(bool, int)> swingCbFunc)
584 {
585 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED
586 return DelayedSingleton<AnsNotification>::GetInstance()->RegisterSwingCallback(swingCbFunc);
587 #else
588 return ERR_OK;
589 #endif
590 }
GetDoNotDisturbProfile(int32_t id,sptr<NotificationDoNotDisturbProfile> & profile)591 ErrCode NotificationHelper::GetDoNotDisturbProfile(int32_t id, sptr<NotificationDoNotDisturbProfile> &profile)
592 {
593 return DelayedSingleton<AnsNotification>::GetInstance()->GetDoNotDisturbProfile(id, profile);
594 }
595
UpdateNotificationTimerByUid(const int32_t uid,const bool isPaused)596 ErrCode NotificationHelper::UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused)
597 {
598 return DelayedSingleton<AnsNotification>::GetInstance()->UpdateNotificationTimerByUid(uid, isPaused);
599 }
600 } // namespace Notification
601 } // namespace OHOS
602