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