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