1 /*
2 * Copyright (C) 2021 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 <aidl/android/hardware/radio/RadioAccessFamily.h>
18 #include <aidl/android/hardware/radio/config/IRadioConfig.h>
19 #include <aidl/android/hardware/radio/network/IndicationFilter.h>
20 #include <android/binder_manager.h>
21
22 #include "radio_network_utils.h"
23
24 #define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
25
26 namespace {
27 const RadioAccessSpecifierBands EUTRAN_BAND_17 =
28 RadioAccessSpecifierBands::make<RadioAccessSpecifierBands::eutranBands>(
29 {EutranBands::BAND_17});
30 const RadioAccessSpecifierBands EUTRAN_BAND_20 =
31 RadioAccessSpecifierBands::make<RadioAccessSpecifierBands::eutranBands>(
32 {EutranBands::BAND_20});
33 const RadioAccessSpecifier EUTRAN_SPECIFIER_17 = {
34 .accessNetwork = AccessNetwork::EUTRAN, .bands = EUTRAN_BAND_17, .channels = {1, 2}};
35 const RadioAccessSpecifier EUTRAN_SPECIFIER_20 = {
36 .accessNetwork = AccessNetwork::EUTRAN, .bands = EUTRAN_BAND_20, .channels = {128, 129}};
37 } // namespace
38
SetUp()39 void RadioNetworkTest::SetUp() {
40 RadioServiceTest::SetUp();
41 std::string serviceName = GetParam();
42
43 if (!isServiceValidForDeviceConfiguration(serviceName)) {
44 ALOGI("Skipped the test due to device configuration.");
45 GTEST_SKIP();
46 }
47
48 radio_network = IRadioNetwork::fromBinder(
49 ndk::SpAIBinder(AServiceManager_waitForService(GetParam().c_str())));
50 ASSERT_NE(nullptr, radio_network.get());
51
52 radioRsp_network = ndk::SharedRefBase::make<RadioNetworkResponse>(*this);
53 ASSERT_NE(nullptr, radioRsp_network.get());
54
55 radioInd_network = ndk::SharedRefBase::make<RadioNetworkIndication>(*this);
56 ASSERT_NE(nullptr, radioInd_network.get());
57
58 radio_network->setResponseFunctions(radioRsp_network, radioInd_network);
59
60 // Assert IRadioSim exists and SIM is present before testing
61 radio_sim = sim::IRadioSim::fromBinder(ndk::SpAIBinder(
62 AServiceManager_waitForService("android.hardware.radio.sim.IRadioSim/slot1")));
63 ASSERT_NE(nullptr, radio_sim.get());
64 updateSimCardStatus();
65 EXPECT_EQ(CardStatus::STATE_PRESENT, cardStatus.cardState);
66
67 // Assert IRadioConfig exists before testing
68 radio_config = config::IRadioConfig::fromBinder(ndk::SpAIBinder(
69 AServiceManager_waitForService("android.hardware.radio.config.IRadioConfig/default")));
70 ASSERT_NE(nullptr, radio_config.get());
71 }
72
stopNetworkScan()73 void RadioNetworkTest::stopNetworkScan() {
74 serial = GetRandomSerialNumber();
75 radio_network->stopNetworkScan(serial);
76 EXPECT_EQ(std::cv_status::no_timeout, wait());
77 }
78
79 /*
80 * Test IRadioNetwork.setAllowedNetworkTypesBitmap and IRadioNetwork.getAllowedNetworkTypesBitmap
81 * for the response returned.
82 */
TEST_P(RadioNetworkTest,setGetAllowedNetworkTypesBitmap)83 TEST_P(RadioNetworkTest, setGetAllowedNetworkTypesBitmap) {
84 if (telephony_flags::enforce_telephony_feature_mapping()) {
85 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
86 GTEST_SKIP() << "Skipping setGetAllowedNetworkTypesBitmap "
87 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
88 }
89 }
90
91 serial = GetRandomSerialNumber();
92
93 // get aidl version
94 int32_t aidl_version;
95 ndk::ScopedAStatus aidl_status = radio_network->getInterfaceVersion(&aidl_version);
96 ASSERT_OK(aidl_status);
97
98 // save current value
99 radio_network->getAllowedNetworkTypesBitmap(serial);
100 EXPECT_EQ(std::cv_status::no_timeout, wait());
101 int32_t currentAllowedNetworkTypesBitmap = radioRsp_network->networkTypeBitmapResponse;
102
103 // set new value
104 int32_t allowedNetworkTypesBitmap = static_cast<int32_t>(RadioAccessFamily::LTE);
105 serial = GetRandomSerialNumber();
106 radio_network->setAllowedNetworkTypesBitmap(serial, allowedNetworkTypesBitmap);
107
108 EXPECT_EQ(std::cv_status::no_timeout, wait());
109 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
110 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
111 ASSERT_TRUE(CheckAnyOfErrors(
112 radioRsp_network->rspInfo.error,
113 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::OPERATION_NOT_ALLOWED,
114 RadioError::MODE_NOT_SUPPORTED, RadioError::INTERNAL_ERR, RadioError::MODEM_ERR,
115 RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED,
116 RadioError::NO_RESOURCES}));
117
118 if (radioRsp_network->rspInfo.error == RadioError::NONE) {
119 sleep(3); // wait for modem
120 serial = GetRandomSerialNumber();
121 radio_network->getAllowedNetworkTypesBitmap(serial);
122
123 EXPECT_EQ(std::cv_status::no_timeout, wait());
124 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
125 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
126 ASSERT_TRUE(CheckAnyOfErrors(
127 radioRsp_network->rspInfo.error,
128 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INTERNAL_ERR,
129 RadioError::OPERATION_NOT_ALLOWED, RadioError::MODE_NOT_SUPPORTED,
130 RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR,
131 RadioError::REQUEST_NOT_SUPPORTED, RadioError::NO_RESOURCES}));
132 if (radioRsp_network->rspInfo.error == RadioError::NONE) {
133 if (aidl_version < 2) {
134 radioRsp_network->networkTypeBitmapResponse
135 &= ~static_cast<int32_t>(RadioAccessFamily::LTE_CA);
136 }
137
138 // verify we get the value we set
139 EXPECT_EQ(radioRsp_network->networkTypeBitmapResponse, allowedNetworkTypesBitmap);
140 }
141 }
142
143 // reset value to previous
144 serial = GetRandomSerialNumber();
145 radio_network->setAllowedNetworkTypesBitmap(serial, currentAllowedNetworkTypesBitmap);
146 EXPECT_EQ(std::cv_status::no_timeout, wait());
147 }
148
149 /*
150 * Test IRadioNetwork.setNrDualConnectivityState() for the response returned.
151 */
TEST_P(RadioNetworkTest,setNrDualConnectivityState)152 TEST_P(RadioNetworkTest, setNrDualConnectivityState) {
153 if (telephony_flags::enforce_telephony_feature_mapping()) {
154 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
155 GTEST_SKIP() << "Skipping setNrDualConnectivityState "
156 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
157 }
158 }
159
160 serial = GetRandomSerialNumber();
161
162 ndk::ScopedAStatus res =
163 radio_network->setNrDualConnectivityState(serial, NrDualConnectivityState::DISABLE);
164 ASSERT_OK(res);
165
166 EXPECT_EQ(std::cv_status::no_timeout, wait());
167 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
168 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
169 if (getRadioHalCapabilities()) {
170 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
171 {RadioError::REQUEST_NOT_SUPPORTED}));
172 } else {
173 ASSERT_TRUE(CheckAnyOfErrors(
174 radioRsp_network->rspInfo.error,
175 {RadioError::RADIO_NOT_AVAILABLE, RadioError::INTERNAL_ERR,
176 RadioError::INVALID_STATE, RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
177 }
178 }
179
180 /*
181 * Test IRadioNetwork.isNrDualConnectivityEnabled() for the response returned.
182 */
TEST_P(RadioNetworkTest,isNrDualConnectivityEnabled)183 TEST_P(RadioNetworkTest, isNrDualConnectivityEnabled) {
184 if (telephony_flags::enforce_telephony_feature_mapping()) {
185 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
186 GTEST_SKIP() << "Skipping isNrDualConnectivityEnabled "
187 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
188 }
189 }
190
191 serial = GetRandomSerialNumber();
192
193 ndk::ScopedAStatus res = radio_network->isNrDualConnectivityEnabled(serial);
194 ASSERT_OK(res);
195
196 EXPECT_EQ(std::cv_status::no_timeout, wait());
197 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
198 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
199 if (getRadioHalCapabilities()) {
200 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
201 {RadioError::REQUEST_NOT_SUPPORTED}));
202 } else {
203 ASSERT_TRUE(CheckAnyOfErrors(
204 radioRsp_network->rspInfo.error,
205 {RadioError::RADIO_NOT_AVAILABLE, RadioError::INTERNAL_ERR, RadioError::NONE}));
206 }
207 }
208
invokeAndExpectResponse(std::function<ndk::ScopedAStatus (int32_t serial)> request,std::vector<RadioError> errors_to_check)209 void RadioNetworkTest::invokeAndExpectResponse(
210 std::function<ndk::ScopedAStatus(int32_t serial)> request,
211 std::vector<RadioError> errors_to_check) {
212 serial = GetRandomSerialNumber();
213
214 ndk::ScopedAStatus res = request(serial);
215 ASSERT_OK(res);
216
217 EXPECT_EQ(std::cv_status::no_timeout, wait());
218 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
219 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
220 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, errors_to_check));
221 }
222
223 /*
224 * Test IRadioNetwork.getUsageSetting()
225 *
226 * Verify that the usage setting can be retrieved.
227 */
TEST_P(RadioNetworkTest,getUsageSetting)228 TEST_P(RadioNetworkTest, getUsageSetting) {
229 if (telephony_flags::enforce_telephony_feature_mapping()) {
230 if (!deviceSupportsFeature(FEATURE_TELEPHONY)) {
231 GTEST_SKIP() << "Skipping getUsageSetting "
232 "due to undefined FEATURE_TELEPHONY";
233 }
234 }
235
236 invokeAndExpectResponse([&](int serial) { return radio_network->getUsageSetting(serial); },
237 {RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_STATE,
238 RadioError::SIM_ABSENT, RadioError::INTERNAL_ERR, RadioError::NONE});
239
240 if (radioRsp_network->rspInfo.error == RadioError::NONE) {
241 ASSERT_TRUE(radioRsp_network->usageSetting == UsageSetting::VOICE_CENTRIC ||
242 radioRsp_network->usageSetting == UsageSetting::DATA_CENTRIC);
243 }
244 }
245
testSetUsageSetting_InvalidValues(std::vector<RadioError> errors)246 void RadioNetworkTest::testSetUsageSetting_InvalidValues(std::vector<RadioError> errors) {
247 invokeAndExpectResponse(
248 [&](int serial) {
249 return radio_network->setUsageSetting(serial,
250 UsageSetting(0) /*below valid range*/);
251 },
252 errors);
253 invokeAndExpectResponse(
254 [&](int serial) {
255 return radio_network->setUsageSetting(serial, UsageSetting(-1) /*negative*/);
256 },
257 errors);
258 invokeAndExpectResponse(
259 [&](int serial) {
260 return radio_network->setUsageSetting(serial,
261 UsageSetting(3) /*above valid range*/);
262 },
263 errors);
264 }
265
266 /*
267 * Test IRadioNetwork.setUsageSetting() and IRadioNetwork.getUsageSetting()
268 *
269 * Verify the following:
270 * -That the usage setting can be retrieved.
271 * -That the usage setting can be successfully set to allowed values.
272 * -That the usage setting cannot be set to invalid values.
273 */
TEST_P(RadioNetworkTest,setUsageSetting)274 TEST_P(RadioNetworkTest, setUsageSetting) {
275 if (telephony_flags::enforce_telephony_feature_mapping()) {
276 if (!deviceSupportsFeature(FEATURE_TELEPHONY)) {
277 GTEST_SKIP() << "Skipping setUsageSetting "
278 "due to undefined FEATURE_TELEPHONY";
279 }
280 }
281
282 invokeAndExpectResponse([&](int serial) { return radio_network->getUsageSetting(serial); },
283 {RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_STATE,
284 RadioError::SIM_ABSENT, RadioError::INTERNAL_ERR, RadioError::NONE});
285
286 if (radioRsp_network->rspInfo.error != RadioError::NONE) {
287 // Test only for invalid values, with the only allowable response being the same error
288 // that was previously provided, or an error indicating invalid arguments.
289 testSetUsageSetting_InvalidValues(
290 {radioRsp_network->rspInfo.error, RadioError::INVALID_ARGUMENTS});
291 // It is unsafe to proceed with setting valid values without knowing the starting value, but
292 // we expect errors anyway, so not necessary.
293 return;
294 } else {
295 // Because querying succeeded, the device is in a valid state to test for invalid values
296 // and the only thing that can change is that we expect to have an EINVAL return each time.
297 testSetUsageSetting_InvalidValues({RadioError::INVALID_ARGUMENTS});
298 }
299
300 // Store the original setting value to reset later.
301 const UsageSetting originalSetting = radioRsp_network->usageSetting;
302
303 // Choose the "other" value that is not the current value for test.
304 const UsageSetting testSetting = radioRsp_network->usageSetting == UsageSetting::VOICE_CENTRIC
305 ? UsageSetting::DATA_CENTRIC
306 : UsageSetting::VOICE_CENTRIC;
307
308 // Set an alternative setting; it may either succeed or be disallowed as out of range for
309 // the current device (if the device only supports its current mode).
310 invokeAndExpectResponse(
311 [&](int serial) { return radio_network->setUsageSetting(serial, testSetting); },
312 {RadioError::INVALID_ARGUMENTS, RadioError::NONE});
313
314 // If there was no error, then we expect the test setting to be set, or if there is an error
315 // we expect the original setting to be maintained.
316 const UsageSetting expectedSetting =
317 radioRsp_network->rspInfo.error == RadioError::NONE ? testSetting : originalSetting;
318 invokeAndExpectResponse([&](int serial) { return radio_network->getUsageSetting(serial); },
319 {RadioError::NONE});
320
321 const UsageSetting updatedSetting = radioRsp_network->usageSetting;
322
323 // Re-set the original setting, which must always succeed.
324 invokeAndExpectResponse(
325 [&](int serial) { return radio_network->setUsageSetting(serial, originalSetting); },
326 {RadioError::NONE});
327
328 // After resetting the value to its original value, update the local cache, which must
329 // always succeed.
330 invokeAndExpectResponse([&](int serial) { return radio_network->getUsageSetting(serial); },
331 {RadioError::NONE});
332
333 // Check that indeed the updated setting was set. We do this after resetting to original
334 // conditions to avoid early-exiting the test and leaving the device in a modified state.
335 EXPECT_EQ(expectedSetting, updatedSetting);
336 // Check that indeed the original setting was reset.
337 EXPECT_EQ(originalSetting, radioRsp_network->usageSetting);
338 }
339
340 /*
341 * Test IRadioNetwork.setSignalStrengthReportingCriteria() with invalid hysteresisDb
342 */
TEST_P(RadioNetworkTest,setSignalStrengthReportingCriteria_invalidHysteresisDb)343 TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_invalidHysteresisDb) {
344 if (telephony_flags::enforce_telephony_feature_mapping()) {
345 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
346 GTEST_SKIP() << "Skipping setSignalStrengthReportingCriteria_invalidHysteresisDb "
347 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
348 }
349 }
350
351 serial = GetRandomSerialNumber();
352
353 SignalThresholdInfo signalThresholdInfo;
354 signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSSI;
355 signalThresholdInfo.hysteresisMs = 5000;
356 signalThresholdInfo.hysteresisDb = 10; // hysteresisDb too large given threshold list deltas
357 signalThresholdInfo.thresholds = {-109, -103, -97, -89};
358 signalThresholdInfo.isEnabled = true;
359 signalThresholdInfo.ran = AccessNetwork::EUTRAN;
360
361 ndk::ScopedAStatus res =
362 radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo});
363 ASSERT_OK(res);
364 EXPECT_EQ(std::cv_status::no_timeout, wait());
365 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
366 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
367
368 ALOGI("setSignalStrengthReportingCriteria_invalidHysteresisDb, rspInfo.error = %s\n",
369 toString(radioRsp_network->rspInfo.error).c_str());
370 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::INVALID_ARGUMENTS}));
371 }
372
373 /*
374 * Test IRadioNetwork.setSignalStrengthReportingCriteria() with empty thresholds
375 */
TEST_P(RadioNetworkTest,setSignalStrengthReportingCriteria_EmptyThresholds)376 TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_EmptyThresholds) {
377 if (telephony_flags::enforce_telephony_feature_mapping()) {
378 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
379 GTEST_SKIP() << "Skipping setSignalStrengthReportingCriteria_EmptyThresholds "
380 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
381 }
382 }
383
384 serial = GetRandomSerialNumber();
385
386 SignalThresholdInfo signalThresholdInfo;
387 signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSSI;
388 signalThresholdInfo.hysteresisMs = 0;
389 signalThresholdInfo.hysteresisDb = 0;
390 signalThresholdInfo.isEnabled = true;
391 signalThresholdInfo.ran = AccessNetwork::EUTRAN;
392
393 ndk::ScopedAStatus res =
394 radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo});
395 ASSERT_OK(res);
396 EXPECT_EQ(std::cv_status::no_timeout, wait());
397 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
398 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
399
400 ALOGI("setSignalStrengthReportingCriteria_EmptyParams, rspInfo.error = %s\n",
401 toString(radioRsp_network->rspInfo.error).c_str());
402 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE}));
403 }
404
405 /*
406 * Test IRadioNetwork.setSignalStrengthReportingCriteria() for GERAN
407 */
TEST_P(RadioNetworkTest,setSignalStrengthReportingCriteria_Geran)408 TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_Geran) {
409 if (telephony_flags::enforce_telephony_feature_mapping()) {
410 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
411 GTEST_SKIP() << "Skipping setSignalStrengthReportingCriteria_Geran "
412 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
413 }
414 }
415
416 serial = GetRandomSerialNumber();
417
418 SignalThresholdInfo signalThresholdInfo;
419 signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSSI;
420 signalThresholdInfo.hysteresisMs = 5000;
421 signalThresholdInfo.hysteresisDb = 2;
422 signalThresholdInfo.thresholds = {-109, -103, -97, -89};
423 signalThresholdInfo.isEnabled = true;
424 signalThresholdInfo.ran = AccessNetwork::GERAN;
425
426 ndk::ScopedAStatus res =
427 radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo});
428 ASSERT_OK(res);
429 EXPECT_EQ(std::cv_status::no_timeout, wait());
430 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
431 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
432
433 ALOGI("setSignalStrengthReportingCriteria_Geran, rspInfo.error = %s\n",
434 toString(radioRsp_network->rspInfo.error).c_str());
435 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
436 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
437 }
438
439 /*
440 * Test IRadioNetwork.setSignalStrengthReportingCriteria() for UTRAN
441 */
TEST_P(RadioNetworkTest,setSignalStrengthReportingCriteria_Utran_Rscp)442 TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_Utran_Rscp) {
443 if (telephony_flags::enforce_telephony_feature_mapping()) {
444 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
445 GTEST_SKIP() << "Skipping setSignalStrengthReportingCriteria_Utran_Rscp "
446 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
447 }
448 }
449
450 serial = GetRandomSerialNumber();
451
452 SignalThresholdInfo signalThresholdInfo;
453 signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSCP;
454 signalThresholdInfo.hysteresisMs = 5000;
455 signalThresholdInfo.hysteresisDb = 2;
456 signalThresholdInfo.thresholds = {-110, -97, -73, -49, -25};
457 signalThresholdInfo.isEnabled = true;
458 signalThresholdInfo.ran = AccessNetwork::UTRAN;
459
460 ndk::ScopedAStatus res =
461 radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo});
462 ASSERT_OK(res);
463 EXPECT_EQ(std::cv_status::no_timeout, wait());
464 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
465 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
466
467 ALOGI("setSignalStrengthReportingCriteria_Utran, rspInfo.error = %s\n",
468 toString(radioRsp_network->rspInfo.error).c_str());
469 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE}));
470 }
471
472 /*
473 * Test IRadioNetwork.setSignalStrengthReportingCriteria() for UTRAN
474 */
TEST_P(RadioNetworkTest,setSignalStrengthReportingCriteria_Utran_Ecno)475 TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_Utran_Ecno) {
476 if (telephony_flags::enforce_telephony_feature_mapping()) {
477 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
478 GTEST_SKIP() << "Skipping setSignalStrengthReportingCriteria_Utran_Ecno "
479 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
480 }
481 }
482
483 serial = GetRandomSerialNumber();
484
485 SignalThresholdInfo signalThresholdInfo;
486 signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_ECNO;
487 signalThresholdInfo.hysteresisMs = 5000;
488 signalThresholdInfo.hysteresisDb = 2;
489 signalThresholdInfo.thresholds = {-22, -18, 0};
490 signalThresholdInfo.isEnabled = true;
491 signalThresholdInfo.ran = AccessNetwork::UTRAN;
492
493 ndk::ScopedAStatus res =
494 radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo});
495 ASSERT_OK(res);
496 EXPECT_EQ(std::cv_status::no_timeout, wait());
497 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
498 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
499
500 ALOGI("setSignalStrengthReportingCriteria_Utran, rspInfo.error = %s\n",
501 toString(radioRsp_network->rspInfo.error).c_str());
502 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
503 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
504 }
505
506 /*
507 * Test IRadioNetwork.setSignalStrengthReportingCriteria() for EUTRAN
508 */
TEST_P(RadioNetworkTest,setSignalStrengthReportingCriteria_Eutran_RSRP)509 TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_Eutran_RSRP) {
510 if (telephony_flags::enforce_telephony_feature_mapping()) {
511 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
512 GTEST_SKIP() << "Skipping setSignalStrengthReportingCriteria_Eutran_RSRP "
513 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
514 }
515 }
516
517 serial = GetRandomSerialNumber();
518
519 SignalThresholdInfo signalThresholdInfo;
520 signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSRP;
521 signalThresholdInfo.hysteresisMs = 5000;
522 signalThresholdInfo.hysteresisDb = 2;
523 signalThresholdInfo.thresholds = {-128, -108, -88, -68};
524 signalThresholdInfo.isEnabled = true;
525 signalThresholdInfo.ran = AccessNetwork::EUTRAN;
526
527 ndk::ScopedAStatus res =
528 radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo});
529 ASSERT_OK(res);
530 EXPECT_EQ(std::cv_status::no_timeout, wait());
531 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
532 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
533
534 ALOGI("setSignalStrengthReportingCriteria_Eutran, rspInfo.error = %s\n",
535 toString(radioRsp_network->rspInfo.error).c_str());
536 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE}));
537 }
538
539 /*
540 * Test IRadioNetwork.setSignalStrengthReportingCriteria() for EUTRAN
541 */
TEST_P(RadioNetworkTest,setSignalStrengthReportingCriteria_Eutran_RSRQ)542 TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_Eutran_RSRQ) {
543 if (telephony_flags::enforce_telephony_feature_mapping()) {
544 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
545 GTEST_SKIP() << "Skipping setSignalStrengthReportingCriteria_Eutran_RSRQ "
546 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
547 }
548 }
549
550 serial = GetRandomSerialNumber();
551
552 SignalThresholdInfo signalThresholdInfo;
553 signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSRQ;
554 signalThresholdInfo.hysteresisMs = 5000;
555 signalThresholdInfo.hysteresisDb = 2;
556 signalThresholdInfo.thresholds = {-27, -20, -13, -6};
557 signalThresholdInfo.isEnabled = true;
558 signalThresholdInfo.ran = AccessNetwork::EUTRAN;
559
560 ndk::ScopedAStatus res =
561 radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo});
562 ASSERT_OK(res);
563 EXPECT_EQ(std::cv_status::no_timeout, wait());
564 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
565 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
566
567 ALOGI("setSignalStrengthReportingCriteria_Eutran, rspInfo.error = %s\n",
568 toString(radioRsp_network->rspInfo.error).c_str());
569 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE}));
570 }
571
572 /*
573 * Test IRadioNetwork.setSignalStrengthReportingCriteria() for EUTRAN
574 */
TEST_P(RadioNetworkTest,setSignalStrengthReportingCriteria_Eutran_RSSNR)575 TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_Eutran_RSSNR) {
576 if (telephony_flags::enforce_telephony_feature_mapping()) {
577 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
578 GTEST_SKIP() << "Skipping setSignalStrengthReportingCriteria_Eutran_RSSNR "
579 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
580 }
581 }
582
583 serial = GetRandomSerialNumber();
584
585 SignalThresholdInfo signalThresholdInfo;
586 signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSSNR;
587 signalThresholdInfo.hysteresisMs = 5000;
588 signalThresholdInfo.hysteresisDb = 2;
589 signalThresholdInfo.thresholds = {-10, 0, 10, 20};
590 signalThresholdInfo.isEnabled = true;
591 signalThresholdInfo.ran = AccessNetwork::EUTRAN;
592
593 ndk::ScopedAStatus res =
594 radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo});
595 ASSERT_OK(res);
596 EXPECT_EQ(std::cv_status::no_timeout, wait());
597 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
598 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
599 }
600
601 /*
602 * Test IRadioNetwork.setSignalStrengthReportingCriteria() for CDMA2000
603 */
TEST_P(RadioNetworkTest,setSignalStrengthReportingCriteria_Cdma2000)604 TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_Cdma2000) {
605 if (telephony_flags::enforce_telephony_feature_mapping()) {
606 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
607 GTEST_SKIP() << "Skipping setSignalStrengthReportingCriteria_Cdma2000 "
608 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
609 }
610 }
611
612 serial = GetRandomSerialNumber();
613
614 SignalThresholdInfo signalThresholdInfo;
615 signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSSI;
616 signalThresholdInfo.hysteresisMs = 5000;
617 signalThresholdInfo.hysteresisDb = 2;
618 signalThresholdInfo.thresholds = {-105, -90, -75, -65};
619 signalThresholdInfo.isEnabled = true;
620 signalThresholdInfo.ran = AccessNetwork::CDMA2000;
621
622 ndk::ScopedAStatus res =
623 radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo});
624 ASSERT_OK(res);
625 EXPECT_EQ(std::cv_status::no_timeout, wait());
626 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
627 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
628
629 ALOGI("setSignalStrengthReportingCriteria_Cdma2000, rspInfo.error = %s\n",
630 toString(radioRsp_network->rspInfo.error).c_str());
631 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE}));
632 }
633
634 /*
635 * Test IRadioNetwork.setSignalStrengthReportingCriteria() for NGRAN_SSRSRP
636 */
TEST_P(RadioNetworkTest,setSignalStrengthReportingCriteria_NGRAN_SSRSRP)637 TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_NGRAN_SSRSRP) {
638 if (telephony_flags::enforce_telephony_feature_mapping()) {
639 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
640 GTEST_SKIP() << "Skipping setSignalStrengthReportingCriteria_NGRAN_SSRSRP "
641 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
642 }
643 }
644
645 serial = GetRandomSerialNumber();
646
647 SignalThresholdInfo signalThresholdInfo;
648 signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_SSRSRP;
649 signalThresholdInfo.hysteresisMs = 5000;
650 signalThresholdInfo.hysteresisDb = 0;
651 signalThresholdInfo.thresholds = {-105, -90, -75, -65};
652 signalThresholdInfo.isEnabled = true;
653 signalThresholdInfo.ran = AccessNetwork::NGRAN;
654
655 ndk::ScopedAStatus res =
656 radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo});
657 ASSERT_OK(res);
658 EXPECT_EQ(std::cv_status::no_timeout, wait());
659 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
660 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
661
662 ALOGI("setSignalStrengthReportingCriteria_NGRAN_SSRSRP, rspInfo.error = %s\n",
663 toString(radioRsp_network->rspInfo.error).c_str());
664
665 // Allow REQUEST_NOT_SUPPORTED because some non-5G device may not support NGRAN for
666 // setSignalStrengthReportingCriteria()
667 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
668 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
669 }
670
671 /*
672 * Test IRadioNetwork.setSignalStrengthReportingCriteria() for NGRAN_SSRSRQ
673 */
TEST_P(RadioNetworkTest,setSignalStrengthReportingCriteria_NGRAN_SSRSRQ)674 TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_NGRAN_SSRSRQ) {
675 if (telephony_flags::enforce_telephony_feature_mapping()) {
676 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
677 GTEST_SKIP() << "Skipping setSignalStrengthReportingCriteria_NGRAN_SSRSRQ "
678 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
679 }
680 }
681
682 serial = GetRandomSerialNumber();
683
684 SignalThresholdInfo signalThresholdInfo;
685 signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_SSRSRQ;
686 signalThresholdInfo.hysteresisMs = 5000;
687 signalThresholdInfo.hysteresisDb = 0;
688 signalThresholdInfo.thresholds = {-43, -20, 0, 20};
689 signalThresholdInfo.isEnabled = true;
690 signalThresholdInfo.ran = AccessNetwork::NGRAN;
691
692 ndk::ScopedAStatus res =
693 radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo});
694 ASSERT_OK(res);
695 EXPECT_EQ(std::cv_status::no_timeout, wait());
696 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
697 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
698
699 ALOGI("setSignalStrengthReportingCriteria_NGRAN_SSRSRQ, rspInfo.error = %s\n",
700 toString(radioRsp_network->rspInfo.error).c_str());
701
702 // Allow REQUEST_NOT_SUPPORTED because some non-5G device may not support NGRAN for
703 // setSignalStrengthReportingCriteria()
704 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
705 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
706 }
707
708 /*
709 * Test IRadioNetwork.setSignalStrengthReportingCriteria() for EUTRAN
710 */
TEST_P(RadioNetworkTest,setSignalStrengthReportingCriteria_Disable_RSSNR)711 TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_Disable_RSSNR) {
712 if (telephony_flags::enforce_telephony_feature_mapping()) {
713 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
714 GTEST_SKIP() << "Skipping setSignalStrengthReportingCriteria_Disable_RSSNR "
715 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
716 }
717 }
718
719 serial = GetRandomSerialNumber();
720
721 SignalThresholdInfo signalThresholdInfo;
722 signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSSNR;
723 signalThresholdInfo.hysteresisMs = 5000;
724 signalThresholdInfo.hysteresisDb = 2;
725 signalThresholdInfo.thresholds = {-10, 0, 10, 20};
726 signalThresholdInfo.isEnabled = false;
727 signalThresholdInfo.ran = AccessNetwork::EUTRAN;
728
729 ndk::ScopedAStatus res =
730 radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo});
731 ASSERT_OK(res);
732 EXPECT_EQ(std::cv_status::no_timeout, wait());
733 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
734 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
735 }
736
737 /*
738 * Test IRadioNetwork.setSignalStrengthReportingCriteria() for NGRAN_SSSINR
739 */
TEST_P(RadioNetworkTest,setSignalStrengthReportingCriteria_NGRAN_SSSINR)740 TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_NGRAN_SSSINR) {
741 if (telephony_flags::enforce_telephony_feature_mapping()) {
742 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
743 GTEST_SKIP() << "Skipping setSignalStrengthReportingCriteria_NGRAN_SSSINR "
744 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
745 }
746 }
747
748 serial = GetRandomSerialNumber();
749
750 SignalThresholdInfo signalThresholdInfo;
751 signalThresholdInfo.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_SSSINR;
752 signalThresholdInfo.hysteresisMs = 5000;
753 signalThresholdInfo.hysteresisDb = 0;
754 signalThresholdInfo.thresholds = {-10, 3, 16, 18};
755 signalThresholdInfo.isEnabled = true;
756 signalThresholdInfo.ran = AccessNetwork::NGRAN;
757
758 ndk::ScopedAStatus res =
759 radio_network->setSignalStrengthReportingCriteria(serial, {signalThresholdInfo});
760 ASSERT_OK(res);
761 EXPECT_EQ(std::cv_status::no_timeout, wait());
762 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
763 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
764
765 ALOGI("setSignalStrengthReportingCriteria_NGRAN_SSSINR, rspInfo.error = %s\n",
766 toString(radioRsp_network->rspInfo.error).c_str());
767
768 // Allow REQUEST_NOT_SUPPORTED because some non-5G device may not support NGRAN for
769 // setSignalStrengthReportingCriteria()
770 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
771 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
772 }
773
774 /*
775 * Test IRadioNetwork.setSignalStrengthReportingCriteria() for multi-RANs per request
776 */
TEST_P(RadioNetworkTest,setSignalStrengthReportingCriteria_multiRansPerRequest)777 TEST_P(RadioNetworkTest, setSignalStrengthReportingCriteria_multiRansPerRequest) {
778 if (telephony_flags::enforce_telephony_feature_mapping()) {
779 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
780 GTEST_SKIP() << "Skipping setSignalStrengthReportingCriteria_multiRansPerRequest "
781 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
782 }
783 }
784
785 SignalThresholdInfo signalThresholdInfoGeran;
786 signalThresholdInfoGeran.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSSI;
787 signalThresholdInfoGeran.hysteresisMs = 5000;
788 signalThresholdInfoGeran.hysteresisDb = 2;
789 signalThresholdInfoGeran.thresholds = {-109, -103, -97, -89};
790 signalThresholdInfoGeran.isEnabled = true;
791 signalThresholdInfoGeran.ran = AccessNetwork::GERAN;
792
793 SignalThresholdInfo signalThresholdInfoUtran;
794 signalThresholdInfoUtran.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSCP;
795 signalThresholdInfoUtran.hysteresisMs = 5000;
796 signalThresholdInfoUtran.hysteresisDb = 2;
797 signalThresholdInfoUtran.thresholds = {-110, -97, -73, -49, -25};
798 signalThresholdInfoUtran.isEnabled = true;
799 signalThresholdInfoUtran.ran = AccessNetwork::UTRAN;
800
801 SignalThresholdInfo signalThresholdInfoEutran;
802 signalThresholdInfoEutran.signalMeasurement = SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSRP;
803 signalThresholdInfoEutran.hysteresisMs = 5000;
804 signalThresholdInfoEutran.hysteresisDb = 2;
805 signalThresholdInfoEutran.thresholds = {-128, -108, -88, -68};
806 signalThresholdInfoEutran.isEnabled = true;
807 signalThresholdInfoEutran.ran = AccessNetwork::EUTRAN;
808
809 SignalThresholdInfo signalThresholdInfoCdma2000;
810 signalThresholdInfoCdma2000.signalMeasurement =
811 SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_RSSI;
812 signalThresholdInfoCdma2000.hysteresisMs = 5000;
813 signalThresholdInfoCdma2000.hysteresisDb = 2;
814 signalThresholdInfoCdma2000.thresholds = {-105, -90, -75, -65};
815 signalThresholdInfoCdma2000.isEnabled = true;
816 signalThresholdInfoCdma2000.ran = AccessNetwork::CDMA2000;
817
818 SignalThresholdInfo signalThresholdInfoNgran;
819 signalThresholdInfoNgran.signalMeasurement =
820 SignalThresholdInfo::SIGNAL_MEASUREMENT_TYPE_SSRSRP;
821 signalThresholdInfoNgran.hysteresisMs = 5000;
822 signalThresholdInfoNgran.hysteresisDb = 0;
823 signalThresholdInfoNgran.thresholds = {-105, -90, -75, -65};
824 signalThresholdInfoNgran.isEnabled = true;
825 signalThresholdInfoNgran.ran = AccessNetwork::NGRAN;
826
827 const static std::vector<SignalThresholdInfo> candidateSignalThresholdInfos = {
828 signalThresholdInfoGeran, signalThresholdInfoUtran, signalThresholdInfoEutran,
829 signalThresholdInfoCdma2000, signalThresholdInfoNgran};
830
831 std::vector<SignalThresholdInfo> supportedSignalThresholdInfos;
832 for (size_t i = 0; i < candidateSignalThresholdInfos.size(); i++) {
833 serial = GetRandomSerialNumber();
834 ndk::ScopedAStatus res = radio_network->setSignalStrengthReportingCriteria(
835 serial, {candidateSignalThresholdInfos[i]});
836 ASSERT_OK(res);
837 EXPECT_EQ(std::cv_status::no_timeout, wait());
838 if (radioRsp_network->rspInfo.error == RadioError::NONE) {
839 supportedSignalThresholdInfos.push_back(signalThresholdInfoEutran);
840 } else {
841 // Refer to IRadioNetworkResponse#setSignalStrengthReportingCriteriaResponse
842 ASSERT_TRUE(CheckAnyOfErrors(
843 radioRsp_network->rspInfo.error,
844 {RadioError::INVALID_ARGUMENTS, RadioError::RADIO_NOT_AVAILABLE}));
845 }
846 }
847
848 ASSERT_FALSE(supportedSignalThresholdInfos.empty());
849
850 serial = GetRandomSerialNumber();
851 ndk::ScopedAStatus res = radio_network->setSignalStrengthReportingCriteria(
852 serial, supportedSignalThresholdInfos);
853 ASSERT_OK(res);
854 EXPECT_EQ(std::cv_status::no_timeout, wait());
855 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
856 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
857
858 ALOGI("setSignalStrengthReportingCriteria_multiRansPerRequest, rspInfo.error = %s\n",
859 toString(radioRsp_network->rspInfo.error).c_str());
860
861 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE}));
862 }
863
864 /*
865 * Test IRadioNetwork.setLinkCapacityReportingCriteria() invalid hysteresisDlKbps
866 */
TEST_P(RadioNetworkTest,setLinkCapacityReportingCriteria_invalidHysteresisDlKbps)867 TEST_P(RadioNetworkTest, setLinkCapacityReportingCriteria_invalidHysteresisDlKbps) {
868 if (telephony_flags::enforce_telephony_feature_mapping()) {
869 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
870 GTEST_SKIP() << "Skipping setLinkCapacityReportingCriteria_invalidHysteresisDlKbps "
871 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
872 }
873 }
874
875 serial = GetRandomSerialNumber();
876
877 ndk::ScopedAStatus res = radio_network->setLinkCapacityReportingCriteria(
878 serial, 5000,
879 5000, // hysteresisDlKbps too big for thresholds delta
880 100, {1000, 5000, 10000, 20000}, {500, 1000, 5000, 10000}, AccessNetwork::EUTRAN);
881 ASSERT_OK(res);
882 EXPECT_EQ(std::cv_status::no_timeout, wait());
883 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
884 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
885
886 ALOGI("setLinkCapacityReportingCriteria_invalidHysteresisDlKbps, rspInfo.error = %s\n",
887 toString(radioRsp_network->rspInfo.error).c_str());
888 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
889 }
890
891 /*
892 * Test IRadioNetwork.setLinkCapacityReportingCriteria() invalid hysteresisUlKbps
893 */
TEST_P(RadioNetworkTest,setLinkCapacityReportingCriteria_invalidHysteresisUlKbps)894 TEST_P(RadioNetworkTest, setLinkCapacityReportingCriteria_invalidHysteresisUlKbps) {
895 if (telephony_flags::enforce_telephony_feature_mapping()) {
896 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
897 GTEST_SKIP() << "Skipping setLinkCapacityReportingCriteria_invalidHysteresisUlKbps "
898 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
899 }
900 }
901
902 serial = GetRandomSerialNumber();
903
904 ndk::ScopedAStatus res = radio_network->setLinkCapacityReportingCriteria(
905 serial, 5000, 500, 1000, // hysteresisUlKbps too big for thresholds delta
906 {1000, 5000, 10000, 20000}, {500, 1000, 5000, 10000}, AccessNetwork::EUTRAN);
907 ASSERT_OK(res);
908 EXPECT_EQ(std::cv_status::no_timeout, wait());
909 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
910 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
911
912 ALOGI("setLinkCapacityReportingCriteria_invalidHysteresisUlKbps, rspInfo.error = %s\n",
913 toString(radioRsp_network->rspInfo.error).c_str());
914 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
915 }
916
917 /*
918 * Test IRadioNetwork.setLinkCapacityReportingCriteria() empty params
919 */
TEST_P(RadioNetworkTest,setLinkCapacityReportingCriteria_emptyParams)920 TEST_P(RadioNetworkTest, setLinkCapacityReportingCriteria_emptyParams) {
921 if (telephony_flags::enforce_telephony_feature_mapping()) {
922 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
923 GTEST_SKIP() << "Skipping setLinkCapacityReportingCriteria_emptyParams "
924 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
925 }
926 }
927
928 serial = GetRandomSerialNumber();
929
930 ndk::ScopedAStatus res = radio_network->setLinkCapacityReportingCriteria(
931 serial, 0, 0, 0, {}, {}, AccessNetwork::EUTRAN);
932 ASSERT_OK(res);
933 EXPECT_EQ(std::cv_status::no_timeout, wait());
934 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
935 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
936
937 ALOGI("setLinkCapacityReportingCriteria_emptyParams, rspInfo.error = %s\n",
938 toString(radioRsp_network->rspInfo.error).c_str());
939 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
940 }
941
942 /*
943 * Test IRadioNetwork.setLinkCapacityReportingCriteria() for GERAN
944 */
TEST_P(RadioNetworkTest,setLinkCapacityReportingCriteria_Geran)945 TEST_P(RadioNetworkTest, setLinkCapacityReportingCriteria_Geran) {
946 if (telephony_flags::enforce_telephony_feature_mapping()) {
947 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
948 GTEST_SKIP() << "Skipping setLinkCapacityReportingCriteria_Geran "
949 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
950 }
951 }
952
953 serial = GetRandomSerialNumber();
954
955 ndk::ScopedAStatus res = radio_network->setLinkCapacityReportingCriteria(
956 serial, 5000, 500, 100, {1000, 5000, 10000, 20000}, {500, 1000, 5000, 10000},
957 AccessNetwork::GERAN);
958 ASSERT_OK(res);
959 EXPECT_EQ(std::cv_status::no_timeout, wait());
960 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
961 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
962
963 ALOGI("setLinkCapacityReportingCriteria_Geran, rspInfo.error = %s\n",
964 toString(radioRsp_network->rspInfo.error).c_str());
965 // Allow REQUEST_NOT_SUPPORTED as setLinkCapacityReportingCriteria() may not be supported
966 // for GERAN
967 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
968 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
969 }
970
971 /*
972 * Test IRadioNetwork.setSystemSelectionChannels() for the response returned.
973 */
TEST_P(RadioNetworkTest,setSystemSelectionChannels)974 TEST_P(RadioNetworkTest, setSystemSelectionChannels) {
975 if (telephony_flags::enforce_telephony_feature_mapping()) {
976 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
977 GTEST_SKIP() << "Skipping setSystemSelectionChannels "
978 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
979 }
980 }
981
982 serial = GetRandomSerialNumber();
983 ndk::ScopedAStatus res = radio_network->getSystemSelectionChannels(serial);
984 EXPECT_EQ(std::cv_status::no_timeout, wait());
985 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
986 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
987 if (radioRsp_network->specifiers.size() == 0) {
988 // TODO (b/189255895): Throw an error once getSystemSelectionChannels is functional.
989 ALOGI("Skipped the test due to empty system selection channels.");
990 GTEST_SKIP();
991 }
992 std::vector<RadioAccessSpecifier> originalSpecifiers = radioRsp_network->specifiers;
993
994 serial = GetRandomSerialNumber();
995 res = radio_network->setSystemSelectionChannels(serial, true,
996 {::EUTRAN_SPECIFIER_17, ::EUTRAN_SPECIFIER_20});
997 ASSERT_OK(res);
998 EXPECT_EQ(std::cv_status::no_timeout, wait());
999 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1000 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1001 ALOGI("setSystemSelectionChannels, rspInfo.error = %s\n",
1002 toString(radioRsp_network->rspInfo.error).c_str());
1003 ASSERT_TRUE(CheckAnyOfErrors(
1004 radioRsp_network->rspInfo.error,
1005 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INTERNAL_ERR}));
1006
1007 if (radioRsp_network->rspInfo.error == RadioError::NONE) {
1008 serial = GetRandomSerialNumber();
1009 res = radio_network->setSystemSelectionChannels(
1010 serial, false, {::EUTRAN_SPECIFIER_17, ::EUTRAN_SPECIFIER_20});
1011 ASSERT_OK(res);
1012 EXPECT_EQ(std::cv_status::no_timeout, wait());
1013 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1014 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1015 ALOGI("setSystemSelectionChannels, rspInfo.error = %s\n",
1016 toString(radioRsp_network->rspInfo.error).c_str());
1017 EXPECT_EQ(RadioError::NONE, radioRsp_network->rspInfo.error);
1018 }
1019
1020 serial = GetRandomSerialNumber();
1021 res = radio_network->setSystemSelectionChannels(serial, true, originalSpecifiers);
1022 EXPECT_EQ(std::cv_status::no_timeout, wait());
1023 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1024 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1025 }
1026
1027 /*
1028 * Test IRadioNetwork.startNetworkScan() for the response returned.
1029 */
TEST_P(RadioNetworkTest,startNetworkScan)1030 TEST_P(RadioNetworkTest, startNetworkScan) {
1031 if (telephony_flags::enforce_telephony_feature_mapping()) {
1032 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1033 GTEST_SKIP() << "Skipping startNetworkScan "
1034 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1035 }
1036 }
1037
1038 serial = GetRandomSerialNumber();
1039
1040 NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT,
1041 .interval = 60,
1042 .specifiers = {::EUTRAN_SPECIFIER_17, ::EUTRAN_SPECIFIER_20},
1043 .maxSearchTime = 60,
1044 .incrementalResults = false,
1045 .incrementalResultsPeriodicity = 1};
1046
1047 ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request);
1048 ASSERT_OK(res);
1049 EXPECT_EQ(std::cv_status::no_timeout, wait());
1050 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1051 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1052 ALOGI("startNetworkScan, rspInfo.error = %s\n",
1053 toString(radioRsp_network->rspInfo.error).c_str());
1054
1055 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1056 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::SIM_ABSENT}));
1057 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
1058 if (deviceSupportsFeature(FEATURE_TELEPHONY_GSM) && isLteConnected()) {
1059 // Modems support 3GPP RAT family need to
1060 // support scanning requests combined with some parameters.
1061 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1062 {RadioError::NONE, RadioError::OPERATION_NOT_ALLOWED}));
1063 } else {
1064 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1065 {RadioError::NONE, RadioError::OPERATION_NOT_ALLOWED,
1066 RadioError::INVALID_ARGUMENTS}));
1067 }
1068 }
1069
1070 if (radioRsp_network->rspInfo.error == RadioError::NONE) {
1071 ALOGI("Stop Network Scan");
1072 stopNetworkScan();
1073 }
1074 }
1075
1076 /*
1077 * Test IRadioNetwork.startNetworkScan() with invalid specifier.
1078 */
TEST_P(RadioNetworkTest,startNetworkScan_InvalidArgument)1079 TEST_P(RadioNetworkTest, startNetworkScan_InvalidArgument) {
1080 if (telephony_flags::enforce_telephony_feature_mapping()) {
1081 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1082 GTEST_SKIP() << "Skipping startNetworkScan_InvalidArgument "
1083 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1084 }
1085 }
1086
1087 serial = GetRandomSerialNumber();
1088
1089 NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT, .interval = 60};
1090
1091 ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request);
1092 ASSERT_OK(res);
1093 EXPECT_EQ(std::cv_status::no_timeout, wait());
1094 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1095 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1096 ALOGI("startNetworkScan_InvalidArgument, rspInfo.error = %s\n",
1097 toString(radioRsp_network->rspInfo.error).c_str());
1098
1099 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1100 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1101 {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
1102 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
1103 ASSERT_TRUE(
1104 CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::INVALID_ARGUMENTS}));
1105 }
1106 }
1107
1108 /*
1109 * Test IRadioNetwork.startNetworkScan() with invalid interval (lower boundary).
1110 */
TEST_P(RadioNetworkTest,startNetworkScan_InvalidInterval1)1111 TEST_P(RadioNetworkTest, startNetworkScan_InvalidInterval1) {
1112 if (telephony_flags::enforce_telephony_feature_mapping()) {
1113 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1114 GTEST_SKIP() << "Skipping startNetworkScan_InvalidInterval1 "
1115 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1116 }
1117 }
1118
1119 serial = GetRandomSerialNumber();
1120
1121 NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_PERIODIC,
1122 .interval = 4,
1123 .specifiers = {::EUTRAN_SPECIFIER_17, ::EUTRAN_SPECIFIER_20},
1124 .maxSearchTime = 60,
1125 .incrementalResults = false,
1126 .incrementalResultsPeriodicity = 1};
1127
1128 ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request);
1129 ASSERT_OK(res);
1130 EXPECT_EQ(std::cv_status::no_timeout, wait());
1131 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1132 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1133 ALOGI("startNetworkScan_InvalidInterval1, rspInfo.error = %s\n",
1134 toString(radioRsp_network->rspInfo.error).c_str());
1135 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1136 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1137 {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
1138 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
1139 ASSERT_TRUE(
1140 CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::INVALID_ARGUMENTS}));
1141 }
1142 }
1143
1144 /*
1145 * Test IRadioNetwork.startNetworkScan() with invalid interval (upper boundary).
1146 */
TEST_P(RadioNetworkTest,startNetworkScan_InvalidInterval2)1147 TEST_P(RadioNetworkTest, startNetworkScan_InvalidInterval2) {
1148 if (telephony_flags::enforce_telephony_feature_mapping()) {
1149 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1150 GTEST_SKIP() << "Skipping startNetworkScan_InvalidInterval2 "
1151 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1152 }
1153 }
1154
1155 serial = GetRandomSerialNumber();
1156
1157 NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_PERIODIC,
1158 .interval = 301,
1159 .specifiers = {::EUTRAN_SPECIFIER_17, ::EUTRAN_SPECIFIER_20},
1160 .maxSearchTime = 60,
1161 .incrementalResults = false,
1162 .incrementalResultsPeriodicity = 1};
1163
1164 ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request);
1165 ASSERT_OK(res);
1166 EXPECT_EQ(std::cv_status::no_timeout, wait());
1167 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1168 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1169 ALOGI("startNetworkScan_InvalidInterval2, rspInfo.error = %s\n",
1170 toString(radioRsp_network->rspInfo.error).c_str());
1171 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1172 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1173 {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
1174 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
1175 ASSERT_TRUE(
1176 CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::INVALID_ARGUMENTS}));
1177 }
1178 }
1179
1180 /*
1181 * Test IRadioNetwork.startNetworkScan() with invalid max search time (lower boundary).
1182 */
TEST_P(RadioNetworkTest,startNetworkScan_InvalidMaxSearchTime1)1183 TEST_P(RadioNetworkTest, startNetworkScan_InvalidMaxSearchTime1) {
1184 if (telephony_flags::enforce_telephony_feature_mapping()) {
1185 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1186 GTEST_SKIP() << "Skipping startNetworkScan_InvalidMaxSearchTime1 "
1187 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1188 }
1189 }
1190
1191 serial = GetRandomSerialNumber();
1192
1193 NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT,
1194 .interval = 60,
1195 .specifiers = {::EUTRAN_SPECIFIER_17, ::EUTRAN_SPECIFIER_20},
1196 .maxSearchTime = 59,
1197 .incrementalResults = false,
1198 .incrementalResultsPeriodicity = 1};
1199
1200 ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request);
1201 ASSERT_OK(res);
1202 EXPECT_EQ(std::cv_status::no_timeout, wait());
1203 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1204 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1205 ALOGI("startNetworkScan_InvalidMaxSearchTime1, rspInfo.error = %s\n",
1206 toString(radioRsp_network->rspInfo.error).c_str());
1207 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1208 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1209 {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
1210 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
1211 ASSERT_TRUE(
1212 CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::INVALID_ARGUMENTS}));
1213 }
1214 }
1215
1216 /*
1217 * Test IRadioNetwork.startNetworkScan() with invalid max search time (upper boundary).
1218 */
TEST_P(RadioNetworkTest,startNetworkScan_InvalidMaxSearchTime2)1219 TEST_P(RadioNetworkTest, startNetworkScan_InvalidMaxSearchTime2) {
1220 if (telephony_flags::enforce_telephony_feature_mapping()) {
1221 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1222 GTEST_SKIP() << "Skipping startNetworkScan_InvalidMaxSearchTime2 "
1223 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1224 }
1225 }
1226
1227 serial = GetRandomSerialNumber();
1228
1229 NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT,
1230 .interval = 60,
1231 .specifiers = {::EUTRAN_SPECIFIER_17, ::EUTRAN_SPECIFIER_20},
1232 .maxSearchTime = 3601,
1233 .incrementalResults = false,
1234 .incrementalResultsPeriodicity = 1};
1235
1236 ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request);
1237 ASSERT_OK(res);
1238 EXPECT_EQ(std::cv_status::no_timeout, wait());
1239 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1240 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1241 ALOGI("startNetworkScan_InvalidMaxSearchTime2, rspInfo.error = %s\n",
1242 toString(radioRsp_network->rspInfo.error).c_str());
1243 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1244 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1245 {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
1246 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
1247 ASSERT_TRUE(
1248 CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::INVALID_ARGUMENTS}));
1249 }
1250 }
1251
1252 /*
1253 * Test IRadioNetwork.startNetworkScan() with invalid periodicity (lower boundary).
1254 */
TEST_P(RadioNetworkTest,startNetworkScan_InvalidPeriodicity1)1255 TEST_P(RadioNetworkTest, startNetworkScan_InvalidPeriodicity1) {
1256 if (telephony_flags::enforce_telephony_feature_mapping()) {
1257 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1258 GTEST_SKIP() << "Skipping startNetworkScan_InvalidPeriodicity1 "
1259 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1260 }
1261 }
1262
1263 serial = GetRandomSerialNumber();
1264
1265 NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT,
1266 .interval = 60,
1267 .specifiers = {::EUTRAN_SPECIFIER_17, ::EUTRAN_SPECIFIER_20},
1268 .maxSearchTime = 600,
1269 .incrementalResults = true,
1270 .incrementalResultsPeriodicity = 0};
1271
1272 ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request);
1273 ASSERT_OK(res);
1274 EXPECT_EQ(std::cv_status::no_timeout, wait());
1275 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1276 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1277 ALOGI("startNetworkScan_InvalidPeriodicity1, rspInfo.error = %s\n",
1278 toString(radioRsp_network->rspInfo.error).c_str());
1279 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1280 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1281 {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
1282 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
1283 ASSERT_TRUE(
1284 CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::INVALID_ARGUMENTS}));
1285 }
1286 }
1287
1288 /*
1289 * Test IRadioNetwork.startNetworkScan() with invalid periodicity (upper boundary).
1290 */
TEST_P(RadioNetworkTest,startNetworkScan_InvalidPeriodicity2)1291 TEST_P(RadioNetworkTest, startNetworkScan_InvalidPeriodicity2) {
1292 if (telephony_flags::enforce_telephony_feature_mapping()) {
1293 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1294 GTEST_SKIP() << "Skipping startNetworkScan_InvalidPeriodicity2 "
1295 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1296 }
1297 }
1298
1299 serial = GetRandomSerialNumber();
1300
1301 NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT,
1302 .interval = 60,
1303 .specifiers = {::EUTRAN_SPECIFIER_17, ::EUTRAN_SPECIFIER_20},
1304 .maxSearchTime = 600,
1305 .incrementalResults = true,
1306 .incrementalResultsPeriodicity = 11};
1307
1308 ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request);
1309 ASSERT_OK(res);
1310 EXPECT_EQ(std::cv_status::no_timeout, wait());
1311 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1312 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1313 ALOGI("startNetworkScan_InvalidPeriodicity2, rspInfo.error = %s\n",
1314 toString(radioRsp_network->rspInfo.error).c_str());
1315 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1316 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1317 {RadioError::SIM_ABSENT, RadioError::INVALID_ARGUMENTS}));
1318 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
1319 ASSERT_TRUE(
1320 CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::INVALID_ARGUMENTS}));
1321 }
1322 }
1323
1324 /*
1325 * Test IRadioNetwork.startNetworkScan() with valid periodicity
1326 */
TEST_P(RadioNetworkTest,startNetworkScan_GoodRequest1)1327 TEST_P(RadioNetworkTest, startNetworkScan_GoodRequest1) {
1328 if (telephony_flags::enforce_telephony_feature_mapping()) {
1329 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1330 GTEST_SKIP() << "Skipping startNetworkScan_GoodRequest1 "
1331 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1332 }
1333 }
1334
1335 serial = GetRandomSerialNumber();
1336
1337 NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT,
1338 .interval = 60,
1339 .specifiers = {::EUTRAN_SPECIFIER_17, ::EUTRAN_SPECIFIER_20},
1340 .maxSearchTime = 360,
1341 .incrementalResults = false,
1342 .incrementalResultsPeriodicity = 10};
1343
1344 ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request);
1345 ASSERT_OK(res);
1346 EXPECT_EQ(std::cv_status::no_timeout, wait());
1347 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1348 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1349 ALOGI("startNetworkScan_GoodRequest1, rspInfo.error = %s\n",
1350 toString(radioRsp_network->rspInfo.error).c_str());
1351 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1352 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1353 {RadioError::NONE, RadioError::SIM_ABSENT}));
1354 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
1355 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1356 {RadioError::NONE, RadioError::INVALID_ARGUMENTS}));
1357 }
1358
1359 if (radioRsp_network->rspInfo.error == RadioError::NONE) {
1360 ALOGI("Stop Network Scan");
1361 stopNetworkScan();
1362 }
1363 }
1364
1365 /*
1366 * Test IRadioNetwork.startNetworkScan() with valid periodicity and plmns
1367 */
TEST_P(RadioNetworkTest,startNetworkScan_GoodRequest2)1368 TEST_P(RadioNetworkTest, startNetworkScan_GoodRequest2) {
1369 if (telephony_flags::enforce_telephony_feature_mapping()) {
1370 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1371 GTEST_SKIP() << "Skipping startNetworkScan_GoodRequest2 "
1372 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1373 }
1374 }
1375
1376 serial = GetRandomSerialNumber();
1377
1378 NetworkScanRequest request = {.type = NetworkScanRequest::SCAN_TYPE_ONE_SHOT,
1379 .interval = 60,
1380 .specifiers = {::EUTRAN_SPECIFIER_17, ::EUTRAN_SPECIFIER_20},
1381 .maxSearchTime = 360,
1382 .incrementalResults = false,
1383 .incrementalResultsPeriodicity = 10,
1384 .mccMncs = {"310410"}};
1385
1386 ndk::ScopedAStatus res = radio_network->startNetworkScan(serial, request);
1387 ASSERT_OK(res);
1388 EXPECT_EQ(std::cv_status::no_timeout, wait());
1389 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1390 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1391 ALOGI("startNetworkScan_GoodRequest2, rspInfo.error = %s\n",
1392 toString(radioRsp_network->rspInfo.error).c_str());
1393 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1394 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1395 {RadioError::NONE, RadioError::SIM_ABSENT}));
1396 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
1397 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1398 {RadioError::NONE, RadioError::INVALID_ARGUMENTS}));
1399 }
1400
1401 if (radioRsp_network->rspInfo.error == RadioError::NONE) {
1402 ALOGI("Stop Network Scan");
1403 stopNetworkScan();
1404 }
1405 }
1406
1407 /*
1408 * Test IRadioNetwork.setNetworkSelectionModeManual() for the response returned.
1409 */
TEST_P(RadioNetworkTest,setNetworkSelectionModeManual)1410 TEST_P(RadioNetworkTest, setNetworkSelectionModeManual) {
1411 if (telephony_flags::enforce_telephony_feature_mapping()) {
1412 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1413 GTEST_SKIP() << "Skipping setNetworkSelectionModeManual "
1414 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1415 }
1416 }
1417
1418 serial = GetRandomSerialNumber();
1419
1420 // can't camp on nonexistent MCCMNC, so we expect this to fail.
1421 ndk::ScopedAStatus res =
1422 radio_network->setNetworkSelectionModeManual(serial, "123456", AccessNetwork::EUTRAN);
1423 EXPECT_EQ(std::cv_status::no_timeout, wait());
1424 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1425 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1426
1427 ASSERT_TRUE(CheckAnyOfErrors(
1428 radioRsp_network->rspInfo.error,
1429 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_ARGUMENTS,
1430 RadioError::INVALID_STATE, RadioError::NO_MEMORY, RadioError::INTERNAL_ERR,
1431 RadioError::SYSTEM_ERR, RadioError::CANCELLED, RadioError::MODEM_ERR}));
1432 }
1433
1434 /*
1435 * Test IRadioNetwork.getBarringInfo() for the response returned.
1436 */
TEST_P(RadioNetworkTest,getBarringInfo)1437 TEST_P(RadioNetworkTest, getBarringInfo) {
1438 if (telephony_flags::enforce_telephony_feature_mapping()) {
1439 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1440 GTEST_SKIP() << "Skipping getBarringInfo "
1441 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1442 }
1443 }
1444
1445 serial = GetRandomSerialNumber();
1446 ndk::ScopedAStatus res = radio_network->getBarringInfo(serial);
1447 EXPECT_EQ(std::cv_status::no_timeout, wait());
1448 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1449 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1450 ASSERT_TRUE(radioRsp_network->barringInfoList.size() > 0);
1451
1452 std::set<int> reportedServices;
1453
1454 // validate that the service types are in range
1455 for (const auto& info : radioRsp_network->barringInfoList) {
1456 ASSERT_TRUE((info.serviceType >= BarringInfo::SERVICE_TYPE_CS_SERVICE &&
1457 info.serviceType <= BarringInfo::SERVICE_TYPE_SMS) ||
1458 (info.serviceType >= BarringInfo::SERVICE_TYPE_OPERATOR_1 &&
1459 info.serviceType <= BarringInfo::SERVICE_TYPE_OPERATOR_32));
1460 reportedServices.insert(info.serviceType);
1461
1462 // Any type that is "conditional" must have valid values for conditional barring
1463 // factor and time.
1464 switch (info.barringType) {
1465 case BarringInfo::BARRING_TYPE_NONE: // fall through
1466 case BarringInfo::BARRING_TYPE_UNCONDITIONAL:
1467 break;
1468 case BarringInfo::BARRING_TYPE_CONDITIONAL: {
1469 const int32_t barringFactor = info.barringTypeSpecificInfo->factor;
1470 ASSERT_TRUE(barringFactor >= 0 && barringFactor <= 100);
1471 ASSERT_TRUE(info.barringTypeSpecificInfo->timeSeconds > 0);
1472 break;
1473 }
1474 default:
1475 FAIL();
1476 }
1477 }
1478
1479 // Certain types of barring are relevant for certain RANs. Ensure that only the right
1480 // types are reported. Note that no types are required, simply that for a given technology
1481 // only certain types are valid. This is one way to check that implementations are
1482 // not providing information that they don't have.
1483 static const std::set<int> UTRA_SERVICES{
1484 BarringInfo::SERVICE_TYPE_CS_SERVICE, BarringInfo::SERVICE_TYPE_PS_SERVICE,
1485 BarringInfo::SERVICE_TYPE_CS_VOICE, BarringInfo::SERVICE_TYPE_EMERGENCY,
1486 BarringInfo::SERVICE_TYPE_SMS,
1487 };
1488
1489 static const std::set<int> EUTRA_SERVICES{
1490 BarringInfo::SERVICE_TYPE_MO_SIGNALLING, BarringInfo::SERVICE_TYPE_MO_DATA,
1491 BarringInfo::SERVICE_TYPE_CS_FALLBACK, BarringInfo::SERVICE_TYPE_MMTEL_VOICE,
1492 BarringInfo::SERVICE_TYPE_MMTEL_VIDEO, BarringInfo::SERVICE_TYPE_EMERGENCY,
1493 BarringInfo::SERVICE_TYPE_SMS,
1494 };
1495
1496 static const std::set<int> NGRA_SERVICES = {
1497 BarringInfo::SERVICE_TYPE_MO_SIGNALLING, BarringInfo::SERVICE_TYPE_MO_DATA,
1498 BarringInfo::SERVICE_TYPE_CS_FALLBACK, BarringInfo::SERVICE_TYPE_MMTEL_VOICE,
1499 BarringInfo::SERVICE_TYPE_MMTEL_VIDEO, BarringInfo::SERVICE_TYPE_EMERGENCY,
1500 BarringInfo::SERVICE_TYPE_SMS, BarringInfo::SERVICE_TYPE_OPERATOR_1,
1501 BarringInfo::SERVICE_TYPE_OPERATOR_2, BarringInfo::SERVICE_TYPE_OPERATOR_3,
1502 BarringInfo::SERVICE_TYPE_OPERATOR_4, BarringInfo::SERVICE_TYPE_OPERATOR_5,
1503 BarringInfo::SERVICE_TYPE_OPERATOR_6, BarringInfo::SERVICE_TYPE_OPERATOR_7,
1504 BarringInfo::SERVICE_TYPE_OPERATOR_8, BarringInfo::SERVICE_TYPE_OPERATOR_9,
1505 BarringInfo::SERVICE_TYPE_OPERATOR_10, BarringInfo::SERVICE_TYPE_OPERATOR_11,
1506 BarringInfo::SERVICE_TYPE_OPERATOR_12, BarringInfo::SERVICE_TYPE_OPERATOR_13,
1507 BarringInfo::SERVICE_TYPE_OPERATOR_14, BarringInfo::SERVICE_TYPE_OPERATOR_15,
1508 BarringInfo::SERVICE_TYPE_OPERATOR_16, BarringInfo::SERVICE_TYPE_OPERATOR_17,
1509 BarringInfo::SERVICE_TYPE_OPERATOR_18, BarringInfo::SERVICE_TYPE_OPERATOR_19,
1510 BarringInfo::SERVICE_TYPE_OPERATOR_20, BarringInfo::SERVICE_TYPE_OPERATOR_21,
1511 BarringInfo::SERVICE_TYPE_OPERATOR_22, BarringInfo::SERVICE_TYPE_OPERATOR_23,
1512 BarringInfo::SERVICE_TYPE_OPERATOR_24, BarringInfo::SERVICE_TYPE_OPERATOR_25,
1513 BarringInfo::SERVICE_TYPE_OPERATOR_26, BarringInfo::SERVICE_TYPE_OPERATOR_27,
1514 BarringInfo::SERVICE_TYPE_OPERATOR_28, BarringInfo::SERVICE_TYPE_OPERATOR_29,
1515 BarringInfo::SERVICE_TYPE_OPERATOR_30, BarringInfo::SERVICE_TYPE_OPERATOR_31,
1516 };
1517
1518 const std::set<int>* compareTo = nullptr;
1519
1520 switch (radioRsp_network->barringCellIdentity.getTag()) {
1521 case CellIdentity::Tag::wcdma:
1522 // fall through
1523 case CellIdentity::Tag::tdscdma:
1524 compareTo = &UTRA_SERVICES;
1525 break;
1526 case CellIdentity::Tag::lte:
1527 compareTo = &EUTRA_SERVICES;
1528 break;
1529 case CellIdentity::Tag::nr:
1530 compareTo = &NGRA_SERVICES;
1531 break;
1532 case CellIdentity::Tag::cdma:
1533 // fall through
1534 default:
1535 FAIL();
1536 break;
1537 }
1538
1539 std::set<int> diff;
1540
1541 std::set_difference(reportedServices.begin(), reportedServices.end(), compareTo->begin(),
1542 compareTo->end(), std::inserter(diff, diff.begin()));
1543 }
1544
1545 /*
1546 * Test IRadioNetwork.getSignalStrength() for the response returned.
1547 */
TEST_P(RadioNetworkTest,getSignalStrength)1548 TEST_P(RadioNetworkTest, getSignalStrength) {
1549 if (telephony_flags::enforce_telephony_feature_mapping()) {
1550 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1551 GTEST_SKIP() << "Skipping getSignalStrength "
1552 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1553 }
1554 }
1555
1556 serial = GetRandomSerialNumber();
1557
1558 radio_network->getSignalStrength(serial);
1559 EXPECT_EQ(std::cv_status::no_timeout, wait());
1560 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1561 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1562
1563 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1564 EXPECT_EQ(RadioError::NONE, radioRsp_network->rspInfo.error);
1565 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
1566 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1567 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE}));
1568 }
1569 }
1570
1571 /*
1572 * Test IRadioNetwork.getCellInfoList() for the response returned.
1573 */
TEST_P(RadioNetworkTest,getCellInfoList)1574 TEST_P(RadioNetworkTest, getCellInfoList) {
1575 if (telephony_flags::enforce_telephony_feature_mapping()) {
1576 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1577 GTEST_SKIP() << "Skipping getCellInfoList "
1578 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1579 }
1580 }
1581
1582 serial = GetRandomSerialNumber();
1583
1584 ndk::ScopedAStatus res = radio_network->getCellInfoList(serial);
1585 ASSERT_OK(res);
1586 EXPECT_EQ(std::cv_status::no_timeout, wait());
1587 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1588 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1589
1590 ALOGI("getCellInfoList, rspInfo.error = %s\n",
1591 toString(radioRsp_network->rspInfo.error).c_str());
1592 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1593 {RadioError::NONE, RadioError::NO_NETWORK_FOUND}));
1594 }
1595
1596 /*
1597 * Test IRadioNetwork.getVoiceRegistrationState() for the response returned.
1598 */
TEST_P(RadioNetworkTest,getVoiceRegistrationState)1599 TEST_P(RadioNetworkTest, getVoiceRegistrationState) {
1600 if (telephony_flags::enforce_telephony_feature_mapping()) {
1601 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1602 GTEST_SKIP() << "Skipping getVoiceRegistrationState "
1603 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1604 }
1605 }
1606
1607 serial = GetRandomSerialNumber();
1608
1609 ndk::ScopedAStatus res = radio_network->getVoiceRegistrationState(serial);
1610 ASSERT_OK(res);
1611 EXPECT_EQ(std::cv_status::no_timeout, wait());
1612 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1613 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1614
1615 ALOGI("getVoiceRegistrationStateResponse, rspInfo.error = %s\n",
1616 toString(radioRsp_network->rspInfo.error).c_str());
1617 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1618 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE}));
1619 }
1620
1621 /*
1622 * Test IRadioNetwork.getDataRegistrationState() for the response returned.
1623 */
TEST_P(RadioNetworkTest,getDataRegistrationState)1624 TEST_P(RadioNetworkTest, getDataRegistrationState) {
1625 if (telephony_flags::enforce_telephony_feature_mapping()) {
1626 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1627 GTEST_SKIP() << "Skipping getDataRegistrationState "
1628 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1629 }
1630 }
1631
1632 serial = GetRandomSerialNumber();
1633
1634 ndk::ScopedAStatus res = radio_network->getDataRegistrationState(serial);
1635 ASSERT_OK(res);
1636 EXPECT_EQ(std::cv_status::no_timeout, wait());
1637 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1638 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1639
1640 ALOGI("getDataRegistrationStateResponse, rspInfo.error = %s\n",
1641 toString(radioRsp_network->rspInfo.error).c_str());
1642 ASSERT_TRUE(CheckAnyOfErrors(
1643 radioRsp_network->rspInfo.error,
1644 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::NOT_PROVISIONED}));
1645
1646 // Check the mcc [0, 999] and mnc [0, 999].
1647 std::string mcc;
1648 std::string mnc;
1649 bool checkMccMnc = true;
1650 CellIdentity cellIdentity = radioRsp_network->dataRegResp.cellIdentity;
1651 switch (cellIdentity.getTag()) {
1652 case CellIdentity::noinit: {
1653 checkMccMnc = false;
1654 break;
1655 }
1656 case CellIdentity::gsm: {
1657 CellIdentityGsm cig = cellIdentity.get<CellIdentity::gsm>();
1658 mcc = cig.mcc;
1659 mnc = cig.mnc;
1660 break;
1661 }
1662 case CellIdentity::wcdma: {
1663 CellIdentityWcdma ciw = cellIdentity.get<CellIdentity::wcdma>();
1664 mcc = ciw.mcc;
1665 mnc = ciw.mnc;
1666 break;
1667 }
1668 case CellIdentity::tdscdma: {
1669 CellIdentityTdscdma cit = cellIdentity.get<CellIdentity::tdscdma>();
1670 mcc = cit.mcc;
1671 mnc = cit.mnc;
1672 break;
1673 }
1674 case CellIdentity::cdma: {
1675 // CellIdentityCdma has no mcc/mnc
1676 CellIdentityCdma cic = cellIdentity.get<CellIdentity::cdma>();
1677 checkMccMnc = false;
1678 break;
1679 }
1680 case CellIdentity::lte: {
1681 CellIdentityLte cil = cellIdentity.get<CellIdentity::lte>();
1682 mcc = cil.mcc;
1683 mnc = cil.mnc;
1684 break;
1685 }
1686 case CellIdentity::nr: {
1687 CellIdentityNr cin = cellIdentity.get<CellIdentity::nr>();
1688 mcc = cin.mcc;
1689 mnc = cin.mnc;
1690 break;
1691 }
1692 }
1693
1694 // 32 bit system might return invalid mcc and mnc string "\xff\xff..."
1695 if (checkMccMnc) {
1696 int mccSize = mcc.size();
1697 EXPECT_TRUE(mccSize == 0 || mccSize == 3);
1698 if (mccSize > 0) {
1699 int mcc_int = stoi(mcc);
1700 EXPECT_TRUE(mcc_int >= 0 && mcc_int <= 999);
1701 }
1702
1703 int mncSize = mnc.size();
1704 EXPECT_TRUE(mncSize == 0 || mncSize == 2 || mncSize == 3);
1705 if (mncSize > 0) {
1706 int mnc_int = stoi(mnc);
1707 EXPECT_TRUE(mnc_int >= 0 && mnc_int <= 999);
1708 }
1709 }
1710
1711 // Check for access technology specific info
1712 AccessTechnologySpecificInfo info = radioRsp_network->dataRegResp.accessTechnologySpecificInfo;
1713 RadioTechnology rat = radioRsp_network->dataRegResp.rat;
1714
1715 // TODO: add logic for cdmaInfo
1716 if (rat == RadioTechnology::LTE) {
1717 ASSERT_EQ(info.getTag(), AccessTechnologySpecificInfo::eutranInfo);
1718 } else if (rat == RadioTechnology::NR) {
1719 ASSERT_TRUE(info.getTag() == AccessTechnologySpecificInfo::ngranNrVopsInfo);
1720 }
1721 }
1722
1723 /*
1724 * Test IRadioNetwork.getAvailableBandModes() for the response returned.
1725 */
TEST_P(RadioNetworkTest,getAvailableBandModes)1726 TEST_P(RadioNetworkTest, getAvailableBandModes) {
1727 if (telephony_flags::enforce_telephony_feature_mapping()) {
1728 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1729 GTEST_SKIP() << "Skipping getAvailableBandModes "
1730 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1731 }
1732 }
1733
1734 serial = GetRandomSerialNumber();
1735
1736 ndk::ScopedAStatus res = radio_network->getAvailableBandModes(serial);
1737 ASSERT_OK(res);
1738 EXPECT_EQ(std::cv_status::no_timeout, wait());
1739 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1740 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1741 ALOGI("getAvailableBandModes, rspInfo.error = %s\n",
1742 toString(radioRsp_network->rspInfo.error).c_str());
1743 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1744 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
1745 RadioError::MODEM_ERR, RadioError::INTERNAL_ERR,
1746 // If REQUEST_NOT_SUPPORTED is returned, then it should also be
1747 // returned for setBandMode().
1748 RadioError::REQUEST_NOT_SUPPORTED}));
1749 bool hasUnspecifiedBandMode = false;
1750 if (radioRsp_network->rspInfo.error == RadioError::NONE) {
1751 for (const RadioBandMode& mode : radioRsp_network->radioBandModes) {
1752 // Automatic mode selection must be supported
1753 if (mode == RadioBandMode::BAND_MODE_UNSPECIFIED) hasUnspecifiedBandMode = true;
1754 }
1755 ASSERT_TRUE(hasUnspecifiedBandMode);
1756 }
1757 }
1758
1759 /*
1760 * Test IRadioNetwork.setIndicationFilter()
1761 */
TEST_P(RadioNetworkTest,setIndicationFilter)1762 TEST_P(RadioNetworkTest, setIndicationFilter) {
1763 if (telephony_flags::enforce_telephony_feature_mapping()) {
1764 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1765 GTEST_SKIP() << "Skipping setIndicationFilter "
1766 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1767 }
1768 }
1769
1770 serial = GetRandomSerialNumber();
1771
1772 ndk::ScopedAStatus res =
1773 radio_network->setIndicationFilter(serial, static_cast<int>(IndicationFilter::ALL));
1774 ASSERT_OK(res);
1775 EXPECT_EQ(std::cv_status::no_timeout, wait());
1776 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1777 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1778
1779 ALOGI("setIndicationFilter, rspInfo.error = %s\n",
1780 toString(radioRsp_network->rspInfo.error).c_str());
1781 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE}));
1782 }
1783
1784 /*
1785 * Test IRadioNetwork.setBarringPassword() for the response returned.
1786 */
TEST_P(RadioNetworkTest,setBarringPassword)1787 TEST_P(RadioNetworkTest, setBarringPassword) {
1788 if (telephony_flags::enforce_telephony_feature_mapping()) {
1789 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1790 GTEST_SKIP() << "Skipping setBarringPassword "
1791 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1792 }
1793 }
1794
1795 serial = GetRandomSerialNumber();
1796 std::string facility = "";
1797 std::string oldPassword = "";
1798 std::string newPassword = "";
1799
1800 radio_network->setBarringPassword(serial, facility, oldPassword, newPassword);
1801
1802 EXPECT_EQ(std::cv_status::no_timeout, wait());
1803 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1804 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1805
1806 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1807 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1808 {RadioError::NONE, RadioError::FDN_CHECK_FAILURE,
1809 RadioError::INVALID_ARGUMENTS, RadioError::MODEM_ERR},
1810 CHECK_GENERAL_ERROR));
1811 }
1812 }
1813
1814 /*
1815 * Test IRadioNetwork.setSuppServiceNotifications() for the response returned.
1816 */
TEST_P(RadioNetworkTest,setSuppServiceNotifications)1817 TEST_P(RadioNetworkTest, setSuppServiceNotifications) {
1818 if (telephony_flags::enforce_telephony_feature_mapping()) {
1819 if (!deviceSupportsFeature(FEATURE_TELEPHONY_CALLING)) {
1820 GTEST_SKIP() << "Skipping setSuppServiceNotifications "
1821 "due to undefined FEATURE_TELEPHONY_CALLING";
1822 }
1823 }
1824
1825 serial = GetRandomSerialNumber();
1826 bool enable = false;
1827
1828 radio_network->setSuppServiceNotifications(serial, enable);
1829
1830 EXPECT_EQ(std::cv_status::no_timeout, wait());
1831 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1832 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1833
1834 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1835 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1836 {RadioError::NONE, RadioError::SIM_ABSENT}));
1837 }
1838 }
1839
1840 /*
1841 * Test IRadioNetwork.getImsRegistrationState() for the response returned.
1842 */
TEST_P(RadioNetworkTest,getImsRegistrationState)1843 TEST_P(RadioNetworkTest, getImsRegistrationState) {
1844 if (telephony_flags::enforce_telephony_feature_mapping()) {
1845 if (!deviceSupportsFeature(FEATURE_TELEPHONY_IMS)) {
1846 GTEST_SKIP() << "Skipping getImsRegistrationState "
1847 "due to undefined FEATURE_TELEPHONY_IMS";
1848 }
1849 }
1850
1851 serial = GetRandomSerialNumber();
1852
1853 radio_network->getImsRegistrationState(serial);
1854
1855 EXPECT_EQ(std::cv_status::no_timeout, wait());
1856 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1857 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1858
1859 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1860 ASSERT_TRUE(CheckAnyOfErrors(
1861 radioRsp_network->rspInfo.error,
1862 {RadioError::NONE, RadioError::MODEM_ERR, RadioError::INVALID_MODEM_STATE},
1863 CHECK_GENERAL_ERROR));
1864 }
1865 }
1866
1867 /*
1868 * Test IRadioNetwork.getOperator() for the response returned.
1869 */
TEST_P(RadioNetworkTest,getOperator)1870 TEST_P(RadioNetworkTest, getOperator) {
1871 if (telephony_flags::enforce_telephony_feature_mapping()) {
1872 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1873 GTEST_SKIP() << "Skipping getOperator "
1874 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1875 }
1876 }
1877
1878 serial = GetRandomSerialNumber();
1879
1880 radio_network->getOperator(serial);
1881 EXPECT_EQ(std::cv_status::no_timeout, wait());
1882 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1883 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1884
1885 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1886 EXPECT_EQ(RadioError::NONE, radioRsp_network->rspInfo.error);
1887 }
1888 }
1889
1890 /*
1891 * Test IRadioNetwork.getNetworkSelectionMode() for the response returned.
1892 */
TEST_P(RadioNetworkTest,getNetworkSelectionMode)1893 TEST_P(RadioNetworkTest, getNetworkSelectionMode) {
1894 if (telephony_flags::enforce_telephony_feature_mapping()) {
1895 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1896 GTEST_SKIP() << "Skipping getNetworkSelectionMode "
1897 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1898 }
1899 }
1900
1901 serial = GetRandomSerialNumber();
1902
1903 radio_network->getNetworkSelectionMode(serial);
1904 EXPECT_EQ(std::cv_status::no_timeout, wait());
1905 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1906 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1907
1908 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1909 EXPECT_EQ(RadioError::NONE, radioRsp_network->rspInfo.error);
1910 }
1911 }
1912
1913 /*
1914 * Test IRadioNetwork.setNetworkSelectionModeAutomatic() for the response returned.
1915 */
TEST_P(RadioNetworkTest,setNetworkSelectionModeAutomatic)1916 TEST_P(RadioNetworkTest, setNetworkSelectionModeAutomatic) {
1917 if (telephony_flags::enforce_telephony_feature_mapping()) {
1918 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1919 GTEST_SKIP() << "Skipping setNetworkSelectionModeAutomatic "
1920 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1921 }
1922 }
1923
1924 serial = GetRandomSerialNumber();
1925
1926 radio_network->setNetworkSelectionModeAutomatic(serial);
1927 EXPECT_EQ(std::cv_status::no_timeout, wait());
1928 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1929 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1930
1931 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1932 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
1933 {RadioError::NONE, RadioError::ILLEGAL_SIM_OR_ME,
1934 RadioError::OPERATION_NOT_ALLOWED},
1935 CHECK_GENERAL_ERROR));
1936 }
1937 }
1938
1939 /*
1940 * Test IRadioNetwork.getAvailableNetworks() for the response returned.
1941 */
TEST_P(RadioNetworkTest,getAvailableNetworks)1942 TEST_P(RadioNetworkTest, getAvailableNetworks) {
1943 if (telephony_flags::enforce_telephony_feature_mapping()) {
1944 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1945 GTEST_SKIP() << "Skipping getAvailableNetworks "
1946 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1947 }
1948 }
1949
1950 serial = GetRandomSerialNumber();
1951
1952 radio_network->getAvailableNetworks(serial);
1953 EXPECT_EQ(std::cv_status::no_timeout, wait());
1954 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1955 ASSERT_TRUE(radioRsp_network->rspInfo.type == RadioResponseType::SOLICITED ||
1956 radioRsp_network->rspInfo.type == RadioResponseType::SOLICITED_ACK_EXP);
1957
1958 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1959 ASSERT_TRUE(CheckAnyOfErrors(
1960 radioRsp_network->rspInfo.error,
1961 {RadioError::NONE, RadioError::CANCELLED, RadioError::DEVICE_IN_USE,
1962 RadioError::MODEM_ERR, RadioError::OPERATION_NOT_ALLOWED},
1963 CHECK_GENERAL_ERROR));
1964 }
1965 }
1966
1967 /*
1968 * Test IRadioNetwork.setBandMode() for the response returned.
1969 */
TEST_P(RadioNetworkTest,setBandMode)1970 TEST_P(RadioNetworkTest, setBandMode) {
1971 if (telephony_flags::enforce_telephony_feature_mapping()) {
1972 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1973 GTEST_SKIP() << "Skipping setBandMode "
1974 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1975 }
1976 }
1977
1978 serial = GetRandomSerialNumber();
1979
1980 radio_network->setBandMode(serial, RadioBandMode::BAND_MODE_USA);
1981 EXPECT_EQ(std::cv_status::no_timeout, wait());
1982 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
1983 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
1984
1985 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
1986 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error, {RadioError::NONE},
1987 CHECK_GENERAL_ERROR));
1988 }
1989 }
1990
1991 /*
1992 * Test IRadioNetwork.setLocationUpdates() for the response returned.
1993 */
TEST_P(RadioNetworkTest,setLocationUpdates)1994 TEST_P(RadioNetworkTest, setLocationUpdates) {
1995 if (telephony_flags::enforce_telephony_feature_mapping()) {
1996 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
1997 GTEST_SKIP() << "Skipping setLocationUpdates "
1998 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
1999 }
2000 }
2001
2002 serial = GetRandomSerialNumber();
2003
2004 radio_network->setLocationUpdates(serial, true);
2005 EXPECT_EQ(std::cv_status::no_timeout, wait());
2006 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2007 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2008
2009 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
2010 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
2011 {RadioError::NONE, RadioError::SIM_ABSENT}));
2012 }
2013 }
2014
2015 /*
2016 * Test IRadioNetwork.setCdmaRoamingPreference() for the response returned.
2017 */
TEST_P(RadioNetworkTest,setCdmaRoamingPreference)2018 TEST_P(RadioNetworkTest, setCdmaRoamingPreference) {
2019 if (telephony_flags::enforce_telephony_feature_mapping()) {
2020 if (!deviceSupportsFeature(FEATURE_TELEPHONY_CDMA)) {
2021 GTEST_SKIP() << "Skipping setCdmaRoamingPreference "
2022 "due to undefined FEATURE_TELEPHONY_CDMA";
2023 }
2024 }
2025
2026 serial = GetRandomSerialNumber();
2027
2028 radio_network->setCdmaRoamingPreference(serial, CdmaRoamingType::HOME_NETWORK);
2029 EXPECT_EQ(std::cv_status::no_timeout, wait());
2030 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2031 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2032
2033 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
2034 ASSERT_TRUE(CheckAnyOfErrors(
2035 radioRsp_network->rspInfo.error,
2036 {RadioError::NONE, RadioError::SIM_ABSENT, RadioError::REQUEST_NOT_SUPPORTED}));
2037 }
2038 }
2039
2040 /*
2041 * Test IRadioNetwork.getCdmaRoamingPreference() for the response returned.
2042 */
TEST_P(RadioNetworkTest,getCdmaRoamingPreference)2043 TEST_P(RadioNetworkTest, getCdmaRoamingPreference) {
2044 if (telephony_flags::enforce_telephony_feature_mapping()) {
2045 if (!deviceSupportsFeature(FEATURE_TELEPHONY_CDMA)) {
2046 GTEST_SKIP() << "Skipping getCdmaRoamingPreference "
2047 "due to undefined FEATURE_TELEPHONY_CDMA";
2048 }
2049 }
2050
2051 serial = GetRandomSerialNumber();
2052
2053 radio_network->getCdmaRoamingPreference(serial);
2054 EXPECT_EQ(std::cv_status::no_timeout, wait());
2055 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2056 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2057
2058 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
2059 ASSERT_TRUE(
2060 CheckAnyOfErrors(radioRsp_network->rspInfo.error,
2061 {RadioError::NONE, RadioError::SIM_ABSENT, RadioError::MODEM_ERR},
2062 CHECK_GENERAL_ERROR));
2063 }
2064 }
2065
2066 /*
2067 * Test IRadioNetwork.getVoiceRadioTechnology() for the response returned.
2068 */
TEST_P(RadioNetworkTest,getVoiceRadioTechnology)2069 TEST_P(RadioNetworkTest, getVoiceRadioTechnology) {
2070 if (telephony_flags::enforce_telephony_feature_mapping()) {
2071 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
2072 GTEST_SKIP() << "Skipping getVoiceRadioTechnology "
2073 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
2074 }
2075 }
2076
2077 serial = GetRandomSerialNumber();
2078
2079 radio_network->getVoiceRadioTechnology(serial);
2080 EXPECT_EQ(std::cv_status::no_timeout, wait());
2081 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2082 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2083
2084 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
2085 EXPECT_EQ(RadioError::NONE, radioRsp_network->rspInfo.error);
2086 }
2087 }
2088
2089 /*
2090 * Test IRadioNetwork.setCellInfoListRate() for the response returned.
2091 */
TEST_P(RadioNetworkTest,setCellInfoListRate)2092 TEST_P(RadioNetworkTest, setCellInfoListRate) {
2093 if (telephony_flags::enforce_telephony_feature_mapping()) {
2094 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
2095 GTEST_SKIP() << "Skipping setCellInfoListRate "
2096 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
2097 }
2098 }
2099
2100 serial = GetRandomSerialNumber();
2101
2102 radio_network->setCellInfoListRate(serial, 10);
2103 EXPECT_EQ(std::cv_status::no_timeout, wait());
2104 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2105 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2106
2107 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
2108 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
2109 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED}));
2110 }
2111 }
2112
2113 /*
2114 * Test IRadioNetwork.supplyNetworkDepersonalization() for the response returned.
2115 */
TEST_P(RadioNetworkTest,supplyNetworkDepersonalization)2116 TEST_P(RadioNetworkTest, supplyNetworkDepersonalization) {
2117 if (telephony_flags::enforce_telephony_feature_mapping()) {
2118 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
2119 GTEST_SKIP() << "Skipping supplyNetworkDepersonalization "
2120 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
2121 }
2122 }
2123
2124 serial = GetRandomSerialNumber();
2125
2126 radio_network->supplyNetworkDepersonalization(serial, std::string("test"));
2127 EXPECT_EQ(std::cv_status::no_timeout, wait());
2128 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2129 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2130
2131 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
2132 ASSERT_TRUE(CheckAnyOfErrors(
2133 radioRsp_network->rspInfo.error,
2134 {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::INTERNAL_ERR,
2135 RadioError::INVALID_SIM_STATE, RadioError::MODEM_ERR, RadioError::NO_MEMORY,
2136 RadioError::PASSWORD_INCORRECT, RadioError::SIM_ABSENT, RadioError::SYSTEM_ERR}));
2137 }
2138 }
2139
2140 /*
2141 * Test IRadioNetwork.setEmergencyMode() for the response returned.
2142 */
TEST_P(RadioNetworkTest,setEmergencyMode)2143 TEST_P(RadioNetworkTest, setEmergencyMode) {
2144 if (telephony_flags::enforce_telephony_feature_mapping()) {
2145 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
2146 GTEST_SKIP() << "Skipping setEmergencyMode "
2147 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
2148 }
2149 }
2150
2151 int32_t aidl_version;
2152 ndk::ScopedAStatus aidl_status = radio_network->getInterfaceVersion(&aidl_version);
2153 ASSERT_OK(aidl_status);
2154 if (aidl_version < 2) {
2155 ALOGI("Skipped the test since setEmergencyMode is not supported on version < 2.");
2156 GTEST_SKIP();
2157 }
2158
2159 serial = GetRandomSerialNumber();
2160
2161 radio_network->setEmergencyMode(serial, EmergencyMode::EMERGENCY_WWAN);
2162 EXPECT_EQ(std::cv_status::no_timeout, wait());
2163 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2164 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2165
2166 ASSERT_TRUE(CheckAnyOfErrors(
2167 radioRsp_network->rspInfo.error,
2168 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED, RadioError::RADIO_NOT_AVAILABLE,
2169 RadioError::MODEM_ERR, RadioError::INVALID_ARGUMENTS}));
2170
2171 // exit emergency mode for other tests
2172 serial = GetRandomSerialNumber();
2173 radio_network->exitEmergencyMode(serial);
2174 }
2175
2176 /*
2177 * Test IRadioNetwork.triggerEmergencyNetworkScan() for the response returned.
2178 */
TEST_P(RadioNetworkTest,triggerEmergencyNetworkScan)2179 TEST_P(RadioNetworkTest, triggerEmergencyNetworkScan) {
2180 if (telephony_flags::enforce_telephony_feature_mapping()) {
2181 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
2182 GTEST_SKIP() << "Skipping triggerEmergencyNetworkScan "
2183 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
2184 }
2185 }
2186
2187 int32_t aidl_version;
2188 ndk::ScopedAStatus aidl_status = radio_network->getInterfaceVersion(&aidl_version);
2189 ASSERT_OK(aidl_status);
2190 if (aidl_version < 2) {
2191 ALOGI("Skipped the test since"
2192 " triggerEmergencyNetworkScan is not supported on version < 2.");
2193 GTEST_SKIP();
2194 }
2195
2196 serial = GetRandomSerialNumber();
2197
2198 radio_network->setEmergencyMode(serial, EmergencyMode::EMERGENCY_WWAN);
2199 EXPECT_EQ(std::cv_status::no_timeout, wait());
2200 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2201 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2202
2203 ASSERT_TRUE(CheckAnyOfErrors(
2204 radioRsp_network->rspInfo.error,
2205 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED, RadioError::RADIO_NOT_AVAILABLE,
2206 RadioError::MODEM_ERR, RadioError::INVALID_ARGUMENTS}));
2207
2208 serial = GetRandomSerialNumber();
2209
2210 EmergencyNetworkScanTrigger scanRequest;
2211 scanRequest.accessNetwork = {AccessNetwork::EUTRAN};
2212 scanRequest.scanType = EmergencyScanType::NO_PREFERENCE;
2213
2214 radio_network->triggerEmergencyNetworkScan(serial, scanRequest);
2215 EXPECT_EQ(std::cv_status::no_timeout, wait());
2216 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2217 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2218
2219 ASSERT_TRUE(CheckAnyOfErrors(
2220 radioRsp_network->rspInfo.error,
2221 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED, RadioError::RADIO_NOT_AVAILABLE,
2222 RadioError::MODEM_ERR, RadioError::INVALID_ARGUMENTS}));
2223
2224 // exit emergency mode for other tests
2225 serial = GetRandomSerialNumber();
2226
2227 radio_network->exitEmergencyMode(serial);
2228
2229 EXPECT_EQ(std::cv_status::no_timeout, wait());
2230 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2231 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2232
2233 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
2234 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED,
2235 RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR}));
2236 }
2237
2238 /*
2239 * Test IRadioNetwork.cancelEmergencyNetworkScan() for the response returned.
2240 */
TEST_P(RadioNetworkTest,cancelEmergencyNetworkScan)2241 TEST_P(RadioNetworkTest, cancelEmergencyNetworkScan) {
2242 if (telephony_flags::enforce_telephony_feature_mapping()) {
2243 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
2244 GTEST_SKIP() << "Skipping cancelEmergencyNetworkScan "
2245 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
2246 }
2247 }
2248
2249 int32_t aidl_version;
2250 ndk::ScopedAStatus aidl_status = radio_network->getInterfaceVersion(&aidl_version);
2251 ASSERT_OK(aidl_status);
2252 if (aidl_version < 2) {
2253 ALOGI("Skipped the test since cancelEmergencyNetworkScan is not supported on version < 2.");
2254 GTEST_SKIP();
2255 }
2256
2257 serial = GetRandomSerialNumber();
2258
2259 radio_network->cancelEmergencyNetworkScan(serial, true);
2260 EXPECT_EQ(std::cv_status::no_timeout, wait());
2261 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2262 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2263
2264 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
2265 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED,
2266 RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR}));
2267 }
2268
2269 /*
2270 * Test IRadioNetwork.exitEmergencyMode() for the response returned.
2271 */
TEST_P(RadioNetworkTest,exitEmergencyMode)2272 TEST_P(RadioNetworkTest, exitEmergencyMode) {
2273 if (telephony_flags::enforce_telephony_feature_mapping()) {
2274 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
2275 GTEST_SKIP() << "Skipping exitEmergencyMode "
2276 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
2277 }
2278 }
2279
2280 int32_t aidl_version;
2281 ndk::ScopedAStatus aidl_status = radio_network->getInterfaceVersion(&aidl_version);
2282 ASSERT_OK(aidl_status);
2283 if (aidl_version < 2) {
2284 ALOGI("Skipped the test since exitEmergencyMode is not supported on version < 2.");
2285 GTEST_SKIP();
2286 }
2287
2288 serial = GetRandomSerialNumber();
2289
2290 radio_network->exitEmergencyMode(serial);
2291 EXPECT_EQ(std::cv_status::no_timeout, wait());
2292 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2293 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2294
2295 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
2296 {RadioError::NONE, RadioError::REQUEST_NOT_SUPPORTED,
2297 RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR}));
2298 }
2299
2300 /*
2301 * Test IRadioNetwork.setN1ModeEnabled() for the response returned.
2302 */
TEST_P(RadioNetworkTest,setN1ModeEnabled)2303 TEST_P(RadioNetworkTest, setN1ModeEnabled) {
2304 if (telephony_flags::enforce_telephony_feature_mapping()) {
2305 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
2306 GTEST_SKIP() << "Skipping setN1ModeEnabled "
2307 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
2308 }
2309 }
2310
2311 int32_t aidl_version;
2312 ndk::ScopedAStatus aidl_status = radio_network->getInterfaceVersion(&aidl_version);
2313 ASSERT_OK(aidl_status);
2314 if (aidl_version < 2) {
2315 ALOGI("Skipped the test since setN1ModeEnabled is not supported on version < 2.");
2316 GTEST_SKIP();
2317 }
2318
2319 serial = GetRandomSerialNumber();
2320
2321 ndk::ScopedAStatus res =
2322 radio_network->setN1ModeEnabled(serial, false);
2323 ASSERT_OK(res);
2324
2325 EXPECT_EQ(std::cv_status::no_timeout, wait());
2326 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2327 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2328 if (getRadioHalCapabilities()) {
2329 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
2330 {RadioError::REQUEST_NOT_SUPPORTED}));
2331 } else {
2332 ASSERT_TRUE(CheckAnyOfErrors(
2333 radioRsp_network->rspInfo.error,
2334 {RadioError::RADIO_NOT_AVAILABLE, RadioError::INTERNAL_ERR,
2335 RadioError::INVALID_STATE, RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
2336 }
2337 }
2338
2339 /*
2340 * Test IRadioNetwork.isN1ModeEnabled() for the response returned.
2341 */
TEST_P(RadioNetworkTest,isN1ModeEnabled)2342 TEST_P(RadioNetworkTest, isN1ModeEnabled) {
2343 if (telephony_flags::enforce_telephony_feature_mapping()) {
2344 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
2345 GTEST_SKIP() << "Skipping isN1ModeEnabled "
2346 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
2347 }
2348 }
2349
2350 int32_t aidl_version;
2351 ndk::ScopedAStatus aidl_status = radio_network->getInterfaceVersion(&aidl_version);
2352 ASSERT_OK(aidl_status);
2353 if (aidl_version < 2) {
2354 ALOGI("Skipped the test since isN1ModeEnabled is not supported on version < 2.");
2355 GTEST_SKIP();
2356 }
2357
2358 serial = GetRandomSerialNumber();
2359
2360 ndk::ScopedAStatus res = radio_network->isN1ModeEnabled(serial);
2361 ASSERT_OK(res);
2362
2363 EXPECT_EQ(std::cv_status::no_timeout, wait());
2364 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2365 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2366 if (getRadioHalCapabilities()) {
2367 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
2368 {RadioError::REQUEST_NOT_SUPPORTED}));
2369 } else {
2370 ASSERT_TRUE(CheckAnyOfErrors(
2371 radioRsp_network->rspInfo.error,
2372 {RadioError::RADIO_NOT_AVAILABLE, RadioError::INTERNAL_ERR,
2373 RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
2374 }
2375 }
2376
2377 /*
2378 * Test IRadioNetwork.setNullCipherAndIntegrityEnabled() for the response returned.
2379 */
TEST_P(RadioNetworkTest,setNullCipherAndIntegrityEnabled)2380 TEST_P(RadioNetworkTest, setNullCipherAndIntegrityEnabled) {
2381 if (telephony_flags::enforce_telephony_feature_mapping()) {
2382 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
2383 GTEST_SKIP() << "Skipping setNullCipherAndIntegrityEnabled "
2384 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
2385 }
2386 }
2387
2388 int32_t aidl_version;
2389 ndk::ScopedAStatus aidl_status = radio_network->getInterfaceVersion(&aidl_version);
2390 ASSERT_OK(aidl_status);
2391 if (aidl_version < 2) {
2392 ALOGI("Skipped the test since"
2393 " setNullCipherAndIntegrityEnabled is not supported on version < 2.");
2394 GTEST_SKIP();
2395 }
2396
2397 serial = GetRandomSerialNumber();
2398
2399 radio_network->setNullCipherAndIntegrityEnabled(serial, false);
2400 EXPECT_EQ(std::cv_status::no_timeout, wait());
2401 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2402 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2403
2404 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
2405 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
2406 RadioError::MODEM_ERR, RadioError::REQUEST_NOT_SUPPORTED}));
2407 }
2408
2409 /**
2410 * Test IRadioNetwork.isNullCipherAndIntegrityEnabled() for the response returned.
2411 */
TEST_P(RadioNetworkTest,isNullCipherAndIntegrityEnabled)2412 TEST_P(RadioNetworkTest, isNullCipherAndIntegrityEnabled) {
2413 if (telephony_flags::enforce_telephony_feature_mapping()) {
2414 if (!deviceSupportsFeature(FEATURE_TELEPHONY_RADIO_ACCESS)) {
2415 GTEST_SKIP() << "Skipping isNullCipherAndIntegrityEnabled "
2416 "due to undefined FEATURE_TELEPHONY_RADIO_ACCESS";
2417 }
2418 }
2419
2420 int32_t aidl_version;
2421 ndk::ScopedAStatus aidl_status = radio_network->getInterfaceVersion(&aidl_version);
2422 ASSERT_OK(aidl_status);
2423 if (aidl_version < 2) {
2424 ALOGI("Skipped the test since"
2425 " isNullCipherAndIntegrityEnabled is not supported on version < 2.");
2426 GTEST_SKIP();
2427 }
2428
2429 serial = GetRandomSerialNumber();
2430
2431 ndk::ScopedAStatus res = radio_network->isNullCipherAndIntegrityEnabled(serial);
2432 ASSERT_OK(res);
2433
2434 EXPECT_EQ(std::cv_status::no_timeout, wait());
2435 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2436 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2437
2438 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
2439 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
2440 RadioError::MODEM_ERR, RadioError::REQUEST_NOT_SUPPORTED}));
2441 }
2442
TEST_P(RadioNetworkTest,isCellularIdentifierTransparencyEnabled)2443 TEST_P(RadioNetworkTest, isCellularIdentifierTransparencyEnabled) {
2444 int32_t aidl_version;
2445 ndk::ScopedAStatus aidl_status = radio_network->getInterfaceVersion(&aidl_version);
2446 ASSERT_OK(aidl_status);
2447 if (aidl_version < 3) {
2448 ALOGI("Skipped the test since"
2449 " isCellularIdentifierTransparencyEnabled is not supported on version < 3.");
2450 GTEST_SKIP();
2451 }
2452
2453 serial = GetRandomSerialNumber();
2454
2455 ndk::ScopedAStatus res = radio_network->isCellularIdentifierTransparencyEnabled(serial);
2456 ASSERT_OK(res);
2457
2458 EXPECT_EQ(std::cv_status::no_timeout, wait());
2459 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2460 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2461
2462 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
2463 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
2464 RadioError::MODEM_ERR, RadioError::REQUEST_NOT_SUPPORTED}));
2465 }
2466
TEST_P(RadioNetworkTest,setCellularIdentifierTransparencyEnabled)2467 TEST_P(RadioNetworkTest, setCellularIdentifierTransparencyEnabled) {
2468 int32_t aidl_version;
2469 ndk::ScopedAStatus aidl_status = radio_network->getInterfaceVersion(&aidl_version);
2470 ASSERT_OK(aidl_status);
2471 if (aidl_version < 3) {
2472 ALOGI("Skipped the test since"
2473 " setCellularIdentifierTransparencyEnabled is not supported on version < 3.");
2474 GTEST_SKIP();
2475 }
2476
2477 // Get current value
2478 serial = GetRandomSerialNumber();
2479 radio_network->isCellularIdentifierTransparencyEnabled(serial);
2480 EXPECT_EQ(std::cv_status::no_timeout, wait());
2481 bool originalTransparencySetting = radioRsp_network->isCellularIdentifierTransparencyEnabled;
2482
2483 // We want to test flipping the value, so we are going to set it to the opposite of what
2484 // the existing setting is. The test for isCellularIdentifierTransparencyEnabled should check
2485 // for the right default value.
2486 bool valueToSet = !originalTransparencySetting;
2487 serial = GetRandomSerialNumber();
2488 radio_network->setCellularIdentifierTransparencyEnabled(serial, valueToSet);
2489 EXPECT_EQ(std::cv_status::no_timeout, wait());
2490 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2491 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2492
2493 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
2494 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
2495 RadioError::MODEM_ERR, RadioError::REQUEST_NOT_SUPPORTED}));
2496
2497 // Assert the value has changed
2498 serial = GetRandomSerialNumber();
2499 ndk::ScopedAStatus res = radio_network->isCellularIdentifierTransparencyEnabled(serial);
2500
2501 ASSERT_OK(res);
2502 EXPECT_EQ(std::cv_status::no_timeout, wait());
2503 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2504 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2505 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
2506 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
2507 RadioError::MODEM_ERR, RadioError::REQUEST_NOT_SUPPORTED}));
2508 EXPECT_EQ(valueToSet, radioRsp_network->isCellularIdentifierTransparencyEnabled);
2509
2510 // Reset original state
2511 radio_network->setCellularIdentifierTransparencyEnabled(serial, originalTransparencySetting);
2512 EXPECT_EQ(std::cv_status::no_timeout, wait());
2513 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2514 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2515 }
2516
2517 /*
2518 * Test IRadioNetwork.setSecurityAlgorithmsUpdatedEnabled for the response returned.
2519 */
TEST_P(RadioNetworkTest,setSecurityAlgorithmsUpdatedEnabled)2520 TEST_P(RadioNetworkTest, setSecurityAlgorithmsUpdatedEnabled) {
2521 int32_t aidl_version;
2522 ndk::ScopedAStatus aidl_status = radio_network->getInterfaceVersion(&aidl_version);
2523 ASSERT_OK(aidl_status);
2524 if (aidl_version < 3) {
2525 ALOGI("Skipped the test since"
2526 " setSecurityAlgorithmsUpdatedEnabled is not supported on version < 3");
2527 GTEST_SKIP();
2528 }
2529
2530 // Get current value
2531 serial = GetRandomSerialNumber();
2532 radio_network->isSecurityAlgorithmsUpdatedEnabled(serial);
2533 EXPECT_EQ(std::cv_status::no_timeout, wait());
2534 bool originalSecuritySetting = radioRsp_network->isSecurityAlgorithmsUpdatedEnabled;
2535
2536 // We want to test flipping the value, so we are going to set it to the opposite of what
2537 // the existing setting is. The test for isSecurityAlgorithmsUpdatedEnabled should check
2538 // for the right default value.
2539 bool valueToSet = !originalSecuritySetting;
2540 serial = GetRandomSerialNumber();
2541 radio_network->setSecurityAlgorithmsUpdatedEnabled(serial, valueToSet);
2542 EXPECT_EQ(std::cv_status::no_timeout, wait());
2543 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2544 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2545
2546 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
2547 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
2548 RadioError::MODEM_ERR, RadioError::REQUEST_NOT_SUPPORTED}));
2549
2550 // Assert the value has changed
2551 serial = GetRandomSerialNumber();
2552 ndk::ScopedAStatus res = radio_network->isSecurityAlgorithmsUpdatedEnabled(serial);
2553
2554 ASSERT_OK(res);
2555 EXPECT_EQ(std::cv_status::no_timeout, wait());
2556 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2557 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2558 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
2559 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
2560 RadioError::MODEM_ERR, RadioError::REQUEST_NOT_SUPPORTED}));
2561 EXPECT_EQ(valueToSet, radioRsp_network->isSecurityAlgorithmsUpdatedEnabled);
2562
2563 // Reset original state
2564 radio_network->setSecurityAlgorithmsUpdatedEnabled(serial, originalSecuritySetting);
2565 EXPECT_EQ(std::cv_status::no_timeout, wait());
2566 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2567 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2568 }
2569
2570 /**
2571 * Test IRadioNetwork.isSecurityAlgorithmsUpdatedEnabled for the response returned.
2572 */
TEST_P(RadioNetworkTest,isSecurityAlgorithmsUpdatedEnabled)2573 TEST_P(RadioNetworkTest, isSecurityAlgorithmsUpdatedEnabled) {
2574 int32_t aidl_version;
2575 ndk::ScopedAStatus aidl_status = radio_network->getInterfaceVersion(&aidl_version);
2576 ASSERT_OK(aidl_status);
2577 if (aidl_version < 3) {
2578 ALOGI("Skipped the test since"
2579 " isSecurityAlgorithmsUpdatedEnabled is not supported on version < 3");
2580 GTEST_SKIP();
2581 }
2582
2583 serial = GetRandomSerialNumber();
2584
2585 ndk::ScopedAStatus res = radio_network->isSecurityAlgorithmsUpdatedEnabled(serial);
2586 ASSERT_OK(res);
2587
2588 EXPECT_EQ(std::cv_status::no_timeout, wait());
2589 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_network->rspInfo.type);
2590 EXPECT_EQ(serial, radioRsp_network->rspInfo.serial);
2591
2592 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_network->rspInfo.error,
2593 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
2594 RadioError::MODEM_ERR, RadioError::REQUEST_NOT_SUPPORTED}));
2595 }
2596