blob: 6ad3237c4d57e1578a2ea46f490aafa89a7ed28f [file] [log] [blame]
Sarah Chinfc5603b2021-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 Chin6d8e49a2021-12-23 16:41:58 -080017#include <aidl/android/hardware/radio/RadioAccessFamily.h>
Sarah Chinfc5603b2021-12-21 11:34:00 -080018#include <aidl/android/hardware/radio/config/IRadioConfig.h>
Sarah Chin6d8e49a2021-12-23 16:41:58 -080019#include <aidl/android/hardware/radio/data/ApnTypes.h>
Sarah Chinfc5603b2021-12-21 11:34:00 -080020#include <android-base/logging.h>
21#include <android/binder_manager.h>
Sarah Chinfc5603b2021-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 Chinc83bce42021-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 Chinfc5603b2021-12-21 11:34:00 -080056 // Assert IRadioConfig exists before testing
Sarah Chinc83bce42021-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 Chinfc5603b2021-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 Chinca421a62022-01-28 15:54:36 -080086 dataProfileInfo.type = DataProfileInfo::TYPE_3GPP;
Sarah Chinfc5603b2021-12-21 11:34:00 -080087 dataProfileInfo.maxConnsTime = 300;
88 dataProfileInfo.maxConns = 20;
89 dataProfileInfo.waitTime = 0;
90 dataProfileInfo.enabled = true;
Sarah Chin6d8e49a2021-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 Chinfc5603b2021-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 Chin91e2e512023-01-18 18:28:03 -0800146 // hardcode osAppId for ENTERPRISE
147 osAppId.osAppId = {static_cast<unsigned char>(-105), static_cast<unsigned char>(-92),
148 static_cast<unsigned char>(-104), static_cast<unsigned char>(-29),
149 static_cast<unsigned char>(-4), static_cast<unsigned char>(-110),
150 static_cast<unsigned char>(92), static_cast<unsigned char>(-108),
151 static_cast<unsigned char>(-119), static_cast<unsigned char>(-122),
152 static_cast<unsigned char>(3), static_cast<unsigned char>(51),
153 static_cast<unsigned char>(-48), static_cast<unsigned char>(110),
154 static_cast<unsigned char>(78), static_cast<unsigned char>(71),
155 static_cast<unsigned char>(10), static_cast<unsigned char>(69),
156 static_cast<unsigned char>(78), static_cast<unsigned char>(84),
157 static_cast<unsigned char>(69), static_cast<unsigned char>(82),
158 static_cast<unsigned char>(80), static_cast<unsigned char>(82),
159 static_cast<unsigned char>(73), static_cast<unsigned char>(83),
160 static_cast<unsigned char>(69)};
Sarah Chinfc5603b2021-12-21 11:34:00 -0800161 trafficDescriptor.osAppId = osAppId;
162
163 DataProfileInfo dataProfileInfo;
164 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
165 dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT;
166 dataProfileInfo.apn = std::string("internet");
167 dataProfileInfo.protocol = PdpProtocolType::IP;
168 dataProfileInfo.roamingProtocol = PdpProtocolType::IP;
169 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
170 dataProfileInfo.user = std::string("username");
171 dataProfileInfo.password = std::string("password");
Sarah Chinca421a62022-01-28 15:54:36 -0800172 dataProfileInfo.type = DataProfileInfo::TYPE_3GPP;
Sarah Chinfc5603b2021-12-21 11:34:00 -0800173 dataProfileInfo.maxConnsTime = 300;
174 dataProfileInfo.maxConns = 20;
175 dataProfileInfo.waitTime = 0;
176 dataProfileInfo.enabled = true;
Sarah Chin6d8e49a2021-12-23 16:41:58 -0800177 dataProfileInfo.supportedApnTypesBitmap =
178 static_cast<int32_t>(ApnTypes::IMS) | static_cast<int32_t>(ApnTypes::IA);
179 dataProfileInfo.bearerBitmap = static_cast<int32_t>(RadioAccessFamily::GPRS) |
180 static_cast<int32_t>(RadioAccessFamily::EDGE) |
181 static_cast<int32_t>(RadioAccessFamily::UMTS) |
182 static_cast<int32_t>(RadioAccessFamily::HSDPA) |
183 static_cast<int32_t>(RadioAccessFamily::HSUPA) |
184 static_cast<int32_t>(RadioAccessFamily::HSPA) |
185 static_cast<int32_t>(RadioAccessFamily::EHRPD) |
186 static_cast<int32_t>(RadioAccessFamily::LTE) |
187 static_cast<int32_t>(RadioAccessFamily::HSPAP) |
188 static_cast<int32_t>(RadioAccessFamily::IWLAN);
Sarah Chinfc5603b2021-12-21 11:34:00 -0800189 dataProfileInfo.mtuV4 = 0;
190 dataProfileInfo.mtuV6 = 0;
191 dataProfileInfo.preferred = true;
192 dataProfileInfo.persistent = false;
193 dataProfileInfo.trafficDescriptor = trafficDescriptor;
194
195 bool roamingAllowed = false;
196
197 std::vector<LinkAddress> addresses = {};
198 std::vector<std::string> dnses = {};
199
200 DataRequestReason reason = DataRequestReason::NORMAL;
201 SliceInfo sliceInfo;
202 bool matchAllRuleAllowed = true;
203
204 ndk::ScopedAStatus res =
205 radio_data->setupDataCall(serial, accessNetwork, dataProfileInfo, roamingAllowed,
206 reason, addresses, dnses, -1, sliceInfo, matchAllRuleAllowed);
207 ASSERT_OK(res);
208
209 EXPECT_EQ(std::cv_status::no_timeout, wait());
210 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
211 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
212 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
213 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
214 {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE,
215 RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW}));
216 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
217 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
218 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
219 RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW}));
220 if (radioRsp_data->setupDataCallResult.trafficDescriptors.size() <= 0) {
221 return;
222 }
223 EXPECT_EQ(trafficDescriptor.osAppId.value().osAppId,
224 radioRsp_data->setupDataCallResult.trafficDescriptors[0].osAppId.value().osAppId);
225 }
226}
227
228/*
229 * Test IRadioData.getSlicingConfig() for the response returned.
230 */
231TEST_P(RadioDataTest, getSlicingConfig) {
232 serial = GetRandomSerialNumber();
233 radio_data->getSlicingConfig(serial);
234 EXPECT_EQ(std::cv_status::no_timeout, wait());
235 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
236 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
237 if (getRadioHalCapabilities()) {
238 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
239 {RadioError::REQUEST_NOT_SUPPORTED}));
240 } else {
241 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
242 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
243 RadioError::INTERNAL_ERR, RadioError::MODEM_ERR}));
244 }
245}
246
247/*
248 * Test IRadioData.setDataThrottling() for the response returned.
249 */
250TEST_P(RadioDataTest, setDataThrottling) {
251 serial = GetRandomSerialNumber();
252
253 ndk::ScopedAStatus res = radio_data->setDataThrottling(
254 serial, DataThrottlingAction::THROTTLE_SECONDARY_CARRIER, 60000);
255 ASSERT_OK(res);
256
257 EXPECT_EQ(std::cv_status::no_timeout, wait());
258 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
259 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
260 if (getRadioHalCapabilities()) {
261 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
262 {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
263 } else {
264 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
265 {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR,
266 RadioError::NONE, RadioError::INVALID_ARGUMENTS}));
267 }
268
269 sleep(1);
270 serial = GetRandomSerialNumber();
271
272 res = radio_data->setDataThrottling(serial, DataThrottlingAction::THROTTLE_ANCHOR_CARRIER,
273 60000);
274 ASSERT_OK(res);
275 EXPECT_EQ(std::cv_status::no_timeout, wait());
276 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
277 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
278 if (getRadioHalCapabilities()) {
279 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
280 {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
281 } else {
282 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
283 {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR,
284 RadioError::NONE, RadioError::INVALID_ARGUMENTS}));
285 }
286
287 sleep(1);
288 serial = GetRandomSerialNumber();
289
290 res = radio_data->setDataThrottling(serial, DataThrottlingAction::HOLD, 60000);
291 ASSERT_OK(res);
292
293 EXPECT_EQ(std::cv_status::no_timeout, wait());
294 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
295 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
296 if (getRadioHalCapabilities()) {
297 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
298 {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
299 } else {
300 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
301 {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR,
302 RadioError::NONE, RadioError::INVALID_ARGUMENTS}));
303 }
304
305 sleep(1);
306 serial = GetRandomSerialNumber();
307
308 res = radio_data->setDataThrottling(serial, DataThrottlingAction::NO_DATA_THROTTLING, 60000);
309 ASSERT_OK(res);
310 EXPECT_EQ(std::cv_status::no_timeout, wait());
311 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
312 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
313 if (getRadioHalCapabilities()) {
314 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
315 {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE}));
316 } else {
317 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
318 {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR,
319 RadioError::NONE, RadioError::INVALID_ARGUMENTS}));
320 }
321
322 sleep(1);
323}
Sarah Chin912bdf32022-01-28 01:02:16 -0800324
325/*
326 * Test IRadioData.setInitialAttachApn() for the response returned.
327 */
328TEST_P(RadioDataTest, setInitialAttachApn) {
329 serial = GetRandomSerialNumber();
330
331 // Create a dataProfileInfo
332 DataProfileInfo dataProfileInfo;
333 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
334 dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT;
335 dataProfileInfo.apn = std::string("internet");
336 dataProfileInfo.protocol = PdpProtocolType::IPV4V6;
337 dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6;
338 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
339 dataProfileInfo.user = std::string("username");
340 dataProfileInfo.password = std::string("password");
Sarah Chinca421a62022-01-28 15:54:36 -0800341 dataProfileInfo.type = DataProfileInfo::TYPE_3GPP;
Sarah Chin912bdf32022-01-28 01:02:16 -0800342 dataProfileInfo.maxConnsTime = 300;
343 dataProfileInfo.maxConns = 20;
344 dataProfileInfo.waitTime = 0;
345 dataProfileInfo.enabled = true;
346 dataProfileInfo.supportedApnTypesBitmap = 320;
347 dataProfileInfo.bearerBitmap = 161543;
348 dataProfileInfo.mtuV4 = 0;
349 dataProfileInfo.mtuV6 = 0;
350 dataProfileInfo.preferred = true;
351 dataProfileInfo.persistent = false;
352
353 radio_data->setInitialAttachApn(serial, dataProfileInfo);
354
355 EXPECT_EQ(std::cv_status::no_timeout, wait());
356 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
357 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
358
359 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
360 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
361 {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE}));
362 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
363 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
364 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE}));
365 }
366}
367
368/*
369 * Test IRadioData.setDataProfile() for the response returned.
370 */
371TEST_P(RadioDataTest, setDataProfile) {
372 serial = GetRandomSerialNumber();
373
374 // Create a dataProfileInfo
375 DataProfileInfo dataProfileInfo;
376 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
377 dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT;
378 dataProfileInfo.apn = std::string("internet");
379 dataProfileInfo.protocol = PdpProtocolType::IPV4V6;
380 dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6;
381 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
382 dataProfileInfo.user = std::string("username");
383 dataProfileInfo.password = std::string("password");
Sarah Chinca421a62022-01-28 15:54:36 -0800384 dataProfileInfo.type = DataProfileInfo::TYPE_3GPP;
Sarah Chin912bdf32022-01-28 01:02:16 -0800385 dataProfileInfo.maxConnsTime = 300;
386 dataProfileInfo.maxConns = 20;
387 dataProfileInfo.waitTime = 0;
388 dataProfileInfo.enabled = true;
389 dataProfileInfo.supportedApnTypesBitmap = 320;
390 dataProfileInfo.bearerBitmap = 161543;
391 dataProfileInfo.mtuV4 = 0;
392 dataProfileInfo.mtuV6 = 0;
393 dataProfileInfo.preferred = true;
394 dataProfileInfo.persistent = true;
395
396 // Create a dataProfileInfoList
397 std::vector<DataProfileInfo> dataProfileInfoList = {dataProfileInfo};
398
399 radio_data->setDataProfile(serial, dataProfileInfoList);
400
401 EXPECT_EQ(std::cv_status::no_timeout, wait());
402 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
403 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
404
405 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
406 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
407 {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE}));
408 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
409 ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error,
410 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE}));
411 }
412}
413
414/*
415 * Test IRadioData.deactivateDataCall() for the response returned.
416 */
417TEST_P(RadioDataTest, deactivateDataCall) {
418 serial = GetRandomSerialNumber();
419 int cid = 1;
420 DataRequestReason reason = DataRequestReason::NORMAL;
421
422 ndk::ScopedAStatus res = radio_data->deactivateDataCall(serial, cid, reason);
423 ASSERT_OK(res);
424
425 EXPECT_EQ(std::cv_status::no_timeout, wait());
426 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
427 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
428
429 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
430 ASSERT_TRUE(
431 CheckAnyOfErrors(radioRsp_data->rspInfo.error,
432 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE,
433 RadioError::INVALID_CALL_ID, RadioError::INVALID_STATE,
434 RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED,
435 RadioError::CANCELLED, RadioError::SIM_ABSENT}));
436 } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) {
437 ASSERT_TRUE(CheckAnyOfErrors(
438 radioRsp_data->rspInfo.error,
439 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_CALL_ID,
440 RadioError::INVALID_STATE, RadioError::INVALID_ARGUMENTS,
441 RadioError::REQUEST_NOT_SUPPORTED, RadioError::CANCELLED}));
442 }
443}
444
445/*
446 * Test IRadioData.startKeepalive() for the response returned.
447 */
448TEST_P(RadioDataTest, startKeepalive) {
449 std::vector<KeepaliveRequest> requests = {
450 {
451 // Invalid IPv4 source address
452 KeepaliveRequest::TYPE_NATT_IPV4,
453 {192, 168, 0 /*, 100*/},
454 1234,
455 {8, 8, 4, 4},
456 4500,
457 20000,
458 0xBAD,
459 },
460 {
461 // Invalid IPv4 destination address
462 KeepaliveRequest::TYPE_NATT_IPV4,
463 {192, 168, 0, 100},
464 1234,
465 {8, 8, 4, 4, 1, 2, 3, 4},
466 4500,
467 20000,
468 0xBAD,
469 },
470 {
471 // Invalid Keepalive Type
472 -1,
473 {192, 168, 0, 100},
474 1234,
475 {8, 8, 4, 4},
476 4500,
477 20000,
478 0xBAD,
479 },
480 {
481 // Invalid IPv6 source address
482 KeepaliveRequest::TYPE_NATT_IPV6,
483 {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE,
484 0xED, 0xBE, 0xEF, 0xBD},
485 1234,
486 {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
487 0x00, 0x88, 0x44},
488 4500,
489 20000,
490 0xBAD,
491 },
492 {
493 // Invalid IPv6 destination address
494 KeepaliveRequest::TYPE_NATT_IPV6,
495 {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE,
496 0xED, 0xBE, 0xEF},
497 1234,
498 {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
499 0x00, 0x88,
500 /*0x44*/},
501 4500,
502 20000,
503 0xBAD,
504 },
505 {
506 // Invalid Context ID (cid), this should survive the initial
507 // range checking and fail in the modem data layer
508 KeepaliveRequest::TYPE_NATT_IPV4,
509 {192, 168, 0, 100},
510 1234,
511 {8, 8, 4, 4},
512 4500,
513 20000,
514 0xBAD,
515 },
516 {
517 // Invalid Context ID (cid), this should survive the initial
518 // range checking and fail in the modem data layer
519 KeepaliveRequest::TYPE_NATT_IPV6,
520 {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE,
521 0xED, 0xBE, 0xEF},
522 1234,
523 {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
524 0x00, 0x88, 0x44},
525 4500,
526 20000,
527 0xBAD,
528 }};
529
530 for (auto req = requests.begin(); req != requests.end(); req++) {
531 serial = GetRandomSerialNumber();
532 radio_data->startKeepalive(serial, *req);
533 EXPECT_EQ(std::cv_status::no_timeout, wait());
534 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
535 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
536
537 ASSERT_TRUE(CheckAnyOfErrors(
538 radioRsp_data->rspInfo.error,
Sarah Chind3f69212023-04-20 16:10:37 -0700539 {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
Sarah Chin912bdf32022-01-28 01:02:16 -0800540 }
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,
Sarah Chind3f69212023-04-20 16:10:37 -0700556 {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED}));
Sarah Chin912bdf32022-01-28 01:02:16 -0800557}
558
559/*
560 * Test IRadioData.getDataCallList() for the response returned.
561 */
562TEST_P(RadioDataTest, getDataCallList) {
563 LOG(DEBUG) << "getDataCallList";
564 serial = GetRandomSerialNumber();
565
566 radio_data->getDataCallList(serial);
567
568 EXPECT_EQ(std::cv_status::no_timeout, wait());
569 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
570 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
571
572 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
573 ASSERT_TRUE(CheckAnyOfErrors(
574 radioRsp_data->rspInfo.error,
575 {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::SIM_ABSENT}));
576 }
577 LOG(DEBUG) << "getDataCallList finished";
578}
579
580/*
581 * Test IRadioData.setDataAllowed() for the response returned.
582 */
583TEST_P(RadioDataTest, setDataAllowed) {
584 LOG(DEBUG) << "setDataAllowed";
585 serial = GetRandomSerialNumber();
586 bool allow = true;
587
588 radio_data->setDataAllowed(serial, allow);
589
590 EXPECT_EQ(std::cv_status::no_timeout, wait());
591 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type);
592 EXPECT_EQ(serial, radioRsp_data->rspInfo.serial);
593
594 if (cardStatus.cardState == CardStatus::STATE_ABSENT) {
595 EXPECT_EQ(RadioError::NONE, radioRsp_data->rspInfo.error);
596 }
597 LOG(DEBUG) << "setDataAllowed finished";
598}