• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_INTERFACE_H
17 #define BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_INTERFACE_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "ans_subscriber_interface.h"
23 #include "iremote_broker.h"
24 #include "notification_bundle_option.h"
25 #include "notification_constant.h"
26 #include "notification_do_not_disturb_date.h"
27 #include "notification_request.h"
28 #include "notification_slot.h"
29 #include "notification_slot_group.h"
30 #include "notification_subscribe_info.h"
31 #include "reminder_request.h"
32 
33 namespace OHOS {
34 namespace Notification {
35 class IAnsManager : public IRemoteBroker {
36 public:
37     IAnsManager() = default;
38     virtual ~IAnsManager() override = default;
39     DISALLOW_COPY_AND_MOVE(IAnsManager);
40 
41     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.Notification.IAnsManager");
42 
43     virtual ErrCode Publish(const std::string &label, const sptr<NotificationRequest> &notification) = 0;
44     virtual ErrCode PublishToDevice(const sptr<NotificationRequest> &notification, const std::string &deviceId) = 0;
45     virtual ErrCode Cancel(int notificationId, const std::string &label) = 0;
46     virtual ErrCode CancelAll() = 0;
47     virtual ErrCode AddSlotByType(NotificationConstant::SlotType slotType) = 0;
48     virtual ErrCode AddSlots(const std::vector<sptr<NotificationSlot>> &slots) = 0;
49     virtual ErrCode RemoveSlotByType(const NotificationConstant::SlotType &slotType) = 0;
50     virtual ErrCode RemoveAllSlots() = 0;
51     virtual ErrCode AddSlotGroups(std::vector<sptr<NotificationSlotGroup>> groups) = 0;
52     virtual ErrCode GetSlotByType(const NotificationConstant::SlotType &slotType, sptr<NotificationSlot> &slot) = 0;
53     virtual ErrCode GetSlots(std::vector<sptr<NotificationSlot>> &slots) = 0;
54     virtual ErrCode GetSlotGroup(const std::string &groupId, sptr<NotificationSlotGroup> &group) = 0;
55     virtual ErrCode GetSlotGroups(std::vector<sptr<NotificationSlotGroup>> &groups) = 0;
56 
57     virtual ErrCode GetSlotNumAsBundle(const sptr<NotificationBundleOption> &bundleOption, int &num) = 0;
58 
59     virtual ErrCode RemoveSlotGroups(const std::vector<std::string> &groupIds) = 0;
60     virtual ErrCode GetActiveNotifications(std::vector<sptr<NotificationRequest>> &notifications) = 0;
61     virtual ErrCode GetActiveNotificationNums(int &num) = 0;
62     virtual ErrCode GetAllActiveNotifications(std::vector<sptr<Notification>> &notifications) = 0;
63     virtual ErrCode GetSpecialActiveNotifications(
64         const std::vector<std::string> &key, std::vector<sptr<Notification>> &notifications) = 0;
65     virtual ErrCode SetNotificationAgent(const std::string &agent) = 0;
66     virtual ErrCode GetNotificationAgent(std::string &agent) = 0;
67     virtual ErrCode CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) = 0;
68     virtual ErrCode PublishAsBundle(
69         const sptr<NotificationRequest> notification, const std::string &representativeBundle) = 0;
70     virtual ErrCode SetNotificationBadgeNum(int num) = 0;
71     virtual ErrCode GetBundleImportance(int &importance) = 0;
72     virtual ErrCode HasNotificationPolicyAccessPermission(bool &granted) = 0;
73     virtual ErrCode SetPrivateNotificationsAllowed(bool allow) = 0;
74     virtual ErrCode GetPrivateNotificationsAllowed(bool &allow) = 0;
75     virtual ErrCode Delete(const std::string &key) = 0;
76 
77     virtual ErrCode RemoveNotification(
78         const sptr<NotificationBundleOption> &bundleOption, int notificationId, const std::string &label) = 0;
79 
80     virtual ErrCode RemoveAllNotifications(const sptr<NotificationBundleOption> &bundleOption) = 0;
81 
82     virtual ErrCode DeleteByBundle(const sptr<NotificationBundleOption> &bundleOption) = 0;
83 
84     virtual ErrCode DeleteAll() = 0;
85     virtual ErrCode GetSlotsByBundle(
86         const sptr<NotificationBundleOption> &bundleOption, std::vector<sptr<NotificationSlot>> &slots) = 0;
87     virtual ErrCode UpdateSlots(
88         const sptr<NotificationBundleOption> &bundleOption, const std::vector<sptr<NotificationSlot>> &slots) = 0;
89     virtual ErrCode UpdateSlotGroups(
90         const sptr<NotificationBundleOption> &bundleOption, const std::vector<sptr<NotificationSlotGroup>> &groups) = 0;
91     virtual ErrCode RequestEnableNotification(const std::string &deviceId) = 0;
92     virtual ErrCode SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) = 0;
93     virtual ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) = 0;
94     virtual ErrCode SetNotificationsEnabledForSpecialBundle(
95         const std::string &deviceId, const sptr<NotificationBundleOption> &bundleOption, bool enabled) = 0;
96     virtual ErrCode SetShowBadgeEnabledForBundle(const sptr<NotificationBundleOption> &bundleOption, bool enabled) = 0;
97     virtual ErrCode GetShowBadgeEnabledForBundle(const sptr<NotificationBundleOption> &bundleOption, bool &enabled) = 0;
98     virtual ErrCode GetShowBadgeEnabled(bool &enabled) = 0;
99     virtual ErrCode Subscribe(const sptr<IAnsSubscriber> &subscriber, const sptr<NotificationSubscribeInfo> &info) = 0;
100     virtual ErrCode Unsubscribe(
101         const sptr<IAnsSubscriber> &subscriber, const sptr<NotificationSubscribeInfo> &info) = 0;
102     virtual ErrCode AreNotificationsSuspended(bool &suspended) = 0;
103     virtual ErrCode GetCurrentAppSorting(sptr<NotificationSortingMap> &sortingMap) = 0;
104     virtual ErrCode IsAllowedNotify(bool &allowed) = 0;
105     virtual ErrCode IsAllowedNotifySelf(bool &allowed) = 0;
106     virtual ErrCode IsSpecialBundleAllowedNotify(const sptr<NotificationBundleOption> &bundleOption, bool &allowed) = 0;
107 
108     virtual ErrCode SetDoNotDisturbDate(const sptr<NotificationDoNotDisturbDate> &date) = 0;
109     virtual ErrCode GetDoNotDisturbDate(sptr<NotificationDoNotDisturbDate> &date) = 0;
110     virtual ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport) = 0;
111 
112     virtual ErrCode CancelGroup(const std::string &groupName) = 0;
113     virtual ErrCode RemoveGroupByBundle(
114         const sptr<NotificationBundleOption> &bundleOption, const std::string &groupName) = 0;
115 
116     virtual ErrCode IsDistributedEnabled(bool &enabled) = 0;
117     virtual ErrCode EnableDistributed(bool enabled) = 0;
118     virtual ErrCode EnableDistributedByBundle(const sptr<NotificationBundleOption> &bundleOption, bool enabled) = 0;
119     virtual ErrCode EnableDistributedSelf(bool enabled) = 0;
120     virtual ErrCode IsDistributedEnableByBundle(const sptr<NotificationBundleOption> &bundleOption, bool &enabled) = 0;
121     virtual ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType) = 0;
122 
123     virtual ErrCode ShellDump(const std::string &dumpOption, std::vector<std::string> &dumpInfo) = 0;
124     virtual ErrCode PublishContinuousTaskNotification(const sptr<NotificationRequest> &request) = 0;
125     virtual ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) = 0;
126     virtual ErrCode PublishReminder(sptr<ReminderRequest> &reminder) = 0;
127     virtual ErrCode CancelReminder(const int32_t reminderId) = 0;
128     virtual ErrCode GetValidReminders(std::vector<sptr<ReminderRequest>> &reminders) = 0;
129     virtual ErrCode CancelAllReminders() = 0;
130     virtual ErrCode IsSupportTemplate(const std::string &templateName, bool &support) = 0;
131     virtual ErrCode IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) = 0;
132     virtual ErrCode SetNotificationsEnabledByUser(const int32_t &deviceId, bool enabled) = 0;
133     virtual ErrCode DeleteAllByUser(const int32_t &userId) = 0;
134     virtual ErrCode SetDoNotDisturbDate(const int32_t &userId, const sptr<NotificationDoNotDisturbDate> &date) = 0;
135     virtual ErrCode GetDoNotDisturbDate(const int32_t &userId, sptr<NotificationDoNotDisturbDate> &date) = 0;
136 
137 protected:
138     enum TransactId : uint32_t {
139         PUBLISH_NOTIFICATION = FIRST_CALL_TRANSACTION,
140         PUBLISH_NOTIFICATION_TO_DEVICE,
141         CANCEL_NOTIFICATION,
142         CANCEL_ALL_NOTIFICATIONS,
143         ADD_SLOT_BY_TYPE,
144         ADD_SLOTS,
145         REMOVE_SLOT_BY_TYPE,
146         REMOVE_ALL_SLOTS,
147         ADD_SLOT_GROUPS,
148         GET_SLOT_BY_TYPE,
149         GET_SLOTS,
150         GET_SLOT_GROUP,
151         GET_SLOT_GROUPS,
152         GET_SLOT_NUM_AS_BUNDLE,
153         REMOVE_SLOT_GROUPS,
154         GET_ACTIVE_NOTIFICATIONS,
155         GET_ACTIVE_NOTIFICATION_NUMS,
156         GET_ALL_ACTIVE_NOTIFICATIONS,
157         GET_SPECIAL_ACTIVE_NOTIFICATIONS,
158         SET_NOTIFICATION_AGENT,
159         GET_NOTIFICATION_AGENT,
160         CAN_PUBLISH_AS_BUNDLE,
161         PUBLISH_AS_BUNDLE,
162         SET_NOTIFICATION_BADGE_NUM,
163         GET_BUNDLE_IMPORTANCE,
164         IS_NOTIFICATION_POLICY_ACCESS_GRANTED,
165         SET_PRIVATIVE_NOTIFICATIONS_ALLOWED,
166         GET_PRIVATIVE_NOTIFICATIONS_ALLOWED,
167         REMOVE_NOTIFICATION,
168         REMOVE_ALL_NOTIFICATIONS,
169         DELETE_NOTIFICATION,
170         DELETE_NOTIFICATION_BY_BUNDLE,
171         DELETE_ALL_NOTIFICATIONS,
172         GET_SLOTS_BY_BUNDLE,
173         UPDATE_SLOTS,
174         UPDATE_SLOT_GROUPS,
175         REQUEST_ENABLE_NOTIFICATION,
176         SET_NOTIFICATION_ENABLED_FOR_BUNDLE,
177         SET_NOTIFICATION_ENABLED_FOR_ALL_BUNDLE,
178         SET_NOTIFICATION_ENABLED_FOR_SPECIAL_BUNDLE,
179         SET_SHOW_BADGE_ENABLED_FOR_BUNDLE,
180         GET_SHOW_BADGE_ENABLED_FOR_BUNDLE,
181         GET_SHOW_BADGE_ENABLED,
182         SUBSCRIBE_NOTIFICATION,
183         UNSUBSCRIBE_NOTIFICATION,
184         ARE_NOTIFICATION_SUSPENDED,
185         GET_CURRENT_APP_SORTING,
186         IS_ALLOWED_NOTIFY,
187         IS_ALLOWED_NOTIFY_SELF,
188         IS_SPECIAL_BUNDLE_ALLOWED_NOTIFY,
189         SET_DO_NOT_DISTURB_DATE,
190         GET_DO_NOT_DISTURB_DATE,
191         DOES_SUPPORT_DO_NOT_DISTURB_MODE,
192         CANCEL_GROUP,
193         REMOVE_GROUP_BY_BUNDLE,
194         IS_DISTRIBUTED_ENABLED,
195         ENABLE_DISTRIBUTED,
196         ENABLE_DISTRIBUTED_BY_BUNDLE,
197         ENABLE_DISTRIBUTED_SELF,
198         IS_DISTRIBUTED_ENABLED_BY_BUNDLE,
199         GET_DEVICE_REMIND_TYPE,
200         SHELL_DUMP,
201         PUBLISH_CONTINUOUS_TASK_NOTIFICATION,
202         CANCEL_CONTINUOUS_TASK_NOTIFICATION,
203         PUBLISH_REMINDER,
204         CANCEL_REMINDER,
205         CANCEL_ALL_REMINDERS,
206         GET_ALL_VALID_REMINDERS,
207         IS_SUPPORT_TEMPLATE,
208         IS_SPECIAL_USER_ALLOWED_NOTIFY,
209         SET_NOTIFICATION_ENABLED_BY_USER,
210         DELETE_ALL_NOTIFICATIONS_BY_USER,
211         SET_DO_NOT_DISTURB_DATE_BY_USER,
212         GET_DO_NOT_DISTURB_DATE_BY_USER
213     };
214 };
215 }  // namespace Notification
216 }  // namespace OHOS
217 
218 #endif  // BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_INTERFACE_H
219