196279301Sopenharmony_ci/* 296279301Sopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 396279301Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 496279301Sopenharmony_ci * you may not use this file except in compliance with the License. 596279301Sopenharmony_ci * You may obtain a copy of the License at 696279301Sopenharmony_ci * 796279301Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 896279301Sopenharmony_ci * 996279301Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1096279301Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1196279301Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1296279301Sopenharmony_ci * See the License for the specific language governing permissions and 1396279301Sopenharmony_ci * limitations under the License. 1496279301Sopenharmony_ci */ 1596279301Sopenharmony_ci 1696279301Sopenharmony_ci#ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_SUBSCRIBER_H 1796279301Sopenharmony_ci#define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_SUBSCRIBER_H 1896279301Sopenharmony_ci 1996279301Sopenharmony_ci#include "ans_manager_interface.h" 2096279301Sopenharmony_ci#include "ans_subscriber_stub.h" 2196279301Sopenharmony_ci#include "notification_request.h" 2296279301Sopenharmony_ci#include "notification_sorting.h" 2396279301Sopenharmony_ci#include "notification_sorting_map.h" 2496279301Sopenharmony_ci 2596279301Sopenharmony_cinamespace OHOS { 2696279301Sopenharmony_cinamespace Notification { 2796279301Sopenharmony_ciclass NotificationSubscriber : public std::enable_shared_from_this<NotificationSubscriber> { 2896279301Sopenharmony_cipublic: 2996279301Sopenharmony_ci NotificationSubscriber(); 3096279301Sopenharmony_ci 3196279301Sopenharmony_ci virtual ~NotificationSubscriber(); 3296279301Sopenharmony_ci 3396279301Sopenharmony_ci /** 3496279301Sopenharmony_ci * @brief Called back when a notification is canceled. 3596279301Sopenharmony_ci * 3696279301Sopenharmony_ci * @param request Indicates the canceled Notification object. 3796279301Sopenharmony_ci * @param sortingMap Indicates the sorting map used by the current subscriber 3896279301Sopenharmony_ci * to obtain notification ranking information. 3996279301Sopenharmony_ci * @param deleteReason Indicates the reason for the deletion. For details, see NotificationConstant. 4096279301Sopenharmony_ci **/ 4196279301Sopenharmony_ci virtual void OnCanceled(const std::shared_ptr<Notification> &request, 4296279301Sopenharmony_ci const std::shared_ptr<NotificationSortingMap> &sortingMap, int32_t deleteReason) = 0; 4396279301Sopenharmony_ci 4496279301Sopenharmony_ci /** 4596279301Sopenharmony_ci * @brief Called back when the subscriber is connected to the Advanced Notification Service (ANS). 4696279301Sopenharmony_ci **/ 4796279301Sopenharmony_ci virtual void OnConnected() = 0; 4896279301Sopenharmony_ci 4996279301Sopenharmony_ci /** 5096279301Sopenharmony_ci * @brief Called back when the subscriber receives a new notification. 5196279301Sopenharmony_ci * 5296279301Sopenharmony_ci * @param request Indicates the received Notification object. 5396279301Sopenharmony_ci * @param sortingMap Indicates the sorting map used by the current subscriber to obtain 5496279301Sopenharmony_ci * notification ranking information. 5596279301Sopenharmony_ci **/ 5696279301Sopenharmony_ci virtual void OnConsumed( 5796279301Sopenharmony_ci const std::shared_ptr<Notification> &request, const std::shared_ptr<NotificationSortingMap> &sortingMap) = 0; 5896279301Sopenharmony_ci 5996279301Sopenharmony_ci /** 6096279301Sopenharmony_ci * @brief Called back when the subscriber is disconnected from the ANS. 6196279301Sopenharmony_ci **/ 6296279301Sopenharmony_ci virtual void OnDisconnected() = 0; 6396279301Sopenharmony_ci 6496279301Sopenharmony_ci /** 6596279301Sopenharmony_ci * @brief Called back when the ranking information about the current notification changes. 6696279301Sopenharmony_ci * 6796279301Sopenharmony_ci * @param sortingMap Indicates the sorting map used to obtain notification ranking information. 6896279301Sopenharmony_ci **/ 6996279301Sopenharmony_ci virtual void OnUpdate(const std::shared_ptr<NotificationSortingMap> &sortingMap) = 0; 7096279301Sopenharmony_ci 7196279301Sopenharmony_ci /** 7296279301Sopenharmony_ci * @brief Called back when connection to the ANS has died. 7396279301Sopenharmony_ci **/ 7496279301Sopenharmony_ci virtual void OnDied() = 0; 7596279301Sopenharmony_ci 7696279301Sopenharmony_ci /** 7796279301Sopenharmony_ci * @brief Called when the Do Not Disturb date changes. 7896279301Sopenharmony_ci * 7996279301Sopenharmony_ci * @param date Indicates the current Do Not Disturb date. 8096279301Sopenharmony_ci **/ 8196279301Sopenharmony_ci virtual void OnDoNotDisturbDateChange(const std::shared_ptr<NotificationDoNotDisturbDate> &date) = 0; 8296279301Sopenharmony_ci 8396279301Sopenharmony_ci /** 8496279301Sopenharmony_ci * @brief Called when the notification permission changes. 8596279301Sopenharmony_ci * 8696279301Sopenharmony_ci * @param callbackData Indicates the properties of the application that notification permission has changed. 8796279301Sopenharmony_ci **/ 8896279301Sopenharmony_ci virtual void OnEnabledNotificationChanged(const std::shared_ptr<EnabledNotificationCallbackData> &callbackData) = 0; 8996279301Sopenharmony_ci 9096279301Sopenharmony_ci /** 9196279301Sopenharmony_ci * @brief The callback function on the badge number changed. 9296279301Sopenharmony_ci * 9396279301Sopenharmony_ci * @param badgeData Indicates the BadgeNumberCallbackData object. 9496279301Sopenharmony_ci */ 9596279301Sopenharmony_ci virtual void OnBadgeChanged(const std::shared_ptr<BadgeNumberCallbackData> &badgeData) = 0; 9696279301Sopenharmony_ci 9796279301Sopenharmony_ci /** 9896279301Sopenharmony_ci * @brief The callback function on the badge enabled state changed. 9996279301Sopenharmony_ci * 10096279301Sopenharmony_ci * @param callbackData Indicates the properties of the application that badge enabled state has changed. 10196279301Sopenharmony_ci */ 10296279301Sopenharmony_ci virtual void OnBadgeEnabledChanged(const sptr<EnabledNotificationCallbackData> &callbackData) = 0; 10396279301Sopenharmony_ci 10496279301Sopenharmony_ci /** 10596279301Sopenharmony_ci * @brief The callback function on the badge number changed. 10696279301Sopenharmony_ci * 10796279301Sopenharmony_ci * @param badgeData Indicates the BadgeNumberCallbackData object. 10896279301Sopenharmony_ci */ 10996279301Sopenharmony_ci virtual void OnBatchCanceled(const std::vector<std::shared_ptr<Notification>> &requestList, 11096279301Sopenharmony_ci const std::shared_ptr<NotificationSortingMap> &sortingMap, int32_t deleteReason) = 0; 11196279301Sopenharmony_ci 11296279301Sopenharmony_ci virtual bool HasOnBatchCancelCallback() 11396279301Sopenharmony_ci { 11496279301Sopenharmony_ci return false; 11596279301Sopenharmony_ci } 11696279301Sopenharmony_ci 11796279301Sopenharmony_ci void SetDeviceType(const std::string &deviceType); 11896279301Sopenharmony_ci 11996279301Sopenharmony_ci std::string GetDeviceType() const; 12096279301Sopenharmony_ci std::shared_ptr<NotificationSubscriber> GetSharedPtr() const; 12196279301Sopenharmony_ci 12296279301Sopenharmony_ci#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED 12396279301Sopenharmony_ci bool ProcessSyncDecision(const std::string &deviceType, std::shared_ptr<Notification> ¬ification) const; 12496279301Sopenharmony_ci#endif 12596279301Sopenharmony_ci 12696279301Sopenharmony_ciprivate: 12796279301Sopenharmony_ci#ifdef NOTIFICATION_SMART_REMINDER_SUPPORTED 12896279301Sopenharmony_ci NotificationConstant::FlagStatus DowngradeReminder( 12996279301Sopenharmony_ci const NotificationConstant::FlagStatus &oldFlags, const NotificationConstant::FlagStatus &judgeFlags) const; 13096279301Sopenharmony_ci#endif 13196279301Sopenharmony_ci 13296279301Sopenharmony_ciprivate: 13396279301Sopenharmony_ci std::string deviceType_; 13496279301Sopenharmony_ci}; 13596279301Sopenharmony_ci} // namespace Notification 13696279301Sopenharmony_ci} // namespace OHOS 13796279301Sopenharmony_ci 13896279301Sopenharmony_ci#endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_SUBSCRIBER_H 139