1 /* 2 * Copyright (C) 2023 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 HCE_SESSION_H 16 #define HCE_SESSION_H 17 18 #include "element_name.h" 19 #include "infc_service.h" 20 #include "ihce_session.h" 21 #include "hce_session_stub.h" 22 #include "host_card_emulation_manager.h" 23 #include "ability_info.h" 24 25 namespace OHOS { 26 namespace NFC { 27 namespace HCE { 28 using AppExecFwk::AbilityInfo; 29 using OHOS::AppExecFwk::ElementName; 30 class HceSession final : public HceSessionStub { 31 public: 32 // Constructor/Destructor 33 explicit HceSession(std::shared_ptr<NFC::INfcService> service); 34 ~HceSession() override; 35 36 HceSession(const HceSession &) = delete; 37 HceSession &operator=(const HceSession &) = delete; 38 39 KITS::ErrorCode RegHceCmdCallbackByToken(const sptr<KITS::IHceCmdCallback> &callback, const std::string &type, 40 Security::AccessToken::AccessTokenID callerToken) override; 41 42 KITS::ErrorCode UnRegHceCmdCallback(const std::string &type, 43 Security::AccessToken::AccessTokenID callerToken) override; 44 KITS::ErrorCode UnRegAllCallback(Security::AccessToken::AccessTokenID callerToken) override; 45 KITS::ErrorCode HandleWhenRemoteDie(Security::AccessToken::AccessTokenID callerToken) override; 46 47 int SendRawFrameByToken(std::string hexCmdData, bool raw, std::string &hexRespData, 48 Security::AccessToken::AccessTokenID callerToken) override; 49 50 int GetPaymentServices(std::vector<AbilityInfo> &abilityInfos) override; 51 52 KITS::ErrorCode IsDefaultService(ElementName &element, const std::string &type, bool &isDefaultService) override; 53 54 KITS::ErrorCode StartHce(const ElementName &element, const std::vector<std::string> &aids) override; 55 56 KITS::ErrorCode StopHce(const ElementName &element, Security::AccessToken::AccessTokenID callerToken) override; 57 58 int32_t Dump(int32_t fd, const std::vector<std::u16string> &args) override; 59 60 private: 61 std::string GetDumpInfo(); 62 #ifdef NFC_SIM_FEATURE 63 void AppendSimBundle(std::vector<AbilityInfo> &paymentAbilityInfos); 64 #endif 65 std::weak_ptr<NFC::INfcService> nfcService_{}; 66 std::weak_ptr<CeService> ceService_{}; 67 }; 68 } // namespace HCE 69 } // namespace NFC 70 } // namespace OHOS 71 #endif 72