1 /*
2 * Copyright (C) 2019 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-base/properties.h>
18 #include <radio_hidl_hal_utils_v1_5.h>
19
20 #define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
21
22 /*
23 * Test IRadio.setSignalStrengthReportingCriteria_1_5() with invalid hysteresisDb
24 */
TEST_P(RadioHidlTest_v1_5,setSignalStrengthReportingCriteria_1_5_invalidHysteresisDb)25 TEST_P(RadioHidlTest_v1_5, setSignalStrengthReportingCriteria_1_5_invalidHysteresisDb) {
26 serial = GetRandomSerialNumber();
27
28 ::android::hardware::radio::V1_5::SignalThresholdInfo signalThresholdInfo;
29 signalThresholdInfo.signalMeasurement = SignalMeasurementType::RSSI;
30 signalThresholdInfo.hysteresisMs = 5000;
31 signalThresholdInfo.hysteresisDb = 10; // hysteresisDb too large given threshold list deltas
32 signalThresholdInfo.thresholds = {-109, -103, -97, -89};
33 signalThresholdInfo.isEnabled = true;
34
35 Return<void> res = radio_v1_5->setSignalStrengthReportingCriteria_1_5(
36 serial, signalThresholdInfo, ::android::hardware::radio::V1_5::AccessNetwork::GERAN);
37 ASSERT_OK(res);
38 EXPECT_EQ(std::cv_status::no_timeout, wait());
39 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
40 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
41
42 ALOGI("setSignalStrengthReportingCriteria_1_5_invalidHysteresisDb, rspInfo.error = %s\n",
43 toString(radioRsp_v1_5->rspInfo.error).c_str());
44 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error, {RadioError::INVALID_ARGUMENTS}));
45 }
46
47 /*
48 * Test IRadio.setSignalStrengthReportingCriteria_1_5() with empty thresholds
49 */
TEST_P(RadioHidlTest_v1_5,setSignalStrengthReportingCriteria_1_5_EmptyThresholds)50 TEST_P(RadioHidlTest_v1_5, setSignalStrengthReportingCriteria_1_5_EmptyThresholds) {
51 serial = GetRandomSerialNumber();
52
53 ::android::hardware::radio::V1_5::SignalThresholdInfo signalThresholdInfo;
54 signalThresholdInfo.signalMeasurement = SignalMeasurementType::RSSI;
55 signalThresholdInfo.hysteresisMs = 0;
56 signalThresholdInfo.hysteresisDb = 0;
57 signalThresholdInfo.isEnabled = true;
58
59 Return<void> res = radio_v1_5->setSignalStrengthReportingCriteria_1_5(
60 serial, signalThresholdInfo, ::android::hardware::radio::V1_5::AccessNetwork::GERAN);
61 ASSERT_OK(res);
62 EXPECT_EQ(std::cv_status::no_timeout, wait());
63 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
64 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
65
66 ALOGI("setSignalStrengthReportingCriteria_1_5_EmptyParams, rspInfo.error = %s\n",
67 toString(radioRsp_v1_5->rspInfo.error).c_str());
68 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error, {RadioError::NONE}));
69 }
70
71 /*
72 * Test IRadio.setSignalStrengthReportingCriteria_1_5() for GERAN
73 */
TEST_P(RadioHidlTest_v1_5,setSignalStrengthReportingCriteria_1_5_Geran)74 TEST_P(RadioHidlTest_v1_5, setSignalStrengthReportingCriteria_1_5_Geran) {
75 serial = GetRandomSerialNumber();
76
77 ::android::hardware::radio::V1_5::SignalThresholdInfo signalThresholdInfo;
78 signalThresholdInfo.signalMeasurement = SignalMeasurementType::RSSI;
79 signalThresholdInfo.hysteresisMs = 5000;
80 signalThresholdInfo.hysteresisDb = 2;
81 signalThresholdInfo.thresholds = {-109, -103, -97, -89};
82 signalThresholdInfo.isEnabled = true;
83
84 Return<void> res = radio_v1_5->setSignalStrengthReportingCriteria_1_5(
85 serial, signalThresholdInfo, ::android::hardware::radio::V1_5::AccessNetwork::GERAN);
86 ASSERT_OK(res);
87 EXPECT_EQ(std::cv_status::no_timeout, wait());
88 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
89 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
90
91 ALOGI("setSignalStrengthReportingCriteria_1_5_Geran, rspInfo.error = %s\n",
92 toString(radioRsp_v1_5->rspInfo.error).c_str());
93 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error, {RadioError::NONE}));
94 }
95
96 /*
97 * Test IRadio.setSignalStrengthReportingCriteria_1_5() for UTRAN
98 */
TEST_P(RadioHidlTest_v1_5,setSignalStrengthReportingCriteria_1_5_Utran)99 TEST_P(RadioHidlTest_v1_5, setSignalStrengthReportingCriteria_1_5_Utran) {
100 serial = GetRandomSerialNumber();
101
102 ::android::hardware::radio::V1_5::SignalThresholdInfo signalThresholdInfo;
103 signalThresholdInfo.signalMeasurement = SignalMeasurementType::RSCP;
104 signalThresholdInfo.hysteresisMs = 5000;
105 signalThresholdInfo.hysteresisDb = 2;
106 signalThresholdInfo.thresholds = {-110, -97, -73, -49, -25};
107 signalThresholdInfo.isEnabled = true;
108
109 Return<void> res = radio_v1_5->setSignalStrengthReportingCriteria_1_5(
110 serial, signalThresholdInfo, ::android::hardware::radio::V1_5::AccessNetwork::UTRAN);
111 ASSERT_OK(res);
112 EXPECT_EQ(std::cv_status::no_timeout, wait());
113 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
114 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
115
116 ALOGI("setSignalStrengthReportingCriteria_1_5_Utran, rspInfo.error = %s\n",
117 toString(radioRsp_v1_5->rspInfo.error).c_str());
118 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error, {RadioError::NONE}));
119 }
120
121 /*
122 * Test IRadio.setSignalStrengthReportingCriteria_1_5() for EUTRAN
123 */
TEST_P(RadioHidlTest_v1_5,setSignalStrengthReportingCriteria_1_5_Eutran_RSRP)124 TEST_P(RadioHidlTest_v1_5, setSignalStrengthReportingCriteria_1_5_Eutran_RSRP) {
125 serial = GetRandomSerialNumber();
126
127 ::android::hardware::radio::V1_5::SignalThresholdInfo signalThresholdInfo;
128 signalThresholdInfo.signalMeasurement = SignalMeasurementType::RSRP;
129 signalThresholdInfo.hysteresisMs = 5000;
130 signalThresholdInfo.hysteresisDb = 2;
131 signalThresholdInfo.thresholds = {-128, -108, -88, -68};
132 signalThresholdInfo.isEnabled = true;
133
134 Return<void> res = radio_v1_5->setSignalStrengthReportingCriteria_1_5(
135 serial, signalThresholdInfo, ::android::hardware::radio::V1_5::AccessNetwork::EUTRAN);
136 ASSERT_OK(res);
137 EXPECT_EQ(std::cv_status::no_timeout, wait());
138 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
139 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
140
141 ALOGI("setSignalStrengthReportingCriteria_1_5_Eutran, rspInfo.error = %s\n",
142 toString(radioRsp_v1_5->rspInfo.error).c_str());
143 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error, {RadioError::NONE}));
144 }
145
146 /*
147 * Test IRadio.setSignalStrengthReportingCriteria_1_5() for EUTRAN
148 */
TEST_P(RadioHidlTest_v1_5,setSignalStrengthReportingCriteria_1_5_Eutran_RSRQ)149 TEST_P(RadioHidlTest_v1_5, setSignalStrengthReportingCriteria_1_5_Eutran_RSRQ) {
150 serial = GetRandomSerialNumber();
151
152 ::android::hardware::radio::V1_5::SignalThresholdInfo signalThresholdInfo;
153 signalThresholdInfo.signalMeasurement = SignalMeasurementType::RSRQ;
154 signalThresholdInfo.hysteresisMs = 5000;
155 signalThresholdInfo.hysteresisDb = 2;
156 signalThresholdInfo.thresholds = {-27, -20, -13, -6};
157 signalThresholdInfo.isEnabled = true;
158
159 Return<void> res = radio_v1_5->setSignalStrengthReportingCriteria_1_5(
160 serial, signalThresholdInfo, ::android::hardware::radio::V1_5::AccessNetwork::EUTRAN);
161 ASSERT_OK(res);
162 EXPECT_EQ(std::cv_status::no_timeout, wait());
163 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
164 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
165
166 ALOGI("setSignalStrengthReportingCriteria_1_5_Eutran, rspInfo.error = %s\n",
167 toString(radioRsp_v1_5->rspInfo.error).c_str());
168 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error, {RadioError::NONE}));
169 }
170
171 /*
172 * Test IRadio.setSignalStrengthReportingCriteria_1_5() for EUTRAN
173 */
TEST_P(RadioHidlTest_v1_5,setSignalStrengthReportingCriteria_1_5_Eutran_RSSNR)174 TEST_P(RadioHidlTest_v1_5, setSignalStrengthReportingCriteria_1_5_Eutran_RSSNR) {
175 serial = GetRandomSerialNumber();
176
177 ::android::hardware::radio::V1_5::SignalThresholdInfo signalThresholdInfo;
178 signalThresholdInfo.signalMeasurement = SignalMeasurementType::RSSNR;
179 signalThresholdInfo.hysteresisMs = 5000;
180 signalThresholdInfo.hysteresisDb = 2;
181 signalThresholdInfo.thresholds = {-10, 0, 10, 20};
182 signalThresholdInfo.isEnabled = true;
183
184 Return<void> res = radio_v1_5->setSignalStrengthReportingCriteria_1_5(
185 serial, signalThresholdInfo, ::android::hardware::radio::V1_5::AccessNetwork::EUTRAN);
186 ASSERT_OK(res);
187 EXPECT_EQ(std::cv_status::no_timeout, wait());
188 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
189 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
190 }
191
192 /*
193 * Test IRadio.setSignalStrengthReportingCriteria_1_5() for CDMA2000
194 */
TEST_P(RadioHidlTest_v1_5,setSignalStrengthReportingCriteria_1_5_Cdma2000)195 TEST_P(RadioHidlTest_v1_5, setSignalStrengthReportingCriteria_1_5_Cdma2000) {
196 serial = GetRandomSerialNumber();
197
198 ::android::hardware::radio::V1_5::SignalThresholdInfo signalThresholdInfo;
199 signalThresholdInfo.signalMeasurement = SignalMeasurementType::RSSI;
200 signalThresholdInfo.hysteresisMs = 5000;
201 signalThresholdInfo.hysteresisDb = 2;
202 signalThresholdInfo.thresholds = {-105, -90, -75, -65};
203 signalThresholdInfo.isEnabled = true;
204
205 Return<void> res = radio_v1_5->setSignalStrengthReportingCriteria_1_5(
206 serial, signalThresholdInfo, ::android::hardware::radio::V1_5::AccessNetwork::CDMA2000);
207 ASSERT_OK(res);
208 EXPECT_EQ(std::cv_status::no_timeout, wait());
209 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
210 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
211
212 ALOGI("setSignalStrengthReportingCriteria_1_5_Cdma2000, rspInfo.error = %s\n",
213 toString(radioRsp_v1_5->rspInfo.error).c_str());
214 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error, {RadioError::NONE}));
215 }
216
217 /*
218 * Test IRadio.setSignalStrengthReportingCriteria_1_5() for NGRAN_SSRSRP
219 */
TEST_P(RadioHidlTest_v1_5,setSignalStrengthReportingCriteria_1_5_NGRAN_SSRSRP)220 TEST_P(RadioHidlTest_v1_5, setSignalStrengthReportingCriteria_1_5_NGRAN_SSRSRP) {
221 serial = GetRandomSerialNumber();
222
223 ::android::hardware::radio::V1_5::SignalThresholdInfo signalThresholdInfo;
224 signalThresholdInfo.signalMeasurement = SignalMeasurementType::SSRSRP;
225 signalThresholdInfo.hysteresisMs = 5000;
226 signalThresholdInfo.hysteresisDb = 0;
227 signalThresholdInfo.thresholds = {-105, -90, -75, -65};
228 signalThresholdInfo.isEnabled = true;
229
230 Return<void> res = radio_v1_5->setSignalStrengthReportingCriteria_1_5(
231 serial, signalThresholdInfo, ::android::hardware::radio::V1_5::AccessNetwork::NGRAN);
232 ASSERT_OK(res);
233 EXPECT_EQ(std::cv_status::no_timeout, wait());
234 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
235 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
236
237 ALOGI("setSignalStrengthReportingCriteria_1_5_NGRAN_SSRSRP, rspInfo.error = %s\n",
238 toString(radioRsp_v1_5->rspInfo.error).c_str());
239
240 // Allow REQUEST_NOT_SUPPORTED because some non-5G device may not support NGRAN for
241 // setSignalStrengthReportingCriteria_1_5()
242 ASSERT_TRUE(
243 CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
244 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
245 }
246
247 /*
248 * Test IRadio.setSignalStrengthReportingCriteria_1_5() for NGRAN_SSRSRQ
249 */
TEST_P(RadioHidlTest_v1_5,setSignalStrengthReportingCriteria_1_5_NGRAN_SSRSRQ)250 TEST_P(RadioHidlTest_v1_5, setSignalStrengthReportingCriteria_1_5_NGRAN_SSRSRQ) {
251 serial = GetRandomSerialNumber();
252
253 ::android::hardware::radio::V1_5::SignalThresholdInfo signalThresholdInfo;
254 signalThresholdInfo.signalMeasurement = SignalMeasurementType::SSRSRQ;
255 signalThresholdInfo.hysteresisMs = 5000;
256 signalThresholdInfo.hysteresisDb = 0;
257 signalThresholdInfo.thresholds = {-43, -20, 0, 20};
258 signalThresholdInfo.isEnabled = true;
259
260 Return<void> res = radio_v1_5->setSignalStrengthReportingCriteria_1_5(
261 serial, signalThresholdInfo, ::android::hardware::radio::V1_5::AccessNetwork::NGRAN);
262 ASSERT_OK(res);
263 EXPECT_EQ(std::cv_status::no_timeout, wait());
264 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
265 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
266
267 ALOGI("setSignalStrengthReportingCriteria_1_5_NGRAN_SSRSRQ, rspInfo.error = %s\n",
268 toString(radioRsp_v1_5->rspInfo.error).c_str());
269
270 // Allow REQUEST_NOT_SUPPORTED because some non-5G device may not support NGRAN for
271 // setSignalStrengthReportingCriteria_1_5()
272 ASSERT_TRUE(
273 CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
274 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
275 }
276
277 /*
278 * Test IRadio.setSignalStrengthReportingCriteria_1_5() for EUTRAN
279 */
TEST_P(RadioHidlTest_v1_5,setSignalStrengthReportingCriteria_1_5_Disable_RSSNR)280 TEST_P(RadioHidlTest_v1_5, setSignalStrengthReportingCriteria_1_5_Disable_RSSNR) {
281 serial = GetRandomSerialNumber();
282
283 ::android::hardware::radio::V1_5::SignalThresholdInfo signalThresholdInfo;
284 signalThresholdInfo.signalMeasurement = SignalMeasurementType::RSSNR;
285 signalThresholdInfo.hysteresisMs = 5000;
286 signalThresholdInfo.hysteresisDb = 2;
287 signalThresholdInfo.thresholds = {-10, 0, 10, 20};
288 signalThresholdInfo.isEnabled = false;
289
290 Return<void> res = radio_v1_5->setSignalStrengthReportingCriteria_1_5(
291 serial, signalThresholdInfo, ::android::hardware::radio::V1_5::AccessNetwork::EUTRAN);
292 ASSERT_OK(res);
293 EXPECT_EQ(std::cv_status::no_timeout, wait());
294 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
295 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
296 }
297
298 /*
299 * Test IRadio.setSignalStrengthReportingCriteria_1_5() for NGRAN_SSSINR
300 */
TEST_P(RadioHidlTest_v1_5,setSignalStrengthReportingCriteria_1_5_NGRAN_SSSINR)301 TEST_P(RadioHidlTest_v1_5, setSignalStrengthReportingCriteria_1_5_NGRAN_SSSINR) {
302 serial = GetRandomSerialNumber();
303
304 ::android::hardware::radio::V1_5::SignalThresholdInfo signalThresholdInfo;
305 signalThresholdInfo.signalMeasurement = SignalMeasurementType::SSSINR;
306 signalThresholdInfo.hysteresisMs = 5000;
307 signalThresholdInfo.hysteresisDb = 0;
308 signalThresholdInfo.thresholds = {-10, 3, 16, 18};
309 signalThresholdInfo.isEnabled = true;
310
311 Return<void> res = radio_v1_5->setSignalStrengthReportingCriteria_1_5(
312 serial, signalThresholdInfo, ::android::hardware::radio::V1_5::AccessNetwork::NGRAN);
313 ASSERT_OK(res);
314 EXPECT_EQ(std::cv_status::no_timeout, wait());
315 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
316 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
317
318 ALOGI("setSignalStrengthReportingCriteria_1_5_NGRAN_SSSINR, rspInfo.error = %s\n",
319 toString(radioRsp_v1_5->rspInfo.error).c_str());
320
321 // Allow REQUEST_NOT_SUPPORTED because some non-5G device may not support NGRAN for
322 // setSignalStrengthReportingCriteria_1_5()
323 ASSERT_TRUE(
324 CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
325 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
326 }
327
328 /*
329 * Test IRadio.setLinkCapacityReportingCriteria_1_5() invalid hysteresisDlKbps
330 */
TEST_P(RadioHidlTest_v1_5,setLinkCapacityReportingCriteria_1_5_invalidHysteresisDlKbps)331 TEST_P(RadioHidlTest_v1_5, setLinkCapacityReportingCriteria_1_5_invalidHysteresisDlKbps) {
332 serial = GetRandomSerialNumber();
333
334 Return<void> res = radio_v1_5->setLinkCapacityReportingCriteria_1_5(
335 serial, 5000,
336 5000, // hysteresisDlKbps too big for thresholds delta
337 100, {1000, 5000, 10000, 20000}, {500, 1000, 5000, 10000},
338 ::android::hardware::radio::V1_5::AccessNetwork::GERAN);
339 ASSERT_OK(res);
340 EXPECT_EQ(std::cv_status::no_timeout, wait());
341 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
342 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
343
344 ALOGI("setLinkCapacityReportingCriteria_1_5_invalidHysteresisDlKbps, rspInfo.error = %s\n",
345 toString(radioRsp_v1_5->rspInfo.error).c_str());
346 // Allow REQUEST_NOT_SUPPORTED as setLinkCapacityReportingCriteria_1_5() may not be supported
347 // for GERAN
348 ASSERT_TRUE(
349 CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
350 {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
351 }
352
353 /*
354 * Test IRadio.setLinkCapacityReportingCriteria_1_5() invalid hysteresisUlKbps
355 */
TEST_P(RadioHidlTest_v1_5,setLinkCapacityReportingCriteria_1_5_invalidHysteresisUlKbps)356 TEST_P(RadioHidlTest_v1_5, setLinkCapacityReportingCriteria_1_5_invalidHysteresisUlKbps) {
357 serial = GetRandomSerialNumber();
358
359 Return<void> res = radio_v1_5->setLinkCapacityReportingCriteria_1_5(
360 serial, 5000, 500,
361 1000, // hysteresisUlKbps too big for thresholds delta
362 {1000, 5000, 10000, 20000}, {500, 1000, 5000, 10000},
363 ::android::hardware::radio::V1_5::AccessNetwork::GERAN);
364 ASSERT_OK(res);
365 EXPECT_EQ(std::cv_status::no_timeout, wait());
366 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
367 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
368
369 ALOGI("setLinkCapacityReportingCriteria_1_5_invalidHysteresisUlKbps, rspInfo.error = %s\n",
370 toString(radioRsp_v1_5->rspInfo.error).c_str());
371 // Allow REQUEST_NOT_SUPPORTED as setLinkCapacityReportingCriteria_1_5() may not be supported
372 // for GERAN
373 ASSERT_TRUE(
374 CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
375 {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
376 }
377
378 /*
379 * Test IRadio.setLinkCapacityReportingCriteria_1_5() empty params
380 */
TEST_P(RadioHidlTest_v1_5,setLinkCapacityReportingCriteria_1_5_emptyParams)381 TEST_P(RadioHidlTest_v1_5, setLinkCapacityReportingCriteria_1_5_emptyParams) {
382 serial = GetRandomSerialNumber();
383
384 Return<void> res = radio_v1_5->setLinkCapacityReportingCriteria_1_5(
385 serial, 0, 0, 0, {}, {}, ::android::hardware::radio::V1_5::AccessNetwork::GERAN);
386 ASSERT_OK(res);
387 EXPECT_EQ(std::cv_status::no_timeout, wait());
388 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
389 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
390
391 ALOGI("setLinkCapacityReportingCriteria_1_5_emptyParams, rspInfo.error = %s\n",
392 toString(radioRsp_v1_5->rspInfo.error).c_str());
393 // Allow REQUEST_NOT_SUPPORTED as setLinkCapacityReportingCriteria_1_5() may not be supported
394 // for GERAN
395 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
396 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
397 }
398
399 /*
400 * Test IRadio.setLinkCapacityReportingCriteria_1_5() for GERAN
401 */
TEST_P(RadioHidlTest_v1_5,setLinkCapacityReportingCriteria_1_5_Geran)402 TEST_P(RadioHidlTest_v1_5, setLinkCapacityReportingCriteria_1_5_Geran) {
403 serial = GetRandomSerialNumber();
404
405 Return<void> res = radio_v1_5->setLinkCapacityReportingCriteria_1_5(
406 serial, 5000, 500, 100, {1000, 5000, 10000, 20000}, {500, 1000, 5000, 10000},
407 ::android::hardware::radio::V1_5::AccessNetwork::GERAN);
408 ASSERT_OK(res);
409 EXPECT_EQ(std::cv_status::no_timeout, wait());
410 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
411 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
412
413 ALOGI("setLinkCapacityReportingCriteria_1_5_Geran, rspInfo.error = %s\n",
414 toString(radioRsp_v1_5->rspInfo.error).c_str());
415 // Allow REQUEST_NOT_SUPPORTED as setLinkCapacityReportingCriteria_1_5() may not be supported
416 // for GERAN
417 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
418 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
419 }
420
421 /*
422 * Test IRadio.enableUiccApplications() for the response returned.
423 * For SIM ABSENT case.
424 */
TEST_P(RadioHidlTest_v1_5,togglingUiccApplicationsSimAbsent)425 TEST_P(RadioHidlTest_v1_5, togglingUiccApplicationsSimAbsent) {
426 // This test case only test SIM ABSENT case.
427 if (cardStatus.base.base.base.cardState != CardState::ABSENT) return;
428
429 // Disable Uicc applications.
430 serial = GetRandomSerialNumber();
431 radio_v1_5->enableUiccApplications(serial, false);
432 EXPECT_EQ(std::cv_status::no_timeout, wait());
433 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
434 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
435 // As SIM is absent, RadioError::SIM_ABSENT should be thrown.
436 EXPECT_EQ(RadioError::SIM_ABSENT, radioRsp_v1_5->rspInfo.error);
437
438 // Query Uicc application enablement.
439 serial = GetRandomSerialNumber();
440 radio_v1_5->areUiccApplicationsEnabled(serial);
441 EXPECT_EQ(std::cv_status::no_timeout, wait());
442 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
443 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
444 // As SIM is absent, RadioError::SIM_ABSENT should be thrown.
445 EXPECT_EQ(RadioError::SIM_ABSENT, radioRsp_v1_5->rspInfo.error);
446 }
447
448 /*
449 * Test IRadio.enableUiccApplications() for the response returned.
450 * For SIM PRESENT case.
451 */
TEST_P(RadioHidlTest_v1_5,togglingUiccApplicationsSimPresent)452 TEST_P(RadioHidlTest_v1_5, togglingUiccApplicationsSimPresent) {
453 // This test case only test SIM ABSENT case.
454 if (cardStatus.base.base.base.cardState != CardState::PRESENT) return;
455 if (cardStatus.applications.size() == 0) return;
456
457 // Disable Uicc applications.
458 serial = GetRandomSerialNumber();
459 radio_v1_5->enableUiccApplications(serial, false);
460 EXPECT_EQ(std::cv_status::no_timeout, wait());
461 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
462 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
463 // As SIM is present, there shouldn't be error.
464 EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error);
465
466 // Query Uicc application enablement.
467 serial = GetRandomSerialNumber();
468 radio_v1_5->areUiccApplicationsEnabled(serial);
469 EXPECT_EQ(std::cv_status::no_timeout, wait());
470 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
471 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
472 // As SIM is present, there shouldn't be error.
473 EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error);
474 ASSERT_FALSE(radioRsp_v1_5->areUiccApplicationsEnabled);
475
476 // Enable Uicc applications.
477 serial = GetRandomSerialNumber();
478 radio_v1_5->enableUiccApplications(serial, true);
479 EXPECT_EQ(std::cv_status::no_timeout, wait());
480 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
481 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
482 // As SIM is present, there shouldn't be error.
483 EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error);
484
485 // Query Uicc application enablement.
486 serial = GetRandomSerialNumber();
487 radio_v1_5->areUiccApplicationsEnabled(serial);
488 EXPECT_EQ(std::cv_status::no_timeout, wait());
489 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
490 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
491 // As SIM is present, there shouldn't be error.
492 EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error);
493 ASSERT_TRUE(radioRsp_v1_5->areUiccApplicationsEnabled);
494 }
495
496 /*
497 * Test IRadio.areUiccApplicationsEnabled() for the response returned.
498 */
TEST_P(RadioHidlTest_v1_5,areUiccApplicationsEnabled)499 TEST_P(RadioHidlTest_v1_5, areUiccApplicationsEnabled) {
500 // Disable Uicc applications.
501 serial = GetRandomSerialNumber();
502 radio_v1_5->areUiccApplicationsEnabled(serial);
503 EXPECT_EQ(std::cv_status::no_timeout, wait());
504 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
505 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
506
507 // If SIM is absent, RadioError::SIM_ABSENT should be thrown. Otherwise there shouldn't be any
508 // error.
509 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
510 EXPECT_EQ(RadioError::SIM_ABSENT, radioRsp_v1_5->rspInfo.error);
511 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
512 EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error);
513 }
514 }
515
516 /*
517 * Test IRadio.setSystemSelectionChannels_1_5() for the response returned.
518 */
TEST_P(RadioHidlTest_v1_5,setSystemSelectionChannels_1_5)519 TEST_P(RadioHidlTest_v1_5, setSystemSelectionChannels_1_5) {
520 serial = GetRandomSerialNumber();
521
522 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band3;
523 band3.eutranBands({::android::hardware::radio::V1_5::EutranBands::BAND_3});
524 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band17;
525 band17.eutranBands({::android::hardware::radio::V1_5::EutranBands::BAND_17});
526 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band20;
527 band20.eutranBands({::android::hardware::radio::V1_5::EutranBands::BAND_20});
528 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band40;
529 band40.eutranBands({::android::hardware::radio::V1_5::EutranBands::BAND_40});
530 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifier3 = {
531 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::EUTRAN,
532 .bands = band3,
533 .channels = {1, 2}};
534 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifier17 = {
535 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::EUTRAN,
536 .bands = band17,
537 .channels = {1, 2}};
538 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifier20 = {
539 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::EUTRAN,
540 .bands = band20,
541 .channels = {128, 129}};
542 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifier40 = {
543 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::EUTRAN,
544 .bands = band40,
545 .channels = {128, 129}};
546
547 Return<void> res = radio_v1_5->setSystemSelectionChannels_1_5(
548 serial, true, {specifier3, specifier17, specifier20, specifier40});
549 ASSERT_OK(res);
550 EXPECT_EQ(std::cv_status::no_timeout, wait());
551 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
552 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
553 ALOGI("setSystemSelectionChannels_1_5, rspInfo.error = %s\n",
554 toString(radioRsp_v1_5->rspInfo.error).c_str());
555 ASSERT_TRUE(CheckAnyOfErrors(
556 radioRsp_v1_5->rspInfo.error,
557 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INTERNAL_ERR}));
558
559 if (radioRsp_v1_5->rspInfo.error == RadioError::NONE) {
560 serial = GetRandomSerialNumber();
561 Return<void> res = radio_v1_5->setSystemSelectionChannels_1_5(
562 serial, false, {specifier3, specifier17, specifier20, specifier40});
563 ASSERT_OK(res);
564 EXPECT_EQ(std::cv_status::no_timeout, wait());
565 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
566 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
567 ALOGI("setSystemSelectionChannels_1_5, rspInfo.error = %s\n",
568 toString(radioRsp_v1_5->rspInfo.error).c_str());
569 EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error);
570 }
571 }
572
573 /*
574 * Test IRadio.startNetworkScan_1_5() for the response returned.
575 */
TEST_P(RadioHidlTest_v1_5,startNetworkScan)576 TEST_P(RadioHidlTest_v1_5, startNetworkScan) {
577 serial = GetRandomSerialNumber();
578
579 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band17;
580 band17.eutranBands({::android::hardware::radio::V1_5::EutranBands::BAND_17});
581 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band20;
582 band20.eutranBands({::android::hardware::radio::V1_5::EutranBands::BAND_20});
583 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifier17 = {
584 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::EUTRAN,
585 .bands = band17,
586 .channels = {1, 2}};
587 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifier20 = {
588 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::EUTRAN,
589 .bands = band20,
590 .channels = {128, 129}};
591
592 ::android::hardware::radio::V1_5::NetworkScanRequest request = {
593 .type = ScanType::ONE_SHOT,
594 .interval = 60,
595 .specifiers = {specifier17, specifier20},
596 .maxSearchTime = 60,
597 .incrementalResults = false,
598 .incrementalResultsPeriodicity = 1};
599
600 Return<void> res = radio_v1_5->startNetworkScan_1_5(serial, request);
601 ASSERT_OK(res);
602 EXPECT_EQ(std::cv_status::no_timeout, wait());
603 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
604 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
605 ALOGI("startNetworkScan, rspInfo.error = %s\n", toString(radioRsp_v1_5->rspInfo.error).c_str());
606
607 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
608 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error, {RadioError::SIM_ABSENT}));
609 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
610 // Modems support 3GPP RAT family need to
611 // support scanning requests combined with some parameters.
612 if (deviceSupportsFeature(FEATURE_TELEPHONY_GSM) && isLteConnected()) {
613 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
614 {RadioError::NONE, RadioError::OPERATION_NOT_ALLOWED}));
615 } else {
616 ASSERT_TRUE(CheckAnyOfErrors(
617 radioRsp_v1_5->rspInfo.error,
618 {RadioError::NONE, RadioError::OPERATION_NOT_ALLOWED,
619 RadioError::REQUEST_NOT_SUPPORTED, RadioError::INVALID_ARGUMENTS}));
620 }
621 }
622
623 if (radioRsp_v1_5->rspInfo.error == RadioError::NONE) {
624 ALOGI("Stop Network Scan");
625 stopNetworkScan();
626 }
627 }
628
629 /*
630 * Test IRadio.startNetworkScan_1_5() with invalid specifier.
631 */
TEST_P(RadioHidlTest_v1_5,startNetworkScan_InvalidArgument)632 TEST_P(RadioHidlTest_v1_5, startNetworkScan_InvalidArgument) {
633 serial = GetRandomSerialNumber();
634
635 ::android::hardware::radio::V1_5::NetworkScanRequest request = {.type = ScanType::ONE_SHOT,
636 .interval = 60};
637
638 Return<void> res = radio_v1_5->startNetworkScan_1_5(serial, request);
639 ASSERT_OK(res);
640 EXPECT_EQ(std::cv_status::no_timeout, wait());
641 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
642 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
643 ALOGI("startNetworkScan_InvalidArgument, rspInfo.error = %s\n",
644 toString(radioRsp_v1_5->rspInfo.error).c_str());
645
646 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
647 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
648 {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
649 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
650 ASSERT_TRUE(CheckAnyOfErrors(
651 radioRsp_v1_5->rspInfo.error,
652 {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
653 }
654 }
655
656 /*
657 * Test IRadio.startNetworkScan_1_5() with invalid interval (lower boundary).
658 */
TEST_P(RadioHidlTest_v1_5,startNetworkScan_InvalidInterval1)659 TEST_P(RadioHidlTest_v1_5, startNetworkScan_InvalidInterval1) {
660 serial = GetRandomSerialNumber();
661
662 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands bandP900;
663 bandP900.geranBands() = {GeranBands::BAND_P900};
664 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band850;
665 band850.geranBands() = {GeranBands::BAND_850};
666 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifierP900 = {
667 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::GERAN,
668 .bands = bandP900,
669 .channels = {1, 2}};
670 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifier850 = {
671 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::GERAN,
672 .bands = band850,
673 .channels = {128, 129}};
674
675 ::android::hardware::radio::V1_5::NetworkScanRequest request = {
676 .type = ScanType::PERIODIC,
677 .interval = 4,
678 .specifiers = {specifierP900, specifier850},
679 .maxSearchTime = 60,
680 .incrementalResults = false,
681 .incrementalResultsPeriodicity = 1};
682
683 Return<void> res = radio_v1_5->startNetworkScan_1_5(serial, request);
684 ASSERT_OK(res);
685 EXPECT_EQ(std::cv_status::no_timeout, wait());
686 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
687 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
688 ALOGI("startNetworkScan_InvalidInterval1, rspInfo.error = %s\n",
689 toString(radioRsp_v1_5->rspInfo.error).c_str());
690 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
691 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
692 {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
693 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
694 ASSERT_TRUE(CheckAnyOfErrors(
695 radioRsp_v1_5->rspInfo.error,
696 {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
697 }
698 }
699
700 /*
701 * Test IRadio.startNetworkScan_1_5() with invalid interval (upper boundary).
702 */
TEST_P(RadioHidlTest_v1_5,startNetworkScan_InvalidInterval2)703 TEST_P(RadioHidlTest_v1_5, startNetworkScan_InvalidInterval2) {
704 serial = GetRandomSerialNumber();
705
706 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands bandP900;
707 bandP900.geranBands() = {GeranBands::BAND_P900};
708 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band850;
709 band850.geranBands() = {GeranBands::BAND_850};
710 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifierP900 = {
711 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::GERAN,
712 .bands = bandP900,
713 .channels = {1, 2}};
714 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifier850 = {
715 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::GERAN,
716 .bands = band850,
717 .channels = {128, 129}};
718
719 ::android::hardware::radio::V1_5::NetworkScanRequest request = {
720 .type = ScanType::PERIODIC,
721 .interval = 301,
722 .specifiers = {specifierP900, specifier850},
723 .maxSearchTime = 60,
724 .incrementalResults = false,
725 .incrementalResultsPeriodicity = 1};
726
727 Return<void> res = radio_v1_5->startNetworkScan_1_5(serial, request);
728 ASSERT_OK(res);
729 EXPECT_EQ(std::cv_status::no_timeout, wait());
730 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
731 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
732 ALOGI("startNetworkScan_InvalidInterval2, rspInfo.error = %s\n",
733 toString(radioRsp_v1_5->rspInfo.error).c_str());
734 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
735 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
736 {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
737 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
738 ASSERT_TRUE(CheckAnyOfErrors(
739 radioRsp_v1_5->rspInfo.error,
740 {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
741 }
742 }
743
744 /*
745 * Test IRadio.startNetworkScan_1_5() with invalid max search time (lower boundary).
746 */
TEST_P(RadioHidlTest_v1_5,startNetworkScan_InvalidMaxSearchTime1)747 TEST_P(RadioHidlTest_v1_5, startNetworkScan_InvalidMaxSearchTime1) {
748 serial = GetRandomSerialNumber();
749
750 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands bandP900;
751 bandP900.geranBands() = {GeranBands::BAND_P900};
752 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band850;
753 band850.geranBands() = {GeranBands::BAND_850};
754 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifierP900 = {
755 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::GERAN,
756 .bands = bandP900,
757 .channels = {1, 2}};
758 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifier850 = {
759 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::GERAN,
760 .bands = band850,
761 .channels = {128, 129}};
762
763 ::android::hardware::radio::V1_5::NetworkScanRequest request = {
764 .type = ScanType::ONE_SHOT,
765 .interval = 60,
766 .specifiers = {specifierP900, specifier850},
767 .maxSearchTime = 59,
768 .incrementalResults = false,
769 .incrementalResultsPeriodicity = 1};
770
771 Return<void> res = radio_v1_5->startNetworkScan_1_5(serial, request);
772 ASSERT_OK(res);
773 EXPECT_EQ(std::cv_status::no_timeout, wait());
774 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
775 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
776 ALOGI("startNetworkScan_InvalidMaxSearchTime1, rspInfo.error = %s\n",
777 toString(radioRsp_v1_5->rspInfo.error).c_str());
778 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
779 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
780 {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
781 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
782 ASSERT_TRUE(CheckAnyOfErrors(
783 radioRsp_v1_5->rspInfo.error,
784 {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
785 }
786 }
787
788 /*
789 * Test IRadio.startNetworkScan_1_5() with invalid max search time (upper boundary).
790 */
TEST_P(RadioHidlTest_v1_5,startNetworkScan_InvalidMaxSearchTime2)791 TEST_P(RadioHidlTest_v1_5, startNetworkScan_InvalidMaxSearchTime2) {
792 serial = GetRandomSerialNumber();
793
794 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands bandP900;
795 bandP900.geranBands() = {GeranBands::BAND_P900};
796 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band850;
797 band850.geranBands() = {GeranBands::BAND_850};
798 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifierP900 = {
799 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::GERAN,
800 .bands = bandP900,
801 .channels = {1, 2}};
802 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifier850 = {
803 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::GERAN,
804 .bands = band850,
805 .channels = {128, 129}};
806
807 ::android::hardware::radio::V1_5::NetworkScanRequest request = {
808 .type = ScanType::ONE_SHOT,
809 .interval = 60,
810 .specifiers = {specifierP900, specifier850},
811 .maxSearchTime = 3601,
812 .incrementalResults = false,
813 .incrementalResultsPeriodicity = 1};
814
815 Return<void> res = radio_v1_5->startNetworkScan_1_5(serial, request);
816 ASSERT_OK(res);
817 EXPECT_EQ(std::cv_status::no_timeout, wait());
818 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
819 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
820 ALOGI("startNetworkScan_InvalidMaxSearchTime2, rspInfo.error = %s\n",
821 toString(radioRsp_v1_5->rspInfo.error).c_str());
822 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
823 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
824 {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
825 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
826 ASSERT_TRUE(CheckAnyOfErrors(
827 radioRsp_v1_5->rspInfo.error,
828 {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
829 }
830 }
831
832 /*
833 * Test IRadio.startNetworkScan_1_5() with invalid periodicity (lower boundary).
834 */
TEST_P(RadioHidlTest_v1_5,startNetworkScan_InvalidPeriodicity1)835 TEST_P(RadioHidlTest_v1_5, startNetworkScan_InvalidPeriodicity1) {
836 serial = GetRandomSerialNumber();
837
838 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands bandP900;
839 bandP900.geranBands() = {GeranBands::BAND_P900};
840 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band850;
841 band850.geranBands() = {GeranBands::BAND_850};
842 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifierP900 = {
843 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::GERAN,
844 .bands = bandP900,
845 .channels = {1, 2}};
846 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifier850 = {
847 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::GERAN,
848 .bands = band850,
849 .channels = {128, 129}};
850
851 ::android::hardware::radio::V1_5::NetworkScanRequest request = {
852 .type = ScanType::ONE_SHOT,
853 .interval = 60,
854 .specifiers = {specifierP900, specifier850},
855 .maxSearchTime = 600,
856 .incrementalResults = true,
857 .incrementalResultsPeriodicity = 0};
858
859 Return<void> res = radio_v1_5->startNetworkScan_1_5(serial, request);
860 ASSERT_OK(res);
861 EXPECT_EQ(std::cv_status::no_timeout, wait());
862 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
863 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
864 ALOGI("startNetworkScan_InvalidPeriodicity1, rspInfo.error = %s\n",
865 toString(radioRsp_v1_5->rspInfo.error).c_str());
866 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
867 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
868 {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
869 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
870 ASSERT_TRUE(CheckAnyOfErrors(
871 radioRsp_v1_5->rspInfo.error,
872 {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
873 }
874 }
875
876 /*
877 * Test IRadio.startNetworkScan_1_5() with invalid periodicity (upper boundary).
878 */
TEST_P(RadioHidlTest_v1_5,startNetworkScan_InvalidPeriodicity2)879 TEST_P(RadioHidlTest_v1_5, startNetworkScan_InvalidPeriodicity2) {
880 serial = GetRandomSerialNumber();
881
882 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands bandP900;
883 bandP900.geranBands() = {GeranBands::BAND_P900};
884 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band850;
885 band850.geranBands() = {GeranBands::BAND_850};
886 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifierP900 = {
887 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::GERAN,
888 .bands = bandP900,
889 .channels = {1, 2}};
890 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifier850 = {
891 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::GERAN,
892 .bands = band850,
893 .channels = {128, 129}};
894
895 ::android::hardware::radio::V1_5::NetworkScanRequest request = {
896 .type = ScanType::ONE_SHOT,
897 .interval = 60,
898 .specifiers = {specifierP900, specifier850},
899 .maxSearchTime = 600,
900 .incrementalResults = true,
901 .incrementalResultsPeriodicity = 11};
902
903 Return<void> res = radio_v1_5->startNetworkScan_1_5(serial, request);
904 ASSERT_OK(res);
905 EXPECT_EQ(std::cv_status::no_timeout, wait());
906 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
907 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
908 ALOGI("startNetworkScan_InvalidPeriodicity2, rspInfo.error = %s\n",
909 toString(radioRsp_v1_5->rspInfo.error).c_str());
910 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
911 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
912 {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
913 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
914 ASSERT_TRUE(CheckAnyOfErrors(
915 radioRsp_v1_5->rspInfo.error,
916 {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
917 }
918 }
919
920 /*
921 * Test IRadio.startNetworkScan_1_5() with valid periodicity
922 */
TEST_P(RadioHidlTest_v1_5,startNetworkScan_GoodRequest1)923 TEST_P(RadioHidlTest_v1_5, startNetworkScan_GoodRequest1) {
924 serial = GetRandomSerialNumber();
925
926 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands bandP900;
927 bandP900.geranBands() = {GeranBands::BAND_P900};
928 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band850;
929 band850.geranBands() = {GeranBands::BAND_850};
930 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifierP900 = {
931 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::GERAN,
932 .bands = bandP900,
933 .channels = {1, 2}};
934 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifier850 = {
935 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::GERAN,
936 .bands = band850,
937 .channels = {128, 129}};
938
939 ::android::hardware::radio::V1_5::NetworkScanRequest request = {
940 .type = ScanType::ONE_SHOT,
941 .interval = 60,
942 .specifiers = {specifierP900, specifier850},
943 .maxSearchTime = 360,
944 .incrementalResults = false,
945 .incrementalResultsPeriodicity = 10};
946
947 Return<void> res = radio_v1_5->startNetworkScan_1_5(serial, request);
948 ASSERT_OK(res);
949 EXPECT_EQ(std::cv_status::no_timeout, wait());
950 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
951 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
952 ALOGI("startNetworkScan_GoodRequest1, rspInfo.error = %s\n",
953 toString(radioRsp_v1_5->rspInfo.error).c_str());
954 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
955 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
956 {RadioError::NONE, RadioError::SIM_ABSENT}));
957 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
958 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
959 {RadioError::NONE, RadioError::INVALID_ARGUMENTS,
960 RadioError::REQUEST_NOT_SUPPORTED}));
961 }
962
963 if (radioRsp_v1_5->rspInfo.error == RadioError::NONE) {
964 ALOGI("Stop Network Scan");
965 stopNetworkScan();
966 }
967 }
968
969 /*
970 * Test IRadio.startNetworkScan_1_5() with valid periodicity and plmns
971 */
TEST_P(RadioHidlTest_v1_5,startNetworkScan_GoodRequest2)972 TEST_P(RadioHidlTest_v1_5, startNetworkScan_GoodRequest2) {
973 serial = GetRandomSerialNumber();
974
975 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands bandP900;
976 bandP900.geranBands() = {GeranBands::BAND_P900};
977 ::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band850;
978 band850.geranBands() = {GeranBands::BAND_850};
979 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifierP900 = {
980 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::GERAN,
981 .bands = bandP900,
982 .channels = {1, 2}};
983 ::android::hardware::radio::V1_5::RadioAccessSpecifier specifier850 = {
984 .radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::GERAN,
985 .bands = band850,
986 .channels = {128, 129}};
987
988 ::android::hardware::radio::V1_5::NetworkScanRequest request = {
989 .type = ScanType::ONE_SHOT,
990 .interval = 60,
991 .specifiers = {specifierP900, specifier850},
992 .maxSearchTime = 360,
993 .incrementalResults = false,
994 .incrementalResultsPeriodicity = 10,
995 .mccMncs = {"310410"}};
996
997 Return<void> res = radio_v1_5->startNetworkScan_1_5(serial, request);
998 ASSERT_OK(res);
999 EXPECT_EQ(std::cv_status::no_timeout, wait());
1000 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
1001 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
1002 ALOGI("startNetworkScan_GoodRequest2, rspInfo.error = %s\n",
1003 toString(radioRsp_v1_5->rspInfo.error).c_str());
1004 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
1005 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
1006 {RadioError::NONE, RadioError::SIM_ABSENT}));
1007 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
1008 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
1009 {RadioError::NONE, RadioError::INVALID_ARGUMENTS,
1010 RadioError::REQUEST_NOT_SUPPORTED}));
1011 }
1012
1013 if (radioRsp_v1_5->rspInfo.error == RadioError::NONE) {
1014 ALOGI("Stop Network Scan");
1015 stopNetworkScan();
1016 }
1017 }
1018
1019 /*
1020 * Test IRadio.setupDataCall_1_5() for the response returned.
1021 */
TEST_P(RadioHidlTest_v1_5,setupDataCall_1_5)1022 TEST_P(RadioHidlTest_v1_5, setupDataCall_1_5) {
1023 serial = GetRandomSerialNumber();
1024
1025 ::android::hardware::radio::V1_5::AccessNetwork accessNetwork =
1026 ::android::hardware::radio::V1_5::AccessNetwork::EUTRAN;
1027
1028 android::hardware::radio::V1_5::DataProfileInfo dataProfileInfo;
1029 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
1030 dataProfileInfo.profileId = DataProfileId::DEFAULT;
1031 dataProfileInfo.apn = hidl_string("internet");
1032 dataProfileInfo.protocol = PdpProtocolType::IP;
1033 dataProfileInfo.roamingProtocol = PdpProtocolType::IP;
1034 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
1035 dataProfileInfo.user = hidl_string("username");
1036 dataProfileInfo.password = hidl_string("password");
1037 dataProfileInfo.type = DataProfileInfoType::THREE_GPP;
1038 dataProfileInfo.maxConnsTime = 300;
1039 dataProfileInfo.maxConns = 20;
1040 dataProfileInfo.waitTime = 0;
1041 dataProfileInfo.enabled = true;
1042 dataProfileInfo.supportedApnTypesBitmap = 320;
1043 dataProfileInfo.bearerBitmap = 161543;
1044 dataProfileInfo.mtuV4 = 0;
1045 dataProfileInfo.mtuV6 = 0;
1046 dataProfileInfo.preferred = true;
1047 dataProfileInfo.persistent = false;
1048
1049 bool roamingAllowed = false;
1050
1051 std::vector<::android::hardware::radio::V1_5::LinkAddress> addresses = {};
1052 std::vector<hidl_string> dnses = {};
1053
1054 ::android::hardware::radio::V1_2::DataRequestReason reason =
1055 ::android::hardware::radio::V1_2::DataRequestReason::NORMAL;
1056
1057 Return<void> res = radio_v1_5->setupDataCall_1_5(serial, accessNetwork, dataProfileInfo,
1058 roamingAllowed, reason, addresses, dnses);
1059 ASSERT_OK(res);
1060
1061 EXPECT_EQ(std::cv_status::no_timeout, wait());
1062 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
1063 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
1064
1065 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
1066 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
1067 {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE,
1068 RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW}));
1069 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
1070 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
1071 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
1072 RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW}));
1073 }
1074 }
1075
1076 /*
1077 * Test IRadio.setInitialAttachApn_1_5() for the response returned.
1078 */
TEST_P(RadioHidlTest_v1_5,setInitialAttachApn_1_5)1079 TEST_P(RadioHidlTest_v1_5, setInitialAttachApn_1_5) {
1080 serial = GetRandomSerialNumber();
1081
1082 // Create a dataProfileInfo
1083 android::hardware::radio::V1_5::DataProfileInfo dataProfileInfo;
1084 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
1085 dataProfileInfo.profileId = DataProfileId::DEFAULT;
1086 dataProfileInfo.apn = hidl_string("internet");
1087 dataProfileInfo.protocol = PdpProtocolType::IPV4V6;
1088 dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6;
1089 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
1090 dataProfileInfo.user = hidl_string("username");
1091 dataProfileInfo.password = hidl_string("password");
1092 dataProfileInfo.type = DataProfileInfoType::THREE_GPP;
1093 dataProfileInfo.maxConnsTime = 300;
1094 dataProfileInfo.maxConns = 20;
1095 dataProfileInfo.waitTime = 0;
1096 dataProfileInfo.enabled = true;
1097 dataProfileInfo.supportedApnTypesBitmap = 320;
1098 dataProfileInfo.bearerBitmap = 161543;
1099 dataProfileInfo.mtuV4 = 0;
1100 dataProfileInfo.mtuV6 = 0;
1101 dataProfileInfo.preferred = true;
1102 dataProfileInfo.persistent = false;
1103
1104 radio_v1_5->setInitialAttachApn_1_5(serial, dataProfileInfo);
1105
1106 EXPECT_EQ(std::cv_status::no_timeout, wait());
1107 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
1108 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
1109
1110 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
1111 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
1112 {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE}));
1113 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
1114 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
1115 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE}));
1116 }
1117 }
1118
1119 /*
1120 * Test IRadio.setDataProfile_1_5() for the response returned.
1121 */
TEST_P(RadioHidlTest_v1_5,setDataProfile_1_5)1122 TEST_P(RadioHidlTest_v1_5, setDataProfile_1_5) {
1123 serial = GetRandomSerialNumber();
1124
1125 // Create a dataProfileInfo
1126 android::hardware::radio::V1_5::DataProfileInfo dataProfileInfo;
1127 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
1128 dataProfileInfo.profileId = DataProfileId::DEFAULT;
1129 dataProfileInfo.apn = hidl_string("internet");
1130 dataProfileInfo.protocol = PdpProtocolType::IPV4V6;
1131 dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6;
1132 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
1133 dataProfileInfo.user = hidl_string("username");
1134 dataProfileInfo.password = hidl_string("password");
1135 dataProfileInfo.type = DataProfileInfoType::THREE_GPP;
1136 dataProfileInfo.maxConnsTime = 300;
1137 dataProfileInfo.maxConns = 20;
1138 dataProfileInfo.waitTime = 0;
1139 dataProfileInfo.enabled = true;
1140 dataProfileInfo.supportedApnTypesBitmap = 320;
1141 dataProfileInfo.bearerBitmap = 161543;
1142 dataProfileInfo.mtuV4 = 0;
1143 dataProfileInfo.mtuV6 = 0;
1144 dataProfileInfo.preferred = true;
1145 dataProfileInfo.persistent = true;
1146
1147 // Create a dataProfileInfoList
1148 android::hardware::hidl_vec<android::hardware::radio::V1_5::DataProfileInfo>
1149 dataProfileInfoList = {dataProfileInfo};
1150
1151 radio_v1_5->setDataProfile_1_5(serial, dataProfileInfoList);
1152
1153 EXPECT_EQ(std::cv_status::no_timeout, wait());
1154 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
1155 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
1156
1157 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
1158 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
1159 {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE}));
1160 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
1161 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
1162 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE}));
1163 }
1164 }
1165
1166 /*
1167 * Test IRadio.setRadioPower_1_5() for the response returned.
1168 */
TEST_P(RadioHidlTest_v1_5,setRadioPower_1_5_emergencyCall_cancelled)1169 TEST_P(RadioHidlTest_v1_5, setRadioPower_1_5_emergencyCall_cancelled) {
1170 // Set radio power to off.
1171 serial = GetRandomSerialNumber();
1172 radio_v1_5->setRadioPower_1_5(serial, false, false, false);
1173 EXPECT_EQ(std::cv_status::no_timeout, wait());
1174 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
1175 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
1176 EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error);
1177
1178 // Set radio power to on with forEmergencyCall being true. This should put modem to only scan
1179 // emergency call bands.
1180 serial = GetRandomSerialNumber();
1181 radio_v1_5->setRadioPower_1_5(serial, true, true, true);
1182 EXPECT_EQ(std::cv_status::no_timeout, wait());
1183 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
1184 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
1185 EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error);
1186
1187 // Set radio power to on with forEmergencyCall being false. This should put modem in regular
1188 // operation modem.
1189 serial = GetRandomSerialNumber();
1190 radio_v1_5->setRadioPower_1_5(serial, true, false, false);
1191 EXPECT_EQ(std::cv_status::no_timeout, wait());
1192 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
1193 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
1194 EXPECT_EQ(RadioError::NONE, radioRsp_v1_5->rspInfo.error);
1195 }
1196
1197 /*
1198 * Test IRadio.setNetworkSelectionModeManual_1_5() for the response returned.
1199 */
TEST_P(RadioHidlTest_v1_5,setNetworkSelectionModeManual_1_5)1200 TEST_P(RadioHidlTest_v1_5, setNetworkSelectionModeManual_1_5) {
1201 serial = GetRandomSerialNumber();
1202
1203 // can't camp on nonexistent MCCMNC, so we expect this to fail.
1204 Return<void> res = radio_v1_5->setNetworkSelectionModeManual_1_5(
1205 serial, "123456", android::hardware::radio::V1_5::RadioAccessNetworks::EUTRAN);
1206 EXPECT_EQ(std::cv_status::no_timeout, wait());
1207 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
1208 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
1209 ALOGI("setNetworkSelectionModeManual_1_5, rspInfo.error = %s\n",
1210 toString(radioRsp_v1_5->rspInfo.error).c_str());
1211 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
1212 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
1213 {RadioError::NONE, RadioError::ILLEGAL_SIM_OR_ME,
1214 RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE},
1215 CHECK_GENERAL_ERROR));
1216 } else if (cardStatus.base.base.base.cardState == CardState::PRESENT) {
1217 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
1218 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
1219 RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE},
1220 CHECK_GENERAL_ERROR));
1221 }
1222 }
1223
1224 /*
1225 * Test IRadio.sendCdmaSmsExpectMore() for the response returned.
1226 */
TEST_P(RadioHidlTest_v1_5,sendCdmaSmsExpectMore)1227 TEST_P(RadioHidlTest_v1_5, sendCdmaSmsExpectMore) {
1228 serial = GetRandomSerialNumber();
1229
1230 // Create a CdmaSmsAddress
1231 CdmaSmsAddress cdmaSmsAddress;
1232 cdmaSmsAddress.digitMode = CdmaSmsDigitMode::FOUR_BIT;
1233 cdmaSmsAddress.numberMode = CdmaSmsNumberMode::NOT_DATA_NETWORK;
1234 cdmaSmsAddress.numberType = CdmaSmsNumberType::UNKNOWN;
1235 cdmaSmsAddress.numberPlan = CdmaSmsNumberPlan::UNKNOWN;
1236 cdmaSmsAddress.digits = (std::vector<uint8_t>){11, 1, 6, 5, 10, 7, 7, 2, 10, 3, 10, 3};
1237
1238 // Create a CdmaSmsSubAddress
1239 CdmaSmsSubaddress cdmaSmsSubaddress;
1240 cdmaSmsSubaddress.subaddressType = CdmaSmsSubaddressType::NSAP;
1241 cdmaSmsSubaddress.odd = false;
1242 cdmaSmsSubaddress.digits = (std::vector<uint8_t>){};
1243
1244 // Create a CdmaSmsMessage
1245 android::hardware::radio::V1_0::CdmaSmsMessage cdmaSmsMessage;
1246 cdmaSmsMessage.teleserviceId = 4098;
1247 cdmaSmsMessage.isServicePresent = false;
1248 cdmaSmsMessage.serviceCategory = 0;
1249 cdmaSmsMessage.address = cdmaSmsAddress;
1250 cdmaSmsMessage.subAddress = cdmaSmsSubaddress;
1251 cdmaSmsMessage.bearerData =
1252 (std::vector<uint8_t>){15, 0, 3, 32, 3, 16, 1, 8, 16, 53, 76, 68, 6, 51, 106, 0};
1253
1254 radio_v1_5->sendCdmaSmsExpectMore(serial, cdmaSmsMessage);
1255
1256 EXPECT_EQ(std::cv_status::no_timeout, wait());
1257 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
1258 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
1259
1260 if (cardStatus.base.base.base.cardState == CardState::ABSENT) {
1261 ASSERT_TRUE(CheckAnyOfErrors(
1262 radioRsp_v1_5->rspInfo.error,
1263 {RadioError::INVALID_ARGUMENTS, RadioError::INVALID_STATE, RadioError::SIM_ABSENT},
1264 CHECK_GENERAL_ERROR));
1265 }
1266 }
1267
1268 /*
1269 * Test IRadio.getBarringInfo() for the response returned.
1270 */
TEST_P(RadioHidlTest_v1_5,getBarringInfo)1271 TEST_P(RadioHidlTest_v1_5, getBarringInfo) {
1272 // If the previous setRadioPower_1_5_emergencyCall_cancelled test has just finished.
1273 // Due to radio restarting, modem may need a little more time to acquire network service
1274 // and barring infos. If voice status is in-service, waiting 3s to get barring infos ready.
1275 // Or waiting 10s if voice status is not in-service.
1276 serial = GetRandomSerialNumber();
1277 radio_v1_5->getVoiceRegistrationState_1_5(serial);
1278 EXPECT_EQ(std::cv_status::no_timeout, wait());
1279 if (isVoiceInService(radioRsp_v1_5->voiceRegResp.regState)) {
1280 sleep(BARRING_INFO_MAX_WAIT_TIME_SECONDS);
1281 } else {
1282 sleep(VOICE_SERVICE_MAX_WAIT_TIME_SECONDS);
1283 }
1284
1285 serial = GetRandomSerialNumber();
1286 Return<void> res = radio_v1_5->getBarringInfo(serial);
1287 EXPECT_EQ(std::cv_status::no_timeout, wait());
1288 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_v1_5->rspInfo.type);
1289 EXPECT_EQ(serial, radioRsp_v1_5->rspInfo.serial);
1290
1291 int32_t firstApiLevel = android::base::GetIntProperty<int32_t>("ro.product.first_api_level", 0);
1292 int32_t boardApiLevel = android::base::GetIntProperty<int32_t>("ro.board.first_api_level", 0);
1293 // Allow devices shipping with Radio::1_5 and Android 11 to not support barring info.
1294 // b/212384410 Some GRF targets lauched with S release but with vendor R release
1295 // do not support getBarringInfo API. Allow these devices to not support barring info.
1296 if ((firstApiLevel > 0 && firstApiLevel <= 30) ||
1297 (boardApiLevel > 0 && boardApiLevel <= 30)) {
1298 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_v1_5->rspInfo.error,
1299 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
1300 // Early exit for devices that don't support barring info.
1301 if (radioRsp_v1_5->rspInfo.error != RadioError::NONE) {
1302 return;
1303 }
1304 }
1305
1306 ASSERT_TRUE(radioRsp_v1_5->barringInfos.size() > 0);
1307
1308 std::set<BarringInfo::ServiceType> reportedServices;
1309
1310 // validate that the service types are in range
1311 for (const auto& info : radioRsp_v1_5->barringInfos) {
1312 ASSERT_TRUE((info.serviceType >= BarringInfo::ServiceType::CS_SERVICE &&
1313 info.serviceType <= BarringInfo::ServiceType::SMS) ||
1314 (info.serviceType >= BarringInfo::ServiceType::OPERATOR_1 &&
1315 info.serviceType <= BarringInfo::ServiceType::OPERATOR_32));
1316 reportedServices.insert(info.serviceType);
1317
1318 // Any type that is "conditional" must have valid values for conditional barring
1319 // factor and time.
1320 switch (info.barringType) {
1321 case BarringInfo::BarringType::NONE: // fall through
1322 case BarringInfo::BarringType::UNCONDITIONAL:
1323 break;
1324 case BarringInfo::BarringType::CONDITIONAL: {
1325 const int32_t barringFactor = info.barringTypeSpecificInfo.conditional().factor;
1326 ASSERT_TRUE(barringFactor >= 0 && barringFactor <= 100);
1327 ASSERT_TRUE(info.barringTypeSpecificInfo.conditional().timeSeconds > 0);
1328 break;
1329 }
1330 default:
1331 FAIL();
1332 }
1333 }
1334
1335 // Certain types of barring are relevant for certain RANs. Ensure that only the right
1336 // types are reported. Note that no types are required, simply that for a given technology
1337 // only certain types are valid. This is one way to check that implementations are
1338 // not providing information that they don't have.
1339 static const std::set<BarringInfo::ServiceType> UTRA_SERVICES{
1340 BarringInfo::ServiceType::CS_SERVICE, BarringInfo::ServiceType::PS_SERVICE,
1341 BarringInfo::ServiceType::CS_VOICE, BarringInfo::ServiceType::EMERGENCY,
1342 BarringInfo::ServiceType::SMS,
1343 };
1344
1345 static const std::set<BarringInfo::ServiceType> EUTRA_SERVICES{
1346 BarringInfo::ServiceType::MO_SIGNALLING, BarringInfo::ServiceType::MO_DATA,
1347 BarringInfo::ServiceType::CS_FALLBACK, BarringInfo::ServiceType::MMTEL_VOICE,
1348 BarringInfo::ServiceType::MMTEL_VIDEO, BarringInfo::ServiceType::EMERGENCY,
1349 BarringInfo::ServiceType::SMS,
1350 };
1351
1352 static const std::set<BarringInfo::ServiceType> NGRA_SERVICES = {
1353 BarringInfo::ServiceType::MO_SIGNALLING, BarringInfo::ServiceType::MO_DATA,
1354 BarringInfo::ServiceType::CS_FALLBACK, BarringInfo::ServiceType::MMTEL_VOICE,
1355 BarringInfo::ServiceType::MMTEL_VIDEO, BarringInfo::ServiceType::EMERGENCY,
1356 BarringInfo::ServiceType::SMS, BarringInfo::ServiceType::OPERATOR_1,
1357 BarringInfo::ServiceType::OPERATOR_2, BarringInfo::ServiceType::OPERATOR_3,
1358 BarringInfo::ServiceType::OPERATOR_4, BarringInfo::ServiceType::OPERATOR_5,
1359 BarringInfo::ServiceType::OPERATOR_6, BarringInfo::ServiceType::OPERATOR_7,
1360 BarringInfo::ServiceType::OPERATOR_8, BarringInfo::ServiceType::OPERATOR_9,
1361 BarringInfo::ServiceType::OPERATOR_10, BarringInfo::ServiceType::OPERATOR_11,
1362 BarringInfo::ServiceType::OPERATOR_12, BarringInfo::ServiceType::OPERATOR_13,
1363 BarringInfo::ServiceType::OPERATOR_14, BarringInfo::ServiceType::OPERATOR_15,
1364 BarringInfo::ServiceType::OPERATOR_16, BarringInfo::ServiceType::OPERATOR_17,
1365 BarringInfo::ServiceType::OPERATOR_18, BarringInfo::ServiceType::OPERATOR_19,
1366 BarringInfo::ServiceType::OPERATOR_20, BarringInfo::ServiceType::OPERATOR_21,
1367 BarringInfo::ServiceType::OPERATOR_22, BarringInfo::ServiceType::OPERATOR_23,
1368 BarringInfo::ServiceType::OPERATOR_24, BarringInfo::ServiceType::OPERATOR_25,
1369 BarringInfo::ServiceType::OPERATOR_26, BarringInfo::ServiceType::OPERATOR_27,
1370 BarringInfo::ServiceType::OPERATOR_28, BarringInfo::ServiceType::OPERATOR_29,
1371 BarringInfo::ServiceType::OPERATOR_30, BarringInfo::ServiceType::OPERATOR_31,
1372 };
1373
1374 const std::set<BarringInfo::ServiceType>* compareTo = nullptr;
1375
1376 switch (radioRsp_v1_5->barringCellIdentity.getDiscriminator()) {
1377 case android::hardware::radio::V1_5::CellIdentity::hidl_discriminator::wcdma:
1378 // fall through
1379 case android::hardware::radio::V1_5::CellIdentity::hidl_discriminator::tdscdma:
1380 compareTo = &UTRA_SERVICES;
1381 break;
1382 case android::hardware::radio::V1_5::CellIdentity::hidl_discriminator::lte:
1383 compareTo = &EUTRA_SERVICES;
1384 break;
1385 case android::hardware::radio::V1_5::CellIdentity::hidl_discriminator::nr:
1386 compareTo = &NGRA_SERVICES;
1387 break;
1388
1389 case android::hardware::radio::V1_5::CellIdentity::hidl_discriminator::cdma:
1390 // fall through
1391 default:
1392 FAIL();
1393 break;
1394 }
1395
1396 std::set<BarringInfo::ServiceType> diff;
1397
1398 std::set_difference(reportedServices.begin(), reportedServices.end(), compareTo->begin(),
1399 compareTo->end(), std::inserter(diff, diff.begin()));
1400 }
1401