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 "radio_sim_utils.h"
18
RadioSimResponse(RadioServiceTest & parent)19 RadioSimResponse::RadioSimResponse(RadioServiceTest& parent) : parent_sim(parent) {}
20
acknowledgeRequest(int32_t)21 ndk::ScopedAStatus RadioSimResponse::acknowledgeRequest(int32_t /*serial*/) {
22 return ndk::ScopedAStatus::ok();
23 }
24
areUiccApplicationsEnabledResponse(const RadioResponseInfo & info,bool enabled)25 ndk::ScopedAStatus RadioSimResponse::areUiccApplicationsEnabledResponse(
26 const RadioResponseInfo& info, bool enabled) {
27 rspInfo = info;
28 areUiccApplicationsEnabled = enabled;
29 parent_sim.notify(info.serial);
30 return ndk::ScopedAStatus::ok();
31 }
32
changeIccPin2ForAppResponse(const RadioResponseInfo & info,int32_t)33 ndk::ScopedAStatus RadioSimResponse::changeIccPin2ForAppResponse(const RadioResponseInfo& info,
34 int32_t /*remainingRetries*/) {
35 rspInfo = info;
36 parent_sim.notify(info.serial);
37 return ndk::ScopedAStatus::ok();
38 }
39
changeIccPinForAppResponse(const RadioResponseInfo & info,int32_t)40 ndk::ScopedAStatus RadioSimResponse::changeIccPinForAppResponse(const RadioResponseInfo& info,
41 int32_t /*remainingRetries*/) {
42 rspInfo = info;
43 parent_sim.notify(info.serial);
44 return ndk::ScopedAStatus::ok();
45 }
46
enableUiccApplicationsResponse(const RadioResponseInfo & info)47 ndk::ScopedAStatus RadioSimResponse::enableUiccApplicationsResponse(const RadioResponseInfo& info) {
48 rspInfo = info;
49 parent_sim.notify(info.serial);
50 return ndk::ScopedAStatus::ok();
51 }
52
getAllowedCarriersResponse(const RadioResponseInfo & info,const CarrierRestrictions & carriers,SimLockMultiSimPolicy multiSimPolicy)53 ndk::ScopedAStatus RadioSimResponse::getAllowedCarriersResponse(
54 const RadioResponseInfo& info, const CarrierRestrictions& carriers,
55 SimLockMultiSimPolicy multiSimPolicy) {
56 rspInfo = info;
57 carrierRestrictionsResp = carriers;
58 multiSimPolicyResp = multiSimPolicy;
59 parent_sim.notify(info.serial);
60 return ndk::ScopedAStatus::ok();
61 }
62
getCdmaSubscriptionResponse(const RadioResponseInfo & info,const std::string &,const std::string &,const std::string &,const std::string &,const std::string &)63 ndk::ScopedAStatus RadioSimResponse::getCdmaSubscriptionResponse(
64 const RadioResponseInfo& info, const std::string& /*mdn*/, const std::string& /*hSid*/,
65 const std::string& /*hNid*/, const std::string& /*min*/, const std::string& /*prl*/) {
66 rspInfo = info;
67 parent_sim.notify(info.serial);
68 return ndk::ScopedAStatus::ok();
69 }
70
getCdmaSubscriptionSourceResponse(const RadioResponseInfo & info,CdmaSubscriptionSource)71 ndk::ScopedAStatus RadioSimResponse::getCdmaSubscriptionSourceResponse(
72 const RadioResponseInfo& info, CdmaSubscriptionSource /*source*/) {
73 rspInfo = info;
74 parent_sim.notify(info.serial);
75 return ndk::ScopedAStatus::ok();
76 }
77
getFacilityLockForAppResponse(const RadioResponseInfo & info,int32_t)78 ndk::ScopedAStatus RadioSimResponse::getFacilityLockForAppResponse(const RadioResponseInfo& info,
79 int32_t /*response*/) {
80 rspInfo = info;
81 parent_sim.notify(info.serial);
82 return ndk::ScopedAStatus::ok();
83 }
84
getIccCardStatusResponse(const RadioResponseInfo & info,const CardStatus & card_status)85 ndk::ScopedAStatus RadioSimResponse::getIccCardStatusResponse(const RadioResponseInfo& info,
86 const CardStatus& card_status) {
87 rspInfo = info;
88 cardStatus = card_status;
89 parent_sim.notify(info.serial);
90 return ndk::ScopedAStatus::ok();
91 }
92
getImsiForAppResponse(const RadioResponseInfo & info,const std::string & imsi_str)93 ndk::ScopedAStatus RadioSimResponse::getImsiForAppResponse(const RadioResponseInfo& info,
94 const std::string& imsi_str) {
95 rspInfo = info;
96 imsi = imsi_str;
97 parent_sim.notify(info.serial);
98 return ndk::ScopedAStatus::ok();
99 }
100
getSimPhonebookCapacityResponse(const RadioResponseInfo & info,const PhonebookCapacity & pbCapacity)101 ndk::ScopedAStatus RadioSimResponse::getSimPhonebookCapacityResponse(
102 const RadioResponseInfo& info, const PhonebookCapacity& pbCapacity) {
103 rspInfo = info;
104 capacity = pbCapacity;
105 parent_sim.notify(info.serial);
106 return ndk::ScopedAStatus::ok();
107 }
108
getSimPhonebookRecordsResponse(const RadioResponseInfo & info)109 ndk::ScopedAStatus RadioSimResponse::getSimPhonebookRecordsResponse(const RadioResponseInfo& info) {
110 rspInfo = info;
111 parent_sim.notify(info.serial);
112 return ndk::ScopedAStatus::ok();
113 }
114
iccCloseLogicalChannelResponse(const RadioResponseInfo & info)115 ndk::ScopedAStatus RadioSimResponse::iccCloseLogicalChannelResponse(const RadioResponseInfo& info) {
116 rspInfo = info;
117 parent_sim.notify(info.serial);
118 return ndk::ScopedAStatus::ok();
119 }
120
iccCloseLogicalChannelWithSessionInfoResponse(const RadioResponseInfo & info)121 ndk::ScopedAStatus RadioSimResponse::iccCloseLogicalChannelWithSessionInfoResponse(
122 const RadioResponseInfo& info) {
123 rspInfo = info;
124 parent_sim.notify(info.serial);
125 return ndk::ScopedAStatus::ok();
126 }
127
iccIoForAppResponse(const RadioResponseInfo & info,const IccIoResult &)128 ndk::ScopedAStatus RadioSimResponse::iccIoForAppResponse(const RadioResponseInfo& info,
129 const IccIoResult& /*iccIo*/) {
130 rspInfo = info;
131 parent_sim.notify(info.serial);
132 return ndk::ScopedAStatus::ok();
133 }
134
iccOpenLogicalChannelResponse(const RadioResponseInfo & info,int32_t,const std::vector<uint8_t> &)135 ndk::ScopedAStatus RadioSimResponse::iccOpenLogicalChannelResponse(
136 const RadioResponseInfo& info, int32_t /*channelId*/,
137 const std::vector<uint8_t>& /*selectResponse*/) {
138 rspInfo = info;
139 parent_sim.notify(info.serial);
140 return ndk::ScopedAStatus::ok();
141 }
142
iccTransmitApduBasicChannelResponse(const RadioResponseInfo & info,const IccIoResult &)143 ndk::ScopedAStatus RadioSimResponse::iccTransmitApduBasicChannelResponse(
144 const RadioResponseInfo& info, const IccIoResult& /*result*/) {
145 rspInfo = info;
146 parent_sim.notify(info.serial);
147 return ndk::ScopedAStatus::ok();
148 }
149
iccTransmitApduLogicalChannelResponse(const RadioResponseInfo & info,const IccIoResult &)150 ndk::ScopedAStatus RadioSimResponse::iccTransmitApduLogicalChannelResponse(
151 const RadioResponseInfo& info, const IccIoResult& /*result*/) {
152 rspInfo = info;
153 parent_sim.notify(info.serial);
154 return ndk::ScopedAStatus::ok();
155 }
156
reportStkServiceIsRunningResponse(const RadioResponseInfo & info)157 ndk::ScopedAStatus RadioSimResponse::reportStkServiceIsRunningResponse(
158 const RadioResponseInfo& info) {
159 rspInfo = info;
160 parent_sim.notify(info.serial);
161 return ndk::ScopedAStatus::ok();
162 }
163
requestIccSimAuthenticationResponse(const RadioResponseInfo & info,const IccIoResult &)164 ndk::ScopedAStatus RadioSimResponse::requestIccSimAuthenticationResponse(
165 const RadioResponseInfo& info, const IccIoResult& /*result*/) {
166 rspInfo = info;
167 parent_sim.notify(info.serial);
168 return ndk::ScopedAStatus::ok();
169 }
170
sendEnvelopeResponse(const RadioResponseInfo & info,const std::string &)171 ndk::ScopedAStatus RadioSimResponse::sendEnvelopeResponse(const RadioResponseInfo& info,
172 const std::string& /*commandResponse*/) {
173 rspInfo = info;
174 parent_sim.notify(info.serial);
175 return ndk::ScopedAStatus::ok();
176 }
177
sendEnvelopeWithStatusResponse(const RadioResponseInfo & info,const IccIoResult &)178 ndk::ScopedAStatus RadioSimResponse::sendEnvelopeWithStatusResponse(const RadioResponseInfo& info,
179 const IccIoResult& /*iccIo*/) {
180 rspInfo = info;
181 parent_sim.notify(info.serial);
182 return ndk::ScopedAStatus::ok();
183 }
184
sendTerminalResponseToSimResponse(const RadioResponseInfo & info)185 ndk::ScopedAStatus RadioSimResponse::sendTerminalResponseToSimResponse(
186 const RadioResponseInfo& info) {
187 rspInfo = info;
188 parent_sim.notify(info.serial);
189 return ndk::ScopedAStatus::ok();
190 }
191
setAllowedCarriersResponse(const RadioResponseInfo & info)192 ndk::ScopedAStatus RadioSimResponse::setAllowedCarriersResponse(const RadioResponseInfo& info) {
193 rspInfo = info;
194 parent_sim.notify(info.serial);
195 return ndk::ScopedAStatus::ok();
196 }
197
setCarrierInfoForImsiEncryptionResponse(const RadioResponseInfo & info)198 ndk::ScopedAStatus RadioSimResponse::setCarrierInfoForImsiEncryptionResponse(
199 const RadioResponseInfo& info) {
200 rspInfo = info;
201 parent_sim.notify(info.serial);
202 return ndk::ScopedAStatus::ok();
203 }
204
setCdmaSubscriptionSourceResponse(const RadioResponseInfo & info)205 ndk::ScopedAStatus RadioSimResponse::setCdmaSubscriptionSourceResponse(
206 const RadioResponseInfo& info) {
207 rspInfo = info;
208 parent_sim.notify(info.serial);
209 return ndk::ScopedAStatus::ok();
210 }
211
setFacilityLockForAppResponse(const RadioResponseInfo & info,int32_t)212 ndk::ScopedAStatus RadioSimResponse::setFacilityLockForAppResponse(const RadioResponseInfo& info,
213 int32_t /*retry*/) {
214 rspInfo = info;
215 parent_sim.notify(info.serial);
216 return ndk::ScopedAStatus::ok();
217 }
218
setSimCardPowerResponse(const RadioResponseInfo & info)219 ndk::ScopedAStatus RadioSimResponse::setSimCardPowerResponse(const RadioResponseInfo& info) {
220 rspInfo = info;
221 parent_sim.notify(info.serial);
222 return ndk::ScopedAStatus::ok();
223 }
224
setUiccSubscriptionResponse(const RadioResponseInfo & info)225 ndk::ScopedAStatus RadioSimResponse::setUiccSubscriptionResponse(const RadioResponseInfo& info) {
226 rspInfo = info;
227 parent_sim.notify(info.serial);
228 return ndk::ScopedAStatus::ok();
229 }
230
supplyIccPin2ForAppResponse(const RadioResponseInfo & info,int32_t)231 ndk::ScopedAStatus RadioSimResponse::supplyIccPin2ForAppResponse(const RadioResponseInfo& info,
232 int32_t /*remainingRetries*/) {
233 rspInfo = info;
234 parent_sim.notify(info.serial);
235 return ndk::ScopedAStatus::ok();
236 }
237
supplyIccPinForAppResponse(const RadioResponseInfo & info,int32_t)238 ndk::ScopedAStatus RadioSimResponse::supplyIccPinForAppResponse(const RadioResponseInfo& info,
239 int32_t /*remainingRetries*/) {
240 rspInfo = info;
241 parent_sim.notify(info.serial);
242 return ndk::ScopedAStatus::ok();
243 }
244
supplyIccPuk2ForAppResponse(const RadioResponseInfo & info,int32_t)245 ndk::ScopedAStatus RadioSimResponse::supplyIccPuk2ForAppResponse(const RadioResponseInfo& info,
246 int32_t /*remainingRetries*/) {
247 rspInfo = info;
248 parent_sim.notify(info.serial);
249 return ndk::ScopedAStatus::ok();
250 }
251
supplyIccPukForAppResponse(const RadioResponseInfo & info,int32_t)252 ndk::ScopedAStatus RadioSimResponse::supplyIccPukForAppResponse(const RadioResponseInfo& info,
253 int32_t /*remainingRetries*/) {
254 rspInfo = info;
255 parent_sim.notify(info.serial);
256 return ndk::ScopedAStatus::ok();
257 }
258
supplySimDepersonalizationResponse(const RadioResponseInfo & info,PersoSubstate,int32_t)259 ndk::ScopedAStatus RadioSimResponse::supplySimDepersonalizationResponse(
260 const RadioResponseInfo& info, PersoSubstate /*persoType*/, int32_t /*remainingRetries*/) {
261 rspInfo = info;
262 parent_sim.notify(info.serial);
263 return ndk::ScopedAStatus::ok();
264 }
265
updateSimPhonebookRecordsResponse(const RadioResponseInfo & info,int32_t recordIndex)266 ndk::ScopedAStatus RadioSimResponse::updateSimPhonebookRecordsResponse(
267 const RadioResponseInfo& info, int32_t recordIndex) {
268 rspInfo = info;
269 updatedRecordIndex = recordIndex;
270 parent_sim.notify(info.serial);
271 return ndk::ScopedAStatus::ok();
272 }
273