1 /*
2  * Copyright (c) 2024 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 
16 #include "secure_element_interface_service.h"
17 #include <hdf_base.h>
18 
19 #define HDF_LOG_TAG secure_element_interface_service
20 
21 namespace OHOS {
22 namespace HDI {
23 namespace SecureElement {
24 namespace SimSecureElement {
25 namespace V1_0 {
SecureElementInterfaceImplGetInstance(void)26 extern "C" ISecureElementInterface *SecureElementInterfaceImplGetInstance(void)
27 {
28     return new (std::nothrow) SecureElementInterfaceService();
29 }
30 
init(const sptr<OHOS::HDI::SecureElement::SimSecureElement::V1_0::ISecureElementCallback> & clientCallback,OHOS::HDI::SecureElement::SimSecureElement::V1_0::SecureElementStatus & status)31 int32_t SecureElementInterfaceService::init(
32     const sptr<OHOS::HDI::SecureElement::SimSecureElement::V1_0::ISecureElementCallback>& clientCallback,
33     OHOS::HDI::SecureElement::SimSecureElement::V1_0::SecureElementStatus& status)
34 {
35     return adaptor_.init(clientCallback, status);
36 }
37 
getAtr(std::vector<uint8_t> & response)38 int32_t SecureElementInterfaceService::getAtr(std::vector<uint8_t>& response)
39 {
40     return adaptor_.getAtr(response);
41 }
42 
isSecureElementPresent(bool & present)43 int32_t SecureElementInterfaceService::isSecureElementPresent(bool& present)
44 {
45     return adaptor_.isSecureElementPresent(present);
46 }
47 
openLogicalChannel(const std::vector<uint8_t> & aid,uint8_t p2,std::vector<uint8_t> & response,uint8_t & channelNumber,OHOS::HDI::SecureElement::SimSecureElement::V1_0::SecureElementStatus & status)48 int32_t SecureElementInterfaceService::openLogicalChannel(const std::vector<uint8_t>& aid, uint8_t p2,
49     std::vector<uint8_t>& response, uint8_t& channelNumber,
50     OHOS::HDI::SecureElement::SimSecureElement::V1_0::SecureElementStatus& status)
51 {
52     return adaptor_.openLogicalChannel(aid, p2, response, channelNumber, status);
53 }
54 
openBasicChannel(const std::vector<uint8_t> & aid,uint8_t p2,std::vector<uint8_t> & response,OHOS::HDI::SecureElement::SimSecureElement::V1_0::SecureElementStatus & status)55 int32_t SecureElementInterfaceService::openBasicChannel(const std::vector<uint8_t>& aid, uint8_t p2,
56     std::vector<uint8_t>& response, OHOS::HDI::SecureElement::SimSecureElement::V1_0::SecureElementStatus& status)
57 {
58     return adaptor_.openBasicChannel(aid, p2, response, status);
59 }
60 
closeChannel(uint8_t channelNumber,OHOS::HDI::SecureElement::SimSecureElement::V1_0::SecureElementStatus & status)61 int32_t SecureElementInterfaceService::closeChannel(uint8_t channelNumber,
62     OHOS::HDI::SecureElement::SimSecureElement::V1_0::SecureElementStatus& status)
63 {
64     return adaptor_.closeChannel(channelNumber, status);
65 }
66 
transmit(const std::vector<uint8_t> & command,std::vector<uint8_t> & response,OHOS::HDI::SecureElement::SimSecureElement::V1_0::SecureElementStatus & status)67 int32_t SecureElementInterfaceService::transmit(const std::vector<uint8_t>& command, std::vector<uint8_t>& response,
68     OHOS::HDI::SecureElement::SimSecureElement::V1_0::SecureElementStatus& status)
69 {
70     return adaptor_.transmit(command, response, status);
71 }
72 
reset(OHOS::HDI::SecureElement::SimSecureElement::V1_0::SecureElementStatus & status)73 int32_t SecureElementInterfaceService::reset(
74     OHOS::HDI::SecureElement::SimSecureElement::V1_0::SecureElementStatus& status)
75 {
76     return adaptor_.reset(status);
77 }
78 } // V1_0
79 } // SimSecureElement
80 } // SecureElement
81 } // HDI
82 } // OHOS
83