• 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     typedef int32_t (*VERIFY_CLOUD_CAPABILITY)(const int32_t &uid, const std::string &permission);
46     typedef bool (*NOTIFICATIONDIALOGCONTROL)();
47 
48 #ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER
49     typedef bool (*IS_PRIVILEGE_MESSAGE)(const sptr<NotificationRequest> &request);
50     typedef bool (*GET_PRIVILEGE_DIALOG_POPPED)(const sptr<NotificationBundleOption>& bundleOption,
51         const int32_t &userId);
52     typedef bool (*SET_DIALOG_OPENSUCCESS_TIMESTAMP)(const sptr<NotificationBundleOption>& bundleOption,
53         const int32_t &userId);
54     typedef bool (*SET_DIALOG_OPENSUCCESS_TIMEINTERVAL)(const sptr<NotificationBundleOption>& bundleOption,
55         const int32_t &userId);
56     typedef void (*HANDLE_PRIVILEGE_MESSAGE)(const sptr<NotificationBundleOption>& bundleOption,
57         const sptr<NotificationRequest> &request, bool isAgentController);
58 #endif
59 
60     ErrCode SyncAdditionConfig(const std::string& key, const std::string& value);
61     void UpdateByCancel(const std::vector<sptr<Notification>>& notifications, int deleteReason);
62     ErrCode GetUnifiedGroupInfo(const sptr<NotificationRequest> &request);
63     void RegisterDataSettingObserver();
64     void SetlocalSwitch(std::string &enable);
65     void CheckIfSetlocalSwitch();
66     int32_t LocalControl(const sptr<NotificationRequest> &request);
67     void UpdateByBundle(const std::string bundleName, int deleteType);
68     int32_t ReminderControl(const std::string &bundleName);
69     int32_t BannerControl(const std::string &bundleName);
70     int32_t VerifyCloudCapability(const int32_t &uid, const std::string &capability);
71     bool NotificationDialogControl();
72 
73 #ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER
74     bool IsPrivilegeMessage(const sptr<NotificationRequest> &request);
75     bool GetPrivilegeDialogPopped(const sptr<NotificationBundleOption>& bundleOption, const int32_t &userId);
76     bool SetDialogOpenSuccessTimeStamp(const sptr<NotificationBundleOption>& bundleOption, const int32_t &userId);
77     bool SetDialogOpenSuccessTimeInterval(const sptr<NotificationBundleOption>& bundleOption, const int32_t &userId);
78     void HandlePrivilegeMessage(const sptr<NotificationBundleOption>& bundleOption,
79         const sptr<NotificationRequest> &request, bool isAgentController);
80 #endif
81 
82 private:
83     static int32_t convertToDelType(int32_t deleteReason);
84 
85     void* extensionWrapperHandle_ = nullptr;
86     SYNC_ADDITION_CONFIG syncAdditionConfig_ = nullptr;
87     UPDATE_BY_CANCEL updateByCancel_ = nullptr;
88     GET_UNIFIED_GROUP_INFO getUnifiedGroupInfo_ = nullptr;
89     INIT_SUMMARY initSummary_ = nullptr;
90     SET_LOCAL_SWITCH setLocalSwitch_ = nullptr;
91     LOCAL_CONTROL localControl_ = nullptr;
92     UPDATE_BY_BUNDLE updateByBundle_ = nullptr;
93     REMINDER_CONTROL reminderControl_ = nullptr;
94     BANNER_CONTROL bannerControl_ = nullptr;
95     VERIFY_CLOUD_CAPABILITY verifyCloudCapability_ = nullptr;
96     NOTIFICATIONDIALOGCONTROL notificationDialogControl_ = nullptr;
97     bool isRegisterDataSettingObserver = false;
98 
99 #ifdef ENABLE_ANS_PRIVILEGED_MESSAGE_EXT_WRAPPER
100     IS_PRIVILEGE_MESSAGE isPrivilegeMessage_ = nullptr;
101     GET_PRIVILEGE_DIALOG_POPPED getPrivilegeDialogPopped_ = nullptr;
102     SET_DIALOG_OPENSUCCESS_TIMESTAMP setDialogOpenSuccessTimeStamp_ = nullptr;
103     SET_DIALOG_OPENSUCCESS_TIMEINTERVAL setDialogOpenSuccessTimeInterval_ = nullptr;
104     HANDLE_PRIVILEGE_MESSAGE handlePrivilegeMessage_ = nullptr;
105 #endif
106 };
107 
108 #define EXTENTION_WRAPPER ::OHOS::DelayedSingleton<ExtensionWrapper>::GetInstance()
109 } // namespace OHOS::Notification
110 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_NOTIFICATION_EXT_H
111