1bc2ed2b3Sopenharmony_ci/* 2bc2ed2b3Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 3bc2ed2b3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4bc2ed2b3Sopenharmony_ci * you may not use this file except in compliance with the License. 5bc2ed2b3Sopenharmony_ci * You may obtain a copy of the License at 6bc2ed2b3Sopenharmony_ci * 7bc2ed2b3Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8bc2ed2b3Sopenharmony_ci * 9bc2ed2b3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10bc2ed2b3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11bc2ed2b3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12bc2ed2b3Sopenharmony_ci * See the License for the specific language governing permissions and 13bc2ed2b3Sopenharmony_ci * limitations under the License. 14bc2ed2b3Sopenharmony_ci */ 15bc2ed2b3Sopenharmony_ci#ifndef NFC_SA_MANAGER_H 16bc2ed2b3Sopenharmony_ci#define NFC_SA_MANAGER_H 17bc2ed2b3Sopenharmony_ci#include "iservice_registry.h" 18bc2ed2b3Sopenharmony_ci#include "nfc_controller_impl.h" 19bc2ed2b3Sopenharmony_ci#include "nfc_event_handler.h" 20bc2ed2b3Sopenharmony_ci#include "nfc_service.h" 21bc2ed2b3Sopenharmony_ci#include "singleton.h" 22bc2ed2b3Sopenharmony_ci#include "system_ability.h" 23bc2ed2b3Sopenharmony_ci 24bc2ed2b3Sopenharmony_cinamespace OHOS { 25bc2ed2b3Sopenharmony_cinamespace NFC { 26bc2ed2b3Sopenharmony_cienum class ServiceRunningState { 27bc2ed2b3Sopenharmony_ci STATE_NOT_START, 28bc2ed2b3Sopenharmony_ci STATE_RUNNING 29bc2ed2b3Sopenharmony_ci}; 30bc2ed2b3Sopenharmony_ci 31bc2ed2b3Sopenharmony_ciclass NfcSaManager : public SystemAbility { 32bc2ed2b3Sopenharmony_ci DECLARE_DELAYED_SINGLETON(NfcSaManager) 33bc2ed2b3Sopenharmony_ci DECLARE_SYSTEM_ABILITY(NfcSaManager); // necessary 34bc2ed2b3Sopenharmony_cipublic: 35bc2ed2b3Sopenharmony_ci DISALLOW_COPY_AND_MOVE(NfcSaManager); 36bc2ed2b3Sopenharmony_ci 37bc2ed2b3Sopenharmony_ci /* Nfc open or close operations */ 38bc2ed2b3Sopenharmony_ci void OnStart() override; 39bc2ed2b3Sopenharmony_ci void OnStop() override; 40bc2ed2b3Sopenharmony_ci void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; 41bc2ed2b3Sopenharmony_ci void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; 42bc2ed2b3Sopenharmony_ci 43bc2ed2b3Sopenharmony_ci /* query service state */ 44bc2ed2b3Sopenharmony_ci ServiceRunningState QueryServiceState() const 45bc2ed2b3Sopenharmony_ci { 46bc2ed2b3Sopenharmony_ci return state_; 47bc2ed2b3Sopenharmony_ci } 48bc2ed2b3Sopenharmony_ci 49bc2ed2b3Sopenharmony_ciprivate: 50bc2ed2b3Sopenharmony_ci bool Init(); 51bc2ed2b3Sopenharmony_ci bool registerToService_ = false; 52bc2ed2b3Sopenharmony_ci ServiceRunningState state_ = ServiceRunningState::STATE_NOT_START; 53bc2ed2b3Sopenharmony_ci 54bc2ed2b3Sopenharmony_ci std::shared_ptr<NfcService> nfcService_; 55bc2ed2b3Sopenharmony_ci sptr<NfcControllerImpl> nfcControllerImpl_; 56bc2ed2b3Sopenharmony_ci std::mutex initMutex_ {}; 57bc2ed2b3Sopenharmony_ci}; 58bc2ed2b3Sopenharmony_ci} // namespace NFC 59bc2ed2b3Sopenharmony_ci} // namespace OHOS 60bc2ed2b3Sopenharmony_ci#endif // NFC_SA_MANAGER_H 61