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_HCE_SESSION_H
16 #define I_HCE_SESSION_H
17 
18 #include "element_name.h"
19 #include "ihce_cmd_callback.h"
20 #include "iremote_broker.h"
21 #include "nfc_sdk_common.h"
22 #include "parcel.h"
23 #include "ability_info.h"
24 
25 namespace OHOS {
26 namespace NFC {
27 namespace HCE {
28 using AppExecFwk::AbilityInfo;
29 using AppExecFwk::ElementName;
30 class IHceSession : public OHOS::IRemoteBroker {
31 public:
32     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.nfc.cardemulation.IHceSession");
33 
~IHceSession()34     virtual ~IHceSession() {}
35     /**
36      * @brief  register on hce cmd
37      * @param  callback: callback
38      * @param  type: register type hcecmd
39      * @return result
40      */
41     virtual KITS::ErrorCode RegHceCmdCallback(const sptr<KITS::IHceCmdCallback> &callback,
42                                               const std::string &type) = 0;
43     /**
44      * @brief  js service send raw data
45      * @param  hexCmdData: raw data from js service
46      * @param  raw: raw if true
47      * @param  hexRespData: response data
48      * @return result
49      */
50     virtual int SendRawFrame(std::string hexCmdData, bool raw, std::string &hexRespData) = 0;
51     /**
52      * @brief  get payment services
53      * @param  abilityInfos: payment services
54      * @return result
55      */
56     virtual int GetPaymentServices(std::vector<AbilityInfo> &abilityInfos) = 0;
57     /**
58      * @brief  stop hce, unregister callback and unset foreground service
59      * @param  element: the element service want to stop hce
60      * @return result
61      */
62     virtual KITS::ErrorCode StopHce(ElementName &element) = 0;
63     /**
64      * @brief  whether the element is default service or not
65      * @param  element: element to be judged
66      * @param  type: card type
67      * @param  isDefaultService:  is default service
68      * @return result
69      */
70     virtual KITS::ErrorCode IsDefaultService(ElementName &element, const std::string &type,
71                                              bool &isDefaultService) = 0;
72     /**
73      * @brief start hce
74      * @param  element: foreground element
75      * @param  aids: dynamic aid
76      * @return result
77      */
78     virtual KITS::ErrorCode StartHce(const ElementName &element, const std::vector<std::string> &aids) = 0;
79 
80 private:
81 };
82 } // namespace HCE
83 } // namespace NFC
84 } // namespace OHOS
85 #endif
86