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