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,std::string instanceKey)76 ErrCode NotificationHelper::PublishNotification(const NotificationRequest &request,
77 std::string instanceKey)
78 {
79 return DelayedSingleton<AnsNotification>::GetInstance()->PublishNotification(
80 request, instanceKey);
81 }
82
PublishNotification(const std::string & label,const NotificationRequest & request,std::string instanceKey)83 ErrCode NotificationHelper::PublishNotification(const std::string &label,
84 const NotificationRequest &request, std::string instanceKey)
85 {
86 return DelayedSingleton<AnsNotification>::GetInstance()->PublishNotification(
87 label, request, instanceKey);
88 }
89
PublishNotificationForIndirectProxy(const NotificationRequest & request)90 ErrCode NotificationHelper::PublishNotificationForIndirectProxy(const NotificationRequest &request)
91 {
92 return DelayedSingleton<AnsNotification>::GetInstance()->PublishNotificationForIndirectProxy(request);
93 }
94
CancelNotification(int32_t notificationId,std::string instanceKey)95 ErrCode NotificationHelper::CancelNotification(int32_t notificationId, std::string instanceKey)
96 {
97 return DelayedSingleton<AnsNotification>::GetInstance()->CancelNotification(
98 notificationId, instanceKey);
99 }
100
CancelNotification(const std::string & label,int32_t notificationId,std::string instanceKey)101 ErrCode NotificationHelper::CancelNotification(const std::string &label, int32_t notificationId,
102 std::string instanceKey)
103 {
104 return DelayedSingleton<AnsNotification>::GetInstance()->CancelNotification(
105 label, notificationId, instanceKey);
106 }
107
CancelAllNotifications(std::string instanceKey)108 ErrCode NotificationHelper::CancelAllNotifications(std::string instanceKey)
109 {
110 return DelayedSingleton<AnsNotification>::GetInstance()->CancelAllNotifications(instanceKey);
111 }
112
CancelAsBundle(int32_t notificationId,const std::string & representativeBundle,int32_t userId)113 ErrCode NotificationHelper::CancelAsBundle(
114 int32_t notificationId, const std::string &representativeBundle, int32_t userId)
115 {
116 return DelayedSingleton<AnsNotification>::GetInstance()->CancelAsBundle(
117 notificationId, representativeBundle, userId);
118 }
119
CancelAsBundle(const NotificationBundleOption & bundleOption,int32_t notificationId)120 ErrCode NotificationHelper::CancelAsBundle(
121 const NotificationBundleOption &bundleOption, int32_t notificationId)
122 {
123 return DelayedSingleton<AnsNotification>::GetInstance()->CancelAsBundle(
124 bundleOption, notificationId);
125 }
126
GetActiveNotificationNums(uint64_t & num)127 ErrCode NotificationHelper::GetActiveNotificationNums(uint64_t &num)
128 {
129 return DelayedSingleton<AnsNotification>::GetInstance()->GetActiveNotificationNums(num);
130 }
131
GetActiveNotifications(std::vector<sptr<NotificationRequest>> & request,std::string instanceKey)132 ErrCode NotificationHelper::GetActiveNotifications(
133 std::vector<sptr<NotificationRequest>> &request, std::string instanceKey)
134 {
135 return DelayedSingleton<AnsNotification>::GetInstance()->GetActiveNotifications(
136 request, instanceKey);
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
RequestEnableNotification(const std::string bundleName,const int32_t uid)191 ErrCode NotificationHelper::RequestEnableNotification(const std::string bundleName, const int32_t uid)
192 {
193 return DelayedSingleton<AnsNotification>::GetInstance()->RequestEnableNotification(
194 bundleName, uid);
195 }
196
HasNotificationPolicyAccessPermission(bool & hasPermission)197 ErrCode NotificationHelper::HasNotificationPolicyAccessPermission(bool &hasPermission)
198 {
199 return DelayedSingleton<AnsNotification>::GetInstance()->HasNotificationPolicyAccessPermission(hasPermission);
200 }
201
GetBundleImportance(NotificationSlot::NotificationLevel & importance)202 ErrCode NotificationHelper::GetBundleImportance(NotificationSlot::NotificationLevel &importance)
203 {
204 return DelayedSingleton<AnsNotification>::GetInstance()->GetBundleImportance(importance);
205 }
206
SubscribeNotification(const NotificationSubscriber & subscriber)207 ErrCode NotificationHelper::SubscribeNotification(const NotificationSubscriber &subscriber)
208 {
209 return DelayedSingleton<AnsNotification>::GetInstance()->SubscribeNotification(subscriber);
210 }
211
SubscribeNotification(const std::shared_ptr<NotificationSubscriber> & subscriber)212 ErrCode NotificationHelper::SubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber)
213 {
214 return DelayedSingleton<AnsNotification>::GetInstance()->SubscribeNotification(subscriber, nullptr);
215 }
216
SubscribeNotificationSelf(const NotificationSubscriber & subscriber)217 ErrCode NotificationHelper::SubscribeNotificationSelf(const NotificationSubscriber &subscriber)
218 {
219 return DelayedSingleton<AnsNotification>::GetInstance()->SubscribeNotificationSelf(subscriber);
220 }
221
SubscribeNotificationSelf(const std::shared_ptr<NotificationSubscriber> & subscriber)222 ErrCode NotificationHelper::SubscribeNotificationSelf(const std::shared_ptr<NotificationSubscriber> &subscriber)
223 {
224 return DelayedSingleton<AnsNotification>::GetInstance()->SubscribeNotificationSelf(subscriber);
225 }
226
SubscribeLocalLiveViewNotification(const NotificationLocalLiveViewSubscriber & subscriber,const bool isNative)227 ErrCode NotificationHelper::SubscribeLocalLiveViewNotification(const NotificationLocalLiveViewSubscriber &subscriber,
228 const bool isNative)
229 {
230 return DelayedSingleton<AnsNotification>::GetInstance()->SubscribeLocalLiveViewNotification(subscriber, isNative);
231 }
232
SubscribeNotification(const NotificationSubscriber & subscriber,const NotificationSubscribeInfo & subscribeInfo)233 ErrCode NotificationHelper::SubscribeNotification(
234 const NotificationSubscriber &subscriber, const NotificationSubscribeInfo &subscribeInfo)
235 {
236 return DelayedSingleton<AnsNotification>::GetInstance()->SubscribeNotification(subscriber, subscribeInfo);
237 }
238
SubscribeNotification(const std::shared_ptr<NotificationSubscriber> & subscriber,const sptr<NotificationSubscribeInfo> & subscribeInfo)239 ErrCode NotificationHelper::SubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber,
240 const sptr<NotificationSubscribeInfo> &subscribeInfo)
241 {
242 return DelayedSingleton<AnsNotification>::GetInstance()->SubscribeNotification(subscriber, subscribeInfo);
243 }
244
UnSubscribeNotification(NotificationSubscriber & subscriber)245 ErrCode NotificationHelper::UnSubscribeNotification(NotificationSubscriber &subscriber)
246 {
247 return DelayedSingleton<AnsNotification>::GetInstance()->UnSubscribeNotification(subscriber);
248 }
249
UnSubscribeNotification(const std::shared_ptr<NotificationSubscriber> & subscriber)250 ErrCode NotificationHelper::UnSubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber)
251 {
252 return DelayedSingleton<AnsNotification>::GetInstance()->UnSubscribeNotification(subscriber);
253 }
254
UnSubscribeNotification(NotificationSubscriber & subscriber,NotificationSubscribeInfo subscribeInfo)255 ErrCode NotificationHelper::UnSubscribeNotification(
256 NotificationSubscriber &subscriber, NotificationSubscribeInfo subscribeInfo)
257 {
258 return DelayedSingleton<AnsNotification>::GetInstance()->UnSubscribeNotification(subscriber, subscribeInfo);
259 }
260
UnSubscribeNotification(const std::shared_ptr<NotificationSubscriber> & subscriber,const sptr<NotificationSubscribeInfo> & subscribeInfo)261 ErrCode NotificationHelper::UnSubscribeNotification(const std::shared_ptr<NotificationSubscriber> &subscriber,
262 const sptr<NotificationSubscribeInfo> &subscribeInfo)
263 {
264 return DelayedSingleton<AnsNotification>::GetInstance()->UnSubscribeNotification(subscriber, subscribeInfo);
265 }
266
TriggerLocalLiveView(const NotificationBundleOption & bundleOption,const int32_t notificationId,const NotificationButtonOption & buttonOption)267 ErrCode NotificationHelper::TriggerLocalLiveView(const NotificationBundleOption &bundleOption,
268 const int32_t notificationId, const NotificationButtonOption &buttonOption)
269 {
270 return DelayedSingleton<AnsNotification>::GetInstance()->TriggerLocalLiveView(
271 bundleOption, notificationId, buttonOption);
272 }
273
RemoveNotification(const std::string & key,int32_t removeReason)274 ErrCode NotificationHelper::RemoveNotification(const std::string &key, int32_t removeReason)
275 {
276 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveNotification(key, removeReason);
277 }
278
RemoveNotification(const NotificationBundleOption & bundleOption,const int32_t notificationId,const std::string & label,int32_t removeReason)279 ErrCode NotificationHelper::RemoveNotification(const NotificationBundleOption &bundleOption,
280 const int32_t notificationId, const std::string &label, int32_t removeReason)
281 {
282 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveNotification(bundleOption,
283 notificationId, label, removeReason);
284 }
285
RemoveAllNotifications(const NotificationBundleOption & bundleOption)286 ErrCode NotificationHelper::RemoveAllNotifications(const NotificationBundleOption &bundleOption)
287 {
288 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveAllNotifications(bundleOption);
289 }
290
RemoveNotifications(const std::vector<std::string> hashcodes,int32_t removeReason)291 ErrCode NotificationHelper::RemoveNotifications(const std::vector<std::string> hashcodes, int32_t removeReason)
292 {
293 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveNotifications(hashcodes, removeReason);
294 }
295
RemoveNotificationsByBundle(const NotificationBundleOption & bundleOption)296 ErrCode NotificationHelper::RemoveNotificationsByBundle(const NotificationBundleOption &bundleOption)
297 {
298 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveNotificationsByBundle(bundleOption);
299 }
300
RemoveNotifications()301 ErrCode NotificationHelper::RemoveNotifications()
302 {
303 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveNotifications();
304 }
305
GetNotificationSlotsForBundle(const NotificationBundleOption & bundleOption,std::vector<sptr<NotificationSlot>> & slots)306 ErrCode NotificationHelper::GetNotificationSlotsForBundle(
307 const NotificationBundleOption &bundleOption, std::vector<sptr<NotificationSlot>> &slots)
308 {
309 return DelayedSingleton<AnsNotification>::GetInstance()->GetNotificationSlotsForBundle(bundleOption, slots);
310 }
311
GetNotificationSlotForBundle(const NotificationBundleOption & bundleOption,const NotificationConstant::SlotType & slotType,sptr<NotificationSlot> & slot)312 ErrCode NotificationHelper::GetNotificationSlotForBundle(
313 const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType,
314 sptr<NotificationSlot> &slot)
315 {
316 return DelayedSingleton<AnsNotification>::GetInstance()->GetNotificationSlotForBundle(bundleOption, slotType, slot);
317 }
318
UpdateNotificationSlots(const NotificationBundleOption & bundleOption,const std::vector<sptr<NotificationSlot>> & slots)319 ErrCode NotificationHelper::UpdateNotificationSlots(
320 const NotificationBundleOption &bundleOption, const std::vector<sptr<NotificationSlot>> &slots)
321 {
322 return DelayedSingleton<AnsNotification>::GetInstance()->UpdateNotificationSlots(bundleOption, slots);
323 }
324
GetAllActiveNotifications(std::vector<sptr<Notification>> & notification)325 ErrCode NotificationHelper::GetAllActiveNotifications(std::vector<sptr<Notification>> ¬ification)
326 {
327 return DelayedSingleton<AnsNotification>::GetInstance()->GetAllActiveNotifications(notification);
328 }
329
GetAllNotificationsBySlotType(std::vector<sptr<Notification>> & notifications,const NotificationConstant::SlotType slotType)330 ErrCode NotificationHelper::GetAllNotificationsBySlotType(std::vector<sptr<Notification>> ¬ifications,
331 const NotificationConstant::SlotType slotType)
332 {
333 return DelayedSingleton<AnsNotification>::GetInstance()->GetAllNotificationsBySlotType(notifications, slotType);
334 }
335
GetAllActiveNotifications(const std::vector<std::string> key,std::vector<sptr<Notification>> & notification)336 ErrCode NotificationHelper::GetAllActiveNotifications(
337 const std::vector<std::string> key, std::vector<sptr<Notification>> ¬ification)
338 {
339 return DelayedSingleton<AnsNotification>::GetInstance()->GetAllActiveNotifications(key, notification);
340 }
341
GetActiveNotificationByFilter(const LiveViewFilter & filter,sptr<NotificationRequest> & request)342 ErrCode NotificationHelper::GetActiveNotificationByFilter(
343 const LiveViewFilter &filter, sptr<NotificationRequest> &request)
344 {
345 return DelayedSingleton<AnsNotification>::GetInstance()->GetActiveNotificationByFilter(filter, request);
346 }
347
IsAllowedNotify(const NotificationBundleOption & bundleOption,bool & allowed)348 ErrCode NotificationHelper::IsAllowedNotify(const NotificationBundleOption &bundleOption, bool &allowed)
349 {
350 return DelayedSingleton<AnsNotification>::GetInstance()->IsAllowedNotify(bundleOption, allowed);
351 }
352
SetNotificationsEnabledForAllBundles(const std::string & deviceId,bool enabled)353 ErrCode NotificationHelper::SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled)
354 {
355 return DelayedSingleton<AnsNotification>::GetInstance()->SetNotificationsEnabledForAllBundles(deviceId, enabled);
356 }
357
SetNotificationsEnabledForDefaultBundle(const std::string & deviceId,bool enabled)358 ErrCode NotificationHelper::SetNotificationsEnabledForDefaultBundle(const std::string &deviceId, bool enabled)
359 {
360 return DelayedSingleton<AnsNotification>::GetInstance()->SetNotificationsEnabledForDefaultBundle(deviceId, enabled);
361 }
362
SetNotificationsEnabledForSpecifiedBundle(const NotificationBundleOption & bundleOption,std::string & deviceId,bool enabled)363 ErrCode NotificationHelper::SetNotificationsEnabledForSpecifiedBundle(
364 const NotificationBundleOption &bundleOption, std::string &deviceId, bool enabled)
365 {
366 return DelayedSingleton<AnsNotification>::GetInstance()->SetNotificationsEnabledForSpecifiedBundle(
367 bundleOption, deviceId, enabled);
368 }
369
SetShowBadgeEnabledForBundle(const NotificationBundleOption & bundleOption,bool enabled)370 ErrCode NotificationHelper::SetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool enabled)
371 {
372 return DelayedSingleton<AnsNotification>::GetInstance()->SetShowBadgeEnabledForBundle(bundleOption, enabled);
373 }
374
GetShowBadgeEnabledForBundle(const NotificationBundleOption & bundleOption,bool & enabled)375 ErrCode NotificationHelper::GetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool &enabled)
376 {
377 return DelayedSingleton<AnsNotification>::GetInstance()->GetShowBadgeEnabledForBundle(bundleOption, enabled);
378 }
379
GetShowBadgeEnabled(bool & enabled)380 ErrCode NotificationHelper::GetShowBadgeEnabled(bool &enabled)
381 {
382 return DelayedSingleton<AnsNotification>::GetInstance()->GetShowBadgeEnabled(enabled);
383 }
384
CancelGroup(const std::string & groupName,std::string instanceKey)385 ErrCode NotificationHelper::CancelGroup(const std::string &groupName, std::string instanceKey)
386 {
387 return DelayedSingleton<AnsNotification>::GetInstance()->CancelGroup(
388 groupName, instanceKey);
389 }
390
RemoveGroupByBundle(const NotificationBundleOption & bundleOption,const std::string & groupName)391 ErrCode NotificationHelper::RemoveGroupByBundle(
392 const NotificationBundleOption &bundleOption, const std::string &groupName)
393 {
394 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveGroupByBundle(bundleOption, groupName);
395 }
396
SetDoNotDisturbDate(const NotificationDoNotDisturbDate & doNotDisturbDate)397 ErrCode NotificationHelper::SetDoNotDisturbDate(const NotificationDoNotDisturbDate &doNotDisturbDate)
398 {
399 return DelayedSingleton<AnsNotification>::GetInstance()->SetDoNotDisturbDate(doNotDisturbDate);
400 }
401
GetDoNotDisturbDate(NotificationDoNotDisturbDate & doNotDisturbDate)402 ErrCode NotificationHelper::GetDoNotDisturbDate(NotificationDoNotDisturbDate &doNotDisturbDate)
403 {
404 return DelayedSingleton<AnsNotification>::GetInstance()->GetDoNotDisturbDate(doNotDisturbDate);
405 }
406
AddDoNotDisturbProfiles(const std::vector<sptr<NotificationDoNotDisturbProfile>> & profiles)407 ErrCode NotificationHelper::AddDoNotDisturbProfiles(const std::vector<sptr<NotificationDoNotDisturbProfile>> &profiles)
408 {
409 return DelayedSingleton<AnsNotification>::GetInstance()->AddDoNotDisturbProfiles(profiles);
410 }
411
RemoveDoNotDisturbProfiles(const std::vector<sptr<NotificationDoNotDisturbProfile>> & profiles)412 ErrCode NotificationHelper::RemoveDoNotDisturbProfiles(
413 const std::vector<sptr<NotificationDoNotDisturbProfile>> &profiles)
414 {
415 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveDoNotDisturbProfiles(profiles);
416 }
417
DoesSupportDoNotDisturbMode(bool & doesSupport)418 ErrCode NotificationHelper::DoesSupportDoNotDisturbMode(bool &doesSupport)
419 {
420 return DelayedSingleton<AnsNotification>::GetInstance()->DoesSupportDoNotDisturbMode(doesSupport);
421 }
422
IsNeedSilentInDoNotDisturbMode(const std::string & phoneNumber,int32_t callerType)423 ErrCode NotificationHelper::IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType)
424 {
425 return DelayedSingleton<AnsNotification>::GetInstance()->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType);
426 }
427
IsDistributedEnabled(bool & enabled)428 ErrCode NotificationHelper::IsDistributedEnabled(bool &enabled)
429 {
430 return DelayedSingleton<AnsNotification>::GetInstance()->IsDistributedEnabled(enabled);
431 }
432
EnableDistributed(const bool enabled)433 ErrCode NotificationHelper::EnableDistributed(const bool enabled)
434 {
435 return DelayedSingleton<AnsNotification>::GetInstance()->EnableDistributed(enabled);
436 }
437
EnableDistributedByBundle(const NotificationBundleOption & bundleOption,const bool enabled)438 ErrCode NotificationHelper::EnableDistributedByBundle(const NotificationBundleOption &bundleOption, const bool enabled)
439 {
440 return DelayedSingleton<AnsNotification>::GetInstance()->EnableDistributedByBundle(bundleOption, enabled);
441 }
442
EnableDistributedSelf(const bool enabled)443 ErrCode NotificationHelper::EnableDistributedSelf(const bool enabled)
444 {
445 return DelayedSingleton<AnsNotification>::GetInstance()->EnableDistributedSelf(enabled);
446 }
447
IsDistributedEnableByBundle(const NotificationBundleOption & bundleOption,bool & enabled)448 ErrCode NotificationHelper::IsDistributedEnableByBundle(const NotificationBundleOption &bundleOption, bool &enabled)
449 {
450 return DelayedSingleton<AnsNotification>::GetInstance()->IsDistributedEnableByBundle(bundleOption, enabled);
451 }
452
GetDeviceRemindType(NotificationConstant::RemindType & remindType)453 ErrCode NotificationHelper::GetDeviceRemindType(NotificationConstant::RemindType &remindType)
454 {
455 return DelayedSingleton<AnsNotification>::GetInstance()->GetDeviceRemindType(remindType);
456 }
457
PublishContinuousTaskNotification(const NotificationRequest & request)458 ErrCode NotificationHelper::PublishContinuousTaskNotification(const NotificationRequest &request)
459 {
460 return DelayedSingleton<AnsNotification>::GetInstance()->PublishContinuousTaskNotification(request);
461 }
462
CancelContinuousTaskNotification(const std::string & label,int32_t notificationId)463 ErrCode NotificationHelper::CancelContinuousTaskNotification(const std::string &label, int32_t notificationId)
464 {
465 return DelayedSingleton<AnsNotification>::GetInstance()->CancelContinuousTaskNotification(label, notificationId);
466 }
467
IsSupportTemplate(const std::string & templateName,bool & support)468 ErrCode NotificationHelper::IsSupportTemplate(const std::string &templateName, bool &support)
469 {
470 return DelayedSingleton<AnsNotification>::GetInstance()->IsSupportTemplate(templateName, support);
471 }
472
IsAllowedNotify(const int32_t & userId,bool & allowed)473 ErrCode NotificationHelper::IsAllowedNotify(const int32_t &userId, bool &allowed)
474 {
475 return DelayedSingleton<AnsNotification>::GetInstance()->IsAllowedNotify(userId, allowed);
476 }
477
SetNotificationsEnabledForAllBundles(const int32_t & userId,bool enabled)478 ErrCode NotificationHelper::SetNotificationsEnabledForAllBundles(const int32_t &userId, bool enabled)
479 {
480 return DelayedSingleton<AnsNotification>::GetInstance()->SetNotificationsEnabledForAllBundles(
481 userId, enabled);
482 }
483
RemoveNotifications(const int32_t & userId)484 ErrCode NotificationHelper::RemoveNotifications(const int32_t &userId)
485 {
486 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveNotifications(userId);
487 }
488
SetDoNotDisturbDate(const int32_t & userId,const NotificationDoNotDisturbDate & doNotDisturbDate)489 ErrCode NotificationHelper::SetDoNotDisturbDate(const int32_t &userId,
490 const NotificationDoNotDisturbDate &doNotDisturbDate)
491 {
492 return DelayedSingleton<AnsNotification>::GetInstance()->SetDoNotDisturbDate(userId, doNotDisturbDate);
493 }
494
GetDoNotDisturbDate(const int32_t & userId,NotificationDoNotDisturbDate & doNotDisturbDate)495 ErrCode NotificationHelper::GetDoNotDisturbDate(const int32_t &userId, NotificationDoNotDisturbDate &doNotDisturbDate)
496 {
497 return DelayedSingleton<AnsNotification>::GetInstance()->GetDoNotDisturbDate(userId, doNotDisturbDate);
498 }
499
SetEnabledForBundleSlot(const NotificationBundleOption & bundleOption,const NotificationConstant::SlotType & slotType,bool enabled,bool isForceControl)500 ErrCode NotificationHelper::SetEnabledForBundleSlot(const NotificationBundleOption &bundleOption,
501 const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl)
502 {
503 return DelayedSingleton<AnsNotification>::GetInstance()->SetEnabledForBundleSlot(bundleOption,
504 slotType, enabled, isForceControl);
505 }
506
GetEnabledForBundleSlot(const NotificationBundleOption & bundleOption,const NotificationConstant::SlotType & slotType,bool & enabled)507 ErrCode NotificationHelper::GetEnabledForBundleSlot(
508 const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType, bool &enabled)
509 {
510 return DelayedSingleton<AnsNotification>::GetInstance()->GetEnabledForBundleSlot(bundleOption, slotType, enabled);
511 }
512
GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType & slotType,bool & enabled)513 ErrCode NotificationHelper::GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled)
514 {
515 return DelayedSingleton<AnsNotification>::GetInstance()->GetEnabledForBundleSlotSelf(slotType, enabled);
516 }
517
SetSyncNotificationEnabledWithoutApp(const int32_t userId,const bool enabled)518 ErrCode NotificationHelper::SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled)
519 {
520 return DelayedSingleton<AnsNotification>::GetInstance()->SetSyncNotificationEnabledWithoutApp(
521 userId, enabled);
522 }
523
GetSyncNotificationEnabledWithoutApp(const int32_t userId,bool & enabled)524 ErrCode NotificationHelper::GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled)
525 {
526 return DelayedSingleton<AnsNotification>::GetInstance()->GetSyncNotificationEnabledWithoutApp(
527 userId, enabled);
528 }
529
SetBadgeNumber(int32_t badgeNumber,std::string instanceKey)530 ErrCode NotificationHelper::SetBadgeNumber(int32_t badgeNumber, std::string instanceKey)
531 {
532 return DelayedSingleton<AnsNotification>::GetInstance()->SetBadgeNumber(badgeNumber, instanceKey);
533 }
534
SetBadgeNumberByBundle(const NotificationBundleOption & bundleOption,int32_t badgeNumber)535 ErrCode NotificationHelper::SetBadgeNumberByBundle(const NotificationBundleOption &bundleOption, int32_t badgeNumber)
536 {
537 return DelayedSingleton<AnsNotification>::GetInstance()->SetBadgeNumberByBundle(bundleOption, badgeNumber);
538 }
539
SetBadgeNumberForDhByBundle(const NotificationBundleOption & bundleOption,int32_t badgeNumber)540 ErrCode NotificationHelper::SetBadgeNumberForDhByBundle(
541 const NotificationBundleOption &bundleOption, int32_t badgeNumber)
542 {
543 return DelayedSingleton<AnsNotification>::GetInstance()->SetBadgeNumberForDhByBundle(bundleOption, badgeNumber);
544 }
545
GetAllNotificationEnabledBundles(std::vector<NotificationBundleOption> & bundleOption)546 ErrCode NotificationHelper::GetAllNotificationEnabledBundles(std::vector<NotificationBundleOption> &bundleOption)
547 {
548 return DelayedSingleton<AnsNotification>::GetInstance()->GetAllNotificationEnabledBundles(bundleOption);
549 }
550
GetAllLiveViewEnabledBundles(std::vector<NotificationBundleOption> & bundleOption)551 ErrCode NotificationHelper::GetAllLiveViewEnabledBundles(std::vector<NotificationBundleOption> &bundleOption)
552 {
553 return DelayedSingleton<AnsNotification>::GetInstance()->GetAllLiveViewEnabledBundles(bundleOption);
554 }
555
GetAllDistribuedEnabledBundles(const std::string & deviceType,std::vector<NotificationBundleOption> & bundleOption)556 ErrCode NotificationHelper::GetAllDistribuedEnabledBundles(const std::string& deviceType,
557 std::vector<NotificationBundleOption> &bundleOption)
558 {
559 return DelayedSingleton<AnsNotification>::GetInstance()->GetAllDistribuedEnabledBundles(deviceType, bundleOption);
560 }
561
RegisterPushCallback(const sptr<IRemoteObject> & pushCallback,const sptr<NotificationCheckRequest> & notificationCheckRequest)562 ErrCode NotificationHelper::RegisterPushCallback(const sptr<IRemoteObject> &pushCallback,
563 const sptr<NotificationCheckRequest> ¬ificationCheckRequest)
564 {
565 return DelayedSingleton<AnsNotification>::GetInstance()->RegisterPushCallback(pushCallback,
566 notificationCheckRequest);
567 }
568
UnregisterPushCallback()569 ErrCode NotificationHelper::UnregisterPushCallback()
570 {
571 return DelayedSingleton<AnsNotification>::GetInstance()->UnregisterPushCallback();
572 }
573
SetDistributedEnabledByBundle(const NotificationBundleOption & bundleOption,const std::string & deviceType,const bool enabled)574 ErrCode NotificationHelper::SetDistributedEnabledByBundle(const NotificationBundleOption &bundleOption,
575 const std::string &deviceType, const bool enabled)
576 {
577 return DelayedSingleton<AnsNotification>::GetInstance()->SetDistributedEnabledByBundle(bundleOption,
578 deviceType, enabled);
579 }
580
IsDistributedEnabledByBundle(const NotificationBundleOption & bundleOption,const std::string & deviceType,bool & enabled)581 ErrCode NotificationHelper::IsDistributedEnabledByBundle(const NotificationBundleOption &bundleOption,
582 const std::string &deviceType, bool &enabled)
583 {
584 return DelayedSingleton<AnsNotification>::GetInstance()->IsDistributedEnabledByBundle(bundleOption,
585 deviceType, enabled);
586 }
587
SetSmartReminderEnabled(const std::string & deviceType,const bool enabled)588 ErrCode NotificationHelper::SetSmartReminderEnabled(const std::string &deviceType, const bool enabled)
589 {
590 return DelayedSingleton<AnsNotification>::GetInstance()->SetSmartReminderEnabled(deviceType, enabled);
591 }
592
IsSmartReminderEnabled(const std::string & deviceType,bool & enabled)593 ErrCode NotificationHelper::IsSmartReminderEnabled(const std::string &deviceType, bool &enabled)
594 {
595 return DelayedSingleton<AnsNotification>::GetInstance()->IsSmartReminderEnabled(deviceType, enabled);
596 }
597
SetDistributedEnabledBySlot(const NotificationConstant::SlotType & slotType,const std::string & deviceType,const bool enabled)598 ErrCode NotificationHelper::SetDistributedEnabledBySlot(
599 const NotificationConstant::SlotType &slotType, const std::string &deviceType, const bool enabled)
600 {
601 return DelayedSingleton<AnsNotification>::GetInstance()->SetDistributedEnabledBySlot(slotType, deviceType, enabled);
602 }
603
IsDistributedEnabledBySlot(const NotificationConstant::SlotType & slotType,const std::string & deviceType,bool & enabled)604 ErrCode NotificationHelper::IsDistributedEnabledBySlot(
605 const NotificationConstant::SlotType &slotType, const std::string &deviceType, bool &enabled)
606 {
607 return DelayedSingleton<AnsNotification>::GetInstance()->IsDistributedEnabledBySlot(slotType, deviceType, enabled);
608 }
609
CancelAsBundleWithAgent(const NotificationBundleOption & bundleOption,const int32_t id)610 ErrCode NotificationHelper::CancelAsBundleWithAgent(const NotificationBundleOption &bundleOption, const int32_t id)
611 {
612 return DelayedSingleton<AnsNotification>::GetInstance()->CancelAsBundleWithAgent(bundleOption, id);
613 }
614
SetAdditionConfig(const std::string & key,const std::string & value)615 ErrCode NotificationHelper::SetAdditionConfig(const std::string &key, const std::string &value)
616 {
617 return DelayedSingleton<AnsNotification>::GetInstance()->SetAdditionConfig(key, value);
618 }
619
SetTargetDeviceStatus(const std::string & deviceType,const uint32_t status)620 ErrCode NotificationHelper::SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status)
621 {
622 return DelayedSingleton<AnsNotification>::GetInstance()->SetTargetDeviceStatus(deviceType, status);
623 }
624
SetTargetDeviceStatus(const std::string & deviceType,const uint32_t status,const uint32_t controlFlag)625 ErrCode NotificationHelper::SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status,
626 const uint32_t controlFlag)
627 {
628 return DelayedSingleton<AnsNotification>::GetInstance()->SetTargetDeviceStatus(deviceType, status, controlFlag);
629 }
630
RegisterSwingCallback(const std::function<void (bool,int)> swingCbFunc)631 ErrCode NotificationHelper::RegisterSwingCallback(const std::function<void(bool, int)> swingCbFunc)
632 {
633 #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED
634 return DelayedSingleton<AnsNotification>::GetInstance()->RegisterSwingCallback(swingCbFunc);
635 #else
636 return ERR_OK;
637 #endif
638 }
GetDoNotDisturbProfile(int32_t id,sptr<NotificationDoNotDisturbProfile> & profile)639 ErrCode NotificationHelper::GetDoNotDisturbProfile(int32_t id, sptr<NotificationDoNotDisturbProfile> &profile)
640 {
641 return DelayedSingleton<AnsNotification>::GetInstance()->GetDoNotDisturbProfile(id, profile);
642 }
643
DistributeOperation(sptr<NotificationOperationInfo> & operationInfo,const sptr<OperationCallbackInterface> & callback)644 ErrCode NotificationHelper::DistributeOperation(sptr<NotificationOperationInfo>& operationInfo,
645 const sptr<OperationCallbackInterface> &callback)
646 {
647 return DelayedSingleton<AnsNotification>::GetInstance()->DistributeOperation(operationInfo, callback);
648 }
649
GetNotificationRequestByHashCode(const std::string & hashCode,sptr<NotificationRequest> & notificationRequest)650 ErrCode NotificationHelper::GetNotificationRequestByHashCode(
651 const std::string& hashCode, sptr<NotificationRequest>& notificationRequest)
652 {
653 return DelayedSingleton<AnsNotification>::GetInstance()->GetNotificationRequestByHashCode(
654 hashCode, notificationRequest);
655 }
656
ReplyDistributeOperation(const std::string & hashCode,const int32_t result)657 ErrCode NotificationHelper::ReplyDistributeOperation(const std::string& hashCode, const int32_t result)
658 {
659 return DelayedSingleton<AnsNotification>::GetInstance()->ReplyDistributeOperation(hashCode, result);
660 }
661
UpdateNotificationTimerByUid(const int32_t uid,const bool isPaused)662 ErrCode NotificationHelper::UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused)
663 {
664 return DelayedSingleton<AnsNotification>::GetInstance()->UpdateNotificationTimerByUid(uid, isPaused);
665 }
666
AllowUseReminder(const std::string & bundleName,bool & isAllowUseReminder)667 ErrCode NotificationHelper::AllowUseReminder(const std::string& bundleName, bool& isAllowUseReminder)
668 {
669 return DelayedSingleton<AnsNotification>::GetInstance()->AllowUseReminder(bundleName, isAllowUseReminder);
670 }
671
DisableNotificationFeature(const NotificationDisable & notificationDisable)672 ErrCode NotificationHelper::DisableNotificationFeature(const NotificationDisable ¬ificationDisable)
673 {
674 return DelayedSingleton<AnsNotification>::GetInstance()->DisableNotificationFeature(notificationDisable);
675 }
676
SetHashCodeRule(const uint32_t type)677 ErrCode NotificationHelper::SetHashCodeRule(const uint32_t type)
678 {
679 return DelayedSingleton<AnsNotification>::GetInstance()->SetHashCodeRule(type);
680 }
681 } // namespace Notification
682 } // namespace OHOS
683