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 I_NCI_CE_INTERFACE_H 16 #define I_NCI_CE_INTERFACE_H 17 #include <string> 18 19 namespace OHOS { 20 namespace NFC { 21 namespace NCI { 22 class INciCeInterface { 23 public: 24 class ICeHostListener { 25 public: ~ICeHostListener()26 virtual ~ICeHostListener() {} 27 28 /** 29 * @brief The notification for filed on. 30 */ 31 virtual void FieldActivated() = 0; 32 33 /** 34 * @brief The notification for field off. 35 */ 36 virtual void FieldDeactivated() = 0; 37 /** 38 * @brief deal with card emulation data 39 * @note 40 * @param data: card emulation data 41 */ 42 virtual void OnCardEmulationData(const std::vector<uint8_t> &data) = 0; 43 /** 44 * @brief card emulation activate 45 * @note 46 */ 47 virtual void OnCardEmulationActivated() = 0; 48 /** 49 * @brief card emulation deactivate 50 * @note 51 */ 52 virtual void OnCardEmulationDeactivated() = 0; 53 }; 54 55 virtual ~INciCeInterface() = default; 56 57 /** 58 * @brief Set the listener to receive the card emulation notifications. 59 * @param listener The listener to receive the card emulation notifications. 60 */ 61 virtual void SetCeHostListener(std::weak_ptr<ICeHostListener> listener) = 0; 62 63 /** 64 * @brief compute the routing parameters based on the default payment app 65 * and all installed app. 66 * @return True if success, otherwise false. 67 */ 68 virtual bool ComputeRoutingParams() = 0; 69 70 /** 71 * @brief Commit the routing parameters to nfc controller. 72 * @return True if success, otherwise false. 73 */ 74 virtual bool CommitRouting() = 0; 75 76 /** 77 * @brief send raw frame data 78 * @param hexCmdData the data to send 79 * @return True if success, otherwise false. 80 */ 81 virtual bool SendRawFrame(std::string &hexCmdData) = 0; 82 83 /** 84 * @brief add aid routing 85 * @param aidStr: aid 86 * @param route: route dest 87 * @param aidInfo: prefix subset etc 88 * @param power: power state 89 * @return True if success, otherwise false. 90 */ 91 virtual bool AddAidRouting(const std::string &aidStr, int route, int aidInfo, int power) = 0; 92 /** 93 * @brief clear aid table 94 * @return True if success, otherwise false. 95 */ 96 virtual bool ClearAidTable() = 0; 97 }; 98 } // namespace NCI 99 } // namespace NFC 100 } // namespace OHOS 101 #endif // I_NCI_CE_INTERFACE_H 102