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_STUB_H 17 #define BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_STUB_H 18 19 #include <functional> 20 #include <map> 21 22 #include "ans_manager_interface.h" 23 #include "iremote_stub.h" 24 25 namespace OHOS { 26 namespace Notification { 27 class AnsManagerStub : public IRemoteStub<IAnsManager> { 28 public: 29 AnsManagerStub(); 30 ~AnsManagerStub() override; 31 DISALLOW_COPY_AND_MOVE(AnsManagerStub); 32 33 virtual int OnRemoteRequest( 34 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 35 36 virtual ErrCode Publish(const std::string &label, const sptr<NotificationRequest> ¬ification) override; 37 virtual ErrCode PublishToDevice( 38 const sptr<NotificationRequest> ¬ification, const std::string &deviceId) override; 39 virtual ErrCode Cancel(int notificationId, const std::string &label) override; 40 virtual ErrCode CancelAll() override; 41 virtual ErrCode AddSlotByType(NotificationConstant::SlotType slotType) override; 42 virtual ErrCode AddSlots(const std::vector<sptr<NotificationSlot>> &slots) override; 43 virtual ErrCode RemoveSlotByType(const NotificationConstant::SlotType &slotType) override; 44 virtual ErrCode RemoveAllSlots() override; 45 virtual ErrCode AddSlotGroups(std::vector<sptr<NotificationSlotGroup>> groups) override; 46 virtual ErrCode GetSlotByType( 47 const NotificationConstant::SlotType &slotType, sptr<NotificationSlot> &slot) override; 48 virtual ErrCode GetSlots(std::vector<sptr<NotificationSlot>> &slots) override; 49 virtual ErrCode GetSlotGroup(const std::string &groupId, sptr<NotificationSlotGroup> &group) override; 50 virtual ErrCode GetSlotGroups(std::vector<sptr<NotificationSlotGroup>> &groups) override; 51 virtual ErrCode GetSlotNumAsBundle(const sptr<NotificationBundleOption> &bundleOption, int &num) override; 52 virtual ErrCode RemoveSlotGroups(const std::vector<std::string> &groupIds) override; 53 virtual ErrCode GetActiveNotifications(std::vector<sptr<NotificationRequest>> ¬ifications) override; 54 virtual ErrCode GetActiveNotificationNums(int &num) override; 55 virtual ErrCode GetAllActiveNotifications(std::vector<sptr<Notification>> ¬ifications) override; 56 virtual ErrCode GetSpecialActiveNotifications( 57 const std::vector<std::string> &key, std::vector<sptr<Notification>> ¬ifications) override; 58 virtual ErrCode SetNotificationAgent(const std::string &agent) override; 59 virtual ErrCode GetNotificationAgent(std::string &agent) override; 60 virtual ErrCode CanPublishAsBundle(const std::string &representativeBundle, bool &canPublish) override; 61 virtual ErrCode PublishAsBundle( 62 const sptr<NotificationRequest> notification, const std::string &representativeBundle) override; 63 virtual ErrCode SetNotificationBadgeNum(int num) override; 64 virtual ErrCode GetBundleImportance(int &importance) override; 65 virtual ErrCode HasNotificationPolicyAccessPermission(bool &granted) override; 66 virtual ErrCode SetPrivateNotificationsAllowed(bool allow) override; 67 virtual ErrCode GetPrivateNotificationsAllowed(bool &allow) override; 68 virtual ErrCode RemoveNotification( 69 const sptr<NotificationBundleOption> &bundleOption, int notificationId, const std::string &label) override; 70 virtual ErrCode RemoveAllNotifications(const sptr<NotificationBundleOption> &bundleOption) override; 71 virtual ErrCode Delete(const std::string &key) override; 72 virtual ErrCode DeleteByBundle(const sptr<NotificationBundleOption> &bundleOption) override; 73 virtual ErrCode DeleteAll() override; 74 virtual ErrCode GetSlotsByBundle( 75 const sptr<NotificationBundleOption> &bundleOption, std::vector<sptr<NotificationSlot>> &slots) override; 76 virtual ErrCode UpdateSlots( 77 const sptr<NotificationBundleOption> &bundleOption, const std::vector<sptr<NotificationSlot>> &slots) override; 78 virtual ErrCode UpdateSlotGroups(const sptr<NotificationBundleOption> &bundleOption, 79 const std::vector<sptr<NotificationSlotGroup>> &groups) override; 80 virtual ErrCode RequestEnableNotification(const std::string &deviceId) override; 81 virtual ErrCode SetNotificationsEnabledForBundle(const std::string &deviceId, bool enabled) override; 82 virtual ErrCode SetNotificationsEnabledForAllBundles(const std::string &deviceId, bool enabled) override; 83 virtual ErrCode SetNotificationsEnabledForSpecialBundle( 84 const std::string &deviceId, const sptr<NotificationBundleOption> &bundleOption, bool enabled) override; 85 virtual ErrCode SetShowBadgeEnabledForBundle( 86 const sptr<NotificationBundleOption> &bundleOption, bool enabled) override; 87 virtual ErrCode GetShowBadgeEnabledForBundle( 88 const sptr<NotificationBundleOption> &bundleOption, bool &enabled) override; 89 virtual ErrCode GetShowBadgeEnabled(bool &enabled) override; 90 virtual ErrCode Subscribe( 91 const sptr<IAnsSubscriber> &subscriber, const sptr<NotificationSubscribeInfo> &info) override; 92 virtual ErrCode Unsubscribe( 93 const sptr<IAnsSubscriber> &subscriber, const sptr<NotificationSubscribeInfo> &info) override; 94 virtual ErrCode AreNotificationsSuspended(bool &suspended) override; 95 virtual ErrCode GetCurrentAppSorting(sptr<NotificationSortingMap> &sortingMap) override; 96 virtual ErrCode IsAllowedNotify(bool &allowed) override; 97 virtual ErrCode IsAllowedNotifySelf(bool &allowed) override; 98 virtual ErrCode IsSpecialBundleAllowedNotify( 99 const sptr<NotificationBundleOption> &bundleOption, bool &allowed) override; 100 101 virtual ErrCode SetDoNotDisturbDate(const sptr<NotificationDoNotDisturbDate> &date) override; 102 virtual ErrCode GetDoNotDisturbDate(sptr<NotificationDoNotDisturbDate> &date) override; 103 virtual ErrCode DoesSupportDoNotDisturbMode(bool &doesSupport) override; 104 virtual ErrCode CancelGroup(const std::string &groupName) override; 105 virtual ErrCode RemoveGroupByBundle( 106 const sptr<NotificationBundleOption> &bundleOption, const std::string &groupName) override; 107 108 virtual ErrCode IsDistributedEnabled(bool &enabled) override; 109 virtual ErrCode EnableDistributed(bool enabled) override; 110 virtual ErrCode EnableDistributedByBundle( 111 const sptr<NotificationBundleOption> &bundleOption, bool enabled) override; 112 virtual ErrCode EnableDistributedSelf(bool enabled) override; 113 virtual ErrCode IsDistributedEnableByBundle( 114 const sptr<NotificationBundleOption> &bundleOption, bool &enabled) override; 115 virtual ErrCode GetDeviceRemindType(NotificationConstant::RemindType &remindType) override; 116 117 virtual ErrCode ShellDump(const std::string &dumpOption, std::vector<std::string> &dumpInfo) override; 118 virtual ErrCode PublishContinuousTaskNotification(const sptr<NotificationRequest> &request) override; 119 virtual ErrCode CancelContinuousTaskNotification(const std::string &label, int32_t notificationId) override; 120 virtual ErrCode PublishReminder(sptr<ReminderRequest> &reminder) override; 121 virtual ErrCode CancelReminder(const int32_t reminderId) override; 122 virtual ErrCode GetValidReminders(std::vector<sptr<ReminderRequest>> &reminders) override; 123 virtual ErrCode CancelAllReminders() override; 124 virtual ErrCode IsSupportTemplate(const std::string &templateName, bool &support) override; 125 virtual ErrCode IsSpecialUserAllowedNotify(const int32_t &userId, bool &allowed) override; 126 virtual ErrCode SetNotificationsEnabledByUser(const int32_t &deviceId, bool enabled) override; 127 virtual ErrCode DeleteAllByUser(const int32_t &userId) override; 128 virtual ErrCode SetDoNotDisturbDate(const int32_t &userId, const sptr<NotificationDoNotDisturbDate> &date) override; 129 virtual ErrCode GetDoNotDisturbDate(const int32_t &userId, sptr<NotificationDoNotDisturbDate> &date) override; 130 131 private: 132 static const std::map<uint32_t, std::function<ErrCode(AnsManagerStub *, MessageParcel &, MessageParcel &)>> 133 interfaces_; 134 135 ErrCode HandlePublish(MessageParcel &data, MessageParcel &reply); 136 ErrCode HandlePublishToDevice(MessageParcel &data, MessageParcel &reply); 137 ErrCode HandleCancel(MessageParcel &data, MessageParcel &reply); 138 ErrCode HandleCancelAll(MessageParcel &data, MessageParcel &reply); 139 ErrCode HandleAddSlotByType(MessageParcel &data, MessageParcel &reply); 140 ErrCode HandleAddSlots(MessageParcel &data, MessageParcel &reply); 141 ErrCode HandleRemoveSlotByType(MessageParcel &data, MessageParcel &reply); 142 ErrCode HandleRemoveAllSlots(MessageParcel &data, MessageParcel &reply); 143 ErrCode HandleAddSlotGroups(MessageParcel &data, MessageParcel &reply); 144 ErrCode HandleGetSlots(MessageParcel &data, MessageParcel &reply); 145 ErrCode HandleGetSlotByType(MessageParcel &data, MessageParcel &reply); 146 ErrCode HandleGetSlotGroup(MessageParcel &data, MessageParcel &reply); 147 ErrCode HandleGetSlotGroups(MessageParcel &data, MessageParcel &reply); 148 ErrCode HandleGetSlotNumAsBundle(MessageParcel &data, MessageParcel &reply); 149 ErrCode HandleRemoveSlotGroups(MessageParcel &data, MessageParcel &reply); 150 ErrCode HandleGetActiveNotifications(MessageParcel &data, MessageParcel &reply); 151 ErrCode HandleGetActiveNotificationNums(MessageParcel &data, MessageParcel &reply); 152 ErrCode HandleGetAllActiveNotifications(MessageParcel &data, MessageParcel &reply); 153 ErrCode HandleGetSpecialActiveNotifications(MessageParcel &data, MessageParcel &reply); 154 ErrCode HandleSetNotificationAgent(MessageParcel &data, MessageParcel &reply); 155 ErrCode HandleGetNotificationAgent(MessageParcel &data, MessageParcel &reply); 156 ErrCode HandleCanPublishAsBundle(MessageParcel &data, MessageParcel &reply); 157 ErrCode HandlePublishAsBundle(MessageParcel &data, MessageParcel &reply); 158 ErrCode HandleSetNotificationBadgeNum(MessageParcel &data, MessageParcel &reply); 159 ErrCode HandleGetBundleImportance(MessageParcel &data, MessageParcel &reply); 160 ErrCode HandleIsNotificationPolicyAccessGranted(MessageParcel &data, MessageParcel &reply); 161 ErrCode HandleSetPrivateNotificationsAllowed(MessageParcel &data, MessageParcel &reply); 162 ErrCode HandleGetPrivateNotificationsAllowed(MessageParcel &data, MessageParcel &reply); 163 ErrCode HandleRemoveNotification(MessageParcel &data, MessageParcel &reply); 164 ErrCode HandleRemoveAllNotifications(MessageParcel &data, MessageParcel &reply); 165 ErrCode HandleDelete(MessageParcel &data, MessageParcel &reply); 166 ErrCode HandleDeleteByBundle(MessageParcel &data, MessageParcel &reply); 167 ErrCode HandleDeleteAll(MessageParcel &data, MessageParcel &reply); 168 ErrCode HandleGetSlotsByBundle(MessageParcel &data, MessageParcel &reply); 169 ErrCode HandleUpdateSlots(MessageParcel &data, MessageParcel &reply); 170 ErrCode HandleUpdateSlotGroups(MessageParcel &data, MessageParcel &reply); 171 ErrCode HandleRequestEnableNotification(MessageParcel &data, MessageParcel &reply); 172 ErrCode HandleSetNotificationsEnabledForBundle(MessageParcel &data, MessageParcel &reply); 173 ErrCode HandleSetNotificationsEnabledForAllBundles(MessageParcel &data, MessageParcel &reply); 174 ErrCode HandleSetNotificationsEnabledForSpecialBundle(MessageParcel &data, MessageParcel &reply); 175 ErrCode HandleSetShowBadgeEnabledForBundle(MessageParcel &data, MessageParcel &reply); 176 ErrCode HandleGetShowBadgeEnabledForBundle(MessageParcel &data, MessageParcel &reply); 177 ErrCode HandleGetShowBadgeEnabled(MessageParcel &data, MessageParcel &reply); 178 ErrCode HandleSubscribe(MessageParcel &data, MessageParcel &reply); 179 ErrCode HandleUnsubscribe(MessageParcel &data, MessageParcel &reply); 180 ErrCode HandleAreNotificationsSuspended(MessageParcel &data, MessageParcel &reply); 181 ErrCode HandleGetCurrentAppSorting(MessageParcel &data, MessageParcel &reply); 182 ErrCode HandleIsAllowedNotify(MessageParcel &data, MessageParcel &reply); 183 ErrCode HandleIsAllowedNotifySelf(MessageParcel &data, MessageParcel &reply); 184 ErrCode HandleIsSpecialBundleAllowedNotify(MessageParcel &data, MessageParcel &reply); 185 ErrCode HandleIsDistributedEnabled(MessageParcel &data, MessageParcel &reply); 186 ErrCode HandleEnableDistributed(MessageParcel &data, MessageParcel &reply); 187 ErrCode HandleEnableDistributedByBundle(MessageParcel &data, MessageParcel &reply); 188 ErrCode HandleEnableDistributedSelf(MessageParcel &data, MessageParcel &reply); 189 ErrCode HandleIsDistributedEnableByBundle(MessageParcel &data, MessageParcel &reply); 190 ErrCode HandleShellDump(MessageParcel &data, MessageParcel &reply); 191 ErrCode HandleCancelGroup(MessageParcel &data, MessageParcel &reply); 192 ErrCode HandleRemoveGroupByBundle(MessageParcel &data, MessageParcel &reply); 193 ErrCode HandleSetDoNotDisturbDate(MessageParcel &data, MessageParcel &reply); 194 ErrCode HandleGetDoNotDisturbDate(MessageParcel &data, MessageParcel &reply); 195 ErrCode HandleDoesSupportDoNotDisturbMode(MessageParcel &data, MessageParcel &reply); 196 ErrCode HandleGetDeviceRemindType(MessageParcel &data, MessageParcel &reply); 197 ErrCode HandlePublishContinuousTaskNotification(MessageParcel &data, MessageParcel &reply); 198 ErrCode HandleCancelContinuousTaskNotification(MessageParcel &data, MessageParcel &reply); 199 ErrCode HandlePublishReminder(MessageParcel &data, MessageParcel &reply); 200 ErrCode HandleCancelReminder(MessageParcel &data, MessageParcel &reply); 201 ErrCode HandleGetValidReminders(MessageParcel &data, MessageParcel &reply); 202 ErrCode HandleCancelAllReminders(MessageParcel &data, MessageParcel &reply); 203 ErrCode HandleIsSupportTemplate(MessageParcel &data, MessageParcel &reply); 204 ErrCode HandleIsSpecialUserAllowedNotifyByUser(MessageParcel &data, MessageParcel &reply); 205 ErrCode HandleSetNotificationsEnabledByUser(MessageParcel &data, MessageParcel &reply); 206 ErrCode HandleDeleteAllByUser(MessageParcel &data, MessageParcel &reply); 207 ErrCode HandleSetDoNotDisturbDateByUser(MessageParcel &data, MessageParcel &reply); 208 ErrCode HandleGetDoNotDisturbDateByUser(MessageParcel &data, MessageParcel &reply); 209 210 template<typename T> 211 bool WriteParcelableVector(const std::vector<sptr<T>> &parcelableVector, MessageParcel &reply, ErrCode &result); 212 213 template<typename T> 214 bool ReadParcelableVector(std::vector<sptr<T>> &parcelableInfos, MessageParcel &data); 215 }; 216 } // namespace Notification 217 } // namespace OHOS 218 219 #endif // BASE_NOTIFICATION_ANS_STANDARD_FRAMEWORKS_ANS_CORE_INCLUDE_ANS_MANAGER_STUB_H 220