1 /*
2 * Copyright (C) 2017 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.h>
18
19 /*
20 * Test IRadio.getSignalStrength() for the response returned.
21 */
TEST_F(RadioHidlTest,getSignalStrength)22 TEST_F(RadioHidlTest, getSignalStrength) {
23 int serial = GetRandomSerialNumber();
24
25 radio->getSignalStrength(serial);
26 EXPECT_EQ(std::cv_status::no_timeout, wait());
27 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
28 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
29
30 if (cardStatus.cardState == CardState::ABSENT) {
31 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
32 }
33 }
34
35 /*
36 * Test IRadio.getVoiceRegistrationState() for the response returned.
37 */
TEST_F(RadioHidlTest,getVoiceRegistrationState)38 TEST_F(RadioHidlTest, getVoiceRegistrationState) {
39 int serial = GetRandomSerialNumber();
40
41 radio->getVoiceRegistrationState(serial);
42 EXPECT_EQ(std::cv_status::no_timeout, wait());
43 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
44 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
45
46 if (cardStatus.cardState == CardState::ABSENT) {
47 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
48 }
49 }
50
51 /*
52 * Test IRadio.getOperator() for the response returned.
53 */
TEST_F(RadioHidlTest,getOperator)54 TEST_F(RadioHidlTest, getOperator) {
55 int serial = GetRandomSerialNumber();
56
57 radio->getOperator(serial);
58 EXPECT_EQ(std::cv_status::no_timeout, wait());
59 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
60 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
61
62 if (cardStatus.cardState == CardState::ABSENT) {
63 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
64 }
65 }
66
67 /*
68 * Test IRadio.setRadioPower() for the response returned.
69 */
TEST_F(RadioHidlTest,setRadioPower)70 TEST_F(RadioHidlTest, setRadioPower) {
71 int serial = GetRandomSerialNumber();
72
73 radio->setRadioPower(serial, 0);
74 EXPECT_EQ(std::cv_status::no_timeout, wait());
75 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
76 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
77
78 if (cardStatus.cardState == CardState::ABSENT) {
79 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
80 }
81 }
82
83 /*
84 * Test IRadio.getNetworkSelectionMode() for the response returned.
85 */
TEST_F(RadioHidlTest,getNetworkSelectionMode)86 TEST_F(RadioHidlTest, getNetworkSelectionMode) {
87 int serial = GetRandomSerialNumber();
88
89 radio->getNetworkSelectionMode(serial);
90 EXPECT_EQ(std::cv_status::no_timeout, wait());
91 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
92 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
93
94 if (cardStatus.cardState == CardState::ABSENT) {
95 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
96 }
97 }
98
99 /*
100 * Test IRadio.setNetworkSelectionModeAutomatic() for the response returned.
101 */
TEST_F(RadioHidlTest,setNetworkSelectionModeAutomatic)102 TEST_F(RadioHidlTest, setNetworkSelectionModeAutomatic) {
103 int serial = GetRandomSerialNumber();
104
105 radio->setNetworkSelectionModeAutomatic(serial);
106 EXPECT_EQ(std::cv_status::no_timeout, wait());
107 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
108 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
109
110 if (cardStatus.cardState == CardState::ABSENT) {
111 ASSERT_TRUE(CheckGeneralError() ||
112 radioRsp->rspInfo.error == RadioError::ILLEGAL_SIM_OR_ME ||
113 radioRsp->rspInfo.error == RadioError::NONE ||
114 radioRsp->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED);
115 }
116 }
117
118 /*
119 * Test IRadio.setNetworkSelectionModeManual() for the response returned.
120 */
TEST_F(RadioHidlTest,setNetworkSelectionModeManual)121 TEST_F(RadioHidlTest, setNetworkSelectionModeManual) {
122 int serial = GetRandomSerialNumber();
123
124 radio->setNetworkSelectionModeManual(serial, "123456");
125 EXPECT_EQ(std::cv_status::no_timeout, wait());
126 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
127 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
128
129 if (cardStatus.cardState == CardState::ABSENT) {
130 ASSERT_TRUE(CheckGeneralError() ||
131 radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
132 radioRsp->rspInfo.error == RadioError::ILLEGAL_SIM_OR_ME ||
133 radioRsp->rspInfo.error == RadioError::NONE ||
134 radioRsp->rspInfo.error == RadioError::INVALID_STATE);
135 }
136 }
137
138 /*
139 * Test IRadio.getAvailableNetworks() for the response returned.
140 */
TEST_F(RadioHidlTest,getAvailableNetworks)141 TEST_F(RadioHidlTest, getAvailableNetworks) {
142 int serial = GetRandomSerialNumber();
143
144 radio->getAvailableNetworks(serial);
145 EXPECT_EQ(std::cv_status::no_timeout, wait());
146 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
147 ASSERT_TRUE(radioRsp->rspInfo.type == RadioResponseType::SOLICITED ||
148 radioRsp->rspInfo.type == RadioResponseType::SOLICITED_ACK_EXP);
149
150 if (cardStatus.cardState == CardState::ABSENT) {
151 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE ||
152 radioRsp->rspInfo.error == RadioError::DEVICE_IN_USE ||
153 radioRsp->rspInfo.error == RadioError::CANCELLED ||
154 radioRsp->rspInfo.error == RadioError::OPERATION_NOT_ALLOWED ||
155 radioRsp->rspInfo.error == RadioError::MODEM_ERR);
156 }
157 }
158
159 /*
160 * Test IRadio.getBasebandVersion() for the response returned.
161 */
TEST_F(RadioHidlTest,getBasebandVersion)162 TEST_F(RadioHidlTest, getBasebandVersion) {
163 int serial = GetRandomSerialNumber();
164
165 radio->getBasebandVersion(serial);
166 EXPECT_EQ(std::cv_status::no_timeout, wait());
167 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
168 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
169
170 if (cardStatus.cardState == CardState::ABSENT) {
171 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
172 }
173 }
174
175 /*
176 * Test IRadio.setBandMode() for the response returned.
177 */
TEST_F(RadioHidlTest,setBandMode)178 TEST_F(RadioHidlTest, setBandMode) {
179 int serial = GetRandomSerialNumber();
180
181 radio->setBandMode(serial, RadioBandMode::BAND_MODE_USA);
182 EXPECT_EQ(std::cv_status::no_timeout, wait());
183 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
184 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
185
186 if (cardStatus.cardState == CardState::ABSENT) {
187 EXPECT_EQ(radioRsp->rspInfo.error, RadioError::NONE);
188 }
189 }
190
191 /*
192 * Test IRadio.getAvailableBandModes() for the response returned.
193 */
TEST_F(RadioHidlTest,getAvailableBandModes)194 TEST_F(RadioHidlTest, getAvailableBandModes) {
195 int serial = GetRandomSerialNumber();
196
197 radio->getAvailableBandModes(serial);
198 EXPECT_EQ(std::cv_status::no_timeout, wait());
199 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
200 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
201
202 if (cardStatus.cardState == CardState::ABSENT) {
203 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
204 }
205 }
206
207 /*
208 * Test IRadio.setPreferredNetworkType() for the response returned.
209 */
TEST_F(RadioHidlTest,setPreferredNetworkType)210 TEST_F(RadioHidlTest, setPreferredNetworkType) {
211 int serial = GetRandomSerialNumber();
212
213 radio->setPreferredNetworkType(serial, PreferredNetworkType::GSM_ONLY);
214 EXPECT_EQ(std::cv_status::no_timeout, wait());
215 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
216 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
217
218 if (cardStatus.cardState == CardState::ABSENT) {
219 EXPECT_EQ(radioRsp->rspInfo.error, RadioError::NONE);
220 }
221 }
222
223 /*
224 * Test IRadio.getPreferredNetworkType() for the response returned.
225 */
TEST_F(RadioHidlTest,getPreferredNetworkType)226 TEST_F(RadioHidlTest, getPreferredNetworkType) {
227 int serial = GetRandomSerialNumber();
228
229 radio->getPreferredNetworkType(serial);
230 EXPECT_EQ(std::cv_status::no_timeout, wait());
231 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
232 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
233
234 if (cardStatus.cardState == CardState::ABSENT) {
235 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
236 }
237 }
238
239 /*
240 * Test IRadio.getNeighboringCids() for the response returned.
241 */
TEST_F(RadioHidlTest,getNeighboringCids)242 TEST_F(RadioHidlTest, getNeighboringCids) {
243 int serial = GetRandomSerialNumber();
244
245 radio->getNeighboringCids(serial);
246 EXPECT_EQ(std::cv_status::no_timeout, wait());
247 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
248 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
249
250 if (cardStatus.cardState == CardState::ABSENT) {
251 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
252 }
253 }
254
255 /*
256 * Test IRadio.setLocationUpdates() for the response returned.
257 */
TEST_F(RadioHidlTest,setLocationUpdates)258 TEST_F(RadioHidlTest, setLocationUpdates) {
259 int serial = GetRandomSerialNumber();
260
261 radio->setLocationUpdates(serial, true);
262 EXPECT_EQ(std::cv_status::no_timeout, wait());
263 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
264 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
265
266 if (cardStatus.cardState == CardState::ABSENT) {
267 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
268 }
269 }
270
271 /*
272 * Test IRadio.setCdmaRoamingPreference() for the response returned.
273 */
TEST_F(RadioHidlTest,setCdmaRoamingPreference)274 TEST_F(RadioHidlTest, setCdmaRoamingPreference) {
275 int serial = GetRandomSerialNumber();
276
277 radio->setCdmaRoamingPreference(serial, CdmaRoamingType::HOME_NETWORK);
278 EXPECT_EQ(std::cv_status::no_timeout, wait());
279 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
280 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
281
282 if (cardStatus.cardState == CardState::ABSENT) {
283 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
284 }
285 }
286
287 /*
288 * Test IRadio.getCdmaRoamingPreference() for the response returned.
289 */
TEST_F(RadioHidlTest,getCdmaRoamingPreference)290 TEST_F(RadioHidlTest, getCdmaRoamingPreference) {
291 int serial = GetRandomSerialNumber();
292
293 radio->getCdmaRoamingPreference(serial);
294 EXPECT_EQ(std::cv_status::no_timeout, wait());
295 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
296 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
297
298 if (cardStatus.cardState == CardState::ABSENT) {
299 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE ||
300 radioRsp->rspInfo.error == RadioError::MODEM_ERR);
301 }
302 }
303
304 /*
305 * Test IRadio.getTTYMode() for the response returned.
306 */
TEST_F(RadioHidlTest,getTTYMode)307 TEST_F(RadioHidlTest, getTTYMode) {
308 int serial = GetRandomSerialNumber();
309
310 radio->getTTYMode(serial);
311 EXPECT_EQ(std::cv_status::no_timeout, wait());
312 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
313 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
314
315 if (cardStatus.cardState == CardState::ABSENT) {
316 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
317 }
318 }
319
320 /*
321 * Test IRadio.setTTYMode() for the response returned.
322 */
TEST_F(RadioHidlTest,setTTYMode)323 TEST_F(RadioHidlTest, setTTYMode) {
324 int serial = GetRandomSerialNumber();
325
326 radio->setTTYMode(serial, TtyMode::OFF);
327 EXPECT_EQ(std::cv_status::no_timeout, wait());
328 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
329 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
330
331 if (cardStatus.cardState == CardState::ABSENT) {
332 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
333 }
334 }
335
336 /*
337 * Test IRadio.setPreferredVoicePrivacy() for the response returned.
338 */
TEST_F(RadioHidlTest,setPreferredVoicePrivacy)339 TEST_F(RadioHidlTest, setPreferredVoicePrivacy) {
340 int serial = GetRandomSerialNumber();
341
342 radio->setPreferredVoicePrivacy(serial, true);
343 EXPECT_EQ(std::cv_status::no_timeout, wait());
344 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
345 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
346
347 if (cardStatus.cardState == CardState::ABSENT) {
348 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
349 }
350 }
351
352 /*
353 * Test IRadio.getPreferredVoicePrivacy() for the response returned.
354 */
TEST_F(RadioHidlTest,getPreferredVoicePrivacy)355 TEST_F(RadioHidlTest, getPreferredVoicePrivacy) {
356 int serial = GetRandomSerialNumber();
357
358 radio->getPreferredVoicePrivacy(serial);
359 EXPECT_EQ(std::cv_status::no_timeout, wait());
360 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
361 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
362
363 if (cardStatus.cardState == CardState::ABSENT) {
364 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
365 }
366 }
367
368 /*
369 * Test IRadio.getCDMASubscription() for the response returned.
370 */
TEST_F(RadioHidlTest,getCDMASubscription)371 TEST_F(RadioHidlTest, getCDMASubscription) {
372 int serial = GetRandomSerialNumber();
373
374 radio->getCDMASubscription(serial);
375 EXPECT_EQ(std::cv_status::no_timeout, wait());
376 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
377 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
378
379 if (cardStatus.cardState == CardState::ABSENT) {
380 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
381 }
382 }
383
384 /*
385 * Test IRadio.getDeviceIdentity() for the response returned.
386 */
TEST_F(RadioHidlTest,getDeviceIdentity)387 TEST_F(RadioHidlTest, getDeviceIdentity) {
388 int serial = GetRandomSerialNumber();
389
390 radio->getDeviceIdentity(serial);
391 EXPECT_EQ(std::cv_status::no_timeout, wait());
392 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
393 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
394
395 if (cardStatus.cardState == CardState::ABSENT) {
396 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
397 }
398 }
399
400 /*
401 * Test IRadio.exitEmergencyCallbackMode() for the response returned.
402 */
TEST_F(RadioHidlTest,exitEmergencyCallbackMode)403 TEST_F(RadioHidlTest, exitEmergencyCallbackMode) {
404 int serial = GetRandomSerialNumber();
405
406 radio->exitEmergencyCallbackMode(serial);
407 EXPECT_EQ(std::cv_status::no_timeout, wait());
408 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
409 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
410
411 if (cardStatus.cardState == CardState::ABSENT) {
412 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
413 }
414 }
415
416 /*
417 * Test IRadio.getCdmaSubscriptionSource() for the response returned.
418 */
TEST_F(RadioHidlTest,getCdmaSubscriptionSource)419 TEST_F(RadioHidlTest, getCdmaSubscriptionSource) {
420 int serial = GetRandomSerialNumber();
421
422 radio->getCdmaSubscriptionSource(serial);
423 EXPECT_EQ(std::cv_status::no_timeout, wait());
424 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
425 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
426
427 if (cardStatus.cardState == CardState::ABSENT) {
428 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
429 }
430 }
431
432 /*
433 * Test IRadio.setCdmaSubscriptionSource() for the response returned.
434 */
TEST_F(RadioHidlTest,setCdmaSubscriptionSource)435 TEST_F(RadioHidlTest, setCdmaSubscriptionSource) {
436 int serial = GetRandomSerialNumber();
437
438 radio->setCdmaSubscriptionSource(serial, CdmaSubscriptionSource::RUIM_SIM);
439 EXPECT_EQ(std::cv_status::no_timeout, wait());
440 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
441 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
442
443 if (cardStatus.cardState == CardState::ABSENT) {
444 std::cout << static_cast<int>(radioRsp->rspInfo.error) << std::endl;
445 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::SIM_ABSENT ||
446 radioRsp->rspInfo.error == RadioError::SUBSCRIPTION_NOT_AVAILABLE ||
447 radioRsp->rspInfo.error == RadioError::NONE);
448 }
449 }
450
451 /*
452 * Test IRadio.getVoiceRadioTechnology() for the response returned.
453 */
TEST_F(RadioHidlTest,getVoiceRadioTechnology)454 TEST_F(RadioHidlTest, getVoiceRadioTechnology) {
455 int serial = GetRandomSerialNumber();
456
457 radio->getVoiceRadioTechnology(serial);
458 EXPECT_EQ(std::cv_status::no_timeout, wait());
459 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
460 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
461
462 if (cardStatus.cardState == CardState::ABSENT) {
463 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
464 }
465 }
466
467 /*
468 * Test IRadio.getCellInfoList() for the response returned.
469 */
TEST_F(RadioHidlTest,getCellInfoList)470 TEST_F(RadioHidlTest, getCellInfoList) {
471 int serial = GetRandomSerialNumber();
472
473 radio->getCellInfoList(serial);
474 EXPECT_EQ(std::cv_status::no_timeout, wait());
475 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
476 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
477
478 if (cardStatus.cardState == CardState::ABSENT) {
479 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE ||
480 radioRsp->rspInfo.error == RadioError::NO_NETWORK_FOUND);
481 }
482 }
483
484 /*
485 * Test IRadio.setCellInfoListRate() for the response returned.
486 */
TEST_F(RadioHidlTest,setCellInfoListRate)487 TEST_F(RadioHidlTest, setCellInfoListRate) {
488 int serial = GetRandomSerialNumber();
489
490 // TODO(sanketpadawe): RIL crashes with value of rate = 10
491 radio->setCellInfoListRate(serial, 10);
492 EXPECT_EQ(std::cv_status::no_timeout, wait());
493 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
494 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
495
496 if (cardStatus.cardState == CardState::ABSENT) {
497 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
498 }
499 }
500
501 /*
502 * Test IRadio.nvReadItem() for the response returned.
503 */
TEST_F(RadioHidlTest,nvReadItem)504 TEST_F(RadioHidlTest, nvReadItem) {
505 int serial = GetRandomSerialNumber();
506
507 radio->nvReadItem(serial, NvItem::LTE_BAND_ENABLE_25);
508 EXPECT_EQ(std::cv_status::no_timeout, wait());
509 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
510 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
511
512 if (cardStatus.cardState == CardState::ABSENT) {
513 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE);
514 }
515 }
516
517 /*
518 * Test IRadio.nvWriteItem() for the response returned.
519 */
TEST_F(RadioHidlTest,nvWriteItem)520 TEST_F(RadioHidlTest, nvWriteItem) {
521 int serial = GetRandomSerialNumber();
522 NvWriteItem item;
523 memset(&item, 0, sizeof(item));
524 item.value = hidl_string();
525
526 radio->nvWriteItem(serial, item);
527 EXPECT_EQ(std::cv_status::no_timeout, wait());
528 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
529 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
530
531 if (cardStatus.cardState == CardState::ABSENT) {
532 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE);
533 }
534 }
535
536 /*
537 * Test IRadio.nvWriteCdmaPrl() for the response returned.
538 */
TEST_F(RadioHidlTest,nvWriteCdmaPrl)539 TEST_F(RadioHidlTest, nvWriteCdmaPrl) {
540 int serial = GetRandomSerialNumber();
541 std::vector<uint8_t> prl = {1, 2, 3, 4, 5};
542
543 radio->nvWriteCdmaPrl(serial, hidl_vec<uint8_t>(prl));
544 EXPECT_EQ(std::cv_status::no_timeout, wait());
545 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
546 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
547
548 if (cardStatus.cardState == CardState::ABSENT) {
549 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE);
550 }
551 }
552
553 /*
554 * Test IRadio.nvResetConfig() for the response returned.
555 */
TEST_F(RadioHidlTest,nvResetConfig)556 TEST_F(RadioHidlTest, nvResetConfig) {
557 int serial = GetRandomSerialNumber();
558
559 radio->nvResetConfig(++serial, ResetNvType::ERASE);
560 EXPECT_EQ(std::cv_status::no_timeout, wait());
561 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
562 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
563
564 if (cardStatus.cardState == CardState::ABSENT) {
565 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
566 }
567 }
568
569 /*
570 * Test IRadio.setUiccSubscription() for the response returned.
571 */
TEST_F(RadioHidlTest,setUiccSubscription)572 TEST_F(RadioHidlTest, setUiccSubscription) {
573 int serial = GetRandomSerialNumber();
574 SelectUiccSub item;
575 memset(&item, 0, sizeof(item));
576
577 radio->setUiccSubscription(serial, item);
578 EXPECT_EQ(std::cv_status::no_timeout, wait());
579 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
580 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
581
582 if (cardStatus.cardState == CardState::ABSENT) {
583 ASSERT_TRUE(CheckGeneralError() ||
584 radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
585 radioRsp->rspInfo.error == RadioError::NONE ||
586 radioRsp->rspInfo.error == RadioError::SUBSCRIPTION_NOT_SUPPORTED ||
587 radioRsp->rspInfo.error == RadioError::MODEM_ERR);
588 }
589 }
590
591 /*
592 * Test IRadio.getHardwareConfig() for the response returned.
593 */
TEST_F(RadioHidlTest,getHardwareConfig)594 TEST_F(RadioHidlTest, getHardwareConfig) {
595 int serial = GetRandomSerialNumber();
596
597 radio->getHardwareConfig(serial);
598 EXPECT_EQ(std::cv_status::no_timeout, wait());
599 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
600 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
601
602 if (cardStatus.cardState == CardState::ABSENT) {
603 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE);
604 }
605 }
606
607 /*
608 * Test IRadio.requestShutdown() for the response returned.
609 */
TEST_F(RadioHidlTest,requestShutdown)610 TEST_F(RadioHidlTest, requestShutdown) {
611 int serial = GetRandomSerialNumber();
612
613 radio->requestShutdown(serial);
614 EXPECT_EQ(std::cv_status::no_timeout, wait());
615 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
616 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
617
618 if (cardStatus.cardState == CardState::ABSENT) {
619 ASSERT_TRUE(CheckGeneralError() || radioRsp->rspInfo.error == RadioError::NONE);
620 }
621 }
622
623 /*
624 * Test IRadio.getRadioCapability() for the response returned.
625 */
TEST_F(RadioHidlTest,getRadioCapability)626 TEST_F(RadioHidlTest, getRadioCapability) {
627 int serial = GetRandomSerialNumber();
628
629 radio->getRadioCapability(serial);
630 EXPECT_EQ(std::cv_status::no_timeout, wait());
631 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
632 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
633
634 if (cardStatus.cardState == CardState::ABSENT) {
635 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
636 }
637 }
638
639 /*
640 * Test IRadio.setRadioCapability() for the response returned.
641 */
TEST_F(RadioHidlTest,setRadioCapability)642 TEST_F(RadioHidlTest, setRadioCapability) {
643 int serial = GetRandomSerialNumber();
644 RadioCapability rc;
645 memset(&rc, 0, sizeof(rc));
646 rc.logicalModemUuid = hidl_string();
647
648 radio->setRadioCapability(serial, rc);
649 EXPECT_EQ(std::cv_status::no_timeout, wait());
650 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
651 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
652
653 if (cardStatus.cardState == CardState::ABSENT) {
654 std::cout << static_cast<int>(radioRsp->rspInfo.error) << std::endl;
655 ASSERT_TRUE(CheckGeneralError() ||
656 radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS ||
657 radioRsp->rspInfo.error == RadioError::INVALID_STATE);
658 }
659 }
660
661 /*
662 * Test IRadio.startLceService() for the response returned.
663 */
TEST_F(RadioHidlTest,startLceService)664 TEST_F(RadioHidlTest, startLceService) {
665 int serial = GetRandomSerialNumber();
666
667 radio->startLceService(serial, 5, true);
668 EXPECT_EQ(std::cv_status::no_timeout, wait());
669 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
670 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
671
672 if (cardStatus.cardState == CardState::ABSENT) {
673 std::cout << static_cast<int>(radioRsp->rspInfo.error) << std::endl;
674 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::RADIO_NOT_AVAILABLE ||
675 radioRsp->rspInfo.error == RadioError::LCE_NOT_SUPPORTED ||
676 radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
677 }
678 }
679
680 /*
681 * Test IRadio.stopLceService() for the response returned.
682 */
TEST_F(RadioHidlTest,stopLceService)683 TEST_F(RadioHidlTest, stopLceService) {
684 int serial = GetRandomSerialNumber();
685
686 radio->stopLceService(serial);
687 EXPECT_EQ(std::cv_status::no_timeout, wait());
688 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
689 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
690
691 if (cardStatus.cardState == CardState::ABSENT) {
692 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE ||
693 radioRsp->rspInfo.error == RadioError::LCE_NOT_SUPPORTED);
694 }
695 }
696
697 /*
698 * Test IRadio.pullLceData() for the response returned.
699 */
TEST_F(RadioHidlTest,pullLceData)700 TEST_F(RadioHidlTest, pullLceData) {
701 int serial = GetRandomSerialNumber();
702
703 radio->pullLceData(serial);
704 EXPECT_EQ(std::cv_status::no_timeout, wait());
705 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
706 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
707
708 if (cardStatus.cardState == CardState::ABSENT) {
709 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::RADIO_NOT_AVAILABLE || CheckOEMError() ||
710 radioRsp->rspInfo.error == RadioError::INTERNAL_ERR);
711 }
712 }
713
714 /*
715 * Test IRadio.getModemActivityInfo() for the response returned.
716 */
TEST_F(RadioHidlTest,getModemActivityInfo)717 TEST_F(RadioHidlTest, getModemActivityInfo) {
718 int serial = GetRandomSerialNumber();
719
720 radio->getModemActivityInfo(serial);
721 EXPECT_EQ(std::cv_status::no_timeout, wait());
722 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
723 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
724
725 if (cardStatus.cardState == CardState::ABSENT) {
726 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE);
727 }
728 }
729
730 /*
731 * Test IRadio.setAllowedCarriers() for the response returned.
732 */
TEST_F(RadioHidlTest,setAllowedCarriers)733 TEST_F(RadioHidlTest, setAllowedCarriers) {
734 int serial = GetRandomSerialNumber();
735 CarrierRestrictions carriers;
736 memset(&carriers, 0, sizeof(carriers));
737 carriers.allowedCarriers.resize(1);
738 carriers.excludedCarriers.resize(0);
739 carriers.allowedCarriers[0].mcc = hidl_string();
740 carriers.allowedCarriers[0].mnc = hidl_string();
741 carriers.allowedCarriers[0].matchType = CarrierMatchType::ALL;
742 carriers.allowedCarriers[0].matchData = hidl_string();
743
744 radio->setAllowedCarriers(serial, false, carriers);
745 EXPECT_EQ(std::cv_status::no_timeout, wait());
746 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
747 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
748
749 if (cardStatus.cardState == CardState::ABSENT) {
750 EXPECT_EQ(radioRsp->rspInfo.error, RadioError::NONE);
751 }
752
753 /* Reset back to no carrier restriction */
754 memset(&carriers, 0, sizeof(carriers));
755 carriers.allowedCarriers.resize(0);
756 carriers.excludedCarriers.resize(0);
757
758 radio->setAllowedCarriers(++serial, true, carriers);
759 EXPECT_EQ(std::cv_status::no_timeout, wait());
760 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
761 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
762
763 if (cardStatus.cardState == CardState::ABSENT) {
764 EXPECT_EQ(radioRsp->rspInfo.error, RadioError::NONE);
765 }
766 }
767
768 /*
769 * Test IRadio.getAllowedCarriers() for the response returned.
770 */
TEST_F(RadioHidlTest,getAllowedCarriers)771 TEST_F(RadioHidlTest, getAllowedCarriers) {
772 int serial = GetRandomSerialNumber();
773
774 radio->getAllowedCarriers(serial);
775 EXPECT_EQ(std::cv_status::no_timeout, wait());
776 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
777 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
778
779 if (cardStatus.cardState == CardState::ABSENT) {
780 EXPECT_EQ(radioRsp->rspInfo.error, RadioError::NONE);
781 }
782 }
783
784 /*
785 * Test IRadio.sendDeviceState() for the response returned.
786 */
TEST_F(RadioHidlTest,sendDeviceState)787 TEST_F(RadioHidlTest, sendDeviceState) {
788 int serial = GetRandomSerialNumber();
789
790 radio->sendDeviceState(serial, DeviceStateType::POWER_SAVE_MODE, true);
791 EXPECT_EQ(std::cv_status::no_timeout, wait());
792 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
793 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
794
795 if (cardStatus.cardState == CardState::ABSENT) {
796 ASSERT_TRUE(CheckGeneralError() ||
797 radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS);
798 }
799 }
800
801 /*
802 * Test IRadio.setIndicationFilter() for the response returned.
803 */
TEST_F(RadioHidlTest,setIndicationFilter)804 TEST_F(RadioHidlTest, setIndicationFilter) {
805 int serial = GetRandomSerialNumber();
806
807 radio->setIndicationFilter(serial, 1);
808 EXPECT_EQ(std::cv_status::no_timeout, wait());
809 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
810 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
811
812 if (cardStatus.cardState == CardState::ABSENT) {
813 ASSERT_TRUE(CheckGeneralError() ||
814 radioRsp->rspInfo.error == RadioError::INVALID_ARGUMENTS);
815 }
816 }
817
818 /*
819 * Test IRadio.setSimCardPower() for the response returned.
820 */
TEST_F(RadioHidlTest,setSimCardPower)821 TEST_F(RadioHidlTest, setSimCardPower) {
822 int serial = GetRandomSerialNumber();
823
824 radio->setSimCardPower(serial, true);
825 EXPECT_EQ(std::cv_status::no_timeout, wait());
826 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
827 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
828
829 if (cardStatus.cardState == CardState::ABSENT) {
830 std::cout << static_cast<int>(radioRsp->rspInfo.error) << std::endl;
831 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE ||
832 radioRsp->rspInfo.error == RadioError::REQUEST_NOT_SUPPORTED);
833 }
834 }