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 #include "infc_controller_callback.h" 18 #include "nfc_controller_stub.h" 19 #include "nfc_sdk_common.h" 20 21 namespace OHOS { 22 namespace NFC { 23 class NfcService; 24 class NfcControllerImpl final : public NfcControllerStub { 25 public: 26 explicit NfcControllerImpl(std::weak_ptr<NfcService> nfcService); 27 ~NfcControllerImpl() override; 28 29 int GetState() override; 30 int TurnOn() override; 31 int TurnOff() override; 32 int IsNfcOpen(bool &isOpen) override; 33 KITS::ErrorCode RegisterCallBack(const sptr<INfcControllerCallback> &callback, 34 const std::string& type, Security::AccessToken::AccessTokenID callerToken) override; 35 KITS::ErrorCode UnRegisterCallBack(const std::string& type, 36 Security::AccessToken::AccessTokenID callerToken) override; 37 KITS::ErrorCode UnRegisterAllCallBack(Security::AccessToken::AccessTokenID callerToken) override; 38 OHOS::sptr<IRemoteObject> GetTagServiceIface() override; 39 OHOS::sptr<IRemoteObject> GetHceServiceIface() override; 40 KITS::ErrorCode RegNdefMsgCallback(const sptr<INdefMsgCallback> &callback) override; 41 #ifdef VENDOR_APPLICATIONS_ENABLED 42 KITS::ErrorCode RegQueryApplicationCb(const sptr<IQueryAppInfoCallback> callback) override; 43 KITS::ErrorCode RegCardEmulationNotifyCb(const sptr<IOnCardEmulationNotifyCb> callback) override; 44 KITS::ErrorCode NotifyEventStatus(int eventType, int arg1, std::string arg2) override; 45 #endif 46 int32_t Dump(int32_t fd, const std::vector<std::u16string>& args) override; 47 48 private: 49 std::string GetDumpInfo(); 50 51 private: 52 std::weak_ptr<NfcService> nfcService_ = {}; 53 std::mutex mutex_ {}; 54 }; 55 } // namespace NFC 56 } // namespace OHOS 57 #endif // NFC_CONTROLLER_IMPL_H 58