1 /*
2  * Copyright (C) 2017 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <sap_hidl_hal_utils.h>
18 
SapCallback(SapHidlTest & parent)19 SapCallback::SapCallback(SapHidlTest& parent) : parent(parent) {}
20 
connectResponse(int32_t token,SapConnectRsp,int32_t)21 Return<void> SapCallback::connectResponse(int32_t token, SapConnectRsp /*sapConnectRsp*/,
22                                           int32_t /*maxMsgSize*/) {
23     sapResponseToken = token;
24     parent.notify();
25     return Void();
26 }
27 
disconnectResponse(int32_t token)28 Return<void> SapCallback::disconnectResponse(int32_t token) {
29     sapResponseToken = token;
30     parent.notify();
31     return Void();
32 }
33 
disconnectIndication(int32_t,SapDisconnectType)34 Return<void> SapCallback::disconnectIndication(int32_t /*token*/,
35                                                SapDisconnectType /*disconnectType*/) {
36     return Void();
37 }
38 
apduResponse(int32_t token,SapResultCode resultCode,const::android::hardware::hidl_vec<uint8_t> &)39 Return<void> SapCallback::apduResponse(int32_t token, SapResultCode resultCode,
40                                        const ::android::hardware::hidl_vec<uint8_t>& /*apduRsp*/) {
41     sapResponseToken = token;
42     sapResultCode = resultCode;
43     parent.notify();
44     return Void();
45 }
46 
transferAtrResponse(int32_t token,SapResultCode resultCode,const::android::hardware::hidl_vec<uint8_t> &)47 Return<void> SapCallback::transferAtrResponse(
48     int32_t token, SapResultCode resultCode,
49     const ::android::hardware::hidl_vec<uint8_t>& /*atr*/) {
50     sapResponseToken = token;
51     sapResultCode = resultCode;
52     parent.notify();
53     return Void();
54 }
55 
powerResponse(int32_t token,SapResultCode resultCode)56 Return<void> SapCallback::powerResponse(int32_t token, SapResultCode resultCode) {
57     sapResponseToken = token;
58     sapResultCode = resultCode;
59     parent.notify();
60     return Void();
61 }
62 
resetSimResponse(int32_t token,SapResultCode resultCode)63 Return<void> SapCallback::resetSimResponse(int32_t token, SapResultCode resultCode) {
64     sapResponseToken = token;
65     sapResultCode = resultCode;
66     parent.notify();
67     return Void();
68 }
69 
statusIndication(int32_t,SapStatus)70 Return<void> SapCallback::statusIndication(int32_t /*token*/, SapStatus /*status*/) {
71     return Void();
72 }
73 
transferCardReaderStatusResponse(int32_t token,SapResultCode resultCode,int32_t)74 Return<void> SapCallback::transferCardReaderStatusResponse(int32_t token, SapResultCode resultCode,
75                                                            int32_t /*cardReaderStatus*/) {
76     sapResponseToken = token;
77     sapResultCode = resultCode;
78     parent.notify();
79     return Void();
80 }
81 
errorResponse(int32_t)82 Return<void> SapCallback::errorResponse(int32_t /*token*/) {
83     return Void();
84 }
85 
transferProtocolResponse(int32_t token,SapResultCode resultCode)86 Return<void> SapCallback::transferProtocolResponse(int32_t token, SapResultCode resultCode) {
87     sapResponseToken = token;
88     sapResultCode = resultCode;
89     parent.notify();
90     return Void();
91 }
92