1 /*
2 * Copyright (C) 2021 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/RadioResponse.h>
18
19 #include "commonStructs.h"
20 #include "debug.h"
21 #include "structs.h"
22
23 #include "collections.h"
24
25 #define RADIO_MODULE "VoiceResponse"
26
27 namespace android::hardware::radio::compat {
28
29 namespace aidl = ::aidl::android::hardware::radio::voice;
30
setResponseFunction(std::shared_ptr<aidl::IRadioVoiceResponse> voiceCb)31 void RadioResponse::setResponseFunction(std::shared_ptr<aidl::IRadioVoiceResponse> voiceCb) {
32 mVoiceCb = voiceCb;
33 }
34
voiceCb()35 std::shared_ptr<aidl::IRadioVoiceResponse> RadioResponse::voiceCb() {
36 return mVoiceCb.get();
37 }
38
acceptCallResponse(const V1_0::RadioResponseInfo & info)39 Return<void> RadioResponse::acceptCallResponse(const V1_0::RadioResponseInfo& info) {
40 LOG_CALL << info.serial;
41 voiceCb()->acceptCallResponse(toAidl(info));
42 return {};
43 }
44
cancelPendingUssdResponse(const V1_0::RadioResponseInfo & info)45 Return<void> RadioResponse::cancelPendingUssdResponse(const V1_0::RadioResponseInfo& info) {
46 LOG_CALL << info.serial;
47 voiceCb()->cancelPendingUssdResponse(toAidl(info));
48 return {};
49 }
50
conferenceResponse(const V1_0::RadioResponseInfo & info)51 Return<void> RadioResponse::conferenceResponse(const V1_0::RadioResponseInfo& info) {
52 LOG_CALL << info.serial;
53 voiceCb()->conferenceResponse(toAidl(info));
54 return {};
55 }
56
dialResponse(const V1_0::RadioResponseInfo & info)57 Return<void> RadioResponse::dialResponse(const V1_0::RadioResponseInfo& info) {
58 LOG_CALL << info.serial;
59 voiceCb()->dialResponse(toAidl(info));
60 return {};
61 }
62
emergencyDialResponse(const V1_0::RadioResponseInfo & info)63 Return<void> RadioResponse::emergencyDialResponse(const V1_0::RadioResponseInfo& info) {
64 LOG_CALL << info.serial;
65 voiceCb()->emergencyDialResponse(toAidl(info));
66 return {};
67 }
68
exitEmergencyCallbackModeResponse(const V1_0::RadioResponseInfo & info)69 Return<void> RadioResponse::exitEmergencyCallbackModeResponse(const V1_0::RadioResponseInfo& info) {
70 LOG_CALL << info.serial;
71 voiceCb()->exitEmergencyCallbackModeResponse(toAidl(info));
72 return {};
73 }
74
explicitCallTransferResponse(const V1_0::RadioResponseInfo & info)75 Return<void> RadioResponse::explicitCallTransferResponse(const V1_0::RadioResponseInfo& info) {
76 LOG_CALL << info.serial;
77 voiceCb()->explicitCallTransferResponse(toAidl(info));
78 return {};
79 }
80
getCallForwardStatusResponse(const V1_0::RadioResponseInfo & info,const hidl_vec<V1_0::CallForwardInfo> & callFwdInfos)81 Return<void> RadioResponse::getCallForwardStatusResponse(
82 const V1_0::RadioResponseInfo& info, const hidl_vec<V1_0::CallForwardInfo>& callFwdInfos) {
83 LOG_CALL << info.serial;
84 voiceCb()->getCallForwardStatusResponse(toAidl(info), toAidl(callFwdInfos));
85 return {};
86 }
87
getCallWaitingResponse(const V1_0::RadioResponseInfo & info,bool enable,int32_t serviceClass)88 Return<void> RadioResponse::getCallWaitingResponse(const V1_0::RadioResponseInfo& info, bool enable,
89 int32_t serviceClass) {
90 LOG_CALL << info.serial;
91 voiceCb()->getCallWaitingResponse(toAidl(info), enable, serviceClass);
92 return {};
93 }
94
getClipResponse(const V1_0::RadioResponseInfo & info,V1_0::ClipStatus status)95 Return<void> RadioResponse::getClipResponse(const V1_0::RadioResponseInfo& info,
96 V1_0::ClipStatus status) {
97 LOG_CALL << info.serial;
98 voiceCb()->getClipResponse(toAidl(info), aidl::ClipStatus(status));
99 return {};
100 }
101
getClirResponse(const V1_0::RadioResponseInfo & info,int32_t n,int32_t m)102 Return<void> RadioResponse::getClirResponse(const V1_0::RadioResponseInfo& info, int32_t n,
103 int32_t m) {
104 LOG_CALL << info.serial;
105 voiceCb()->getClirResponse(toAidl(info), n, m);
106 return {};
107 }
108
getCurrentCallsResponse(const V1_0::RadioResponseInfo & info,const hidl_vec<V1_0::Call> & calls)109 Return<void> RadioResponse::getCurrentCallsResponse(const V1_0::RadioResponseInfo& info,
110 const hidl_vec<V1_0::Call>& calls) {
111 LOG_CALL << info.serial;
112 voiceCb()->getCurrentCallsResponse(toAidl(info), toAidl(calls));
113 return {};
114 }
115
getCurrentCallsResponse_1_2(const V1_0::RadioResponseInfo & info,const hidl_vec<V1_2::Call> & calls)116 Return<void> RadioResponse::getCurrentCallsResponse_1_2(const V1_0::RadioResponseInfo& info,
117 const hidl_vec<V1_2::Call>& calls) {
118 LOG_CALL << info.serial;
119 voiceCb()->getCurrentCallsResponse(toAidl(info), toAidl(calls));
120 return {};
121 }
122
getCurrentCallsResponse_1_6(const V1_6::RadioResponseInfo & info,const hidl_vec<V1_6::Call> & calls)123 Return<void> RadioResponse::getCurrentCallsResponse_1_6(const V1_6::RadioResponseInfo& info,
124 const hidl_vec<V1_6::Call>& calls) {
125 LOG_CALL << info.serial;
126 voiceCb()->getCurrentCallsResponse(toAidl(info), toAidl(calls));
127 return {};
128 }
129
getLastCallFailCauseResponse(const V1_0::RadioResponseInfo & info,const V1_0::LastCallFailCauseInfo & failCauseinfo)130 Return<void> RadioResponse::getLastCallFailCauseResponse(
131 const V1_0::RadioResponseInfo& info, const V1_0::LastCallFailCauseInfo& failCauseinfo) {
132 LOG_CALL << info.serial;
133 voiceCb()->getLastCallFailCauseResponse(toAidl(info), toAidl(failCauseinfo));
134 return {};
135 }
136
getMuteResponse(const V1_0::RadioResponseInfo & info,bool enable)137 Return<void> RadioResponse::getMuteResponse(const V1_0::RadioResponseInfo& info, bool enable) {
138 LOG_CALL << info.serial;
139 voiceCb()->getMuteResponse(toAidl(info), enable);
140 return {};
141 }
142
getPreferredVoicePrivacyResponse(const V1_0::RadioResponseInfo & info,bool enable)143 Return<void> RadioResponse::getPreferredVoicePrivacyResponse(const V1_0::RadioResponseInfo& info,
144 bool enable) {
145 LOG_CALL << info.serial;
146 voiceCb()->getPreferredVoicePrivacyResponse(toAidl(info), enable);
147 return {};
148 }
149
getTTYModeResponse(const V1_0::RadioResponseInfo & info,V1_0::TtyMode mode)150 Return<void> RadioResponse::getTTYModeResponse(const V1_0::RadioResponseInfo& info,
151 V1_0::TtyMode mode) {
152 LOG_CALL << info.serial;
153 voiceCb()->getTtyModeResponse(toAidl(info), aidl::TtyMode(mode));
154 return {};
155 }
156
handleStkCallSetupRequestFromSimResponse(const V1_0::RadioResponseInfo & info)157 Return<void> RadioResponse::handleStkCallSetupRequestFromSimResponse(
158 const V1_0::RadioResponseInfo& info) {
159 LOG_CALL << info.serial;
160 voiceCb()->handleStkCallSetupRequestFromSimResponse(toAidl(info));
161 return {};
162 }
163
hangupConnectionResponse(const V1_0::RadioResponseInfo & info)164 Return<void> RadioResponse::hangupConnectionResponse(const V1_0::RadioResponseInfo& info) {
165 LOG_CALL << info.serial;
166 voiceCb()->hangupConnectionResponse(toAidl(info));
167 return {};
168 }
169
hangupForegroundResumeBackgroundResponse(const V1_0::RadioResponseInfo & info)170 Return<void> RadioResponse::hangupForegroundResumeBackgroundResponse(
171 const V1_0::RadioResponseInfo& info) {
172 LOG_CALL << info.serial;
173 voiceCb()->hangupForegroundResumeBackgroundResponse(toAidl(info));
174 return {};
175 }
176
hangupWaitingOrBackgroundResponse(const V1_0::RadioResponseInfo & info)177 Return<void> RadioResponse::hangupWaitingOrBackgroundResponse(const V1_0::RadioResponseInfo& info) {
178 LOG_CALL << info.serial;
179 voiceCb()->hangupWaitingOrBackgroundResponse(toAidl(info));
180 return {};
181 }
182
rejectCallResponse(const V1_0::RadioResponseInfo & info)183 Return<void> RadioResponse::rejectCallResponse(const V1_0::RadioResponseInfo& info) {
184 LOG_CALL << info.serial;
185 voiceCb()->rejectCallResponse(toAidl(info));
186 return {};
187 }
188
sendBurstDtmfResponse(const V1_0::RadioResponseInfo & info)189 Return<void> RadioResponse::sendBurstDtmfResponse(const V1_0::RadioResponseInfo& info) {
190 LOG_CALL << info.serial;
191 voiceCb()->sendBurstDtmfResponse(toAidl(info));
192 return {};
193 }
194
sendCDMAFeatureCodeResponse(const V1_0::RadioResponseInfo & info)195 Return<void> RadioResponse::sendCDMAFeatureCodeResponse(const V1_0::RadioResponseInfo& info) {
196 LOG_CALL << info.serial;
197 voiceCb()->sendCdmaFeatureCodeResponse(toAidl(info));
198 return {};
199 }
200
sendDtmfResponse(const V1_0::RadioResponseInfo & info)201 Return<void> RadioResponse::sendDtmfResponse(const V1_0::RadioResponseInfo& info) {
202 LOG_CALL << info.serial;
203 voiceCb()->sendDtmfResponse(toAidl(info));
204 return {};
205 }
206
sendUssdResponse(const V1_0::RadioResponseInfo & info)207 Return<void> RadioResponse::sendUssdResponse(const V1_0::RadioResponseInfo& info) {
208 LOG_CALL << info.serial;
209 voiceCb()->sendUssdResponse(toAidl(info));
210 return {};
211 }
212
separateConnectionResponse(const V1_0::RadioResponseInfo & info)213 Return<void> RadioResponse::separateConnectionResponse(const V1_0::RadioResponseInfo& info) {
214 LOG_CALL << info.serial;
215 voiceCb()->separateConnectionResponse(toAidl(info));
216 return {};
217 }
218
setCallForwardResponse(const V1_0::RadioResponseInfo & info)219 Return<void> RadioResponse::setCallForwardResponse(const V1_0::RadioResponseInfo& info) {
220 LOG_CALL << info.serial;
221 voiceCb()->setCallForwardResponse(toAidl(info));
222 return {};
223 }
224
setCallWaitingResponse(const V1_0::RadioResponseInfo & info)225 Return<void> RadioResponse::setCallWaitingResponse(const V1_0::RadioResponseInfo& info) {
226 LOG_CALL << info.serial;
227 voiceCb()->setCallWaitingResponse(toAidl(info));
228 return {};
229 }
230
setClirResponse(const V1_0::RadioResponseInfo & info)231 Return<void> RadioResponse::setClirResponse(const V1_0::RadioResponseInfo& info) {
232 LOG_CALL << info.serial;
233 voiceCb()->setClirResponse(toAidl(info));
234 return {};
235 }
236
setMuteResponse(const V1_0::RadioResponseInfo & info)237 Return<void> RadioResponse::setMuteResponse(const V1_0::RadioResponseInfo& info) {
238 LOG_CALL << info.serial;
239 voiceCb()->setMuteResponse(toAidl(info));
240 return {};
241 }
242
setPreferredVoicePrivacyResponse(const V1_0::RadioResponseInfo & info)243 Return<void> RadioResponse::setPreferredVoicePrivacyResponse(const V1_0::RadioResponseInfo& info) {
244 LOG_CALL << info.serial;
245 voiceCb()->setPreferredVoicePrivacyResponse(toAidl(info));
246 return {};
247 }
248
setTTYModeResponse(const V1_0::RadioResponseInfo & info)249 Return<void> RadioResponse::setTTYModeResponse(const V1_0::RadioResponseInfo& info) {
250 LOG_CALL << info.serial;
251 voiceCb()->setTtyModeResponse(toAidl(info));
252 return {};
253 }
254
startDtmfResponse(const V1_0::RadioResponseInfo & info)255 Return<void> RadioResponse::startDtmfResponse(const V1_0::RadioResponseInfo& info) {
256 LOG_CALL << info.serial;
257 voiceCb()->startDtmfResponse(toAidl(info));
258 return {};
259 }
260
stopDtmfResponse(const V1_0::RadioResponseInfo & info)261 Return<void> RadioResponse::stopDtmfResponse(const V1_0::RadioResponseInfo& info) {
262 LOG_CALL << info.serial;
263 voiceCb()->stopDtmfResponse(toAidl(info));
264 return {};
265 }
266
switchWaitingOrHoldingAndActiveResponse(const V1_0::RadioResponseInfo & info)267 Return<void> RadioResponse::switchWaitingOrHoldingAndActiveResponse(
268 const V1_0::RadioResponseInfo& info) {
269 LOG_CALL << info.serial;
270 voiceCb()->switchWaitingOrHoldingAndActiveResponse(toAidl(info));
271 return {};
272 }
273
274 } // namespace android::hardware::radio::compat
275