1 /*
2 * Copyright (C) 2022 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 <libradiocompat/SapCallback.h>
18
19 #include "commonStructs.h"
20 #include "debug.h"
21 #include "structs.h"
22
23 #include "collections.h"
24
25 #define RADIO_MODULE "SapCallback"
26
27 namespace android::hardware::radio::compat {
28
29 namespace aidl = ::aidl::android::hardware::radio::sap;
30
setResponseFunction(const std::shared_ptr<aidl::ISapCallback> & callback)31 void SapCallback::setResponseFunction(const std::shared_ptr<aidl::ISapCallback>& callback) {
32 mCallback = callback;
33 }
34
respond()35 std::shared_ptr<aidl::ISapCallback> SapCallback::respond() {
36 return mCallback.get();
37 }
38
apduResponse(int32_t serial,V1_0::SapResultCode resultCode,const hidl_vec<uint8_t> & apduRsp)39 Return<void> SapCallback::apduResponse(int32_t serial, V1_0::SapResultCode resultCode,
40 const hidl_vec<uint8_t>& apduRsp) {
41 LOG_CALL << serial;
42 respond()->apduResponse(serial, toAidl(resultCode), apduRsp);
43 return {};
44 }
45
connectResponse(int32_t serial,V1_0::SapConnectRsp sapConnectRsp,int32_t maxMsgSize)46 Return<void> SapCallback::connectResponse(int32_t serial, V1_0::SapConnectRsp sapConnectRsp,
47 int32_t maxMsgSize) {
48 LOG_CALL << serial;
49 respond()->connectResponse(serial, toAidl(sapConnectRsp), maxMsgSize);
50 return {};
51 }
52
disconnectIndication(int32_t serial,V1_0::SapDisconnectType disconnectType)53 Return<void> SapCallback::disconnectIndication(int32_t serial,
54 V1_0::SapDisconnectType disconnectType) {
55 LOG_CALL << serial;
56 respond()->disconnectIndication(serial, toAidl(disconnectType));
57 return {};
58 }
59
disconnectResponse(int32_t serial)60 Return<void> SapCallback::disconnectResponse(int32_t serial) {
61 LOG_CALL << serial;
62 respond()->disconnectResponse(serial);
63 return {};
64 }
65
errorResponse(int32_t serial)66 Return<void> SapCallback::errorResponse(int32_t serial) {
67 LOG_CALL << serial;
68 respond()->errorResponse(serial);
69 return {};
70 }
71
powerResponse(int32_t serial,V1_0::SapResultCode resultCode)72 Return<void> SapCallback::powerResponse(int32_t serial, V1_0::SapResultCode resultCode) {
73 LOG_CALL << serial;
74 respond()->powerResponse(serial, toAidl(resultCode));
75 return {};
76 }
77
resetSimResponse(int32_t serial,V1_0::SapResultCode resultCode)78 Return<void> SapCallback::resetSimResponse(int32_t serial, V1_0::SapResultCode resultCode) {
79 LOG_CALL << serial;
80 respond()->resetSimResponse(serial, toAidl(resultCode));
81 return {};
82 }
83
statusIndication(int32_t serial,V1_0::SapStatus status)84 Return<void> SapCallback::statusIndication(int32_t serial, V1_0::SapStatus status) {
85 LOG_CALL << serial;
86 respond()->statusIndication(serial, toAidl(status));
87 return {};
88 }
89
transferAtrResponse(int32_t serial,V1_0::SapResultCode resultCode,const hidl_vec<uint8_t> & atr)90 Return<void> SapCallback::transferAtrResponse(int32_t serial, V1_0::SapResultCode resultCode,
91 const hidl_vec<uint8_t>& atr) {
92 LOG_CALL << serial;
93 respond()->transferAtrResponse(serial, toAidl(resultCode), atr);
94 return {};
95 }
96
transferCardReaderStatusResponse(int32_t serial,V1_0::SapResultCode resultCode,int32_t cardReaderStatus)97 Return<void> SapCallback::transferCardReaderStatusResponse(int32_t serial,
98 V1_0::SapResultCode resultCode,
99 int32_t cardReaderStatus) {
100 LOG_CALL << serial;
101 respond()->transferCardReaderStatusResponse(serial, toAidl(resultCode), cardReaderStatus);
102 return {};
103 }
104
transferProtocolResponse(int32_t serial,V1_0::SapResultCode resultCode)105 Return<void> SapCallback::transferProtocolResponse(int32_t serial, V1_0::SapResultCode resultCode) {
106 LOG_CALL << serial;
107 respond()->transferProtocolResponse(serial, toAidl(resultCode));
108 return {};
109 }
110
111 } // namespace android::hardware::radio::compat
112