• 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_CONTROLLER_IMPL_H
16 #define NFC_CONTROLLER_IMPL_H
17 
18 #include "access_token.h"
19 #include "infc_controller_callback.h"
20 #include "nfc_controller_stub.h"
21 #include "nfc_sdk_common.h"
22 
23 namespace OHOS {
24 namespace NFC {
25 class NfcService;
26 class NfcControllerImpl final : public NfcControllerStub {
27 public:
28     explicit NfcControllerImpl(std::weak_ptr<NfcService> nfcService);
29     ~NfcControllerImpl() override;
30 
31     int32_t CallbackEnter(uint32_t code) override;
32     int32_t CallbackExit(uint32_t code, int32_t result) override;
33 
34     ErrCode GetState(int32_t& funcResult) override;
35     ErrCode TurnOn() override;
36     ErrCode TurnOff() override;
37 
38     ErrCode RegisterNfcStatusCallBack(const sptr<INfcControllerCallback>& cb, const std::string& type) override;
39 
40     ErrCode UnregisterNfcStatusCallBack(const std::string& type) override;
41 
42     KITS::ErrorCode UnRegisterAllCallBack(Security::AccessToken::AccessTokenID callerToken);
43     ErrCode GetTagServiceIface(sptr<IRemoteObject>& funcResult) override;
44     ErrCode GetHceServiceIface(sptr<IRemoteObject>& funcResult) override;
45     ErrCode RegNdefMsgCb(const sptr<INdefMsgCallback>& cb) override;
46 
47     ErrCode RegQueryApplicationCb(const sptr<IQueryAppInfoCallback>& cb) override;
48     ErrCode RegCardEmulationNotifyCb(const sptr<IOnCardEmulationNotifyCb>& cb) override;
49     ErrCode NotifyEventStatus(int32_t eventType, int32_t arg1, const std::string& arg2) override;
50 
51     void RemoveNfcDeathRecipient(const wptr<IRemoteObject> &remote);
52 
53 private:
54     std::weak_ptr<NfcService> nfcService_ = {};
55     std::mutex mutex_ {};
56     sptr<INfcControllerCallback> callback_ = nullptr;
57     sptr<IRemoteObject::DeathRecipient> deathRecipient_ = nullptr;
58 };
59 }  // namespace NFC
60 }  // namespace OHOS
61 #endif  // NFC_CONTROLLER_IMPL_H
62