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_STUB_H 16 #define NFC_CONTROLLER_STUB_H 17 18 #include "infc_controller_callback.h" 19 #include "infc_controller_service.h" 20 #include "iremote_stub.h" 21 #include "nfc_controller_callback_proxy.h" 22 #include "nfc_sdk_common.h" 23 #include "message_parcel.h" 24 #include "access_token.h" 25 26 namespace OHOS { 27 namespace NFC { 28 class NfcControllerStub : public OHOS::IRemoteStub<OHOS::NFC::INfcControllerService> { 29 public: 30 int OnRemoteRequest(uint32_t code, /* [in] */ 31 OHOS::MessageParcel& data, /* [in] */ 32 OHOS::MessageParcel& reply, /* [out] */ 33 OHOS::MessageOption& option) override; /* [in] */ 34 NfcControllerStub()35 NfcControllerStub() {} ~NfcControllerStub()36 virtual ~NfcControllerStub() {} 37 virtual KITS::ErrorCode RegisterCallBack(const sptr<INfcControllerCallback> &callback, 38 const std::string& type, Security::AccessToken::AccessTokenID callerToken) = 0; 39 virtual KITS::ErrorCode UnRegisterCallBack(const std::string& type, 40 Security::AccessToken::AccessTokenID callerToken) = 0; 41 virtual KITS::ErrorCode UnRegisterAllCallBack(Security::AccessToken::AccessTokenID callerToken) = 0; 42 void RemoveNfcDeathRecipient(const wptr<IRemoteObject> &remote); 43 44 private: 45 int HandleGetState(OHOS::MessageParcel& data, OHOS::MessageParcel& reply); 46 int HandleTurnOn(OHOS::MessageParcel& data, OHOS::MessageParcel& reply); 47 int HandleTurnOff(OHOS::MessageParcel& data, OHOS::MessageParcel& reply); 48 int HandleIsNfcOpen(OHOS::MessageParcel& data, OHOS::MessageParcel& reply); 49 int HandleRegisterCallBack(OHOS::MessageParcel& data, OHOS::MessageParcel& reply); 50 int HandleUnRegisterCallBack(OHOS::MessageParcel& data, OHOS::MessageParcel& reply); 51 int HandleGetNfcTagInterface(MessageParcel& data, MessageParcel& reply); 52 53 private: 54 KITS::ErrorCode RegisterCallBack(const sptr<INfcControllerCallback> &callback, 55 const std::string& type) override; 56 KITS::ErrorCode UnRegisterCallBack(const std::string& type) override; 57 58 private: 59 sptr<INfcControllerCallback> callback_; 60 sptr<IRemoteObject::DeathRecipient> deathRecipient_ {nullptr}; 61 }; 62 } // namespace NFC 63 } // namespace OHOS 64 #endif // NFC_CONTROLLER_STUB_H 65