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