• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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_FRAMEWORKS_ANS_CORE_INCLUDE_REMINDER_EVENT_MANAGER_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_ANS_CORE_INCLUDE_REMINDER_EVENT_MANAGER_H
18 
19 #include "common_event_subscriber.h"
20 #include "reminder_data_manager.h"
21 #include "system_ability_status_change_stub.h"
22 
23 #include <memory>
24 
25 namespace OHOS {
26 namespace Notification {
27 class ReminderEventManager {
28 public:
29     explicit ReminderEventManager(std::shared_ptr<ReminderDataManager> &reminderDataManager);
~ReminderEventManager()30     virtual ~ReminderEventManager() {};
31     ReminderEventManager(ReminderEventManager &other) = delete;
32     ReminderEventManager& operator = (const ReminderEventManager &other) = delete;
33 
34 private:
35     void init(std::shared_ptr<ReminderDataManager> &reminderDataManager) const;
36 
37 class ReminderEventSubscriber : public EventFwk::CommonEventSubscriber {
38 public:
39     ReminderEventSubscriber(const EventFwk::CommonEventSubscribeInfo &subscriberInfo,
40         std::shared_ptr<ReminderDataManager> &reminderDataManager);
41     virtual void OnReceiveEvent(const EventFwk::CommonEventData &data);
42 
43 private:
44     sptr<NotificationBundleOption> GetBundleOption(const OHOS::EventFwk::Want &want) const;
45     void HandlePackageRemove(const EventFwk::Want &want) const;
46     void HandleProcessDied(const EventFwk::Want &want) const;
47     std::shared_ptr<ReminderDataManager> reminderDataManager_ = nullptr;
48 };
49 
50 class ReminderEventCustomSubscriber : public EventFwk::CommonEventSubscriber {
51 public:
52     ReminderEventCustomSubscriber(const EventFwk::CommonEventSubscribeInfo &subscriberInfo,
53         std::shared_ptr<ReminderDataManager> &reminderDataManager);
54     virtual void OnReceiveEvent(const EventFwk::CommonEventData &data);
55 
56 private:
57     std::shared_ptr<ReminderDataManager> reminderDataManager_ = nullptr;
58 };
59 
60 class SystemAbilityStatusChangeListener : public OHOS::SystemAbilityStatusChangeStub {
61 public:
62     explicit SystemAbilityStatusChangeListener(std::shared_ptr<ReminderDataManager> &reminderDataManager);
~SystemAbilityStatusChangeListener()63     ~SystemAbilityStatusChangeListener() {};
64     virtual void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override;
65     virtual void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override;
66 private:
67     std::shared_ptr<ReminderDataManager> reminderDataManager_ = nullptr;
68 };
69 };
70 }  // namespace OHOS
71 }  // namespace Notification
72 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_FRAMEWORKS_ANS_CORE_INCLUDE_REMINDER_EVENT_MANAGER_H
73