1 /*
2 * Copyright (C) 2020 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_hidl_hal_utils_v1_6.h>
18
19 #define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
20
21 /*
22 * Test IRadio.setAllowedNetworkTypesBitmap for the response returned.
23 */
TEST_P(RadioHidlTest_v1_6,setAllowedNetworkTypesBitmap)24 TEST_P(RadioHidlTest_v1_6, setAllowedNetworkTypesBitmap) {
25 serial = GetRandomSerialNumber();
26 ::android::hardware::hidl_bitfield<::android::hardware::radio::V1_4::RadioAccessFamily>
27 allowedNetworkTypesBitmap{};
28 allowedNetworkTypesBitmap |= ::android::hardware::radio::V1_4::RadioAccessFamily::LTE;
29
30 radio_v1_6->setAllowedNetworkTypesBitmap(serial, allowedNetworkTypesBitmap);
31
32 EXPECT_EQ(std::cv_status::no_timeout, wait());
33 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
34 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
35 ASSERT_TRUE(
36 CheckAnyOfErrors(radioRsp_v1_6->rspInfo.error,
37 {::android::hardware::radio::V1_6::RadioError::NONE,
38 ::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
39 ::android::hardware::radio::V1_6::RadioError::OPERATION_NOT_ALLOWED,
40 ::android::hardware::radio::V1_6::RadioError::MODE_NOT_SUPPORTED,
41 ::android::hardware::radio::V1_6::RadioError::INTERNAL_ERR,
42 ::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS,
43 ::android::hardware::radio::V1_6::RadioError::MODEM_ERR,
44 ::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED,
45 ::android::hardware::radio::V1_6::RadioError::NO_RESOURCES}));
46 }
47
48 /*
49 * Test IRadio.getAllowedNetworkTypesBitmap for the response returned.
50 */
TEST_P(RadioHidlTest_v1_6,getAllowedNetworkTypesBitmap)51 TEST_P(RadioHidlTest_v1_6, getAllowedNetworkTypesBitmap) {
52 serial = GetRandomSerialNumber();
53 ::android::hardware::hidl_bitfield<::android::hardware::radio::V1_4::RadioAccessFamily>
54 allowedNetworkTypesBitmap{};
55 allowedNetworkTypesBitmap |= ::android::hardware::radio::V1_4::RadioAccessFamily::LTE;
56
57 radio_v1_6->setAllowedNetworkTypesBitmap(serial, allowedNetworkTypesBitmap);
58
59 EXPECT_EQ(std::cv_status::no_timeout, wait());
60 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
61 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
62
63 if (radioRsp_v1_6->rspInfo.error == ::android::hardware::radio::V1_6::RadioError::NONE) {
64 sleep(3); // wait for modem
65 serial = GetRandomSerialNumber();
66 radio_v1_6->getAllowedNetworkTypesBitmap(serial);
67
68 EXPECT_EQ(std::cv_status::no_timeout, wait());
69 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
70 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
71 ASSERT_TRUE(CheckAnyOfErrors(
72 radioRsp_v1_6->rspInfo.error,
73 {::android::hardware::radio::V1_6::RadioError::NONE,
74 ::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
75 ::android::hardware::radio::V1_6::RadioError::OPERATION_NOT_ALLOWED,
76 ::android::hardware::radio::V1_6::RadioError::MODE_NOT_SUPPORTED,
77 ::android::hardware::radio::V1_6::RadioError::INTERNAL_ERR,
78 ::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS,
79 ::android::hardware::radio::V1_6::RadioError::MODEM_ERR,
80 ::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED,
81 ::android::hardware::radio::V1_6::RadioError::NO_RESOURCES}));
82 }
83 }
84
85 /*
86 * Test IRadio.setupDataCall_1_6() for the response returned.
87 */
TEST_P(RadioHidlTest_v1_6,setupDataCall_1_6)88 TEST_P(RadioHidlTest_v1_6, setupDataCall_1_6) {
89 serial = GetRandomSerialNumber();
90
91 ::android::hardware::radio::V1_5::AccessNetwork accessNetwork =
92 ::android::hardware::radio::V1_5::AccessNetwork::EUTRAN;
93
94 android::hardware::radio::V1_5::DataProfileInfo dataProfileInfo;
95 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
96 dataProfileInfo.profileId = DataProfileId::DEFAULT;
97 dataProfileInfo.apn = hidl_string("internet");
98 dataProfileInfo.protocol = PdpProtocolType::IP;
99 dataProfileInfo.roamingProtocol = PdpProtocolType::IP;
100 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
101 dataProfileInfo.user = hidl_string("username");
102 dataProfileInfo.password = hidl_string("password");
103 dataProfileInfo.type = DataProfileInfoType::THREE_GPP;
104 dataProfileInfo.maxConnsTime = 300;
105 dataProfileInfo.maxConns = 20;
106 dataProfileInfo.waitTime = 0;
107 dataProfileInfo.enabled = true;
108 dataProfileInfo.supportedApnTypesBitmap = 320;
109 dataProfileInfo.bearerBitmap = 161543;
110 dataProfileInfo.mtuV4 = 0;
111 dataProfileInfo.mtuV6 = 0;
112 dataProfileInfo.preferred = true;
113 dataProfileInfo.persistent = false;
114
115 bool roamingAllowed = false;
116
117 std::vector<::android::hardware::radio::V1_5::LinkAddress> addresses = {};
118 std::vector<hidl_string> dnses = {};
119
120 ::android::hardware::radio::V1_2::DataRequestReason reason =
121 ::android::hardware::radio::V1_2::DataRequestReason::NORMAL;
122
123 ::android::hardware::radio::V1_6::OptionalSliceInfo optionalSliceInfo;
124 memset(&optionalSliceInfo, 0, sizeof(optionalSliceInfo));
125
126 ::android::hardware::radio::V1_6::OptionalTrafficDescriptor optionalTrafficDescriptor;
127 memset(&optionalTrafficDescriptor, 0, sizeof(optionalTrafficDescriptor));
128
129 bool matchAllRuleAllowed = true;
130
131 Return<void> res =
132 radio_v1_6->setupDataCall_1_6(serial, accessNetwork, dataProfileInfo, roamingAllowed,
133 reason, addresses, dnses, -1, optionalSliceInfo,
134 optionalTrafficDescriptor, matchAllRuleAllowed);
135 ASSERT_OK(res);
136
137 EXPECT_EQ(std::cv_status::no_timeout, wait());
138 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
139 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
140 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
141 ASSERT_TRUE(CheckAnyOfErrors(
142 radioRsp_v1_6->rspInfo.error,
143 {::android::hardware::radio::V1_6::RadioError::SIM_ABSENT,
144 ::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
145 ::android::hardware::radio::V1_6::RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW}));
146 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
147 ASSERT_TRUE(CheckAnyOfErrors(
148 radioRsp_v1_6->rspInfo.error,
149 {::android::hardware::radio::V1_6::RadioError::NONE,
150 ::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
151 ::android::hardware::radio::V1_6::RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW}));
152 }
153 }
154
TEST_P(RadioHidlTest_v1_6,setupDataCall_1_6_osAppId)155 TEST_P(RadioHidlTest_v1_6, setupDataCall_1_6_osAppId) {
156 serial = GetRandomSerialNumber();
157
158 ::android::hardware::radio::V1_5::AccessNetwork accessNetwork =
159 ::android::hardware::radio::V1_5::AccessNetwork::EUTRAN;
160
161 android::hardware::radio::V1_5::DataProfileInfo dataProfileInfo;
162 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
163 dataProfileInfo.profileId = DataProfileId::DEFAULT;
164 dataProfileInfo.apn = hidl_string("internet");
165 dataProfileInfo.protocol = PdpProtocolType::IP;
166 dataProfileInfo.roamingProtocol = PdpProtocolType::IP;
167 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
168 dataProfileInfo.user = hidl_string("username");
169 dataProfileInfo.password = hidl_string("password");
170 dataProfileInfo.type = DataProfileInfoType::THREE_GPP;
171 dataProfileInfo.maxConnsTime = 300;
172 dataProfileInfo.maxConns = 20;
173 dataProfileInfo.waitTime = 0;
174 dataProfileInfo.enabled = true;
175 dataProfileInfo.supportedApnTypesBitmap = 320;
176 dataProfileInfo.bearerBitmap = 161543;
177 dataProfileInfo.mtuV4 = 0;
178 dataProfileInfo.mtuV6 = 0;
179 dataProfileInfo.preferred = true;
180 dataProfileInfo.persistent = false;
181
182 bool roamingAllowed = false;
183
184 std::vector<::android::hardware::radio::V1_5::LinkAddress> addresses = {};
185 std::vector<hidl_string> dnses = {};
186
187 ::android::hardware::radio::V1_2::DataRequestReason reason =
188 ::android::hardware::radio::V1_2::DataRequestReason::NORMAL;
189
190 ::android::hardware::radio::V1_6::OptionalSliceInfo optionalSliceInfo;
191 memset(&optionalSliceInfo, 0, sizeof(optionalSliceInfo));
192
193 ::android::hardware::radio::V1_6::OptionalTrafficDescriptor optionalTrafficDescriptor;
194 memset(&optionalTrafficDescriptor, 0, sizeof(optionalTrafficDescriptor));
195
196 ::android::hardware::radio::V1_6::TrafficDescriptor trafficDescriptor;
197 ::android::hardware::radio::V1_6::OsAppId osAppId;
198 osAppId.osAppId = 1;
199 trafficDescriptor.osAppId.value(osAppId);
200 optionalTrafficDescriptor.value(trafficDescriptor);
201
202 bool matchAllRuleAllowed = true;
203
204 Return<void> res =
205 radio_v1_6->setupDataCall_1_6(serial, accessNetwork, dataProfileInfo, roamingAllowed,
206 reason, addresses, dnses, -1, optionalSliceInfo,
207 optionalTrafficDescriptor, matchAllRuleAllowed);
208 ASSERT_OK(res);
209
210 EXPECT_EQ(std::cv_status::no_timeout, wait());
211 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
212 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
213 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
214 ASSERT_TRUE(CheckAnyOfErrors(
215 radioRsp_v1_6->rspInfo.error,
216 {::android::hardware::radio::V1_6::RadioError::SIM_ABSENT,
217 ::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
218 ::android::hardware::radio::V1_6::RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW}));
219 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
220 ASSERT_TRUE(CheckAnyOfErrors(
221 radioRsp_v1_6->rspInfo.error,
222 {::android::hardware::radio::V1_6::RadioError::NONE,
223 ::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
224 ::android::hardware::radio::V1_6::RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW}));
225 if (radioRsp_v1_6->setupDataCallResult.trafficDescriptors.size() <= 0) {
226 return;
227 }
228 EXPECT_EQ(optionalTrafficDescriptor.value().osAppId.value().osAppId,
229 radioRsp_v1_6->setupDataCallResult.trafficDescriptors[0].osAppId.value().osAppId);
230 }
231 }
232
233 /*
234 * Test IRadio.getSlicingConfig() for the response returned.
235 */
TEST_P(RadioHidlTest_v1_6,getSlicingConfig)236 TEST_P(RadioHidlTest_v1_6, getSlicingConfig) {
237 serial = GetRandomSerialNumber();
238 radio_v1_6->getSlicingConfig(serial);
239 EXPECT_EQ(std::cv_status::no_timeout, wait());
240 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
241 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
242 if (getRadioHalCapabilities()) {
243 ASSERT_TRUE(CheckAnyOfErrors(
244 radioRsp_v1_6->rspInfo.error,
245 {::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED}));
246 } else {
247 ASSERT_TRUE(
248 CheckAnyOfErrors(radioRsp_v1_6->rspInfo.error,
249 {::android::hardware::radio::V1_6::RadioError::NONE,
250 ::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
251 ::android::hardware::radio::V1_6::RadioError::INTERNAL_ERR,
252 ::android::hardware::radio::V1_6::RadioError::MODEM_ERR}));
253 }
254 }
255
256 /*
257 * Test IRadio_1_6.sendSms() for the response returned.
258 */
TEST_P(RadioHidlTest_v1_6,sendSms_1_6)259 TEST_P(RadioHidlTest_v1_6, sendSms_1_6) {
260 LOG(DEBUG) << "sendSms";
261 serial = GetRandomSerialNumber();
262 GsmSmsMessage msg;
263 msg.smscPdu = "";
264 msg.pdu = "01000b916105770203f3000006d4f29c3e9b01";
265
266 radio_v1_6->sendSms_1_6(serial, msg);
267
268 EXPECT_EQ(std::cv_status::no_timeout, wait());
269 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
270 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
271
272 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
273 ASSERT_TRUE(CheckAnyOfErrors(
274 radioRsp_v1_6->rspInfo.error,
275 {::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS,
276 ::android::hardware::radio::V1_6::RadioError::INVALID_STATE,
277 ::android::hardware::radio::V1_6::RadioError::SIM_ABSENT},
278 CHECK_GENERAL_ERROR));
279 EXPECT_EQ(0, radioRsp_v1_6->sendSmsResult.errorCode);
280 }
281 LOG(DEBUG) << "sendSms finished";
282 }
283
284 /*
285 * Test IRadio_1_6.sendSmsExpectMore() for the response returned.
286 */
TEST_P(RadioHidlTest_v1_6,sendSmsExpectMore_1_6)287 TEST_P(RadioHidlTest_v1_6, sendSmsExpectMore_1_6) {
288 LOG(DEBUG) << "sendSmsExpectMore";
289 serial = GetRandomSerialNumber();
290 GsmSmsMessage msg;
291 msg.smscPdu = "";
292 msg.pdu = "01000b916105770203f3000006d4f29c3e9b01";
293
294 radio_v1_6->sendSmsExpectMore_1_6(serial, msg);
295
296 EXPECT_EQ(std::cv_status::no_timeout, wait());
297 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
298 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
299
300 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
301 ASSERT_TRUE(CheckAnyOfErrors(
302 radioRsp_v1_6->rspInfo.error,
303 {::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS,
304 ::android::hardware::radio::V1_6::RadioError::INVALID_STATE,
305 ::android::hardware::radio::V1_6::RadioError::SIM_ABSENT},
306 CHECK_GENERAL_ERROR));
307 }
308 LOG(DEBUG) << "sendSmsExpectMore finished";
309 }
310
311 /*
312 * Test IRadio_1_6.sendCdmaSms() for the response returned.
313 */
TEST_P(RadioHidlTest_v1_6,sendCdmaSms_1_6)314 TEST_P(RadioHidlTest_v1_6, sendCdmaSms_1_6) {
315 LOG(DEBUG) << "sendCdmaSms";
316 serial = GetRandomSerialNumber();
317
318 // Create a CdmaSmsAddress
319 CdmaSmsAddress cdmaSmsAddress;
320 cdmaSmsAddress.digitMode = CdmaSmsDigitMode::FOUR_BIT;
321 cdmaSmsAddress.numberMode = CdmaSmsNumberMode::NOT_DATA_NETWORK;
322 cdmaSmsAddress.numberType = CdmaSmsNumberType::UNKNOWN;
323 cdmaSmsAddress.numberPlan = CdmaSmsNumberPlan::UNKNOWN;
324 cdmaSmsAddress.digits = (std::vector<uint8_t>){11, 1, 6, 5, 10, 7, 7, 2, 10, 3, 10, 3};
325
326 // Create a CdmaSmsSubAddress
327 CdmaSmsSubaddress cdmaSmsSubaddress;
328 cdmaSmsSubaddress.subaddressType = CdmaSmsSubaddressType::NSAP;
329 cdmaSmsSubaddress.odd = false;
330 cdmaSmsSubaddress.digits = (std::vector<uint8_t>){};
331
332 // Create a CdmaSmsMessage
333 android::hardware::radio::V1_0::CdmaSmsMessage cdmaSmsMessage;
334 cdmaSmsMessage.teleserviceId = 4098;
335 cdmaSmsMessage.isServicePresent = false;
336 cdmaSmsMessage.serviceCategory = 0;
337 cdmaSmsMessage.address = cdmaSmsAddress;
338 cdmaSmsMessage.subAddress = cdmaSmsSubaddress;
339 cdmaSmsMessage.bearerData =
340 (std::vector<uint8_t>){15, 0, 3, 32, 3, 16, 1, 8, 16, 53, 76, 68, 6, 51, 106, 0};
341
342 radio_v1_6->sendCdmaSms_1_6(serial, cdmaSmsMessage);
343
344 EXPECT_EQ(std::cv_status::no_timeout, wait());
345 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
346 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
347
348 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
349 ASSERT_TRUE(CheckAnyOfErrors(
350 radioRsp_v1_6->rspInfo.error,
351 {::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS,
352 ::android::hardware::radio::V1_6::RadioError::INVALID_STATE,
353 ::android::hardware::radio::V1_6::RadioError::SIM_ABSENT},
354 CHECK_GENERAL_ERROR));
355 }
356 LOG(DEBUG) << "sendCdmaSms finished";
357 }
358
359 /*
360 * Test IRadio_1_6.sendCdmaSmsExpectMore() for the response returned.
361 */
TEST_P(RadioHidlTest_v1_6,sendCdmaSmsExpectMore_1_6)362 TEST_P(RadioHidlTest_v1_6, sendCdmaSmsExpectMore_1_6) {
363 serial = GetRandomSerialNumber();
364
365 // Create a CdmaSmsAddress
366 CdmaSmsAddress cdmaSmsAddress;
367 cdmaSmsAddress.digitMode = CdmaSmsDigitMode::FOUR_BIT;
368 cdmaSmsAddress.numberMode = CdmaSmsNumberMode::NOT_DATA_NETWORK;
369 cdmaSmsAddress.numberType = CdmaSmsNumberType::UNKNOWN;
370 cdmaSmsAddress.numberPlan = CdmaSmsNumberPlan::UNKNOWN;
371 cdmaSmsAddress.digits = (std::vector<uint8_t>){11, 1, 6, 5, 10, 7, 7, 2, 10, 3, 10, 3};
372
373 // Create a CdmaSmsSubAddress
374 CdmaSmsSubaddress cdmaSmsSubaddress;
375 cdmaSmsSubaddress.subaddressType = CdmaSmsSubaddressType::NSAP;
376 cdmaSmsSubaddress.odd = false;
377 cdmaSmsSubaddress.digits = (std::vector<uint8_t>){};
378
379 // Create a CdmaSmsMessage
380 android::hardware::radio::V1_0::CdmaSmsMessage cdmaSmsMessage;
381 cdmaSmsMessage.teleserviceId = 4098;
382 cdmaSmsMessage.isServicePresent = false;
383 cdmaSmsMessage.serviceCategory = 0;
384 cdmaSmsMessage.address = cdmaSmsAddress;
385 cdmaSmsMessage.subAddress = cdmaSmsSubaddress;
386 cdmaSmsMessage.bearerData =
387 (std::vector<uint8_t>){15, 0, 3, 32, 3, 16, 1, 8, 16, 53, 76, 68, 6, 51, 106, 0};
388
389 radio_v1_6->sendCdmaSmsExpectMore_1_6(serial, cdmaSmsMessage);
390
391 EXPECT_EQ(std::cv_status::no_timeout, wait());
392 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
393 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
394
395 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
396 ASSERT_TRUE(CheckAnyOfErrors(
397 radioRsp_v1_6->rspInfo.error,
398 {::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS,
399 ::android::hardware::radio::V1_6::RadioError::INVALID_STATE,
400 ::android::hardware::radio::V1_6::RadioError::SIM_ABSENT},
401 CHECK_GENERAL_ERROR));
402 }
403 }
404
405 /*
406 * Test IRadio.setRadioPower_1_6() for the response returned by
407 * IRadio.setRadioPowerResponse_1_6().
408 */
TEST_P(RadioHidlTest_v1_6,setRadioPower_1_6_emergencyCall_cancelled)409 TEST_P(RadioHidlTest_v1_6, setRadioPower_1_6_emergencyCall_cancelled) {
410 // Set radio power to off.
411 serial = GetRandomSerialNumber();
412 radio_v1_6->setRadioPower_1_6(serial, false, false, false);
413 EXPECT_EQ(std::cv_status::no_timeout, wait());
414 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
415 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
416 EXPECT_EQ(::android::hardware::radio::V1_6::RadioError::NONE, radioRsp_v1_6->rspInfo.error);
417
418 // Set radio power to on with forEmergencyCall being true. This should put modem to only scan
419 // emergency call bands.
420 serial = GetRandomSerialNumber();
421 radio_v1_6->setRadioPower_1_6(serial, true, true, true);
422 EXPECT_EQ(std::cv_status::no_timeout, wait());
423 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
424 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
425 EXPECT_EQ(::android::hardware::radio::V1_6::RadioError::NONE, radioRsp_v1_6->rspInfo.error);
426
427 // Set radio power to on with forEmergencyCall being false. This should put modem in regular
428 // operation modem.
429 serial = GetRandomSerialNumber();
430 radio_v1_6->setRadioPower_1_6(serial, true, false, false);
431 EXPECT_EQ(std::cv_status::no_timeout, wait());
432 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
433 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
434 EXPECT_EQ(::android::hardware::radio::V1_6::RadioError::NONE, radioRsp_v1_6->rspInfo.error);
435 }
436
437 /*
438 * Test IRadio.setNrDualConnectivityState() for the response returned.
439 */
TEST_P(RadioHidlTest_v1_6,setNrDualConnectivityState)440 TEST_P(RadioHidlTest_v1_6, setNrDualConnectivityState) {
441 serial = GetRandomSerialNumber();
442
443 Return<void> res =
444 radio_v1_6->setNrDualConnectivityState(serial, NrDualConnectivityState::DISABLE);
445 ASSERT_OK(res);
446
447 EXPECT_EQ(std::cv_status::no_timeout, wait());
448 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
449 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
450 if (getRadioHalCapabilities()) {
451 ASSERT_TRUE(CheckAnyOfErrors(
452 radioRsp_v1_6->rspInfo.error,
453 {::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED}));
454 } else {
455 ASSERT_TRUE(CheckAnyOfErrors(
456 radioRsp_v1_6->rspInfo.error,
457 {::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
458 ::android::hardware::radio::V1_6::RadioError::INTERNAL_ERR,
459 ::android::hardware::radio::V1_6::RadioError::INVALID_STATE,
460 ::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED,
461 ::android::hardware::radio::V1_6::RadioError::NONE}));
462 }
463 }
464
465 /*
466 * Test IRadio.isNrDualConnectivityEnabled() for the response returned.
467 */
TEST_P(RadioHidlTest_v1_6,isNrDualConnectivityEnabled)468 TEST_P(RadioHidlTest_v1_6, isNrDualConnectivityEnabled) {
469 serial = GetRandomSerialNumber();
470
471 Return<void> res = radio_v1_6->isNrDualConnectivityEnabled(serial);
472 ASSERT_OK(res);
473
474 EXPECT_EQ(std::cv_status::no_timeout, wait());
475 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
476 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
477 if (getRadioHalCapabilities()) {
478 ASSERT_TRUE(CheckAnyOfErrors(
479 radioRsp_v1_6->rspInfo.error,
480 {::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED}));
481 } else {
482 ASSERT_TRUE(
483 CheckAnyOfErrors(radioRsp_v1_6->rspInfo.error,
484 {::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
485 ::android::hardware::radio::V1_6::RadioError::INTERNAL_ERR,
486 ::android::hardware::radio::V1_6::RadioError::NONE}));
487 }
488 }
489
490 /*
491 * Test IRadio.setDataThrottling() for the response returned.
492 */
TEST_P(RadioHidlTest_v1_6,setDataThrottling)493 TEST_P(RadioHidlTest_v1_6, setDataThrottling) {
494 serial = GetRandomSerialNumber();
495
496 Return<void> res = radio_v1_6->setDataThrottling(
497 serial, DataThrottlingAction::THROTTLE_SECONDARY_CARRIER, 60000);
498 ASSERT_OK(res);
499
500 EXPECT_EQ(std::cv_status::no_timeout, wait());
501 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
502 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
503 if (getRadioHalCapabilities()) {
504 ASSERT_TRUE(CheckAnyOfErrors(
505 radioRsp_v1_6->rspInfo.error,
506 {::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED,
507 ::android::hardware::radio::V1_6::RadioError::NONE}));
508 } else {
509 ASSERT_TRUE(CheckAnyOfErrors(
510 radioRsp_v1_6->rspInfo.error,
511 {::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
512 ::android::hardware::radio::V1_6::RadioError::MODEM_ERR,
513 ::android::hardware::radio::V1_6::RadioError::NONE,
514 ::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS}));
515 }
516
517 sleep(1);
518 serial = GetRandomSerialNumber();
519
520 res = radio_v1_6->setDataThrottling(serial, DataThrottlingAction::THROTTLE_ANCHOR_CARRIER,
521 60000);
522 ASSERT_OK(res);
523 EXPECT_EQ(std::cv_status::no_timeout, wait());
524 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
525 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
526 if (getRadioHalCapabilities()) {
527 ASSERT_TRUE(CheckAnyOfErrors(
528 radioRsp_v1_6->rspInfo.error,
529 {::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED,
530 ::android::hardware::radio::V1_6::RadioError::NONE}));
531 } else {
532 ASSERT_TRUE(CheckAnyOfErrors(
533 radioRsp_v1_6->rspInfo.error,
534 {::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
535 ::android::hardware::radio::V1_6::RadioError::MODEM_ERR,
536 ::android::hardware::radio::V1_6::RadioError::NONE,
537 ::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS}));
538 }
539
540 sleep(1);
541 serial = GetRandomSerialNumber();
542
543 res = radio_v1_6->setDataThrottling(serial, DataThrottlingAction::HOLD, 60000);
544 ASSERT_OK(res);
545
546 EXPECT_EQ(std::cv_status::no_timeout, wait());
547 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
548 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
549 if (getRadioHalCapabilities()) {
550 ASSERT_TRUE(CheckAnyOfErrors(
551 radioRsp_v1_6->rspInfo.error,
552 {::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED,
553 ::android::hardware::radio::V1_6::RadioError::NONE}));
554 } else {
555 ASSERT_TRUE(CheckAnyOfErrors(
556 radioRsp_v1_6->rspInfo.error,
557 {::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
558 ::android::hardware::radio::V1_6::RadioError::MODEM_ERR,
559 ::android::hardware::radio::V1_6::RadioError::NONE,
560 ::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS}));
561 }
562
563 sleep(1);
564 serial = GetRandomSerialNumber();
565
566 res = radio_v1_6->setDataThrottling(serial, DataThrottlingAction::NO_DATA_THROTTLING, 60000);
567 ASSERT_OK(res);
568 EXPECT_EQ(std::cv_status::no_timeout, wait());
569 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
570 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
571 if (getRadioHalCapabilities()) {
572 ASSERT_TRUE(CheckAnyOfErrors(
573 radioRsp_v1_6->rspInfo.error,
574 {::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED,
575 ::android::hardware::radio::V1_6::RadioError::NONE}));
576 } else {
577 ASSERT_TRUE(CheckAnyOfErrors(
578 radioRsp_v1_6->rspInfo.error,
579 {::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
580 ::android::hardware::radio::V1_6::RadioError::MODEM_ERR,
581 ::android::hardware::radio::V1_6::RadioError::NONE,
582 ::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS}));
583 }
584
585 sleep(1);
586 }
587
588 /*
589 * Test IRadio.setSimCardPower_1_6() for the response returned.
590 */
TEST_P(RadioHidlTest_v1_6,setSimCardPower_1_6)591 TEST_P(RadioHidlTest_v1_6, setSimCardPower_1_6) {
592 /* Test setSimCardPower power down */
593 serial = GetRandomSerialNumber();
594 radio_v1_6->setSimCardPower_1_6(serial, CardPowerState::POWER_DOWN);
595 EXPECT_EQ(std::cv_status::no_timeout, wait());
596 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
597 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
598 ASSERT_TRUE(
599 CheckAnyOfErrors(radioRsp_v1_6->rspInfo.error,
600 {::android::hardware::radio::V1_6::RadioError::NONE,
601 ::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS,
602 ::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE}));
603
604 // Give some time for modem to fully power up the SIM card
605 sleep(MODEM_SET_SIM_POWER_DELAY_IN_SECONDS);
606
607 // setSimCardPower_1_6 does not return until the request is handled, and should not trigger
608 // CardState::ABSENT when turning off power
609 if (radioRsp_v1_6->rspInfo.error == ::android::hardware::radio::V1_6::RadioError::NONE) {
610 /* Wait some time for setting sim power down and then verify it */
611 updateSimCardStatus();
612 // We cannot assert the consistency of CardState here due to b/203031664
613 // EXPECT_EQ(CardState::PRESENT, cardStatus.base.base.base.cardState);
614 // applications should be an empty vector of AppStatus
615 EXPECT_EQ(0, cardStatus.applications.size());
616 }
617
618 /* Test setSimCardPower power up */
619 serial = GetRandomSerialNumber();
620 radio_v1_6->setSimCardPower_1_6(serial, CardPowerState::POWER_UP);
621 EXPECT_EQ(std::cv_status::no_timeout, wait());
622 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
623 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
624 ASSERT_TRUE(
625 CheckAnyOfErrors(radioRsp_v1_6->rspInfo.error,
626 {::android::hardware::radio::V1_6::RadioError::NONE,
627 ::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS,
628 ::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE}));
629
630 // Give some time for modem to fully power up the SIM card
631 sleep(MODEM_SET_SIM_POWER_DELAY_IN_SECONDS);
632
633 // setSimCardPower_1_6 does not return until the request is handled. Just verify that we still
634 // have CardState::PRESENT after turning the power back on
635 if (radioRsp_v1_6->rspInfo.error == ::android::hardware::radio::V1_6::RadioError::NONE) {
636 updateSimCardStatus();
637 EXPECT_EQ(CardState::PRESENT, cardStatus.base.base.base.cardState);
638 }
639 }
640
641 /*
642 * Test IRadio.emergencyDial() for the response returned.
643 */
TEST_P(RadioHidlTest_v1_6,emergencyDial_1_6)644 TEST_P(RadioHidlTest_v1_6, emergencyDial_1_6) {
645 if (!deviceSupportsFeature(FEATURE_VOICE_CALL)) {
646 ALOGI("Skipping emergencyDial because voice call is not supported in device");
647 return;
648 } else if (!deviceSupportsFeature(FEATURE_TELEPHONY_GSM) &&
649 !deviceSupportsFeature(FEATURE_TELEPHONY_CDMA)) {
650 ALOGI("Skipping emergencyDial because gsm/cdma radio is not supported in device");
651 return;
652 } else {
653 ALOGI("Running emergencyDial because voice call is supported in device");
654 }
655
656 serial = GetRandomSerialNumber();
657
658 ::android::hardware::radio::V1_0::Dial dialInfo;
659 dialInfo.address = hidl_string("911");
660 int categories = static_cast<int>(
661 ::android::hardware::radio::V1_4::EmergencyServiceCategory::UNSPECIFIED);
662 std::vector<hidl_string> urns = {""};
663 ::android::hardware::radio::V1_4::EmergencyCallRouting routing =
664 ::android::hardware::radio::V1_4::EmergencyCallRouting::UNKNOWN;
665
666 Return<void> res =
667 radio_v1_6->emergencyDial_1_6(serial, dialInfo, categories, urns, routing, true, true);
668 ASSERT_OK(res);
669 EXPECT_EQ(std::cv_status::no_timeout, wait());
670 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo_v1_0.type);
671 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo_v1_0.serial);
672
673 ALOGI("emergencyDial, rspInfo_v1_0.error = %s\n",
674 toString(radioRsp_v1_6->rspInfo_v1_0.error).c_str());
675
676 ::android::hardware::radio::V1_0::RadioError rspEmergencyDial =
677 radioRsp_v1_6->rspInfo_v1_0.error;
678 // In DSDS or TSTS, we only check the result if the current slot is IN_SERVICE
679 // or Emergency_Only.
680 if (isDsDsEnabled() || isTsTsEnabled()) {
681 serial = GetRandomSerialNumber();
682 radio_v1_6->getVoiceRegistrationState_1_6(serial);
683 EXPECT_EQ(std::cv_status::no_timeout, wait());
684 if (isVoiceEmergencyOnly(radioRsp_v1_6->voiceRegResp.regState) ||
685 isVoiceInService(radioRsp_v1_6->voiceRegResp.regState)) {
686 EXPECT_EQ(::android::hardware::radio::V1_0::RadioError::NONE, rspEmergencyDial);
687 }
688 } else {
689 EXPECT_EQ(::android::hardware::radio::V1_0::RadioError::NONE, rspEmergencyDial);
690 }
691
692 // Give some time for modem to establish the emergency call channel.
693 sleep(MODEM_EMERGENCY_CALL_ESTABLISH_TIME);
694
695 // Disconnect all the potential established calls to prevent them affecting other tests.
696 clearPotentialEstablishedCalls();
697 }
698
699 /*
700 * Test IRadio.emergencyDial() with specified service and its response returned.
701 */
TEST_P(RadioHidlTest_v1_6,emergencyDial_1_6_withServices)702 TEST_P(RadioHidlTest_v1_6, emergencyDial_1_6_withServices) {
703 if (!deviceSupportsFeature(FEATURE_VOICE_CALL)) {
704 ALOGI("Skipping emergencyDial because voice call is not supported in device");
705 return;
706 } else if (!deviceSupportsFeature(FEATURE_TELEPHONY_GSM) &&
707 !deviceSupportsFeature(FEATURE_TELEPHONY_CDMA)) {
708 ALOGI("Skipping emergencyDial because gsm/cdma radio is not supported in device");
709 return;
710 } else {
711 ALOGI("Running emergencyDial because voice call is supported in device");
712 }
713
714 serial = GetRandomSerialNumber();
715
716 ::android::hardware::radio::V1_0::Dial dialInfo;
717 dialInfo.address = hidl_string("911");
718 int categories =
719 static_cast<int>(::android::hardware::radio::V1_4::EmergencyServiceCategory::AMBULANCE);
720 std::vector<hidl_string> urns = {"urn:service:sos.ambulance"};
721 ::android::hardware::radio::V1_4::EmergencyCallRouting routing =
722 ::android::hardware::radio::V1_4::EmergencyCallRouting::UNKNOWN;
723
724 Return<void> res =
725 radio_v1_6->emergencyDial_1_6(serial, dialInfo, categories, urns, routing, true, true);
726 ASSERT_OK(res);
727 EXPECT_EQ(std::cv_status::no_timeout, wait());
728 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo_v1_0.type);
729 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo_v1_0.serial);
730
731 ALOGI("emergencyDial_withServices, rspInfo_v1_0.error = %s\n",
732 toString(radioRsp_v1_6->rspInfo_v1_0.error).c_str());
733 ::android::hardware::radio::V1_0::RadioError rspEmergencyDial =
734 radioRsp_v1_6->rspInfo_v1_0.error;
735
736 // In DSDS or TSTS, we only check the result if the current slot is IN_SERVICE
737 // or Emergency_Only.
738 if (isDsDsEnabled() || isTsTsEnabled()) {
739 serial = GetRandomSerialNumber();
740 radio_v1_6->getVoiceRegistrationState_1_6(serial);
741 EXPECT_EQ(std::cv_status::no_timeout, wait());
742 if (isVoiceEmergencyOnly(radioRsp_v1_6->voiceRegResp.regState) ||
743 isVoiceInService(radioRsp_v1_6->voiceRegResp.regState)) {
744 EXPECT_EQ(::android::hardware::radio::V1_0::RadioError::NONE, rspEmergencyDial);
745 }
746 } else {
747 EXPECT_EQ(::android::hardware::radio::V1_0::RadioError::NONE, rspEmergencyDial);
748 }
749 // Give some time for modem to establish the emergency call channel.
750 sleep(MODEM_EMERGENCY_CALL_ESTABLISH_TIME);
751
752 // Disconnect all the potential established calls to prevent them affecting other tests.
753 clearPotentialEstablishedCalls();
754 }
755
756 /*
757 * Test IRadio.emergencyDial() with known emergency call routing and its response returned.
758 */
TEST_P(RadioHidlTest_v1_6,emergencyDial_1_6_withEmergencyRouting)759 TEST_P(RadioHidlTest_v1_6, emergencyDial_1_6_withEmergencyRouting) {
760 if (!deviceSupportsFeature(FEATURE_VOICE_CALL)) {
761 ALOGI("Skipping emergencyDial because voice call is not supported in device");
762 return;
763 } else if (!deviceSupportsFeature(FEATURE_TELEPHONY_GSM) &&
764 !deviceSupportsFeature(FEATURE_TELEPHONY_CDMA)) {
765 ALOGI("Skipping emergencyDial because gsm/cdma radio is not supported in device");
766 return;
767 } else {
768 ALOGI("Running emergencyDial because voice call is supported in device");
769 }
770
771 serial = GetRandomSerialNumber();
772
773 ::android::hardware::radio::V1_0::Dial dialInfo;
774 dialInfo.address = hidl_string("911");
775 int categories = static_cast<int>(
776 ::android::hardware::radio::V1_4::EmergencyServiceCategory::UNSPECIFIED);
777 std::vector<hidl_string> urns = {""};
778 ::android::hardware::radio::V1_4::EmergencyCallRouting routing =
779 ::android::hardware::radio::V1_4::EmergencyCallRouting::EMERGENCY;
780
781 Return<void> res =
782 radio_v1_6->emergencyDial_1_6(serial, dialInfo, categories, urns, routing, true, true);
783 ASSERT_OK(res);
784 EXPECT_EQ(std::cv_status::no_timeout, wait());
785 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo_v1_0.type);
786 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo_v1_0.serial);
787
788 ALOGI("emergencyDial_withEmergencyRouting, rspInfo_v1_0.error = %s\n",
789 toString(radioRsp_v1_6->rspInfo_v1_0.error).c_str());
790 ::android::hardware::radio::V1_0::RadioError rspEmergencyDial =
791 radioRsp_v1_6->rspInfo_v1_0.error;
792
793 // In DSDS or TSTS, we only check the result if the current slot is IN_SERVICE
794 // or Emergency_Only.
795 if (isDsDsEnabled() || isTsTsEnabled()) {
796 serial = GetRandomSerialNumber();
797 radio_v1_6->getVoiceRegistrationState_1_6(serial);
798 EXPECT_EQ(std::cv_status::no_timeout, wait());
799 if (isVoiceEmergencyOnly(radioRsp_v1_6->voiceRegResp.regState) ||
800 isVoiceInService(radioRsp_v1_6->voiceRegResp.regState)) {
801 EXPECT_EQ(::android::hardware::radio::V1_0::RadioError::NONE, rspEmergencyDial);
802 }
803 } else {
804 EXPECT_EQ(::android::hardware::radio::V1_0::RadioError::NONE, rspEmergencyDial);
805 }
806
807 // Give some time for modem to establish the emergency call channel.
808 sleep(MODEM_EMERGENCY_CALL_ESTABLISH_TIME);
809
810 // Disconnect all the potential established calls to prevent them affecting other tests.
811 clearPotentialEstablishedCalls();
812 }
813
814 /*
815 * Test IRadio.getCurrentCalls_1_6() for the response returned.
816 */
TEST_P(RadioHidlTest_v1_6,getCurrentCalls_1_6)817 TEST_P(RadioHidlTest_v1_6, getCurrentCalls_1_6) {
818 serial = GetRandomSerialNumber();
819 radio_v1_6->getCurrentCalls_1_6(serial);
820 EXPECT_EQ(std::cv_status::no_timeout, wait());
821 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
822 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
823 EXPECT_EQ(::android::hardware::radio::V1_6::RadioError::NONE, radioRsp_v1_6->rspInfo.error);
824 }
825
826 /*
827 * Test IRadio.setCarrierInfoForImsiEncryption_1_6() for the response returned.
828 */
TEST_P(RadioHidlTest_v1_6,setCarrierInfoForImsiEncryption_1_6)829 TEST_P(RadioHidlTest_v1_6, setCarrierInfoForImsiEncryption_1_6) {
830 serial = GetRandomSerialNumber();
831 ::android::hardware::radio::V1_6::ImsiEncryptionInfo imsiInfo;
832 imsiInfo.base.mcc = "310";
833 imsiInfo.base.mnc = "004";
834 imsiInfo.base.carrierKey = (std::vector<uint8_t>){1, 2, 3, 4, 5, 6};
835 imsiInfo.base.keyIdentifier = "Test";
836 imsiInfo.base.expirationTime = 20180101;
837 imsiInfo.keyType = PublicKeyType::EPDG;
838
839 radio_v1_6->setCarrierInfoForImsiEncryption_1_6(serial, imsiInfo);
840 EXPECT_EQ(std::cv_status::no_timeout, wait());
841 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo_v1_0.type);
842 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo_v1_0.serial);
843
844 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
845 ASSERT_TRUE(CheckAnyOfErrors(
846 radioRsp_v1_6->rspInfo.error,
847 {::android::hardware::radio::V1_6::RadioError::NONE,
848 ::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED}));
849 }
850 }
851
852 /*
853 * Test IRadio.getSimPhonebookRecords() for the response returned.
854 */
TEST_P(RadioHidlTest_v1_6,getSimPhonebookRecords)855 TEST_P(RadioHidlTest_v1_6, getSimPhonebookRecords) {
856 serial = GetRandomSerialNumber();
857 radio_v1_6->getSimPhonebookRecords(serial);
858 EXPECT_EQ(std::cv_status::no_timeout, wait());
859 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
860 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
861 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
862 ASSERT_TRUE(CheckAnyOfErrors(
863 radioRsp_v1_6->rspInfo.error,
864 {::android::hardware::radio::V1_6::RadioError::INVALID_SIM_STATE,
865 ::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
866 ::android::hardware::radio::V1_6::RadioError::MODEM_ERR,
867 ::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS,
868 ::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED},
869 CHECK_GENERAL_ERROR));
870 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
871 ASSERT_TRUE(CheckAnyOfErrors(
872 radioRsp_v1_6->rspInfo.error,
873 {::android::hardware::radio::V1_6::RadioError::NONE,
874 ::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED},
875 CHECK_GENERAL_ERROR));
876 }
877 }
878
879 /*
880 * Test IRadio.getSimPhonebookCapacity for the response returned.
881 */
TEST_P(RadioHidlTest_v1_6,getSimPhonebookCapacity)882 TEST_P(RadioHidlTest_v1_6, getSimPhonebookCapacity) {
883 serial = GetRandomSerialNumber();
884 radio_v1_6->getSimPhonebookCapacity(serial);
885 EXPECT_EQ(std::cv_status::no_timeout, wait());
886 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
887 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
888 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
889 ASSERT_TRUE(CheckAnyOfErrors(
890 radioRsp_v1_6->rspInfo.error,
891 {::android::hardware::radio::V1_6::RadioError::INVALID_SIM_STATE,
892 ::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
893 ::android::hardware::radio::V1_6::RadioError::MODEM_ERR,
894 ::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS,
895 ::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED},
896 CHECK_GENERAL_ERROR));
897 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
898 ASSERT_TRUE(CheckAnyOfErrors(
899 radioRsp_v1_6->rspInfo.error,
900 {::android::hardware::radio::V1_6::RadioError::NONE,
901 ::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED},
902 CHECK_GENERAL_ERROR));
903
904 ::android::hardware::radio::V1_6::PhonebookCapacity pbCapacity =
905 radioRsp_v1_6->capacity;
906 if(pbCapacity.maxAdnRecords > 0) {
907 EXPECT_TRUE(pbCapacity.maxNameLen > 0 && pbCapacity.maxNumberLen > 0);
908 EXPECT_TRUE(pbCapacity.usedAdnRecords <= pbCapacity.maxAdnRecords);
909 }
910
911 if(pbCapacity.maxEmailRecords > 0) {
912 EXPECT_TRUE(pbCapacity.maxEmailLen > 0);
913 EXPECT_TRUE(pbCapacity.usedEmailRecords <= pbCapacity.maxEmailRecords);
914 }
915
916 if(pbCapacity.maxAdditionalNumberRecords > 0) {
917 EXPECT_TRUE(pbCapacity.maxAdditionalNumberLen > 0);
918 EXPECT_TRUE(pbCapacity.usedAdditionalNumberRecords <= pbCapacity.maxAdditionalNumberRecords);
919 }
920 }
921 }
922
923 /*
924 * Test IRadio.updateSimPhonebookRecords() for the response returned.
925 */
TEST_P(RadioHidlTest_v1_6,updateSimPhonebookRecords)926 TEST_P(RadioHidlTest_v1_6, updateSimPhonebookRecords) {
927 serial = GetRandomSerialNumber();
928 radio_v1_6->getSimPhonebookCapacity(serial);
929 EXPECT_EQ(std::cv_status::no_timeout, wait());
930 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
931 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
932 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
933 ASSERT_TRUE(CheckAnyOfErrors(
934 radioRsp_v1_6->rspInfo.error,
935 {::android::hardware::radio::V1_6::RadioError::INVALID_SIM_STATE,
936 ::android::hardware::radio::V1_6::RadioError::RADIO_NOT_AVAILABLE,
937 ::android::hardware::radio::V1_6::RadioError::MODEM_ERR,
938 ::android::hardware::radio::V1_6::RadioError::INVALID_ARGUMENTS,
939 ::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED},
940 CHECK_GENERAL_ERROR));
941 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
942 ASSERT_TRUE(CheckAnyOfErrors(
943 radioRsp_v1_6->rspInfo.error,
944 {::android::hardware::radio::V1_6::RadioError::NONE,
945 ::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED},
946 CHECK_GENERAL_ERROR));
947 ::android::hardware::radio::V1_6::PhonebookCapacity pbCapacity =
948 radioRsp_v1_6->capacity;
949
950 serial = GetRandomSerialNumber();
951 radio_v1_6->getSimPhonebookRecords(serial);
952
953 EXPECT_EQ(std::cv_status::no_timeout, wait());
954 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
955 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
956 ASSERT_TRUE(CheckAnyOfErrors(
957 radioRsp_v1_6->rspInfo.error,
958 {::android::hardware::radio::V1_6::RadioError::NONE,
959 ::android::hardware::radio::V1_6::RadioError::REQUEST_NOT_SUPPORTED},
960 CHECK_GENERAL_ERROR));
961
962 if(pbCapacity.maxAdnRecords > 0
963 && pbCapacity.usedAdnRecords < pbCapacity.maxAdnRecords) {
964 // Add a phonebook record
965 PhonebookRecordInfo recordInfo;
966 recordInfo.recordId = 0;
967 recordInfo.name = "ABC";
968 recordInfo.number = "1234567890";
969 serial = GetRandomSerialNumber();
970 radio_v1_6->updateSimPhonebookRecords(serial, recordInfo);
971
972 EXPECT_EQ(std::cv_status::no_timeout, wait());
973 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
974 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
975 EXPECT_EQ(::android::hardware::radio::V1_6::RadioError::NONE, radioRsp_v1_6->rspInfo.error);
976 int index = radioRsp_v1_6->updatedRecordIndex;
977 EXPECT_TRUE(index > 0);
978
979 // Deleted a phonebook record
980 recordInfo.recordId = index;
981 recordInfo.name = "";
982 recordInfo.number = "";
983 serial = GetRandomSerialNumber();
984 radio_v1_6->updateSimPhonebookRecords(serial, recordInfo);
985
986 EXPECT_EQ(std::cv_status::no_timeout, wait());
987 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_6->rspInfo.type);
988 EXPECT_EQ(serial, radioRsp_v1_6->rspInfo.serial);
989 EXPECT_EQ(::android::hardware::radio::V1_6::RadioError::NONE, radioRsp_v1_6->rspInfo.error);
990 }
991 }
992 }
993