blob: 1cc6a36a2627928a63a677248511ef2676747951 [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);
236 if (getRadioHalCapabilities()) {
237 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
238 {RadioError::REQUEST_NOT_SUPPORTED}));
239 } else {
240 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
241 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
242 RadioError::INTERNAL_ERR, RadioError::MODEM_ERR}));
243 }
244}
245
246/*
247 * Test IRadioData.setDataThrottling() for the response returned.
248 */
249TEST_P(RadioDataTest, setDataThrottling) {
250 serial = GetRandomSerialNumber();
251
252 ndk::ScopedAStatus res = radio_data->setDataThrottling(
253 serial, DataThrottlingAction::THROTTLE_SECONDARY_CARRIER, 60000);
254 ASSERT_OK(res);
255
256 EXPECT_EQ(std::cv_status::no_timeout, wait());
257 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
258 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
259 if (getRadioHalCapabilities()) {
260 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
261 {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
262 } else {
263 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
264 {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR,
265 RadioError::NONE, RadioError::INVALID_ARGUMENTS}));
266 }
267
268 sleep(1);
269 serial = GetRandomSerialNumber();
270
271 res = radio_data->setDataThrottling(serial, DataThrottlingAction::THROTTLE_ANCHOR_CARRIER,
272 60000);
273 ASSERT_OK(res);
274 EXPECT_EQ(std::cv_status::no_timeout, wait());
275 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
276 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
277 if (getRadioHalCapabilities()) {
278 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
279 {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
280 } else {
281 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
282 {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR,
283 RadioError::NONE, RadioError::INVALID_ARGUMENTS}));
284 }
285
286 sleep(1);
287 serial = GetRandomSerialNumber();
288
289 res = radio_data->setDataThrottling(serial, DataThrottlingAction::HOLD, 60000);
290 ASSERT_OK(res);
291
292 EXPECT_EQ(std::cv_status::no_timeout, wait());
293 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
294 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
295 if (getRadioHalCapabilities()) {
296 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
297 {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
298 } else {
299 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
300 {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR,
301 RadioError::NONE, RadioError::INVALID_ARGUMENTS}));
302 }
303
304 sleep(1);
305 serial = GetRandomSerialNumber();
306
307 res = radio_data->setDataThrottling(serial, DataThrottlingAction::NO_DATA_THROTTLING, 60000);
308 ASSERT_OK(res);
309 EXPECT_EQ(std::cv_status::no_timeout, wait());
310 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
311 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
312 if (getRadioHalCapabilities()) {
313 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
314 {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
315 } else {
316 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
317 {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR,
318 RadioError::NONE, RadioError::INVALID_ARGUMENTS}));
319 }
320
321 sleep(1);
322}
Sarah Chin52de0ad2022-01-28 01:02:16 -0800323
324/*
325 * Test IRadioData.setInitialAttachApn() for the response returned.
326 */
327TEST_P(RadioDataTest, setInitialAttachApn) {
328 serial = GetRandomSerialNumber();
329
330 // Create a dataProfileInfo
331 DataProfileInfo dataProfileInfo;
332 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
333 dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT;
334 dataProfileInfo.apn = std::string("internet");
335 dataProfileInfo.protocol = PdpProtocolType::IPV4V6;
336 dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6;
337 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
338 dataProfileInfo.user = std::string("username");
339 dataProfileInfo.password = std::string("password");
Sarah Chinf746a912022-01-28 15:54:36 -0800340 dataProfileInfo.type = DataProfileInfo::TYPE_3GPP;
Sarah Chin52de0ad2022-01-28 01:02:16 -0800341 dataProfileInfo.maxConnsTime = 300;
342 dataProfileInfo.maxConns = 20;
343 dataProfileInfo.waitTime = 0;
344 dataProfileInfo.enabled = true;
345 dataProfileInfo.supportedApnTypesBitmap = 320;
346 dataProfileInfo.bearerBitmap = 161543;
347 dataProfileInfo.mtuV4 = 0;
348 dataProfileInfo.mtuV6 = 0;
349 dataProfileInfo.preferred = true;
350 dataProfileInfo.persistent = false;
351
352 radio_data->setInitialAttachApn(serial, dataProfileInfo);
353
354 EXPECT_EQ(std::cv_status::no_timeout, wait());
355 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
356 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
357
358 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
359 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
360 {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE}));
361 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
362 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
363 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE}));
364 }
365}
366
367/*
368 * Test IRadioData.setDataProfile() for the response returned.
369 */
370TEST_P(RadioDataTest, setDataProfile) {
371 serial = GetRandomSerialNumber();
372
373 // Create a dataProfileInfo
374 DataProfileInfo dataProfileInfo;
375 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
376 dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT;
377 dataProfileInfo.apn = std::string("internet");
378 dataProfileInfo.protocol = PdpProtocolType::IPV4V6;
379 dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6;
380 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
381 dataProfileInfo.user = std::string("username");
382 dataProfileInfo.password = std::string("password");
Sarah Chinf746a912022-01-28 15:54:36 -0800383 dataProfileInfo.type = DataProfileInfo::TYPE_3GPP;
Sarah Chin52de0ad2022-01-28 01:02:16 -0800384 dataProfileInfo.maxConnsTime = 300;
385 dataProfileInfo.maxConns = 20;
386 dataProfileInfo.waitTime = 0;
387 dataProfileInfo.enabled = true;
388 dataProfileInfo.supportedApnTypesBitmap = 320;
389 dataProfileInfo.bearerBitmap = 161543;
390 dataProfileInfo.mtuV4 = 0;
391 dataProfileInfo.mtuV6 = 0;
392 dataProfileInfo.preferred = true;
393 dataProfileInfo.persistent = true;
394
395 // Create a dataProfileInfoList
396 std::vector<DataProfileInfo> dataProfileInfoList = {dataProfileInfo};
397
398 radio_data->setDataProfile(serial, dataProfileInfoList);
399
400 EXPECT_EQ(std::cv_status::no_timeout, wait());
401 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
402 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
403
404 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
405 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
406 {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE}));
407 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
408 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
409 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE}));
410 }
411}
412
413/*
414 * Test IRadioData.deactivateDataCall() for the response returned.
415 */
416TEST_P(RadioDataTest, deactivateDataCall) {
417 serial = GetRandomSerialNumber();
418 int cid = 1;
419 DataRequestReason reason = DataRequestReason::NORMAL;
420
421 ndk::ScopedAStatus res = radio_data->deactivateDataCall(serial, cid, reason);
422 ASSERT_OK(res);
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(
430 CheckAnyOfErrors(radioRsp_data->rspInfo.error,
431 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
432 RadioError::INVALID_CALL_ID, RadioError::INVALID_STATE,
433 RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED,
434 RadioError::CANCELLED, RadioError::SIM_ABSENT}));
435 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
436 ASSERT_TRUE(CheckAnyOfErrors(
437 radioRsp_data->rspInfo.error,
438 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_CALL_ID,
439 RadioError::INVALID_STATE, RadioError::INVALID_ARGUMENTS,
440 RadioError::REQUEST_NOT_SUPPORTED, RadioError::CANCELLED}));
441 }
442}
443
444/*
445 * Test IRadioData.startKeepalive() for the response returned.
446 */
447TEST_P(RadioDataTest, startKeepalive) {
448 std::vector<KeepaliveRequest> requests = {
449 {
450 // Invalid IPv4 source address
451 KeepaliveRequest::TYPE_NATT_IPV4,
452 {192, 168, 0 /*, 100*/},
453 1234,
454 {8, 8, 4, 4},
455 4500,
456 20000,
457 0xBAD,
458 },
459 {
460 // Invalid IPv4 destination address
461 KeepaliveRequest::TYPE_NATT_IPV4,
462 {192, 168, 0, 100},
463 1234,
464 {8, 8, 4, 4, 1, 2, 3, 4},
465 4500,
466 20000,
467 0xBAD,
468 },
469 {
470 // Invalid Keepalive Type
471 -1,
472 {192, 168, 0, 100},
473 1234,
474 {8, 8, 4, 4},
475 4500,
476 20000,
477 0xBAD,
478 },
479 {
480 // Invalid IPv6 source address
481 KeepaliveRequest::TYPE_NATT_IPV6,
482 {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE,
483 0xED, 0xBE, 0xEF, 0xBD},
484 1234,
485 {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
486 0x00, 0x88, 0x44},
487 4500,
488 20000,
489 0xBAD,
490 },
491 {
492 // Invalid IPv6 destination address
493 KeepaliveRequest::TYPE_NATT_IPV6,
494 {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE,
495 0xED, 0xBE, 0xEF},
496 1234,
497 {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
498 0x00, 0x88,
499 /*0x44*/},
500 4500,
501 20000,
502 0xBAD,
503 },
504 {
505 // Invalid Context ID (cid), this should survive the initial
506 // range checking and fail in the modem data layer
507 KeepaliveRequest::TYPE_NATT_IPV4,
508 {192, 168, 0, 100},
509 1234,
510 {8, 8, 4, 4},
511 4500,
512 20000,
513 0xBAD,
514 },
515 {
516 // Invalid Context ID (cid), this should survive the initial
517 // range checking and fail in the modem data layer
518 KeepaliveRequest::TYPE_NATT_IPV6,
519 {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE,
520 0xED, 0xBE, 0xEF},
521 1234,
522 {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
523 0x00, 0x88, 0x44},
524 4500,
525 20000,
526 0xBAD,
527 }};
528
529 for (auto req = requests.begin(); req != requests.end(); req++) {
530 serial = GetRandomSerialNumber();
531 radio_data->startKeepalive(serial, *req);
532 EXPECT_EQ(std::cv_status::no_timeout, wait());
533 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
534 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
535
536 ASSERT_TRUE(CheckAnyOfErrors(
537 radioRsp_data->rspInfo.error,
538 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_ARGUMENTS,
539 RadioError::REQUEST_NOT_SUPPORTED}));
540 }
541}
542
543/*
544 * Test IRadioData.stopKeepalive() for the response returned.
545 */
546TEST_P(RadioDataTest, stopKeepalive) {
547 serial = GetRandomSerialNumber();
548
549 radio_data->stopKeepalive(serial, 0xBAD);
550 EXPECT_EQ(std::cv_status::no_timeout, wait());
551 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
552 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
553
554 ASSERT_TRUE(
555 CheckAnyOfErrors(radioRsp_data->rspInfo.error,
556 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
557 RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
558}
559
560/*
561 * Test IRadioData.getDataCallList() for the response returned.
562 */
563TEST_P(RadioDataTest, getDataCallList) {
564 LOG(DEBUG) << "getDataCallList";
565 serial = GetRandomSerialNumber();
566
567 radio_data->getDataCallList(serial);
568
569 EXPECT_EQ(std::cv_status::no_timeout, wait());
570 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
571 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
572
573 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
574 ASSERT_TRUE(CheckAnyOfErrors(
575 radioRsp_data->rspInfo.error,
576 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::SIM_ABSENT}));
577 }
578 LOG(DEBUG) << "getDataCallList finished";
579}
580
581/*
582 * Test IRadioData.setDataAllowed() for the response returned.
583 */
584TEST_P(RadioDataTest, setDataAllowed) {
585 LOG(DEBUG) << "setDataAllowed";
586 serial = GetRandomSerialNumber();
587 bool allow = true;
588
589 radio_data->setDataAllowed(serial, allow);
590
591 EXPECT_EQ(std::cv_status::no_timeout, wait());
592 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
593 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
594
595 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
596 EXPECT_EQ(RadioError::NONE, radioRsp_data->rspInfo.error);
597 }
598 LOG(DEBUG) << "setDataAllowed finished";
599}