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/data/ApnTypes.h>
20 #include <android/binder_manager.h>
21
22 #include "radio_data_utils.h"
23
24 #define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
25
SetUp()26 void RadioDataTest::SetUp() {
27 RadioServiceTest::SetUp();
28 std::string serviceName = GetParam();
29
30 if (!isServiceValidForDeviceConfiguration(serviceName)) {
31 ALOGI("Skipped the test due to device configuration.");
32 GTEST_SKIP();
33 }
34
35 radio_data = IRadioData::fromBinder(
36 ndk::SpAIBinder(AServiceManager_waitForService(GetParam().c_str())));
37 ASSERT_NE(nullptr, radio_data.get());
38
39 radioRsp_data = ndk::SharedRefBase::make<RadioDataResponse>(*this);
40 ASSERT_NE(nullptr, radioRsp_data.get());
41
42 radioInd_data = ndk::SharedRefBase::make<RadioDataIndication>(*this);
43 ASSERT_NE(nullptr, radioInd_data.get());
44
45 radio_data->setResponseFunctions(radioRsp_data, radioInd_data);
46
47 // Assert IRadioSim exists and SIM is present before testing
48 radio_sim = sim::IRadioSim::fromBinder(ndk::SpAIBinder(
49 AServiceManager_waitForService("android.hardware.radio.sim.IRadioSim/slot1")));
50 ASSERT_NE(nullptr, radio_sim.get());
51 updateSimCardStatus();
52 EXPECT_EQ(CardStatus::STATE_PRESENT, cardStatus.cardState);
53
54 // Assert IRadioConfig exists before testing
55 radio_config = config::IRadioConfig::fromBinder(ndk::SpAIBinder(
56 AServiceManager_waitForService("android.hardware.radio.config.IRadioConfig/default")));
57 ASSERT_NE(nullptr, radio_config.get());
58 }
59
getDataCallList()60 ndk::ScopedAStatus RadioDataTest::getDataCallList() {
61 serial = GetRandomSerialNumber();
62 radio_data->getDataCallList(serial);
63 EXPECT_EQ(std::cv_status::no_timeout, wait());
64 return ndk::ScopedAStatus::ok();
65 }
66
67 /*
68 * Test IRadioData.setupDataCall() for the response returned.
69 */
TEST_P(RadioDataTest,setupDataCall)70 TEST_P(RadioDataTest, setupDataCall) {
71 if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) {
72 GTEST_SKIP() << "setupDataCall : required FEATURE_TELEPHONY_DATA";
73 }
74
75 serial = GetRandomSerialNumber();
76
77 AccessNetwork accessNetwork = AccessNetwork::EUTRAN;
78
79 DataProfileInfo dataProfileInfo;
80 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
81 dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT;
82 dataProfileInfo.apn = std::string("internet");
83 dataProfileInfo.protocol = PdpProtocolType::IP;
84 dataProfileInfo.roamingProtocol = PdpProtocolType::IP;
85 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
86 dataProfileInfo.user = std::string("username");
87 dataProfileInfo.password = std::string("password");
88 dataProfileInfo.type = DataProfileInfo::TYPE_3GPP;
89 dataProfileInfo.maxConnsTime = 300;
90 dataProfileInfo.maxConns = 20;
91 dataProfileInfo.waitTime = 0;
92 dataProfileInfo.enabled = true;
93 dataProfileInfo.supportedApnTypesBitmap =
94 static_cast<int32_t>(ApnTypes::IMS) | static_cast<int32_t>(ApnTypes::IA);
95 dataProfileInfo.bearerBitmap = static_cast<int32_t>(RadioAccessFamily::GPRS) |
96 static_cast<int32_t>(RadioAccessFamily::EDGE) |
97 static_cast<int32_t>(RadioAccessFamily::UMTS) |
98 static_cast<int32_t>(RadioAccessFamily::HSDPA) |
99 static_cast<int32_t>(RadioAccessFamily::HSUPA) |
100 static_cast<int32_t>(RadioAccessFamily::HSPA) |
101 static_cast<int32_t>(RadioAccessFamily::EHRPD) |
102 static_cast<int32_t>(RadioAccessFamily::LTE) |
103 static_cast<int32_t>(RadioAccessFamily::HSPAP) |
104 static_cast<int32_t>(RadioAccessFamily::IWLAN);
105 dataProfileInfo.mtuV4 = 0;
106 dataProfileInfo.mtuV6 = 0;
107 dataProfileInfo.preferred = true;
108 dataProfileInfo.persistent = false;
109
110 bool roamingAllowed = false;
111
112 std::vector<LinkAddress> addresses = {};
113 std::vector<std::string> dnses = {};
114
115 DataRequestReason reason = DataRequestReason::NORMAL;
116 SliceInfo sliceInfo;
117 bool matchAllRuleAllowed = true;
118
119 ndk::ScopedAStatus res =
120 radio_data->setupDataCall(serial, accessNetwork, dataProfileInfo, roamingAllowed,
121 reason, addresses, dnses, -1, sliceInfo, matchAllRuleAllowed);
122 ASSERT_OK(res);
123
124 EXPECT_EQ(std::cv_status::no_timeout, wait());
125 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
126 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
127 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
128 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
129 {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE,
130 RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW}));
131 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
132 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
133 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
134 RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW}));
135 }
136 }
137
138 /*
139 * Test IRadioData.setupDataCall() with osAppId for the response returned.
140 */
TEST_P(RadioDataTest,setupDataCall_osAppId)141 TEST_P(RadioDataTest, setupDataCall_osAppId) {
142 if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) {
143 GTEST_SKIP() << "Skipping setupDataCall_osAppId "
144 "due to undefined FEATURE_TELEPHONY_DATA";
145 }
146
147 serial = GetRandomSerialNumber();
148
149 AccessNetwork accessNetwork = AccessNetwork::EUTRAN;
150
151 TrafficDescriptor trafficDescriptor;
152 OsAppId osAppId;
153 osAppId.osAppId = {static_cast<unsigned char>(-105), static_cast<unsigned char>(-92),
154 static_cast<unsigned char>(-104), static_cast<unsigned char>(-29),
155 static_cast<unsigned char>(-4), static_cast<unsigned char>(-110),
156 static_cast<unsigned char>(92), static_cast<unsigned char>(-108),
157 static_cast<unsigned char>(-119), static_cast<unsigned char>(-122),
158 static_cast<unsigned char>(3), static_cast<unsigned char>(51),
159 static_cast<unsigned char>(-48), static_cast<unsigned char>(110),
160 static_cast<unsigned char>(78), static_cast<unsigned char>(71),
161 static_cast<unsigned char>(10), static_cast<unsigned char>(69),
162 static_cast<unsigned char>(78), static_cast<unsigned char>(84),
163 static_cast<unsigned char>(69), static_cast<unsigned char>(82),
164 static_cast<unsigned char>(80), static_cast<unsigned char>(82),
165 static_cast<unsigned char>(73), static_cast<unsigned char>(83),
166 static_cast<unsigned char>(69)};
167 trafficDescriptor.osAppId = osAppId;
168
169 DataProfileInfo dataProfileInfo;
170 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
171 dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT;
172 dataProfileInfo.apn = std::string("internet");
173 dataProfileInfo.protocol = PdpProtocolType::IP;
174 dataProfileInfo.roamingProtocol = PdpProtocolType::IP;
175 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
176 dataProfileInfo.user = std::string("username");
177 dataProfileInfo.password = std::string("password");
178 dataProfileInfo.type = DataProfileInfo::TYPE_3GPP;
179 dataProfileInfo.maxConnsTime = 300;
180 dataProfileInfo.maxConns = 20;
181 dataProfileInfo.waitTime = 0;
182 dataProfileInfo.enabled = true;
183 dataProfileInfo.supportedApnTypesBitmap =
184 static_cast<int32_t>(ApnTypes::IMS) | static_cast<int32_t>(ApnTypes::IA);
185 dataProfileInfo.bearerBitmap = static_cast<int32_t>(RadioAccessFamily::GPRS) |
186 static_cast<int32_t>(RadioAccessFamily::EDGE) |
187 static_cast<int32_t>(RadioAccessFamily::UMTS) |
188 static_cast<int32_t>(RadioAccessFamily::HSDPA) |
189 static_cast<int32_t>(RadioAccessFamily::HSUPA) |
190 static_cast<int32_t>(RadioAccessFamily::HSPA) |
191 static_cast<int32_t>(RadioAccessFamily::EHRPD) |
192 static_cast<int32_t>(RadioAccessFamily::LTE) |
193 static_cast<int32_t>(RadioAccessFamily::HSPAP) |
194 static_cast<int32_t>(RadioAccessFamily::IWLAN);
195 dataProfileInfo.mtuV4 = 0;
196 dataProfileInfo.mtuV6 = 0;
197 dataProfileInfo.preferred = true;
198 dataProfileInfo.persistent = false;
199 dataProfileInfo.trafficDescriptor = trafficDescriptor;
200
201 bool roamingAllowed = false;
202
203 std::vector<LinkAddress> addresses = {};
204 std::vector<std::string> dnses = {};
205
206 DataRequestReason reason = DataRequestReason::NORMAL;
207 SliceInfo sliceInfo;
208 bool matchAllRuleAllowed = true;
209
210 ndk::ScopedAStatus res =
211 radio_data->setupDataCall(serial, accessNetwork, dataProfileInfo, roamingAllowed,
212 reason, addresses, dnses, -1, sliceInfo, matchAllRuleAllowed);
213 ASSERT_OK(res);
214
215 EXPECT_EQ(std::cv_status::no_timeout, wait());
216 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
217 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
218 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
219 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
220 {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE,
221 RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW}));
222 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
223 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
224 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
225 RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW}));
226 if (radioRsp_data->setupDataCallResult.trafficDescriptors.size() <= 0 ||
227 !radioRsp_data->setupDataCallResult.trafficDescriptors[0].osAppId.has_value()) {
228 return;
229 }
230 EXPECT_EQ(trafficDescriptor.osAppId.value().osAppId,
231 radioRsp_data->setupDataCallResult.trafficDescriptors[0].osAppId.value().osAppId);
232 }
233 }
234
235 /*
236 * Test IRadioData.getSlicingConfig() for the response returned.
237 */
TEST_P(RadioDataTest,getSlicingConfig)238 TEST_P(RadioDataTest, getSlicingConfig) {
239 if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) {
240 GTEST_SKIP() << "Skipping getSlicingConfig "
241 "due to undefined FEATURE_TELEPHONY_DATA";
242 }
243
244 serial = GetRandomSerialNumber();
245 radio_data->getSlicingConfig(serial);
246 EXPECT_EQ(std::cv_status::no_timeout, wait());
247 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
248 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
249 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
250 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
251 RadioError::INTERNAL_ERR, RadioError::MODEM_ERR,
252 RadioError::REQUEST_NOT_SUPPORTED}));
253 }
254
255 /*
256 * Test IRadioData.setDataThrottling() for the response returned.
257 */
TEST_P(RadioDataTest,setDataThrottling)258 TEST_P(RadioDataTest, setDataThrottling) {
259 if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) {
260 GTEST_SKIP() << "Skipping setDataThrottling "
261 "due to undefined FEATURE_TELEPHONY_DATA";
262 }
263
264 serial = GetRandomSerialNumber();
265
266 ndk::ScopedAStatus res = radio_data->setDataThrottling(
267 serial, DataThrottlingAction::THROTTLE_SECONDARY_CARRIER, 60000);
268 ASSERT_OK(res);
269
270 EXPECT_EQ(std::cv_status::no_timeout, wait());
271 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
272 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
273 if (getRadioHalCapabilities()) {
274 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
275 {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
276 } else {
277 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
278 {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR,
279 RadioError::NONE, RadioError::INVALID_ARGUMENTS}));
280 }
281
282 sleep(1);
283 serial = GetRandomSerialNumber();
284
285 res = radio_data->setDataThrottling(serial, DataThrottlingAction::THROTTLE_ANCHOR_CARRIER,
286 60000);
287 ASSERT_OK(res);
288 EXPECT_EQ(std::cv_status::no_timeout, wait());
289 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
290 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
291 if (getRadioHalCapabilities()) {
292 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
293 {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
294 } else {
295 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
296 {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR,
297 RadioError::NONE, RadioError::INVALID_ARGUMENTS}));
298 }
299
300 sleep(1);
301 serial = GetRandomSerialNumber();
302
303 res = radio_data->setDataThrottling(serial, DataThrottlingAction::HOLD, 60000);
304 ASSERT_OK(res);
305
306 EXPECT_EQ(std::cv_status::no_timeout, wait());
307 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
308 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
309 if (getRadioHalCapabilities()) {
310 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
311 {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
312 } else {
313 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
314 {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR,
315 RadioError::NONE, RadioError::INVALID_ARGUMENTS}));
316 }
317
318 sleep(1);
319 serial = GetRandomSerialNumber();
320
321 res = radio_data->setDataThrottling(serial, DataThrottlingAction::NO_DATA_THROTTLING, 60000);
322 ASSERT_OK(res);
323 EXPECT_EQ(std::cv_status::no_timeout, wait());
324 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
325 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
326 if (getRadioHalCapabilities()) {
327 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
328 {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
329 } else {
330 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
331 {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR,
332 RadioError::NONE, RadioError::INVALID_ARGUMENTS}));
333 }
334
335 sleep(1);
336 }
337
338 /*
339 * Test IRadioData.setInitialAttachApn() for the response returned.
340 */
TEST_P(RadioDataTest,setInitialAttachApn)341 TEST_P(RadioDataTest, setInitialAttachApn) {
342 if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) {
343 GTEST_SKIP() << "Skipping setInitialAttachApn "
344 "due to undefined FEATURE_TELEPHONY_DATA";
345 }
346
347 serial = GetRandomSerialNumber();
348
349 // Create a dataProfileInfo
350 DataProfileInfo dataProfileInfo;
351 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
352 dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT;
353 dataProfileInfo.apn = std::string("internet");
354 dataProfileInfo.protocol = PdpProtocolType::IPV4V6;
355 dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6;
356 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
357 dataProfileInfo.user = std::string("username");
358 dataProfileInfo.password = std::string("password");
359 dataProfileInfo.type = DataProfileInfo::TYPE_3GPP;
360 dataProfileInfo.maxConnsTime = 300;
361 dataProfileInfo.maxConns = 20;
362 dataProfileInfo.waitTime = 0;
363 dataProfileInfo.enabled = true;
364 dataProfileInfo.supportedApnTypesBitmap = 320;
365 dataProfileInfo.bearerBitmap = 161543;
366 dataProfileInfo.mtuV4 = 0;
367 dataProfileInfo.mtuV6 = 0;
368 dataProfileInfo.preferred = true;
369 dataProfileInfo.persistent = false;
370
371 radio_data->setInitialAttachApn(serial, dataProfileInfo);
372
373 EXPECT_EQ(std::cv_status::no_timeout, wait());
374 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
375 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
376
377 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
378 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
379 {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE}));
380 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
381 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
382 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE}));
383 }
384 }
385
386 /*
387 * Test IRadioData.setDataProfile() for the response returned.
388 */
TEST_P(RadioDataTest,setDataProfile)389 TEST_P(RadioDataTest, setDataProfile) {
390 if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) {
391 GTEST_SKIP() << "Skipping setDataProfile "
392 "due to undefined FEATURE_TELEPHONY_DATA";
393 }
394
395 serial = GetRandomSerialNumber();
396
397 // Create a dataProfileInfo
398 DataProfileInfo dataProfileInfo;
399 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
400 dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT;
401 dataProfileInfo.apn = std::string("internet");
402 dataProfileInfo.protocol = PdpProtocolType::IPV4V6;
403 dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6;
404 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
405 dataProfileInfo.user = std::string("username");
406 dataProfileInfo.password = std::string("password");
407 dataProfileInfo.type = DataProfileInfo::TYPE_3GPP;
408 dataProfileInfo.maxConnsTime = 300;
409 dataProfileInfo.maxConns = 20;
410 dataProfileInfo.waitTime = 0;
411 dataProfileInfo.enabled = true;
412 dataProfileInfo.supportedApnTypesBitmap = 320;
413 dataProfileInfo.bearerBitmap = 161543;
414 dataProfileInfo.mtuV4 = 0;
415 dataProfileInfo.mtuV6 = 0;
416 dataProfileInfo.preferred = true;
417 dataProfileInfo.persistent = true;
418
419 // Create a dataProfileInfoList
420 std::vector<DataProfileInfo> dataProfileInfoList = {dataProfileInfo};
421
422 radio_data->setDataProfile(serial, dataProfileInfoList);
423
424 EXPECT_EQ(std::cv_status::no_timeout, wait());
425 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
426 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
427
428 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
429 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
430 {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE}));
431 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
432 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
433 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE}));
434 }
435 }
436
437 /*
438 * Test IRadioData.deactivateDataCall() for the response returned.
439 */
TEST_P(RadioDataTest,deactivateDataCall)440 TEST_P(RadioDataTest, deactivateDataCall) {
441 if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) {
442 GTEST_SKIP() << "Skipping deactivateDataCall "
443 "due to undefined FEATURE_TELEPHONY_DATA";
444 }
445
446 serial = GetRandomSerialNumber();
447 int cid = 1;
448 DataRequestReason reason = DataRequestReason::NORMAL;
449
450 ndk::ScopedAStatus res = radio_data->deactivateDataCall(serial, cid, reason);
451 ASSERT_OK(res);
452
453 EXPECT_EQ(std::cv_status::no_timeout, wait());
454 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
455 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
456
457 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
458 ASSERT_TRUE(
459 CheckAnyOfErrors(radioRsp_data->rspInfo.error,
460 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
461 RadioError::INVALID_CALL_ID, RadioError::INVALID_STATE,
462 RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED,
463 RadioError::CANCELLED, RadioError::SIM_ABSENT}));
464 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
465 ASSERT_TRUE(CheckAnyOfErrors(
466 radioRsp_data->rspInfo.error,
467 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_CALL_ID,
468 RadioError::INVALID_STATE, RadioError::INVALID_ARGUMENTS,
469 RadioError::REQUEST_NOT_SUPPORTED, RadioError::CANCELLED}));
470 }
471 }
472
473 /*
474 * Test IRadioData.startKeepalive() for the response returned.
475 */
TEST_P(RadioDataTest,startKeepalive)476 TEST_P(RadioDataTest, startKeepalive) {
477 if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) {
478 GTEST_SKIP() << "Skipping startKeepalive "
479 "due to undefined FEATURE_TELEPHONY_DATA";
480 }
481
482 std::vector<KeepaliveRequest> requests = {
483 {
484 // Invalid IPv4 source address
485 KeepaliveRequest::TYPE_NATT_IPV4,
486 {192, 168, 0 /*, 100*/},
487 1234,
488 {8, 8, 4, 4},
489 4500,
490 20000,
491 0xBAD,
492 },
493 {
494 // Invalid IPv4 destination address
495 KeepaliveRequest::TYPE_NATT_IPV4,
496 {192, 168, 0, 100},
497 1234,
498 {8, 8, 4, 4, 1, 2, 3, 4},
499 4500,
500 20000,
501 0xBAD,
502 },
503 {
504 // Invalid Keepalive Type
505 -1,
506 {192, 168, 0, 100},
507 1234,
508 {8, 8, 4, 4},
509 4500,
510 20000,
511 0xBAD,
512 },
513 {
514 // Invalid IPv6 source address
515 KeepaliveRequest::TYPE_NATT_IPV6,
516 {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE,
517 0xED, 0xBE, 0xEF, 0xBD},
518 1234,
519 {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
520 0x00, 0x88, 0x44},
521 4500,
522 20000,
523 0xBAD,
524 },
525 {
526 // Invalid IPv6 destination address
527 KeepaliveRequest::TYPE_NATT_IPV6,
528 {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE,
529 0xED, 0xBE, 0xEF},
530 1234,
531 {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
532 0x00, 0x88,
533 /*0x44*/},
534 4500,
535 20000,
536 0xBAD,
537 },
538 {
539 // Invalid Context ID (cid), this should survive the initial
540 // range checking and fail in the modem data layer
541 KeepaliveRequest::TYPE_NATT_IPV4,
542 {192, 168, 0, 100},
543 1234,
544 {8, 8, 4, 4},
545 4500,
546 20000,
547 0xBAD,
548 },
549 {
550 // Invalid Context ID (cid), this should survive the initial
551 // range checking and fail in the modem data layer
552 KeepaliveRequest::TYPE_NATT_IPV6,
553 {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE,
554 0xED, 0xBE, 0xEF},
555 1234,
556 {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
557 0x00, 0x88, 0x44},
558 4500,
559 20000,
560 0xBAD,
561 }};
562
563 for (auto req = requests.begin(); req != requests.end(); req++) {
564 serial = GetRandomSerialNumber();
565 radio_data->startKeepalive(serial, *req);
566 EXPECT_EQ(std::cv_status::no_timeout, wait());
567 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
568 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
569
570 ASSERT_TRUE(CheckAnyOfErrors(
571 radioRsp_data->rspInfo.error,
572 {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
573 }
574 }
575
576 /*
577 * Test IRadioData.stopKeepalive() for the response returned.
578 */
TEST_P(RadioDataTest,stopKeepalive)579 TEST_P(RadioDataTest, stopKeepalive) {
580 if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) {
581 GTEST_SKIP() << "Skipping stopKeepalive "
582 "due to undefined FEATURE_TELEPHONY_DATA";
583 }
584
585 serial = GetRandomSerialNumber();
586
587 radio_data->stopKeepalive(serial, 0xBAD);
588 EXPECT_EQ(std::cv_status::no_timeout, wait());
589 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
590 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
591
592 ASSERT_TRUE(
593 CheckAnyOfErrors(radioRsp_data->rspInfo.error,
594 {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
595 }
596
597 /*
598 * Test IRadioData.getDataCallList() for the response returned.
599 */
TEST_P(RadioDataTest,getDataCallList)600 TEST_P(RadioDataTest, getDataCallList) {
601 if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) {
602 GTEST_SKIP() << "Skipping getDataCallList "
603 "due to undefined FEATURE_TELEPHONY_DATA";
604 }
605
606 serial = GetRandomSerialNumber();
607
608 radio_data->getDataCallList(serial);
609
610 EXPECT_EQ(std::cv_status::no_timeout, wait());
611 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
612 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
613
614 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
615 ASSERT_TRUE(CheckAnyOfErrors(
616 radioRsp_data->rspInfo.error,
617 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::SIM_ABSENT}));
618 }
619 }
620
621 /*
622 * Test IRadioData.setDataAllowed() for the response returned.
623 */
TEST_P(RadioDataTest,setDataAllowed)624 TEST_P(RadioDataTest, setDataAllowed) {
625 if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) {
626 GTEST_SKIP() << "Skipping setDataAllowed "
627 "due to undefined FEATURE_TELEPHONY_DATA";
628 }
629
630 serial = GetRandomSerialNumber();
631 bool allow = true;
632
633 radio_data->setDataAllowed(serial, allow);
634
635 EXPECT_EQ(std::cv_status::no_timeout, wait());
636 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
637 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
638
639 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
640 EXPECT_EQ(RadioError::NONE, radioRsp_data->rspInfo.error);
641 }
642 }
643