• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #ifndef NFC_SA_MANAGER_H
16 #define NFC_SA_MANAGER_H
17 
18 #include "common_event_handler.h"
19 #include "iservice_registry.h"
20 #include "nfc_controller_impl.h"
21 #include "nfc_service.h"
22 #include "singleton.h"
23 #include "system_ability.h"
24 
25 namespace OHOS {
26 namespace NFC {
27 enum class ServiceRunningState {
28     STATE_NOT_START,
29     STATE_RUNNING
30 };
31 
32 class NfcSaManager : public SystemAbility {
33     DECLARE_DELAYED_SINGLETON(NfcSaManager)
34     DECLARE_SYSTEM_ABILITY(NfcSaManager); // necessary
35 public:
36     DISALLOW_COPY_AND_MOVE(NfcSaManager);
37 
38     /* Nfc open or close operations */
39     void OnStart() override;
40     void OnStop() override;
41     void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override;
42     void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override;
43 
44     /* query service state */
QueryServiceState()45     ServiceRunningState QueryServiceState() const
46     {
47         return state_;
48     }
49 
50 private:
51     bool Init();
52     bool registerToService_ = false;
53     ServiceRunningState state_ = ServiceRunningState::STATE_NOT_START;
54 
55     std::shared_ptr<NfcService> nfcService_;
56     sptr<NfcControllerImpl> nfcControllerImpl_;
57 };
58 }  // namespace NFC
59 }  // namespace OHOS
60 #endif  // NFC_SA_MANAGER_H
61