/* * Copyright (c) 2021-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "notification_helper.h" #include "ans_notification.h" #include "singleton.h" #include namespace OHOS { namespace Notification { ErrCode NotificationHelper::AddNotificationSlot(const NotificationSlot &slot) { return DelayedSingleton::GetInstance()->AddNotificationSlot(slot); } ErrCode NotificationHelper::AddSlotByType(const NotificationConstant::SlotType &slotType) { return DelayedSingleton::GetInstance()->AddSlotByType(slotType); } ErrCode NotificationHelper::AddNotificationSlots(const std::vector &slots) { return DelayedSingleton::GetInstance()->AddNotificationSlots(slots); } ErrCode NotificationHelper::RemoveNotificationSlot(const NotificationConstant::SlotType &slotType) { return DelayedSingleton::GetInstance()->RemoveNotificationSlot(slotType); } ErrCode NotificationHelper::RemoveAllSlots() { return DelayedSingleton::GetInstance()->RemoveAllSlots(); } ErrCode NotificationHelper::GetNotificationSlot( const NotificationConstant::SlotType &slotType, sptr &slot) { return DelayedSingleton::GetInstance()->GetNotificationSlot(slotType, slot); } ErrCode NotificationHelper::GetNotificationSlots(std::vector> &slots) { return DelayedSingleton::GetInstance()->GetNotificationSlots(slots); } ErrCode NotificationHelper::GetNotificationSlotNumAsBundle(const NotificationBundleOption &bundleOption, uint64_t &num) { return DelayedSingleton::GetInstance()->GetNotificationSlotNumAsBundle(bundleOption, num); } ErrCode NotificationHelper::GetNotificationSlotFlagsAsBundle(const NotificationBundleOption &bundleOption, uint32_t &slotFlags) { return DelayedSingleton::GetInstance()->GetNotificationSlotFlagsAsBundle(bundleOption, slotFlags); } ErrCode NotificationHelper::SetNotificationSlotFlagsAsBundle(const NotificationBundleOption &bundleOption, uint32_t slotFlags) { return DelayedSingleton::GetInstance()->SetNotificationSlotFlagsAsBundle(bundleOption, slotFlags); } ErrCode NotificationHelper::PublishNotification(const NotificationRequest &request) { return DelayedSingleton::GetInstance()->PublishNotification(request); } ErrCode NotificationHelper::PublishNotification(const std::string &label, const NotificationRequest &request) { return DelayedSingleton::GetInstance()->PublishNotification(label, request); } ErrCode NotificationHelper::PublishNotificationForIndirectProxy(const NotificationRequest &request) { return DelayedSingleton::GetInstance()->PublishNotificationForIndirectProxy(request); } ErrCode NotificationHelper::CancelNotification(int32_t notificationId) { return DelayedSingleton::GetInstance()->CancelNotification(notificationId); } ErrCode NotificationHelper::CancelNotification(const std::string &label, int32_t notificationId) { return DelayedSingleton::GetInstance()->CancelNotification(label, notificationId); } ErrCode NotificationHelper::CancelAllNotifications() { return DelayedSingleton::GetInstance()->CancelAllNotifications(); } ErrCode NotificationHelper::CancelAsBundle( int32_t notificationId, const std::string &representativeBundle, int32_t userId) { return DelayedSingleton::GetInstance()->CancelAsBundle( notificationId, representativeBundle, userId); } ErrCode NotificationHelper::CancelAsBundle( const NotificationBundleOption &bundleOption, int32_t notificationId) { return DelayedSingleton::GetInstance()->CancelAsBundle( bundleOption, notificationId); } ErrCode NotificationHelper::GetActiveNotificationNums(uint64_t &num) { return DelayedSingleton::GetInstance()->GetActiveNotificationNums(num); } ErrCode NotificationHelper::GetActiveNotifications(std::vector> &request) { return DelayedSingleton::GetInstance()->GetActiveNotifications(request); } ErrCode NotificationHelper::SetNotificationAgent(const std::string &agent) { return DelayedSingleton::GetInstance()->SetNotificationAgent(agent); } ErrCode NotificationHelper::GetNotificationAgent(std::string &agent) { return DelayedSingleton::GetInstance()->GetNotificationAgent(agent); } ErrCode NotificationHelper::CanPublishNotificationAsBundle(const std::string &representativeBundle, bool &canPublish) { return DelayedSingleton::GetInstance()->CanPublishNotificationAsBundle( representativeBundle, canPublish); } ErrCode NotificationHelper::PublishNotificationAsBundle( const std::string &representativeBundle, const NotificationRequest &request) { return DelayedSingleton::GetInstance()->PublishNotificationAsBundle(representativeBundle, request); } ErrCode NotificationHelper::SetNotificationBadgeNum() { return DelayedSingleton::GetInstance()->SetNotificationBadgeNum(); } ErrCode NotificationHelper::SetNotificationBadgeNum(int32_t num) { return DelayedSingleton::GetInstance()->SetNotificationBadgeNum(num); } ErrCode NotificationHelper::IsAllowedNotify(bool &allowed) { return DelayedSingleton::GetInstance()->IsAllowedNotify(allowed); } ErrCode NotificationHelper::IsAllowedNotifySelf(bool &allowed) { return DelayedSingleton::GetInstance()->IsAllowedNotifySelf(allowed); } ErrCode NotificationHelper::CanPopEnableNotificationDialog(sptr &hostClient, bool &canPop, std::string &bundleName) { return DelayedSingleton::GetInstance()->CanPopEnableNotificationDialog( hostClient, canPop, bundleName); } ErrCode NotificationHelper::RemoveEnableNotificationDialog() { return DelayedSingleton::GetInstance()->RemoveEnableNotificationDialog(); } ErrCode NotificationHelper::RequestEnableNotification(std::string &deviceId, sptr &hostClient, sptr &callerToken) { return DelayedSingleton::GetInstance()->RequestEnableNotification( deviceId, hostClient, callerToken); } ErrCode NotificationHelper::HasNotificationPolicyAccessPermission(bool &hasPermission) { return DelayedSingleton::GetInstance()->HasNotificationPolicyAccessPermission(hasPermission); } ErrCode NotificationHelper::GetBundleImportance(NotificationSlot::NotificationLevel &importance) { return DelayedSingleton::GetInstance()->GetBundleImportance(importance); } ErrCode NotificationHelper::SubscribeNotification(const NotificationSubscriber &subscriber) { return DelayedSingleton::GetInstance()->SubscribeNotification(subscriber); } ErrCode NotificationHelper::SubscribeNotification(const std::shared_ptr &subscriber) { return DelayedSingleton::GetInstance()->SubscribeNotification(subscriber, nullptr); } ErrCode NotificationHelper::SubscribeNotificationSelf(const NotificationSubscriber &subscriber) { return DelayedSingleton::GetInstance()->SubscribeNotificationSelf(subscriber); } ErrCode NotificationHelper::SubscribeNotificationSelf(const std::shared_ptr &subscriber) { return DelayedSingleton::GetInstance()->SubscribeNotificationSelf(subscriber); } ErrCode NotificationHelper::SubscribeLocalLiveViewNotification(const NotificationLocalLiveViewSubscriber &subscriber, const bool isNative) { return DelayedSingleton::GetInstance()->SubscribeLocalLiveViewNotification(subscriber, isNative); } ErrCode NotificationHelper::SubscribeNotification( const NotificationSubscriber &subscriber, const NotificationSubscribeInfo &subscribeInfo) { return DelayedSingleton::GetInstance()->SubscribeNotification(subscriber, subscribeInfo); } ErrCode NotificationHelper::SubscribeNotification(const std::shared_ptr &subscriber, const sptr &subscribeInfo) { return DelayedSingleton::GetInstance()->SubscribeNotification(subscriber, subscribeInfo); } ErrCode NotificationHelper::UnSubscribeNotification(NotificationSubscriber &subscriber) { return DelayedSingleton::GetInstance()->UnSubscribeNotification(subscriber); } ErrCode NotificationHelper::UnSubscribeNotification(const std::shared_ptr &subscriber) { return DelayedSingleton::GetInstance()->UnSubscribeNotification(subscriber); } ErrCode NotificationHelper::UnSubscribeNotification( NotificationSubscriber &subscriber, NotificationSubscribeInfo subscribeInfo) { return DelayedSingleton::GetInstance()->UnSubscribeNotification(subscriber, subscribeInfo); } ErrCode NotificationHelper::UnSubscribeNotification(const std::shared_ptr &subscriber, const sptr &subscribeInfo) { return DelayedSingleton::GetInstance()->UnSubscribeNotification(subscriber, subscribeInfo); } ErrCode NotificationHelper::TriggerLocalLiveView(const NotificationBundleOption &bundleOption, const int32_t notificationId, const NotificationButtonOption &buttonOption) { return DelayedSingleton::GetInstance()->TriggerLocalLiveView( bundleOption, notificationId, buttonOption); } ErrCode NotificationHelper::RemoveNotification(const std::string &key, int32_t removeReason) { return DelayedSingleton::GetInstance()->RemoveNotification(key, removeReason); } ErrCode NotificationHelper::RemoveNotification(const NotificationBundleOption &bundleOption, const int32_t notificationId, const std::string &label, int32_t removeReason) { return DelayedSingleton::GetInstance()->RemoveNotification(bundleOption, notificationId, label, removeReason); } ErrCode NotificationHelper::RemoveAllNotifications(const NotificationBundleOption &bundleOption) { return DelayedSingleton::GetInstance()->RemoveAllNotifications(bundleOption); } ErrCode NotificationHelper::RemoveNotifications(const std::vector hashcodes, int32_t removeReason) { return DelayedSingleton::GetInstance()->RemoveNotifications(hashcodes, removeReason); } ErrCode NotificationHelper::RemoveNotificationsByBundle(const NotificationBundleOption &bundleOption) { return DelayedSingleton::GetInstance()->RemoveNotificationsByBundle(bundleOption); } ErrCode NotificationHelper::RemoveNotifications() { return DelayedSingleton::GetInstance()->RemoveNotifications(); } ErrCode NotificationHelper::GetNotificationSlotsForBundle( const NotificationBundleOption &bundleOption, std::vector> &slots) { return DelayedSingleton::GetInstance()->GetNotificationSlotsForBundle(bundleOption, slots); } ErrCode NotificationHelper::GetNotificationSlotForBundle( const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType, sptr &slot) { return DelayedSingleton::GetInstance()->GetNotificationSlotForBundle(bundleOption, slotType, slot); } ErrCode NotificationHelper::UpdateNotificationSlots( const NotificationBundleOption &bundleOption, const std::vector> &slots) { return DelayedSingleton::GetInstance()->UpdateNotificationSlots(bundleOption, slots); } ErrCode NotificationHelper::GetAllActiveNotifications(std::vector> ¬ification) { return DelayedSingleton::GetInstance()->GetAllActiveNotifications(notification); } ErrCode NotificationHelper::GetAllActiveNotifications( const std::vector key, std::vector> ¬ification) { return DelayedSingleton::GetInstance()->GetAllActiveNotifications(key, notification); } ErrCode NotificationHelper::GetActiveNotificationByFilter( const LiveViewFilter &filter, sptr &request) { return DelayedSingleton::GetInstance()->GetActiveNotificationByFilter(filter, request); } ErrCode NotificationHelper::IsAllowedNotify(const NotificationBundleOption &bundleOption, bool &allowed) { return DelayedSingleton::GetInstance()->IsAllowedNotify(bundleOption, allowed); } ErrCode NotificationHelper::SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) { return DelayedSingleton::GetInstance()->SetNotificationsEnabledForAllBundles(deviceId, enabled); } ErrCode NotificationHelper::SetNotificationsEnabledForDefaultBundle(const std::string &deviceId, bool enabled) { return DelayedSingleton::GetInstance()->SetNotificationsEnabledForDefaultBundle(deviceId, enabled); } ErrCode NotificationHelper::SetNotificationsEnabledForSpecifiedBundle( const NotificationBundleOption &bundleOption, std::string &deviceId, bool enabled) { return DelayedSingleton::GetInstance()->SetNotificationsEnabledForSpecifiedBundle( bundleOption, deviceId, enabled); } ErrCode NotificationHelper::SetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool enabled) { return DelayedSingleton::GetInstance()->SetShowBadgeEnabledForBundle(bundleOption, enabled); } ErrCode NotificationHelper::GetShowBadgeEnabledForBundle(const NotificationBundleOption &bundleOption, bool &enabled) { return DelayedSingleton::GetInstance()->GetShowBadgeEnabledForBundle(bundleOption, enabled); } ErrCode NotificationHelper::GetShowBadgeEnabled(bool &enabled) { return DelayedSingleton::GetInstance()->GetShowBadgeEnabled(enabled); } ErrCode NotificationHelper::CancelGroup(const std::string &groupName) { return DelayedSingleton::GetInstance()->CancelGroup(groupName); } ErrCode NotificationHelper::RemoveGroupByBundle( const NotificationBundleOption &bundleOption, const std::string &groupName) { return DelayedSingleton::GetInstance()->RemoveGroupByBundle(bundleOption, groupName); } ErrCode NotificationHelper::SetDoNotDisturbDate(const NotificationDoNotDisturbDate &doNotDisturbDate) { return DelayedSingleton::GetInstance()->SetDoNotDisturbDate(doNotDisturbDate); } ErrCode NotificationHelper::GetDoNotDisturbDate(NotificationDoNotDisturbDate &doNotDisturbDate) { return DelayedSingleton::GetInstance()->GetDoNotDisturbDate(doNotDisturbDate); } ErrCode NotificationHelper::AddDoNotDisturbProfiles(const std::vector> &profiles) { return DelayedSingleton::GetInstance()->AddDoNotDisturbProfiles(profiles); } ErrCode NotificationHelper::RemoveDoNotDisturbProfiles( const std::vector> &profiles) { return DelayedSingleton::GetInstance()->RemoveDoNotDisturbProfiles(profiles); } ErrCode NotificationHelper::DoesSupportDoNotDisturbMode(bool &doesSupport) { return DelayedSingleton::GetInstance()->DoesSupportDoNotDisturbMode(doesSupport); } ErrCode NotificationHelper::IsNeedSilentInDoNotDisturbMode(const std::string &phoneNumber, int32_t callerType) { return DelayedSingleton::GetInstance()->IsNeedSilentInDoNotDisturbMode(phoneNumber, callerType); } ErrCode NotificationHelper::IsDistributedEnabled(bool &enabled) { return DelayedSingleton::GetInstance()->IsDistributedEnabled(enabled); } ErrCode NotificationHelper::EnableDistributed(const bool enabled) { return DelayedSingleton::GetInstance()->EnableDistributed(enabled); } ErrCode NotificationHelper::EnableDistributedByBundle(const NotificationBundleOption &bundleOption, const bool enabled) { return DelayedSingleton::GetInstance()->EnableDistributedByBundle(bundleOption, enabled); } ErrCode NotificationHelper::EnableDistributedSelf(const bool enabled) { return DelayedSingleton::GetInstance()->EnableDistributedSelf(enabled); } ErrCode NotificationHelper::IsDistributedEnableByBundle(const NotificationBundleOption &bundleOption, bool &enabled) { return DelayedSingleton::GetInstance()->IsDistributedEnableByBundle(bundleOption, enabled); } ErrCode NotificationHelper::GetDeviceRemindType(NotificationConstant::RemindType &remindType) { return DelayedSingleton::GetInstance()->GetDeviceRemindType(remindType); } ErrCode NotificationHelper::PublishContinuousTaskNotification(const NotificationRequest &request) { return DelayedSingleton::GetInstance()->PublishContinuousTaskNotification(request); } ErrCode NotificationHelper::CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) { return DelayedSingleton::GetInstance()->CancelContinuousTaskNotification(label, notificationId); } ErrCode NotificationHelper::IsSupportTemplate(const std::string &templateName, bool &support) { return DelayedSingleton::GetInstance()->IsSupportTemplate(templateName, support); } ErrCode NotificationHelper::IsAllowedNotify(const int32_t &userId, bool &allowed) { return DelayedSingleton::GetInstance()->IsAllowedNotify(userId, allowed); } ErrCode NotificationHelper::SetNotificationsEnabledForAllBundles(const int32_t &userId, bool enabled) { return DelayedSingleton::GetInstance()->SetNotificationsEnabledForAllBundles( userId, enabled); } ErrCode NotificationHelper::RemoveNotifications(const int32_t &userId) { return DelayedSingleton::GetInstance()->RemoveNotifications(userId); } ErrCode NotificationHelper::SetDoNotDisturbDate(const int32_t &userId, const NotificationDoNotDisturbDate &doNotDisturbDate) { return DelayedSingleton::GetInstance()->SetDoNotDisturbDate(userId, doNotDisturbDate); } ErrCode NotificationHelper::GetDoNotDisturbDate(const int32_t &userId, NotificationDoNotDisturbDate &doNotDisturbDate) { return DelayedSingleton::GetInstance()->GetDoNotDisturbDate(userId, doNotDisturbDate); } ErrCode NotificationHelper::SetEnabledForBundleSlot(const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType, bool enabled, bool isForceControl) { return DelayedSingleton::GetInstance()->SetEnabledForBundleSlot(bundleOption, slotType, enabled, isForceControl); } ErrCode NotificationHelper::GetEnabledForBundleSlot( const NotificationBundleOption &bundleOption, const NotificationConstant::SlotType &slotType, bool &enabled) { return DelayedSingleton::GetInstance()->GetEnabledForBundleSlot(bundleOption, slotType, enabled); } ErrCode NotificationHelper::GetEnabledForBundleSlotSelf(const NotificationConstant::SlotType &slotType, bool &enabled) { return DelayedSingleton::GetInstance()->GetEnabledForBundleSlotSelf(slotType, enabled); } ErrCode NotificationHelper::SetSyncNotificationEnabledWithoutApp(const int32_t userId, const bool enabled) { return DelayedSingleton::GetInstance()->SetSyncNotificationEnabledWithoutApp( userId, enabled); } ErrCode NotificationHelper::GetSyncNotificationEnabledWithoutApp(const int32_t userId, bool &enabled) { return DelayedSingleton::GetInstance()->GetSyncNotificationEnabledWithoutApp( userId, enabled); } ErrCode NotificationHelper::SetBadgeNumber(int32_t badgeNumber) { return DelayedSingleton::GetInstance()->SetBadgeNumber(badgeNumber); } ErrCode NotificationHelper::SetBadgeNumberByBundle(const NotificationBundleOption &bundleOption, int32_t badgeNumber) { return DelayedSingleton::GetInstance()->SetBadgeNumberByBundle(bundleOption, badgeNumber); } ErrCode NotificationHelper::GetAllNotificationEnabledBundles(std::vector &bundleOption) { return DelayedSingleton::GetInstance()->GetAllNotificationEnabledBundles(bundleOption); } ErrCode NotificationHelper::RegisterPushCallback(const sptr &pushCallback, const sptr ¬ificationCheckRequest) { return DelayedSingleton::GetInstance()->RegisterPushCallback(pushCallback, notificationCheckRequest); } ErrCode NotificationHelper::UnregisterPushCallback() { return DelayedSingleton::GetInstance()->UnregisterPushCallback(); } ErrCode NotificationHelper::SetDistributedEnabledByBundle(const NotificationBundleOption &bundleOption, const std::string &deviceType, const bool enabled) { return DelayedSingleton::GetInstance()->SetDistributedEnabledByBundle(bundleOption, deviceType, enabled); } ErrCode NotificationHelper::IsDistributedEnabledByBundle(const NotificationBundleOption &bundleOption, const std::string &deviceType, bool &enabled) { return DelayedSingleton::GetInstance()->IsDistributedEnabledByBundle(bundleOption, deviceType, enabled); } ErrCode NotificationHelper::SetSmartReminderEnabled(const std::string &deviceType, const bool enabled) { return DelayedSingleton::GetInstance()->SetSmartReminderEnabled(deviceType, enabled); } ErrCode NotificationHelper::IsSmartReminderEnabled(const std::string &deviceType, bool &enabled) { return DelayedSingleton::GetInstance()->IsSmartReminderEnabled(deviceType, enabled); } ErrCode NotificationHelper::CancelAsBundleWithAgent(const NotificationBundleOption &bundleOption, const int32_t id) { return DelayedSingleton::GetInstance()->CancelAsBundleWithAgent(bundleOption, id); } ErrCode NotificationHelper::SetAdditionConfig(const std::string &key, const std::string &value) { return DelayedSingleton::GetInstance()->SetAdditionConfig(key, value); } ErrCode NotificationHelper::SetTargetDeviceStatus(const std::string &deviceType, const uint32_t status) { return DelayedSingleton::GetInstance()->SetTargetDeviceStatus(deviceType, status); } ErrCode NotificationHelper::RegisterSwingCallback(const std::function swingCbFunc) { #ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED return DelayedSingleton::GetInstance()->RegisterSwingCallback(swingCbFunc); #else return ERR_OK; #endif } ErrCode NotificationHelper::GetDoNotDisturbProfile(int32_t id, sptr &profile) { return DelayedSingleton::GetInstance()->GetDoNotDisturbProfile(id, profile); } ErrCode NotificationHelper::UpdateNotificationTimerByUid(const int32_t uid, const bool isPaused) { return DelayedSingleton::GetInstance()->UpdateNotificationTimerByUid(uid, isPaused); } } // namespace Notification } // namespace OHOS