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