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 field 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      * @param  defaultPaymentType: default payment type
67      * @return True if success, otherwise false.
68      */
69     virtual bool ComputeRoutingParams(int defaultPaymentType) = 0;
70 
71     /**
72      * @brief Commit the routing parameters to nfc controller.
73      * @return True if success, otherwise false.
74      */
75     virtual bool CommitRouting() = 0;
76 
77     /**
78      * @brief  send raw frame data
79      * @param  hexCmdData the data to send
80      * @return True if success, otherwise false.
81      */
82     virtual bool SendRawFrame(std::string &hexCmdData) = 0;
83 
84     /**
85      * @brief  add aid routing
86      * @param  aidStr: aid
87      * @param  route: route dest
88      * @param  aidInfo: prefix subset etc
89      * @param  power: power state
90      * @return True if success, otherwise false.
91      */
92     virtual bool AddAidRouting(const std::string &aidStr, int route, int aidInfo, int power) = 0;
93     /**
94      * @brief  clear aid table
95      * @return True if success, otherwise false.
96      */
97     virtual bool ClearAidTable() = 0;
98 
99     /**
100      * @brief get sim bundle name of the vendor
101      * @return sim bundle name of the vendor
102      */
103     virtual std::string GetSimVendorBundleName() = 0;
104 
105     /**
106      * @brief Notify Default Payment Type
107      * @param paymentType see enum DefaultPaymentType
108      */
109     virtual void NotifyDefaultPaymentType(int paymentType) = 0;
110 };
111 } // namespace NCI
112 } // namespace NFC
113 } // namespace OHOS
114 #endif // I_NCI_CE_INTERFACE_H
115