• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_NOTIFICATION_EXT_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_NOTIFICATION_EXT_H
18 
19 #include <string>
20 
21 #include "errors.h"
22 #include "nocopyable.h"
23 #include "notification.h"
24 #include "notification_request.h"
25 #include "notification_unified_group_Info.h"
26 #include "singleton.h"
27 #include "advanced_aggregation_data_roaming_observer.h"
28 
29 namespace OHOS::Notification {
30 class ExtensionWrapper final {
31     DECLARE_DELAYED_SINGLETON(ExtensionWrapper);
32 public:
33     DISALLOW_COPY_AND_MOVE(ExtensionWrapper);
34     void InitExtentionWrapper();
35     typedef ErrCode (*SYNC_ADDITION_CONFIG)(const std::string& key, const std::string& value);
36     typedef void (*UPDATE_BY_CANCEL)(const std::vector<sptr<Notification>>& notifications, int deleteType);
37     typedef ErrCode (*GET_UNIFIED_GROUP_INFO)(const sptr<NotificationRequest> &request);
38     typedef void (*UPDATE_GROUP_INFO)(const std::string &key, std::shared_ptr<NotificationUnifiedGroupInfo> &groupInfo);
39     typedef void (*INIT_SUMMARY)(UPDATE_GROUP_INFO func);
40     typedef void (*SET_LOCAL_SWITCH)(bool status);
41     typedef int32_t (*LOCAL_CONTROL)(const sptr<NotificationRequest> &request);
42     typedef void (*UPDATE_BY_BUNDLE)(const std::string bundleName, int deleteType);
43     typedef int32_t (*REMINDER_CONTROL)(const std::string &bundleName);
44     typedef int32_t (*BANNER_CONTROL)(const std::string &bundleName);
45 
46 #ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER
47     typedef bool (*MODIFY_REMINDER_FLAGS)(const sptr<NotificationRequest> &request);
48 #endif
49 
50     ErrCode SyncAdditionConfig(const std::string& key, const std::string& value);
51     void UpdateByCancel(const std::vector<sptr<Notification>>& notifications, int deleteReason);
52     ErrCode GetUnifiedGroupInfo(const sptr<NotificationRequest> &request);
53     void RegisterDataSettingObserver();
54     void SetlocalSwitch(std::string &enable);
55     void CheckIfSetlocalSwitch();
56     int32_t LocalControl(const sptr<NotificationRequest> &request);
57     void UpdateByBundle(const std::string bundleName, int deleteType);
58     int32_t ReminderControl(const std::string &bundleName);
59     int32_t BannerControl(const std::string &bundleName);
60 
61 #ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER
62     bool ModifyReminderFlags(const sptr<NotificationRequest> &request);
63 #endif
64 
65 private:
66     static int32_t convertToDelType(int32_t deleteReason);
67 
68     void* extensionWrapperHandle_ = nullptr;
69     SYNC_ADDITION_CONFIG syncAdditionConfig_ = nullptr;
70     UPDATE_BY_CANCEL updateByCancel_ = nullptr;
71     GET_UNIFIED_GROUP_INFO getUnifiedGroupInfo_ = nullptr;
72     INIT_SUMMARY initSummary_ = nullptr;
73     SET_LOCAL_SWITCH setLocalSwitch_ = nullptr;
74     LOCAL_CONTROL localControl_ = nullptr;
75     UPDATE_BY_BUNDLE updateByBundle_ = nullptr;
76     REMINDER_CONTROL reminderControl_ = nullptr;
77     BANNER_CONTROL bannerControl_ = nullptr;
78     bool isRegisterDataSettingObserver = false;
79 
80 #ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER
81     MODIFY_REMINDER_FLAGS modifyReminderFlags_ = nullptr;
82 #endif
83 };
84 
85 #define EXTENTION_WRAPPER ::OHOS::DelayedSingleton<ExtensionWrapper>::GetInstance()
86 } // namespace OHOS::Notification
87 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_NOTIFICATION_EXT_H
88