1 /* 2 * Copyright (C) 2025 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 MOCK_NFC_SERVICE_H 16 #define MOCK_NFC_SERVICE_H 17 #include <future> 18 #include <mutex> 19 #include "nfc_service.h" 20 21 namespace OHOS { 22 namespace NFC { 23 class MockNfcService : public NfcService { 24 public: 25 bool Initialize(); 26 std::weak_ptr<NfcService> GetInstance() const; 27 void OnTagDiscovered(uint32_t tagDiscId) override; 28 void OnTagLost(uint32_t tagDiscId) override; 29 void FieldActivated() override; 30 void FieldDeactivated() override; 31 #ifdef VENDOR_APPLICATIONS_ENABLED 32 void OnVendorEvent(int eventType, int arg1, std::string arg2); 33 #endif 34 void OnCardEmulationData(const std::vector<uint8_t>& data) override; 35 void OnCardEmulationActivated() override; 36 void OnCardEmulationDeactivated() override; 37 OHOS::sptr<IRemoteObject> GetTagServiceIface() override; 38 OHOS::sptr<IRemoteObject> GetHceServiceIface() override; 39 40 bool IsNfcEnabled() override; 41 int GetNfcState() override; 42 int GetScreenState() override; 43 int GetNciVersion() override; 44 std::weak_ptr<NCI::INciNfccInterface> GetNciNfccProxy(void); 45 std::weak_ptr<NCI::INciTagInterface> GetNciTagProxy(void); 46 std::weak_ptr<NfcPollingManager> GetNfcPollingManager() override; 47 std::weak_ptr<NfcRoutingManager> GetNfcRoutingManager() override; 48 49 std::weak_ptr<CeService> GetCeService() override; 50 std::string GetSimVendorBundleName() override; 51 52 std::weak_ptr<TAG::TagDispatcher> GetTagDispatcher() override; 53 void NotifyMessageToVendor(int key, const std::string &value); 54 55 private: 56 std::weak_ptr<NfcService> nfcService_ {}; 57 std::shared_ptr<NCI::INciNfccInterface> nciNfccProxy_ {}; 58 std::shared_ptr<NCI::INciTagInterface> nciTagProxy_ {}; 59 std::shared_ptr<NCI::INciCeInterface> nciCeProxy_ {}; 60 // polling manager 61 std::shared_ptr<NfcPollingManager> nfcPollingManager_ {}; 62 // routing manager 63 std::shared_ptr<NfcRoutingManager> nfcRoutingManager_ {}; 64 OHOS::sptr<IRemoteObject> tagSessionIface_{}; 65 OHOS::sptr<IRemoteObject> hceSessionIface_ {}; 66 std::shared_ptr<NfcEventHandler> eventHandler_ {}; 67 std::shared_ptr<CeService> ceService_ {}; 68 std::shared_ptr<TAG::TagDispatcher> tagDispatcher_ {}; 69 OHOS::sptr<NfcControllerImpl> nfcControllerImpl_ {}; 70 }; 71 } // namespace NFC 72 } // namespace OHOS 73 #endif // MOCK_NFC_SERVICE_H 74