• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "SimResponse"
26 
27 namespace android::hardware::radio::compat {
28 
29 namespace aidl = ::aidl::android::hardware::radio::sim;
30 
setResponseFunction(std::shared_ptr<aidl::IRadioSimResponse> simCb)31 void RadioResponse::setResponseFunction(std::shared_ptr<aidl::IRadioSimResponse> simCb) {
32     mSimCb = simCb;
33 }
34 
simCb()35 std::shared_ptr<aidl::IRadioSimResponse> RadioResponse::simCb() {
36     return mSimCb.get();
37 }
38 
areUiccApplicationsEnabledResponse(const V1_0::RadioResponseInfo & info,bool enabled)39 Return<void> RadioResponse::areUiccApplicationsEnabledResponse(const V1_0::RadioResponseInfo& info,
40                                                                bool enabled) {
41     LOG_CALL << info.serial;
42     simCb()->areUiccApplicationsEnabledResponse(toAidl(info), enabled);
43     return {};
44 }
45 
changeIccPin2ForAppResponse(const V1_0::RadioResponseInfo & info,int32_t remainingRetries)46 Return<void> RadioResponse::changeIccPin2ForAppResponse(const V1_0::RadioResponseInfo& info,
47                                                         int32_t remainingRetries) {
48     LOG_CALL << info.serial;
49     simCb()->changeIccPin2ForAppResponse(toAidl(info), remainingRetries);
50     return {};
51 }
52 
changeIccPinForAppResponse(const V1_0::RadioResponseInfo & info,int32_t remainingRetries)53 Return<void> RadioResponse::changeIccPinForAppResponse(const V1_0::RadioResponseInfo& info,
54                                                        int32_t remainingRetries) {
55     LOG_CALL << info.serial;
56     simCb()->changeIccPinForAppResponse(toAidl(info), remainingRetries);
57     return {};
58 }
59 
enableUiccApplicationsResponse(const V1_0::RadioResponseInfo & info)60 Return<void> RadioResponse::enableUiccApplicationsResponse(const V1_0::RadioResponseInfo& info) {
61     LOG_CALL << info.serial;
62     simCb()->enableUiccApplicationsResponse(toAidl(info));
63     return {};
64 }
65 
getAllowedCarriersResponse(const V1_0::RadioResponseInfo & info,bool allAllowed,const V1_0::CarrierRestrictions & cr)66 Return<void> RadioResponse::getAllowedCarriersResponse(  //
67         const V1_0::RadioResponseInfo& info, bool allAllowed, const V1_0::CarrierRestrictions& cr) {
68     LOG_CALL << info.serial;
69     aidl::CarrierRestrictions aidlCr = toAidl(cr);
70     if (allAllowed) aidlCr = {};
71     simCb()->getAllowedCarriersResponse(toAidl(info), aidlCr, {});
72     return {};
73 }
74 
getAllowedCarriersResponse_1_4(const V1_0::RadioResponseInfo & info,const V1_4::CarrierRestrictionsWithPriority & carriers,V1_4::SimLockMultiSimPolicy multiSimPolicy)75 Return<void> RadioResponse::getAllowedCarriersResponse_1_4(
76         const V1_0::RadioResponseInfo& info, const V1_4::CarrierRestrictionsWithPriority& carriers,
77         V1_4::SimLockMultiSimPolicy multiSimPolicy) {
78     LOG_CALL << info.serial;
79     simCb()->getAllowedCarriersResponse(toAidl(info), toAidl(carriers),
80                                         aidl::SimLockMultiSimPolicy(multiSimPolicy));
81     return {};
82 }
83 
getCDMASubscriptionResponse(const V1_0::RadioResponseInfo & info,const hidl_string & mdn,const hidl_string & hSid,const hidl_string & hNid,const hidl_string & min,const hidl_string & prl)84 Return<void> RadioResponse::getCDMASubscriptionResponse(
85         const V1_0::RadioResponseInfo& info, const hidl_string& mdn, const hidl_string& hSid,
86         const hidl_string& hNid, const hidl_string& min, const hidl_string& prl) {
87     LOG_CALL << info.serial;
88     simCb()->getCdmaSubscriptionResponse(toAidl(info), mdn, hSid, hNid, min, prl);
89     return {};
90 }
91 
getCdmaSubscriptionSourceResponse(const V1_0::RadioResponseInfo & info,V1_0::CdmaSubscriptionSource s)92 Return<void> RadioResponse::getCdmaSubscriptionSourceResponse(const V1_0::RadioResponseInfo& info,
93                                                               V1_0::CdmaSubscriptionSource s) {
94     LOG_CALL << info.serial;
95     simCb()->getCdmaSubscriptionSourceResponse(toAidl(info), aidl::CdmaSubscriptionSource(s));
96     return {};
97 }
98 
getFacilityLockForAppResponse(const V1_0::RadioResponseInfo & info,int32_t response)99 Return<void> RadioResponse::getFacilityLockForAppResponse(const V1_0::RadioResponseInfo& info,
100                                                           int32_t response) {
101     LOG_CALL << info.serial;
102     simCb()->getFacilityLockForAppResponse(toAidl(info), response);
103     return {};
104 }
105 
getIccCardStatusResponse(const V1_0::RadioResponseInfo & info,const V1_0::CardStatus & cardStatus)106 Return<void> RadioResponse::getIccCardStatusResponse(const V1_0::RadioResponseInfo& info,
107                                                      const V1_0::CardStatus& cardStatus) {
108     LOG_CALL << info.serial;
109     simCb()->getIccCardStatusResponse(toAidl(info), toAidl(cardStatus));
110     return {};
111 }
112 
getIccCardStatusResponse_1_2(const V1_0::RadioResponseInfo & info,const V1_2::CardStatus & cardStatus)113 Return<void> RadioResponse::getIccCardStatusResponse_1_2(const V1_0::RadioResponseInfo& info,
114                                                          const V1_2::CardStatus& cardStatus) {
115     LOG_CALL << info.serial;
116     simCb()->getIccCardStatusResponse(toAidl(info), toAidl(cardStatus));
117     return {};
118 }
119 
getIccCardStatusResponse_1_4(const V1_0::RadioResponseInfo & info,const V1_4::CardStatus & cardStatus)120 Return<void> RadioResponse::getIccCardStatusResponse_1_4(const V1_0::RadioResponseInfo& info,
121                                                          const V1_4::CardStatus& cardStatus) {
122     LOG_CALL << info.serial;
123     simCb()->getIccCardStatusResponse(toAidl(info), toAidl(cardStatus));
124     return {};
125 }
126 
getIccCardStatusResponse_1_5(const V1_0::RadioResponseInfo & info,const V1_5::CardStatus & cardStatus)127 Return<void> RadioResponse::getIccCardStatusResponse_1_5(const V1_0::RadioResponseInfo& info,
128                                                          const V1_5::CardStatus& cardStatus) {
129     LOG_CALL << info.serial;
130     simCb()->getIccCardStatusResponse(toAidl(info), toAidl(cardStatus));
131     return {};
132 }
133 
getIMSIForAppResponse(const V1_0::RadioResponseInfo & info,const hidl_string & imsi)134 Return<void> RadioResponse::getIMSIForAppResponse(const V1_0::RadioResponseInfo& info,
135                                                   const hidl_string& imsi) {
136     LOG_CALL << info.serial;
137     simCb()->getImsiForAppResponse(toAidl(info), imsi);
138     return {};
139 }
140 
getSimPhonebookCapacityResponse(const V1_6::RadioResponseInfo & info,const V1_6::PhonebookCapacity & capacity)141 Return<void> RadioResponse::getSimPhonebookCapacityResponse(
142         const V1_6::RadioResponseInfo& info, const V1_6::PhonebookCapacity& capacity) {
143     LOG_CALL << info.serial;
144     simCb()->getSimPhonebookCapacityResponse(toAidl(info), toAidl(capacity));
145     return {};
146 }
147 
getSimPhonebookRecordsResponse(const V1_6::RadioResponseInfo & info)148 Return<void> RadioResponse::getSimPhonebookRecordsResponse(const V1_6::RadioResponseInfo& info) {
149     LOG_CALL << info.serial;
150     simCb()->getSimPhonebookRecordsResponse(toAidl(info));
151     return {};
152 }
153 
iccCloseLogicalChannelResponse(const V1_0::RadioResponseInfo & info)154 Return<void> RadioResponse::iccCloseLogicalChannelResponse(const V1_0::RadioResponseInfo& info) {
155     LOG_CALL << info.serial;
156     simCb()->iccCloseLogicalChannelResponse(toAidl(info));
157     return {};
158 }
159 
iccIOForAppResponse(const V1_0::RadioResponseInfo & info,const V1_0::IccIoResult & iccIo)160 Return<void> RadioResponse::iccIOForAppResponse(const V1_0::RadioResponseInfo& info,
161                                                 const V1_0::IccIoResult& iccIo) {
162     LOG_CALL << info.serial;
163     simCb()->iccIoForAppResponse(toAidl(info), toAidl(iccIo));
164     return {};
165 }
166 
iccOpenLogicalChannelResponse(const V1_0::RadioResponseInfo & info,int32_t chanId,const hidl_vec<int8_t> & selectResp)167 Return<void> RadioResponse::iccOpenLogicalChannelResponse(  //
168         const V1_0::RadioResponseInfo& info, int32_t chanId, const hidl_vec<int8_t>& selectResp) {
169     LOG_CALL << info.serial;
170     simCb()->iccOpenLogicalChannelResponse(toAidl(info), chanId, toAidl(selectResp));
171     return {};
172 }
173 
iccTransmitApduBasicChannelResponse(const V1_0::RadioResponseInfo & info,const V1_0::IccIoResult & result)174 Return<void> RadioResponse::iccTransmitApduBasicChannelResponse(const V1_0::RadioResponseInfo& info,
175                                                                 const V1_0::IccIoResult& result) {
176     LOG_CALL << info.serial;
177     simCb()->iccTransmitApduBasicChannelResponse(toAidl(info), toAidl(result));
178     return {};
179 }
180 
iccTransmitApduLogicalChannelResponse(const V1_0::RadioResponseInfo & info,const V1_0::IccIoResult & result)181 Return<void> RadioResponse::iccTransmitApduLogicalChannelResponse(
182         const V1_0::RadioResponseInfo& info, const V1_0::IccIoResult& result) {
183     LOG_CALL << info.serial;
184     simCb()->iccTransmitApduLogicalChannelResponse(toAidl(info), toAidl(result));
185     return {};
186 }
187 
reportStkServiceIsRunningResponse(const V1_0::RadioResponseInfo & info)188 Return<void> RadioResponse::reportStkServiceIsRunningResponse(const V1_0::RadioResponseInfo& info) {
189     LOG_CALL << info.serial;
190     simCb()->reportStkServiceIsRunningResponse(toAidl(info));
191     return {};
192 }
193 
requestIccSimAuthenticationResponse(const V1_0::RadioResponseInfo & info,const V1_0::IccIoResult & result)194 Return<void> RadioResponse::requestIccSimAuthenticationResponse(const V1_0::RadioResponseInfo& info,
195                                                                 const V1_0::IccIoResult& result) {
196     LOG_CALL << info.serial;
197     simCb()->requestIccSimAuthenticationResponse(toAidl(info), toAidl(result));
198     return {};
199 }
200 
requestIsimAuthenticationResponse(const V1_0::RadioResponseInfo & info,const hidl_string &)201 Return<void> RadioResponse::requestIsimAuthenticationResponse(const V1_0::RadioResponseInfo& info,
202                                                               const hidl_string&) {
203     LOG_CALL << info.serial;
204     LOG(ERROR) << "requestIsimAuthenticationResponse is not supposed to be called";
205     return {};
206 }
207 
sendEnvelopeResponse(const V1_0::RadioResponseInfo & info,const hidl_string & commandResponse)208 Return<void> RadioResponse::sendEnvelopeResponse(const V1_0::RadioResponseInfo& info,
209                                                  const hidl_string& commandResponse) {
210     LOG_CALL << info.serial;
211     simCb()->sendEnvelopeResponse(toAidl(info), commandResponse);
212     return {};
213 }
214 
sendEnvelopeWithStatusResponse(const V1_0::RadioResponseInfo & info,const V1_0::IccIoResult & iccIo)215 Return<void> RadioResponse::sendEnvelopeWithStatusResponse(const V1_0::RadioResponseInfo& info,
216                                                            const V1_0::IccIoResult& iccIo) {
217     LOG_CALL << info.serial;
218     simCb()->sendEnvelopeWithStatusResponse(toAidl(info), toAidl(iccIo));
219     return {};
220 }
221 
sendTerminalResponseToSimResponse(const V1_0::RadioResponseInfo & info)222 Return<void> RadioResponse::sendTerminalResponseToSimResponse(const V1_0::RadioResponseInfo& info) {
223     LOG_CALL << info.serial;
224     simCb()->sendTerminalResponseToSimResponse(toAidl(info));
225     return {};
226 }
227 
setAllowedCarriersResponse(const V1_0::RadioResponseInfo & info,int32_t numAllowed)228 Return<void> RadioResponse::setAllowedCarriersResponse(const V1_0::RadioResponseInfo& info,
229                                                        int32_t numAllowed) {
230     LOG_CALL << info.serial << ' ' << numAllowed;
231     simCb()->setAllowedCarriersResponse(toAidl(info));
232     return {};
233 }
234 
setAllowedCarriersResponse_1_4(const V1_0::RadioResponseInfo & info)235 Return<void> RadioResponse::setAllowedCarriersResponse_1_4(const V1_0::RadioResponseInfo& info) {
236     LOG_CALL << info.serial;
237     simCb()->setAllowedCarriersResponse(toAidl(info));
238     return {};
239 }
240 
setCarrierInfoForImsiEncryptionResponse(const V1_0::RadioResponseInfo & info)241 Return<void> RadioResponse::setCarrierInfoForImsiEncryptionResponse(
242         const V1_0::RadioResponseInfo& info) {
243     LOG_CALL << info.serial;
244     simCb()->setCarrierInfoForImsiEncryptionResponse(toAidl(info));
245     return {};
246 }
247 
setCdmaSubscriptionSourceResponse(const V1_0::RadioResponseInfo & info)248 Return<void> RadioResponse::setCdmaSubscriptionSourceResponse(const V1_0::RadioResponseInfo& info) {
249     LOG_CALL << info.serial;
250     simCb()->setCdmaSubscriptionSourceResponse(toAidl(info));
251     return {};
252 }
253 
setFacilityLockForAppResponse(const V1_0::RadioResponseInfo & info,int32_t retry)254 Return<void> RadioResponse::setFacilityLockForAppResponse(const V1_0::RadioResponseInfo& info,
255                                                           int32_t retry) {
256     LOG_CALL << info.serial;
257     simCb()->setFacilityLockForAppResponse(toAidl(info), retry);
258     return {};
259 }
260 
setSimCardPowerResponse(const V1_0::RadioResponseInfo & info)261 Return<void> RadioResponse::setSimCardPowerResponse(const V1_0::RadioResponseInfo& info) {
262     LOG_CALL << info.serial;
263     simCb()->setSimCardPowerResponse(toAidl(info));
264     return {};
265 }
266 
setSimCardPowerResponse_1_1(const V1_0::RadioResponseInfo & info)267 Return<void> RadioResponse::setSimCardPowerResponse_1_1(const V1_0::RadioResponseInfo& info) {
268     LOG_CALL << info.serial;
269     simCb()->setSimCardPowerResponse(toAidl(info));
270     return {};
271 }
272 
setSimCardPowerResponse_1_6(const V1_6::RadioResponseInfo & info)273 Return<void> RadioResponse::setSimCardPowerResponse_1_6(const V1_6::RadioResponseInfo& info) {
274     LOG_CALL << info.serial;
275     simCb()->setSimCardPowerResponse(toAidl(info));
276     return {};
277 }
278 
setUiccSubscriptionResponse(const V1_0::RadioResponseInfo & info)279 Return<void> RadioResponse::setUiccSubscriptionResponse(const V1_0::RadioResponseInfo& info) {
280     LOG_CALL << info.serial;
281     simCb()->setUiccSubscriptionResponse(toAidl(info));
282     return {};
283 }
284 
supplyIccPin2ForAppResponse(const V1_0::RadioResponseInfo & info,int32_t remainingRetries)285 Return<void> RadioResponse::supplyIccPin2ForAppResponse(const V1_0::RadioResponseInfo& info,
286                                                         int32_t remainingRetries) {
287     LOG_CALL << info.serial;
288     simCb()->supplyIccPin2ForAppResponse(toAidl(info), remainingRetries);
289     return {};
290 }
291 
supplyIccPinForAppResponse(const V1_0::RadioResponseInfo & info,int32_t remainingRetries)292 Return<void> RadioResponse::supplyIccPinForAppResponse(const V1_0::RadioResponseInfo& info,
293                                                        int32_t remainingRetries) {
294     LOG_CALL << info.serial;
295     simCb()->supplyIccPinForAppResponse(toAidl(info), remainingRetries);
296     return {};
297 }
298 
supplyIccPuk2ForAppResponse(const V1_0::RadioResponseInfo & info,int32_t remainingRetries)299 Return<void> RadioResponse::supplyIccPuk2ForAppResponse(const V1_0::RadioResponseInfo& info,
300                                                         int32_t remainingRetries) {
301     LOG_CALL << info.serial;
302     simCb()->supplyIccPuk2ForAppResponse(toAidl(info), remainingRetries);
303     return {};
304 }
305 
supplyIccPukForAppResponse(const V1_0::RadioResponseInfo & info,int32_t remainingRetries)306 Return<void> RadioResponse::supplyIccPukForAppResponse(const V1_0::RadioResponseInfo& info,
307                                                        int32_t remainingRetries) {
308     LOG_CALL << info.serial;
309     simCb()->supplyIccPukForAppResponse(toAidl(info), remainingRetries);
310     return {};
311 }
312 
supplySimDepersonalizationResponse(const V1_0::RadioResponseInfo & info,V1_5::PersoSubstate persoType,int32_t rRet)313 Return<void> RadioResponse::supplySimDepersonalizationResponse(const V1_0::RadioResponseInfo& info,
314                                                                V1_5::PersoSubstate persoType,
315                                                                int32_t rRet) {
316     LOG_CALL << info.serial;
317     simCb()->supplySimDepersonalizationResponse(toAidl(info), aidl::PersoSubstate(persoType), rRet);
318     return {};
319 }
320 
updateSimPhonebookRecordsResponse(const V1_6::RadioResponseInfo & info,int32_t updatedRecordIndex)321 Return<void> RadioResponse::updateSimPhonebookRecordsResponse(const V1_6::RadioResponseInfo& info,
322                                                               int32_t updatedRecordIndex) {
323     LOG_CALL << info.serial;
324     simCb()->updateSimPhonebookRecordsResponse(toAidl(info), updatedRecordIndex);
325     return {};
326 }
327 
328 }  // namespace android::hardware::radio::compat
329