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 <android/hardware/radio/1.4/IRadio.h>
18 #include <radio_hidl_hal_utils_v1_2.h>
19 #include <vector>
20 
21 #define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
22 
23 namespace {
24 const RadioAccessSpecifier GERAN_SPECIFIER_P900 = {.radioAccessNetwork = RadioAccessNetworks::GERAN,
25                                                    .geranBands = {GeranBands::BAND_P900},
26                                                    .channels = {1, 2}};
27 const RadioAccessSpecifier GERAN_SPECIFIER_850 = {.radioAccessNetwork = RadioAccessNetworks::GERAN,
28                                                   .geranBands = {GeranBands::BAND_850},
29                                                   .channels = {128, 129}};
30 }  // namespace
31 
32 /*
33  * Test IRadio.startNetworkScan() for the response returned.
34  */
TEST_P(RadioHidlTest_v1_2,startNetworkScan)35 TEST_P(RadioHidlTest_v1_2, startNetworkScan) {
36     serial = GetRandomSerialNumber();
37 
38     if (radioConfig != NULL && DDS_LOGICAL_SLOT_INDEX != logicalSlotId) {
39         // Some DSDS devices have a limitation that network scans can only be performed on the
40         // logical modem that currently used for packet data. For now, skip the test on the
41         // non-data SIM. This exemption is removed in HAL version 1.4. See b/135243177 for
42         // additional information.
43         ALOGI("Skip network scan on non-dds SIM, slot id = %d", logicalSlotId);
44         return;
45     }
46 
47     ::android::hardware::radio::V1_2::NetworkScanRequest request = {
48             .type = ScanType::ONE_SHOT,
49             .interval = 60,
50             .specifiers = {::GERAN_SPECIFIER_P900, ::GERAN_SPECIFIER_850},
51             .maxSearchTime = 60,
52             .incrementalResults = false,
53             .incrementalResultsPeriodicity = 1};
54 
55     Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
56     ASSERT_OK(res);
57     EXPECT_EQ(std::cv_status::no_timeout, wait());
58     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
59     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
60 
61     // startNetworkScan_1_2 is deprecated in radio::V1_4 with startNetworkScan_1_4
62     SKIP_TEST_IF_REQUEST_NOT_SUPPORTED_WITH_HAL_VERSION_AT_LEAST(1_4);
63 
64     ALOGI("startNetworkScan, rspInfo.error = %s\n", toString(radioRsp_v1_2->rspInfo.error).c_str());
65     if (cardStatus.base.cardState == CardState::ABSENT) {
66         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error, {RadioError::SIM_ABSENT}));
67     } else if (cardStatus.base.cardState == CardState::PRESENT) {
68         // REQUEST_NOT_SUPPORTED should not be allowed as it is not an optional API. However, the
69         // comments in the hal were not updated to indicate that, hence allowing it as a valid
70         // error for now. This should be fixed correctly, possibly in a future version of the hal
71         // (b/110421924). This is being allowed because some vendors do not support
72         // this request on dual sim devices.
73         // OPERATION_NOT_ALLOWED should not be allowed; however, some vendors do not support the
74         // required manual GSM search functionality. This is tracked in b/112206766.
75         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
76                                      {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED,
77                                       RadioError::OPERATION_NOT_ALLOWED}));
78     }
79 
80     if (radioRsp_v1_2->rspInfo.error == RadioError::NONE) {
81         ALOGI("Stop Network Scan");
82         stopNetworkScan();
83     }
84 }
85 
86 /*
87  * Test IRadio.startNetworkScan() with invalid specifier.
88  */
TEST_P(RadioHidlTest_v1_2,startNetworkScan_InvalidArgument)89 TEST_P(RadioHidlTest_v1_2, startNetworkScan_InvalidArgument) {
90     serial = GetRandomSerialNumber();
91 
92     ::android::hardware::radio::V1_2::NetworkScanRequest request = {.type = ScanType::ONE_SHOT,
93                                                                     .interval = 60};
94 
95     Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
96     ASSERT_OK(res);
97     EXPECT_EQ(std::cv_status::no_timeout, wait());
98     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
99     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
100 
101     // startNetworkScan_1_2 is deprecated in radio::V1_4 with startNetworkScan_1_4
102     SKIP_TEST_IF_REQUEST_NOT_SUPPORTED_WITH_HAL_VERSION_AT_LEAST(1_4);
103 
104     ALOGI("startNetworkScan_InvalidArgument, rspInfo.error = %s\n",
105           toString(radioRsp_v1_2->rspInfo.error).c_str());
106     if (cardStatus.base.cardState == CardState::ABSENT) {
107         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
108                                      {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
109     } else if (cardStatus.base.cardState == CardState::PRESENT) {
110         ASSERT_TRUE(
111             CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
112                              {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
113     }
114 }
115 
116 /*
117  * Test IRadio.startNetworkScan() with invalid interval (lower boundary).
118  */
TEST_P(RadioHidlTest_v1_2,startNetworkScan_InvalidInterval1)119 TEST_P(RadioHidlTest_v1_2, startNetworkScan_InvalidInterval1) {
120     serial = GetRandomSerialNumber();
121 
122     ::android::hardware::radio::V1_2::NetworkScanRequest request = {
123             .type = ScanType::ONE_SHOT,
124             .interval = 4,
125             .specifiers = {::GERAN_SPECIFIER_P900, ::GERAN_SPECIFIER_850},
126             .maxSearchTime = 60,
127             .incrementalResults = false,
128             .incrementalResultsPeriodicity = 1};
129 
130     Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
131     ASSERT_OK(res);
132     EXPECT_EQ(std::cv_status::no_timeout, wait());
133     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
134     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
135 
136     // startNetworkScan_1_2 is deprecated in radio::V1_4 with startNetworkScan_1_4
137     SKIP_TEST_IF_REQUEST_NOT_SUPPORTED_WITH_HAL_VERSION_AT_LEAST(1_4);
138 
139     ALOGI("startNetworkScan_InvalidInterval1, rspInfo.error = %s\n",
140           toString(radioRsp_v1_2->rspInfo.error).c_str());
141     if (cardStatus.base.cardState == CardState::ABSENT) {
142         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
143                                      {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
144     } else if (cardStatus.base.cardState == CardState::PRESENT) {
145         ASSERT_TRUE(
146             CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
147                              {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
148     }
149 }
150 
151 /*
152  * Test IRadio.startNetworkScan() with invalid interval (upper boundary).
153  */
TEST_P(RadioHidlTest_v1_2,startNetworkScan_InvalidInterval2)154 TEST_P(RadioHidlTest_v1_2, startNetworkScan_InvalidInterval2) {
155     serial = GetRandomSerialNumber();
156 
157     ::android::hardware::radio::V1_2::NetworkScanRequest request = {
158             .type = ScanType::ONE_SHOT,
159             .interval = 301,
160             .specifiers = {::GERAN_SPECIFIER_P900, ::GERAN_SPECIFIER_850},
161             .maxSearchTime = 60,
162             .incrementalResults = false,
163             .incrementalResultsPeriodicity = 1};
164 
165     Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
166     ASSERT_OK(res);
167     EXPECT_EQ(std::cv_status::no_timeout, wait());
168     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
169     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
170 
171     // startNetworkScan_1_2 is deprecated in radio::V1_4 with startNetworkScan_1_4
172     SKIP_TEST_IF_REQUEST_NOT_SUPPORTED_WITH_HAL_VERSION_AT_LEAST(1_4);
173 
174     ALOGI("startNetworkScan_InvalidInterval2, rspInfo.error = %s\n",
175           toString(radioRsp_v1_2->rspInfo.error).c_str());
176     if (cardStatus.base.cardState == CardState::ABSENT) {
177         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
178                                      {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
179     } else if (cardStatus.base.cardState == CardState::PRESENT) {
180         ASSERT_TRUE(
181             CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
182                              {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
183     }
184 }
185 
186 /*
187  * Test IRadio.startNetworkScan() with invalid max search time (lower boundary).
188  */
TEST_P(RadioHidlTest_v1_2,startNetworkScan_InvalidMaxSearchTime1)189 TEST_P(RadioHidlTest_v1_2, startNetworkScan_InvalidMaxSearchTime1) {
190     serial = GetRandomSerialNumber();
191 
192     ::android::hardware::radio::V1_2::NetworkScanRequest request = {
193             .type = ScanType::ONE_SHOT,
194             .interval = 60,
195             .specifiers = {::GERAN_SPECIFIER_P900, ::GERAN_SPECIFIER_850},
196             .maxSearchTime = 59,
197             .incrementalResults = false,
198             .incrementalResultsPeriodicity = 1};
199 
200     Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
201     ASSERT_OK(res);
202     EXPECT_EQ(std::cv_status::no_timeout, wait());
203     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
204     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
205 
206     // startNetworkScan_1_2 is deprecated in radio::V1_4 with startNetworkScan_1_4
207     SKIP_TEST_IF_REQUEST_NOT_SUPPORTED_WITH_HAL_VERSION_AT_LEAST(1_4);
208 
209     ALOGI("startNetworkScan_InvalidMaxSearchTime1, rspInfo.error = %s\n",
210           toString(radioRsp_v1_2->rspInfo.error).c_str());
211     if (cardStatus.base.cardState == CardState::ABSENT) {
212         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
213                                      {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
214     } else if (cardStatus.base.cardState == CardState::PRESENT) {
215         ASSERT_TRUE(
216             CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
217                              {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
218     }
219 }
220 
221 /*
222  * Test IRadio.startNetworkScan() with invalid max search time (upper boundary).
223  */
TEST_P(RadioHidlTest_v1_2,startNetworkScan_InvalidMaxSearchTime2)224 TEST_P(RadioHidlTest_v1_2, startNetworkScan_InvalidMaxSearchTime2) {
225     serial = GetRandomSerialNumber();
226 
227     ::android::hardware::radio::V1_2::NetworkScanRequest request = {
228             .type = ScanType::ONE_SHOT,
229             .interval = 60,
230             .specifiers = {::GERAN_SPECIFIER_P900, ::GERAN_SPECIFIER_850},
231             .maxSearchTime = 3601,
232             .incrementalResults = false,
233             .incrementalResultsPeriodicity = 1};
234 
235     Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
236     ASSERT_OK(res);
237     EXPECT_EQ(std::cv_status::no_timeout, wait());
238     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
239     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
240 
241     // startNetworkScan_1_2 is deprecated in radio::V1_4 with startNetworkScan_1_4
242     SKIP_TEST_IF_REQUEST_NOT_SUPPORTED_WITH_HAL_VERSION_AT_LEAST(1_4);
243 
244     ALOGI("startNetworkScan_InvalidMaxSearchTime2, rspInfo.error = %s\n",
245           toString(radioRsp_v1_2->rspInfo.error).c_str());
246     if (cardStatus.base.cardState == CardState::ABSENT) {
247         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
248                                      {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
249     } else if (cardStatus.base.cardState == CardState::PRESENT) {
250         ASSERT_TRUE(
251             CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
252                              {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
253     }
254 }
255 
256 /*
257  * Test IRadio.startNetworkScan() with invalid periodicity (lower boundary).
258  */
TEST_P(RadioHidlTest_v1_2,startNetworkScan_InvalidPeriodicity1)259 TEST_P(RadioHidlTest_v1_2, startNetworkScan_InvalidPeriodicity1) {
260     serial = GetRandomSerialNumber();
261 
262     ::android::hardware::radio::V1_2::NetworkScanRequest request = {
263             .type = ScanType::ONE_SHOT,
264             .interval = 60,
265             .specifiers = {::GERAN_SPECIFIER_P900, ::GERAN_SPECIFIER_850},
266             .maxSearchTime = 600,
267             .incrementalResults = true,
268             .incrementalResultsPeriodicity = 0};
269 
270     Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
271     ASSERT_OK(res);
272     EXPECT_EQ(std::cv_status::no_timeout, wait());
273     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
274     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
275 
276     // startNetworkScan_1_2 is deprecated in radio::V1_4 with startNetworkScan_1_4
277     SKIP_TEST_IF_REQUEST_NOT_SUPPORTED_WITH_HAL_VERSION_AT_LEAST(1_4);
278 
279     ALOGI("startNetworkScan_InvalidPeriodicity1, rspInfo.error = %s\n",
280           toString(radioRsp_v1_2->rspInfo.error).c_str());
281     if (cardStatus.base.cardState == CardState::ABSENT) {
282         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
283                                      {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
284     } else if (cardStatus.base.cardState == CardState::PRESENT) {
285         ASSERT_TRUE(
286             CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
287                              {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
288     }
289 }
290 
291 /*
292  * Test IRadio.startNetworkScan() with invalid periodicity (upper boundary).
293  */
TEST_P(RadioHidlTest_v1_2,startNetworkScan_InvalidPeriodicity2)294 TEST_P(RadioHidlTest_v1_2, startNetworkScan_InvalidPeriodicity2) {
295     serial = GetRandomSerialNumber();
296 
297     ::android::hardware::radio::V1_2::NetworkScanRequest request = {
298             .type = ScanType::ONE_SHOT,
299             .interval = 60,
300             .specifiers = {::GERAN_SPECIFIER_P900, ::GERAN_SPECIFIER_850},
301             .maxSearchTime = 600,
302             .incrementalResults = true,
303             .incrementalResultsPeriodicity = 11};
304 
305     Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
306     ASSERT_OK(res);
307     EXPECT_EQ(std::cv_status::no_timeout, wait());
308     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
309     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
310 
311     // startNetworkScan_1_2 is deprecated in radio::V1_4 with startNetworkScan_1_4
312     SKIP_TEST_IF_REQUEST_NOT_SUPPORTED_WITH_HAL_VERSION_AT_LEAST(1_4);
313 
314     ALOGI("startNetworkScan_InvalidPeriodicity2, rspInfo.error = %s\n",
315           toString(radioRsp_v1_2->rspInfo.error).c_str());
316     if (cardStatus.base.cardState == CardState::ABSENT) {
317         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
318                                      {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
319     } else if (cardStatus.base.cardState == CardState::PRESENT) {
320         ASSERT_TRUE(
321             CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
322                              {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
323     }
324 }
325 
326 /*
327  * The following test is disabled due to b/112206766
328  *
329  * Test IRadio.startNetworkScan() with valid periodicity
330  */
TEST_P(RadioHidlTest_v1_2,DISABLED_startNetworkScan_GoodRequest1)331 TEST_P(RadioHidlTest_v1_2, DISABLED_startNetworkScan_GoodRequest1) {
332     serial = GetRandomSerialNumber();
333 
334     ::android::hardware::radio::V1_2::NetworkScanRequest request = {
335             .type = ScanType::ONE_SHOT,
336             .interval = 60,
337             .specifiers = {::GERAN_SPECIFIER_P900, ::GERAN_SPECIFIER_850},
338             // Some vendor may not support max search time of 360s.
339             // This issue is tracked in b/112205669.
340             .maxSearchTime = 300,
341             .incrementalResults = false,
342             .incrementalResultsPeriodicity = 10};
343 
344     Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
345     ASSERT_OK(res);
346     EXPECT_EQ(std::cv_status::no_timeout, wait());
347     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
348     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
349 
350     // startNetworkScan_1_2 is deprecated in radio::V1_4 with startNetworkScan_1_4
351     SKIP_TEST_IF_REQUEST_NOT_SUPPORTED_WITH_HAL_VERSION_AT_LEAST(1_4);
352 
353     ALOGI("startNetworkScan_InvalidArgument, rspInfo.error = %s\n",
354           toString(radioRsp_v1_2->rspInfo.error).c_str());
355     if (cardStatus.base.cardState == CardState::ABSENT) {
356         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
357                                      {RadioError::NONE, RadioError::SIM_ABSENT}));
358     } else if (cardStatus.base.cardState == CardState::PRESENT) {
359         ASSERT_TRUE(CheckAnyOfErrors(
360             radioRsp_v1_2->rspInfo.error,
361             {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
362     }
363 }
364 
365 /*
366  * The following test is disabled due to b/112206766
367  *
368  * Test IRadio.startNetworkScan() with valid periodicity and plmns
369  */
TEST_P(RadioHidlTest_v1_2,DISABLED_startNetworkScan_GoodRequest2)370 TEST_P(RadioHidlTest_v1_2, DISABLED_startNetworkScan_GoodRequest2) {
371     serial = GetRandomSerialNumber();
372 
373     ::android::hardware::radio::V1_2::NetworkScanRequest request = {
374             .type = ScanType::ONE_SHOT,
375             .interval = 60,
376             .specifiers = {::GERAN_SPECIFIER_P900, ::GERAN_SPECIFIER_850},
377             // Some vendor may not support max search time of 360s.
378             // This issue is tracked in b/112205669.
379             .maxSearchTime = 300,
380             .incrementalResults = false,
381             .incrementalResultsPeriodicity = 10,
382             .mccMncs = {"310410"}};
383 
384     Return<void> res = radio_v1_2->startNetworkScan_1_2(serial, request);
385     ASSERT_OK(res);
386     EXPECT_EQ(std::cv_status::no_timeout, wait());
387     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
388     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
389 
390     // startNetworkScan_1_2 is deprecated in radio::V1_4 with startNetworkScan_1_4
391     SKIP_TEST_IF_REQUEST_NOT_SUPPORTED_WITH_HAL_VERSION_AT_LEAST(1_4);
392 
393     ALOGI("startNetworkScan_InvalidArgument, rspInfo.error = %s\n",
394           toString(radioRsp_v1_2->rspInfo.error).c_str());
395     if (cardStatus.base.cardState == CardState::ABSENT) {
396         ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
397                                      {RadioError::NONE, RadioError::SIM_ABSENT}));
398     } else if (cardStatus.base.cardState == CardState::PRESENT) {
399         ASSERT_TRUE(CheckAnyOfErrors(
400             radioRsp_v1_2->rspInfo.error,
401             {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
402     }
403 }
404 
405 /*
406  * Test IRadio.setIndicationFilter_1_2()
407  */
TEST_P(RadioHidlTest_v1_2,setIndicationFilter_1_2)408 TEST_P(RadioHidlTest_v1_2, setIndicationFilter_1_2) {
409     serial = GetRandomSerialNumber();
410 
411     Return<void> res = radio_v1_2->setIndicationFilter_1_2(
412         serial, static_cast<int>(::android::hardware::radio::V1_2::IndicationFilter::ALL));
413     ASSERT_OK(res);
414     EXPECT_EQ(std::cv_status::no_timeout, wait());
415     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
416     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
417 
418     ALOGI("setIndicationFilter_1_2, rspInfo.error = %s\n",
419           toString(radioRsp_v1_2->rspInfo.error).c_str());
420     ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error, {RadioError::NONE}));
421 }
422 
423 /*
424  * Test IRadio.setSignalStrengthReportingCriteria() with invalid hysteresisDb
425  */
TEST_P(RadioHidlTest_v1_2,setSignalStrengthReportingCriteria_invalidHysteresisDb)426 TEST_P(RadioHidlTest_v1_2, setSignalStrengthReportingCriteria_invalidHysteresisDb) {
427     serial = GetRandomSerialNumber();
428 
429     Return<void> res = radio_v1_2->setSignalStrengthReportingCriteria(
430         serial, 5000,
431         10,  // hysteresisDb too large given threshold list deltas
432         {-109, -103, -97, -89}, ::android::hardware::radio::V1_2::AccessNetwork::GERAN);
433     ASSERT_OK(res);
434     EXPECT_EQ(std::cv_status::no_timeout, wait());
435     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
436     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
437 
438     ALOGI("setSignalStrengthReportingCriteria_invalidHysteresisDb, rspInfo.error = %s\n",
439           toString(radioRsp_v1_2->rspInfo.error).c_str());
440     ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error, {RadioError::INVALID_ARGUMENTS}));
441 }
442 
443 /*
444  * Test IRadio.setSignalStrengthReportingCriteria() with empty parameters
445  */
TEST_P(RadioHidlTest_v1_2,setSignalStrengthReportingCriteria_EmptyParams)446 TEST_P(RadioHidlTest_v1_2, setSignalStrengthReportingCriteria_EmptyParams) {
447     serial = GetRandomSerialNumber();
448 
449     Return<void> res = radio_v1_2->setSignalStrengthReportingCriteria(
450         serial, 0, 0, {}, ::android::hardware::radio::V1_2::AccessNetwork::GERAN);
451     ASSERT_OK(res);
452     EXPECT_EQ(std::cv_status::no_timeout, wait());
453     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
454     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
455 
456     ALOGI("setSignalStrengthReportingCriteria_EmptyParams, rspInfo.error = %s\n",
457           toString(radioRsp_v1_2->rspInfo.error).c_str());
458     ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error, {RadioError::NONE}));
459 }
460 
461 /*
462  * Test IRadio.setSignalStrengthReportingCriteria() for GERAN
463  */
TEST_P(RadioHidlTest_v1_2,setSignalStrengthReportingCriteria_Geran)464 TEST_P(RadioHidlTest_v1_2, setSignalStrengthReportingCriteria_Geran) {
465     serial = GetRandomSerialNumber();
466 
467     Return<void> res = radio_v1_2->setSignalStrengthReportingCriteria(
468         serial, 5000, 2, {-109, -103, -97, -89},
469         ::android::hardware::radio::V1_2::AccessNetwork::GERAN);
470     ASSERT_OK(res);
471     EXPECT_EQ(std::cv_status::no_timeout, wait());
472     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
473     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
474 
475     ALOGI("setSignalStrengthReportingCriteria_Geran, rspInfo.error = %s\n",
476           toString(radioRsp_v1_2->rspInfo.error).c_str());
477     ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error, {RadioError::NONE}));
478 }
479 
480 /*
481  * Test IRadio.setSignalStrengthReportingCriteria() for UTRAN
482  */
TEST_P(RadioHidlTest_v1_2,setSignalStrengthReportingCriteria_Utran)483 TEST_P(RadioHidlTest_v1_2, setSignalStrengthReportingCriteria_Utran) {
484     serial = GetRandomSerialNumber();
485 
486     Return<void> res = radio_v1_2->setSignalStrengthReportingCriteria(
487         serial, 5000, 2, {-110, -97, -73, -49, -25},
488         ::android::hardware::radio::V1_2::AccessNetwork::UTRAN);
489     ASSERT_OK(res);
490     EXPECT_EQ(std::cv_status::no_timeout, wait());
491     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
492     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
493 
494     ALOGI("setSignalStrengthReportingCriteria_Utran, rspInfo.error = %s\n",
495           toString(radioRsp_v1_2->rspInfo.error).c_str());
496     ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error, {RadioError::NONE}));
497 }
498 
499 /*
500  * Test IRadio.setSignalStrengthReportingCriteria() for EUTRAN
501  */
TEST_P(RadioHidlTest_v1_2,setSignalStrengthReportingCriteria_Eutran)502 TEST_P(RadioHidlTest_v1_2, setSignalStrengthReportingCriteria_Eutran) {
503     serial = GetRandomSerialNumber();
504 
505     Return<void> res = radio_v1_2->setSignalStrengthReportingCriteria(
506         serial, 5000, 2, {-140, -128, -118, -108, -98, -44},
507         ::android::hardware::radio::V1_2::AccessNetwork::EUTRAN);
508     ASSERT_OK(res);
509     EXPECT_EQ(std::cv_status::no_timeout, wait());
510     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
511     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
512 
513     ALOGI("setSignalStrengthReportingCriteria_Eutran, rspInfo.error = %s\n",
514           toString(radioRsp_v1_2->rspInfo.error).c_str());
515     ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error, {RadioError::NONE}));
516 }
517 
518 /*
519  * Test IRadio.setSignalStrengthReportingCriteria() for CDMA2000
520  */
TEST_P(RadioHidlTest_v1_2,setSignalStrengthReportingCriteria_Cdma2000)521 TEST_P(RadioHidlTest_v1_2, setSignalStrengthReportingCriteria_Cdma2000) {
522     serial = GetRandomSerialNumber();
523 
524     Return<void> res = radio_v1_2->setSignalStrengthReportingCriteria(
525         serial, 5000, 2, {-105, -90, -75, -65},
526         ::android::hardware::radio::V1_2::AccessNetwork::CDMA2000);
527     ASSERT_OK(res);
528     EXPECT_EQ(std::cv_status::no_timeout, wait());
529     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
530     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
531 
532     ALOGI("setSignalStrengthReportingCriteria_Cdma2000, rspInfo.error = %s\n",
533           toString(radioRsp_v1_2->rspInfo.error).c_str());
534     ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error, {RadioError::NONE}));
535 }
536 
537 /*
538  * Test IRadio.setLinkCapacityReportingCriteria() invalid hysteresisDlKbps
539  */
TEST_P(RadioHidlTest_v1_2,setLinkCapacityReportingCriteria_invalidHysteresisDlKbps)540 TEST_P(RadioHidlTest_v1_2, setLinkCapacityReportingCriteria_invalidHysteresisDlKbps) {
541     serial = GetRandomSerialNumber();
542 
543     Return<void> res = radio_v1_2->setLinkCapacityReportingCriteria(
544         serial, 5000,
545         5000,  // hysteresisDlKbps too big for thresholds delta
546         100, {1000, 5000, 10000, 20000}, {500, 1000, 5000, 10000},
547         ::android::hardware::radio::V1_2::AccessNetwork::GERAN);
548     ASSERT_OK(res);
549     EXPECT_EQ(std::cv_status::no_timeout, wait());
550     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
551     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
552 
553     ALOGI("setLinkCapacityReportingCriteria_invalidHysteresisDlKbps, rspInfo.error = %s\n",
554           toString(radioRsp_v1_2->rspInfo.error).c_str());
555     // Allow REQUEST_NOT_SUPPORTED as setLinkCapacityReportingCriteria() may not be supported for
556     // GERAN
557     ASSERT_TRUE(
558         CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
559                          {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
560 }
561 
562 /*
563  * Test IRadio.setLinkCapacityReportingCriteria() invalid hysteresisUlKbps
564  */
TEST_P(RadioHidlTest_v1_2,setLinkCapacityReportingCriteria_invalidHysteresisUlKbps)565 TEST_P(RadioHidlTest_v1_2, setLinkCapacityReportingCriteria_invalidHysteresisUlKbps) {
566     serial = GetRandomSerialNumber();
567 
568     Return<void> res = radio_v1_2->setLinkCapacityReportingCriteria(
569         serial, 5000, 500,
570         1000,  // hysteresisUlKbps too big for thresholds delta
571         {1000, 5000, 10000, 20000}, {500, 1000, 5000, 10000},
572         ::android::hardware::radio::V1_2::AccessNetwork::GERAN);
573     ASSERT_OK(res);
574     EXPECT_EQ(std::cv_status::no_timeout, wait());
575     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
576     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
577 
578     ALOGI("setLinkCapacityReportingCriteria_invalidHysteresisUlKbps, rspInfo.error = %s\n",
579           toString(radioRsp_v1_2->rspInfo.error).c_str());
580     // Allow REQUEST_NOT_SUPPORTED as setLinkCapacityReportingCriteria() may not be supported for
581     // GERAN
582     ASSERT_TRUE(
583         CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
584                          {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
585 }
586 
587 /*
588  * Test IRadio.setLinkCapacityReportingCriteria() empty params
589  */
TEST_P(RadioHidlTest_v1_2,setLinkCapacityReportingCriteria_emptyParams)590 TEST_P(RadioHidlTest_v1_2, setLinkCapacityReportingCriteria_emptyParams) {
591     serial = GetRandomSerialNumber();
592 
593     Return<void> res = radio_v1_2->setLinkCapacityReportingCriteria(
594         serial, 0, 0, 0, {}, {}, ::android::hardware::radio::V1_2::AccessNetwork::GERAN);
595     ASSERT_OK(res);
596     EXPECT_EQ(std::cv_status::no_timeout, wait());
597     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
598     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
599 
600     ALOGI("setLinkCapacityReportingCriteria_emptyParams, rspInfo.error = %s\n",
601           toString(radioRsp_v1_2->rspInfo.error).c_str());
602     // Allow REQUEST_NOT_SUPPORTED as setLinkCapacityReportingCriteria() may not be supported for
603     // GERAN
604     ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
605                                  {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
606 }
607 
608 /*
609  * Test IRadio.setLinkCapacityReportingCriteria() GERAN
610  */
TEST_P(RadioHidlTest_v1_2,setLinkCapacityReportingCriteria_Geran)611 TEST_P(RadioHidlTest_v1_2, setLinkCapacityReportingCriteria_Geran) {
612     serial = GetRandomSerialNumber();
613 
614     Return<void> res = radio_v1_2->setLinkCapacityReportingCriteria(
615         serial, 5000, 500, 100, {1000, 5000, 10000, 20000}, {500, 1000, 5000, 10000},
616         ::android::hardware::radio::V1_2::AccessNetwork::GERAN);
617     ASSERT_OK(res);
618     EXPECT_EQ(std::cv_status::no_timeout, wait());
619     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
620     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
621 
622     ALOGI("setLinkCapacityReportingCriteria_invalidHysteresisUlKbps, rspInfo.error = %s\n",
623           toString(radioRsp_v1_2->rspInfo.error).c_str());
624     // Allow REQUEST_NOT_SUPPORTED as setLinkCapacityReportingCriteria() may not be supported for
625     // GERAN
626     ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
627                                  {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
628 }
629 
630 /*
631  * Test IRadio.setupDataCall_1_2() for the response returned.
632  */
TEST_P(RadioHidlTest_v1_2,setupDataCall_1_2)633 TEST_P(RadioHidlTest_v1_2, setupDataCall_1_2) {
634     serial = GetRandomSerialNumber();
635 
636     ::android::hardware::radio::V1_2::AccessNetwork accessNetwork =
637         ::android::hardware::radio::V1_2::AccessNetwork::EUTRAN;
638 
639     DataProfileInfo dataProfileInfo;
640     memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
641     dataProfileInfo.profileId = DataProfileId::IMS;
642     dataProfileInfo.apn = hidl_string("VZWIMS");
643     dataProfileInfo.protocol = hidl_string("IPV4V6");
644     dataProfileInfo.roamingProtocol = hidl_string("IPV6");
645     dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
646     dataProfileInfo.user = "";
647     dataProfileInfo.password = "";
648     dataProfileInfo.type = DataProfileInfoType::THREE_GPP2;
649     dataProfileInfo.maxConnsTime = 300;
650     dataProfileInfo.maxConns = 20;
651     dataProfileInfo.waitTime = 0;
652     dataProfileInfo.enabled = true;
653     dataProfileInfo.supportedApnTypesBitmap = 320;
654     dataProfileInfo.bearerBitmap = 161543;
655     dataProfileInfo.mtu = 0;
656     dataProfileInfo.mvnoType = MvnoType::NONE;
657     dataProfileInfo.mvnoMatchData = hidl_string();
658 
659     bool modemCognitive = false;
660     bool roamingAllowed = false;
661     bool isRoaming = false;
662 
663     ::android::hardware::radio::V1_2::DataRequestReason reason =
664         ::android::hardware::radio::V1_2::DataRequestReason::NORMAL;
665     std::vector<hidl_string> addresses = {""};
666     std::vector<hidl_string> dnses = {""};
667 
668     Return<void> res = radio_v1_2->setupDataCall_1_2(serial, accessNetwork, dataProfileInfo,
669                                                      modemCognitive, roamingAllowed, isRoaming,
670                                                      reason, addresses, dnses);
671     ASSERT_OK(res);
672 
673     EXPECT_EQ(std::cv_status::no_timeout, wait());
674     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
675     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
676 
677     if (cardStatus.base.cardState == CardState::ABSENT) {
678         ASSERT_TRUE(CheckAnyOfErrors(
679             radioRsp_v1_2->rspInfo.error,
680             {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_ARGUMENTS,
681              RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW, RadioError::REQUEST_NOT_SUPPORTED}));
682     } else if (cardStatus.base.cardState == CardState::PRESENT) {
683         ASSERT_TRUE(CheckAnyOfErrors(
684             radioRsp_v1_2->rspInfo.error,
685             {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_ARGUMENTS,
686              RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW, RadioError::REQUEST_NOT_SUPPORTED}));
687     }
688 }
689 
690 /*
691  * Test IRadio.deactivateDataCall_1_2() for the response returned.
692  */
TEST_P(RadioHidlTest_v1_2,deactivateDataCall_1_2)693 TEST_P(RadioHidlTest_v1_2, deactivateDataCall_1_2) {
694     serial = GetRandomSerialNumber();
695     int cid = 1;
696     ::android::hardware::radio::V1_2::DataRequestReason reason =
697         ::android::hardware::radio::V1_2::DataRequestReason::NORMAL;
698 
699     Return<void> res = radio_v1_2->deactivateDataCall_1_2(serial, cid, reason);
700     ASSERT_OK(res);
701 
702     EXPECT_EQ(std::cv_status::no_timeout, wait());
703     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
704     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
705 
706     if (cardStatus.base.cardState == CardState::ABSENT) {
707         ASSERT_TRUE(CheckAnyOfErrors(
708             radioRsp_v1_2->rspInfo.error,
709             {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_CALL_ID,
710              RadioError::INVALID_STATE, RadioError::INVALID_ARGUMENTS,
711              RadioError::REQUEST_NOT_SUPPORTED, RadioError::CANCELLED, RadioError::SIM_ABSENT}));
712     } else if (cardStatus.base.cardState == CardState::PRESENT) {
713         ASSERT_TRUE(CheckAnyOfErrors(
714             radioRsp_v1_2->rspInfo.error,
715             {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_CALL_ID,
716              RadioError::INVALID_STATE, RadioError::INVALID_ARGUMENTS,
717              RadioError::REQUEST_NOT_SUPPORTED, RadioError::CANCELLED}));
718     }
719 }
720 
721 /*
722  * Test IRadio.getCellInfoList() for the response returned.
723  */
TEST_P(RadioHidlTest_v1_2,getCellInfoList_1_2)724 TEST_P(RadioHidlTest_v1_2, getCellInfoList_1_2) {
725     serial = GetRandomSerialNumber();
726 
727     Return<void> res = radio_v1_2->getCellInfoList(serial);
728     ASSERT_OK(res);
729     EXPECT_EQ(std::cv_status::no_timeout, wait());
730     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
731     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
732 
733     ALOGI("getCellInfoList_1_2, rspInfo.error = %s\n",
734           toString(radioRsp_v1_2->rspInfo.error).c_str());
735     ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
736                                  {RadioError::NONE, RadioError::NO_NETWORK_FOUND}));
737 }
738 
739 /*
740  * Test IRadio.getVoiceRegistrationState() for the response returned.
741  */
TEST_P(RadioHidlTest_v1_2,getVoiceRegistrationState)742 TEST_P(RadioHidlTest_v1_2, getVoiceRegistrationState) {
743     serial = GetRandomSerialNumber();
744 
745     Return<void> res = radio_v1_2->getVoiceRegistrationState(serial);
746     ASSERT_OK(res);
747     EXPECT_EQ(std::cv_status::no_timeout, wait());
748     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
749     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
750 
751     ALOGI("getVoiceRegistrationStateResponse_1_2, rspInfo.error = %s\n",
752           toString(radioRsp_v1_2->rspInfo.error).c_str());
753     ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
754                                  {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE}));
755 }
756 
757 /*
758  * Test IRadio.getDataRegistrationState() for the response returned.
759  */
TEST_P(RadioHidlTest_v1_2,getDataRegistrationState)760 TEST_P(RadioHidlTest_v1_2, getDataRegistrationState) {
761     serial = GetRandomSerialNumber();
762 
763     Return<void> res = radio_v1_2->getDataRegistrationState(serial);
764     ASSERT_OK(res);
765     EXPECT_EQ(std::cv_status::no_timeout, wait());
766     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
767     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
768 
769     ALOGI("getDataRegistrationStateResponse_1_2, rspInfo.error = %s\n",
770           toString(radioRsp_v1_2->rspInfo.error).c_str());
771     ASSERT_TRUE(CheckAnyOfErrors(
772         radioRsp_v1_2->rspInfo.error,
773         {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::NOT_PROVISIONED}));
774 
775     // Check the mcc [0, 999] and mnc [0, 999].
776     string hidl_mcc;
777     string hidl_mnc;
778     bool checkMccMnc = true;
779     int totalIdentitySizeExpected = 1;
780     ::android::hardware::radio::V1_2::CellIdentity cellIdentities =
781         radioRsp_v1_2->dataRegResp.cellIdentity;
782     CellInfoType cellInfoType = cellIdentities.cellInfoType;
783 
784     if (cellInfoType == CellInfoType::NONE) {
785         // All the fields are 0
786         totalIdentitySizeExpected = 0;
787         checkMccMnc = false;
788     } else if (cellInfoType == CellInfoType::GSM) {
789         EXPECT_EQ(1, cellIdentities.cellIdentityGsm.size());
790         ::android::hardware::radio::V1_2::CellIdentityGsm cig = cellIdentities.cellIdentityGsm[0];
791         hidl_mcc = cig.base.mcc;
792         hidl_mnc = cig.base.mnc;
793     } else if (cellInfoType == CellInfoType::LTE) {
794         EXPECT_EQ(1, cellIdentities.cellIdentityLte.size());
795         ::android::hardware::radio::V1_2::CellIdentityLte cil = cellIdentities.cellIdentityLte[0];
796         hidl_mcc = cil.base.mcc;
797         hidl_mnc = cil.base.mnc;
798     } else if (cellInfoType == CellInfoType::WCDMA) {
799         EXPECT_EQ(1, cellIdentities.cellIdentityWcdma.size());
800         ::android::hardware::radio::V1_2::CellIdentityWcdma ciw =
801             cellIdentities.cellIdentityWcdma[0];
802         hidl_mcc = ciw.base.mcc;
803         hidl_mnc = ciw.base.mnc;
804     } else if (cellInfoType == CellInfoType::TD_SCDMA) {
805         EXPECT_EQ(1, cellIdentities.cellIdentityTdscdma.size());
806         ::android::hardware::radio::V1_2::CellIdentityTdscdma cit =
807             cellIdentities.cellIdentityTdscdma[0];
808         hidl_mcc = cit.base.mcc;
809         hidl_mnc = cit.base.mnc;
810     } else {
811         // CellIndentityCdma has no mcc and mnc.
812         EXPECT_EQ(CellInfoType::CDMA, cellInfoType);
813         EXPECT_EQ(1, cellIdentities.cellIdentityCdma.size());
814         checkMccMnc = false;
815     }
816 
817     // Check only one CellIdentity is size 1, and others must be 0.
818     EXPECT_EQ(totalIdentitySizeExpected,
819               cellIdentities.cellIdentityGsm.size() + cellIdentities.cellIdentityCdma.size() +
820                   cellIdentities.cellIdentityLte.size() + cellIdentities.cellIdentityWcdma.size() +
821                   cellIdentities.cellIdentityTdscdma.size());
822 
823     // 32 bit system might return invalid mcc and mnc hidl string "\xff\xff..."
824     if (checkMccMnc && hidl_mcc.size() < 4 && hidl_mnc.size() < 4) {
825         int mcc = stoi(hidl_mcc);
826         int mnc = stoi(hidl_mnc);
827         EXPECT_TRUE(mcc >= 0 && mcc <= 999);
828         EXPECT_TRUE(mnc >= 0 && mnc <= 999);
829     }
830 }
831 
832 /*
833  * Test IRadio.getAvailableBandModes() for the response returned.
834  */
TEST_P(RadioHidlTest_v1_2,getAvailableBandModes)835 TEST_P(RadioHidlTest_v1_2, getAvailableBandModes) {
836     serial = GetRandomSerialNumber();
837 
838     Return<void> res = radio_v1_2->getAvailableBandModes(serial);
839     ASSERT_OK(res);
840     EXPECT_EQ(std::cv_status::no_timeout, wait());
841     EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_2->rspInfo.type);
842     EXPECT_EQ(serial, radioRsp_v1_2->rspInfo.serial);
843     ALOGI("getAvailableBandModes, rspInfo.error = %s\n",
844           toString(radioRsp_v1_2->rspInfo.error).c_str());
845     ASSERT_TRUE(
846         CheckAnyOfErrors(radioRsp_v1_2->rspInfo.error,
847                          {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR,
848                           RadioError::INTERNAL_ERR,
849                           // If REQUEST_NOT_SUPPORTED is returned, then it should also be returned
850                           // for setRandMode().
851                           RadioError::REQUEST_NOT_SUPPORTED}));
852     bool hasUnspecifiedBandMode = false;
853     if (radioRsp_v1_2->rspInfo.error == RadioError::NONE) {
854         for (const RadioBandMode& mode : radioRsp_v1_2->radioBandModes) {
855             // Automatic mode selection must be supported
856             if (mode == RadioBandMode::BAND_MODE_UNSPECIFIED) hasUnspecifiedBandMode = true;
857         }
858         ASSERT_TRUE(hasUnspecifiedBandMode);
859     }
860 }
861