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_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_NOTIFICATION_SERVICE_ABILITY_H 17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_NOTIFICATION_SERVICE_ABILITY_H 18 19 #include "system_ability.h" 20 21 #include "advanced_datashare_observer.h" 22 #include "advanced_notification_service.h" 23 #include "reminder_data_manager.h" 24 #include "system_ability_definition.h" 25 #include "notification_extension_wrapper.h" 26 27 namespace OHOS { 28 namespace Notification { 29 class AdvancedNotificationServiceAbility final : public SystemAbility { 30 public: 31 /** 32 * @brief The constructor of service ability. 33 * 34 * @param systemAbilityId Indicates the system ability id. 35 * @param runOnCreate Run the system ability on created. 36 */ 37 AdvancedNotificationServiceAbility(const int32_t systemAbilityId, bool runOnCreate); 38 39 /** 40 * @brief The deconstructor. 41 */ 42 ~AdvancedNotificationServiceAbility() final; 43 44 DISALLOW_COPY_AND_MOVE(AdvancedNotificationServiceAbility); 45 DECLARE_SYSTEM_ABILITY(AdvancedNotificationServiceAbility); 46 47 private: 48 void OnStart() final; 49 void OnStop() final; 50 void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; 51 void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; 52 void OnReceiveEvent(const EventFwk::CommonEventData &data); 53 int32_t OnExtension(const std::string& extension, MessageParcel& data, MessageParcel& reply) override; 54 55 private: 56 std::atomic<bool> isDatashaReready_ {false}; 57 sptr<AdvancedNotificationService> service_; 58 std::shared_ptr<ReminderDataManager> reminderAgent_; 59 std::shared_ptr<SystemEventSubscriber> subscriber_ = nullptr; 60 }; 61 } // namespace Notification 62 } // namespace OHOS 63 64 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_SERVICES_ANS_INCLUDE_NOTIFICATION_SERVICE_ABILITY_H 65