Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Sarah Chin | 6d8e49a | 2021-12-23 16:41:58 -0800 | [diff] [blame] | 17 | #include <aidl/android/hardware/radio/RadioAccessFamily.h> |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 18 | #include <aidl/android/hardware/radio/config/IRadioConfig.h> |
Sarah Chin | 6d8e49a | 2021-12-23 16:41:58 -0800 | [diff] [blame] | 19 | #include <aidl/android/hardware/radio/data/ApnTypes.h> |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 20 | #include <android-base/logging.h> |
| 21 | #include <android/binder_manager.h> |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 22 | |
| 23 | #include "radio_data_utils.h" |
| 24 | |
| 25 | #define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk()) |
| 26 | |
| 27 | void 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 Chin | c83bce4 | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 49 | // 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 Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 56 | // Assert IRadioConfig exists before testing |
Sarah Chin | c83bce4 | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 57 | radio_config = config::IRadioConfig::fromBinder(ndk::SpAIBinder( |
| 58 | AServiceManager_waitForService("android.hardware.radio.config.IRadioConfig/default"))); |
| 59 | ASSERT_NE(nullptr, radio_config.get()); |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | ndk::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 | */ |
| 72 | TEST_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 Chin | ca421a6 | 2022-01-28 15:54:36 -0800 | [diff] [blame^] | 86 | dataProfileInfo.type = DataProfileInfo::TYPE_3GPP; |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 87 | dataProfileInfo.maxConnsTime = 300; |
| 88 | dataProfileInfo.maxConns = 20; |
| 89 | dataProfileInfo.waitTime = 0; |
| 90 | dataProfileInfo.enabled = true; |
Sarah Chin | 6d8e49a | 2021-12-23 16:41:58 -0800 | [diff] [blame] | 91 | 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 Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 103 | 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 | */ |
| 139 | TEST_P(RadioDataTest, setupDataCall_osAppId) { |
| 140 | serial = GetRandomSerialNumber(); |
| 141 | |
| 142 | AccessNetwork accessNetwork = AccessNetwork::EUTRAN; |
| 143 | |
| 144 | TrafficDescriptor trafficDescriptor; |
| 145 | OsAppId osAppId; |
| 146 | std::string osAppIdString("osAppId"); |
Sarah Chin | 6d8e49a | 2021-12-23 16:41:58 -0800 | [diff] [blame] | 147 | std::vector<unsigned char> osAppIdVec(osAppIdString.begin(), osAppIdString.end()); |
| 148 | osAppId.osAppId = osAppIdVec; |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 149 | trafficDescriptor.osAppId = osAppId; |
| 150 | |
| 151 | DataProfileInfo dataProfileInfo; |
| 152 | memset(&dataProfileInfo, 0, sizeof(dataProfileInfo)); |
| 153 | dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT; |
| 154 | dataProfileInfo.apn = std::string("internet"); |
| 155 | dataProfileInfo.protocol = PdpProtocolType::IP; |
| 156 | dataProfileInfo.roamingProtocol = PdpProtocolType::IP; |
| 157 | dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP; |
| 158 | dataProfileInfo.user = std::string("username"); |
| 159 | dataProfileInfo.password = std::string("password"); |
Sarah Chin | ca421a6 | 2022-01-28 15:54:36 -0800 | [diff] [blame^] | 160 | dataProfileInfo.type = DataProfileInfo::TYPE_3GPP; |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 161 | dataProfileInfo.maxConnsTime = 300; |
| 162 | dataProfileInfo.maxConns = 20; |
| 163 | dataProfileInfo.waitTime = 0; |
| 164 | dataProfileInfo.enabled = true; |
Sarah Chin | 6d8e49a | 2021-12-23 16:41:58 -0800 | [diff] [blame] | 165 | dataProfileInfo.supportedApnTypesBitmap = |
| 166 | static_cast<int32_t>(ApnTypes::IMS) | static_cast<int32_t>(ApnTypes::IA); |
| 167 | dataProfileInfo.bearerBitmap = static_cast<int32_t>(RadioAccessFamily::GPRS) | |
| 168 | static_cast<int32_t>(RadioAccessFamily::EDGE) | |
| 169 | static_cast<int32_t>(RadioAccessFamily::UMTS) | |
| 170 | static_cast<int32_t>(RadioAccessFamily::HSDPA) | |
| 171 | static_cast<int32_t>(RadioAccessFamily::HSUPA) | |
| 172 | static_cast<int32_t>(RadioAccessFamily::HSPA) | |
| 173 | static_cast<int32_t>(RadioAccessFamily::EHRPD) | |
| 174 | static_cast<int32_t>(RadioAccessFamily::LTE) | |
| 175 | static_cast<int32_t>(RadioAccessFamily::HSPAP) | |
| 176 | static_cast<int32_t>(RadioAccessFamily::IWLAN); |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 177 | dataProfileInfo.mtuV4 = 0; |
| 178 | dataProfileInfo.mtuV6 = 0; |
| 179 | dataProfileInfo.preferred = true; |
| 180 | dataProfileInfo.persistent = false; |
| 181 | dataProfileInfo.trafficDescriptor = trafficDescriptor; |
| 182 | |
| 183 | bool roamingAllowed = false; |
| 184 | |
| 185 | std::vector<LinkAddress> addresses = {}; |
| 186 | std::vector<std::string> dnses = {}; |
| 187 | |
| 188 | DataRequestReason reason = DataRequestReason::NORMAL; |
| 189 | SliceInfo sliceInfo; |
| 190 | bool matchAllRuleAllowed = true; |
| 191 | |
| 192 | ndk::ScopedAStatus res = |
| 193 | radio_data->setupDataCall(serial, accessNetwork, dataProfileInfo, roamingAllowed, |
| 194 | reason, addresses, dnses, -1, sliceInfo, matchAllRuleAllowed); |
| 195 | ASSERT_OK(res); |
| 196 | |
| 197 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 198 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 199 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 200 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 201 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 202 | {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE, |
| 203 | RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW})); |
| 204 | } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { |
| 205 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 206 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, |
| 207 | RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW})); |
| 208 | if (radioRsp_data->setupDataCallResult.trafficDescriptors.size() <= 0) { |
| 209 | return; |
| 210 | } |
| 211 | EXPECT_EQ(trafficDescriptor.osAppId.value().osAppId, |
| 212 | radioRsp_data->setupDataCallResult.trafficDescriptors[0].osAppId.value().osAppId); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | /* |
| 217 | * Test IRadioData.getSlicingConfig() for the response returned. |
| 218 | */ |
| 219 | TEST_P(RadioDataTest, getSlicingConfig) { |
| 220 | serial = GetRandomSerialNumber(); |
| 221 | radio_data->getSlicingConfig(serial); |
| 222 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 223 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 224 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 225 | if (getRadioHalCapabilities()) { |
| 226 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 227 | {RadioError::REQUEST_NOT_SUPPORTED})); |
| 228 | } else { |
| 229 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 230 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, |
| 231 | RadioError::INTERNAL_ERR, RadioError::MODEM_ERR})); |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | /* |
| 236 | * Test IRadioData.setDataThrottling() for the response returned. |
| 237 | */ |
| 238 | TEST_P(RadioDataTest, setDataThrottling) { |
| 239 | serial = GetRandomSerialNumber(); |
| 240 | |
| 241 | ndk::ScopedAStatus res = radio_data->setDataThrottling( |
| 242 | serial, DataThrottlingAction::THROTTLE_SECONDARY_CARRIER, 60000); |
| 243 | ASSERT_OK(res); |
| 244 | |
| 245 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 246 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 247 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 248 | if (getRadioHalCapabilities()) { |
| 249 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 250 | {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE})); |
| 251 | } else { |
| 252 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 253 | {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR, |
| 254 | RadioError::NONE, RadioError::INVALID_ARGUMENTS})); |
| 255 | } |
| 256 | |
| 257 | sleep(1); |
| 258 | serial = GetRandomSerialNumber(); |
| 259 | |
| 260 | res = radio_data->setDataThrottling(serial, DataThrottlingAction::THROTTLE_ANCHOR_CARRIER, |
| 261 | 60000); |
| 262 | ASSERT_OK(res); |
| 263 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 264 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 265 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 266 | if (getRadioHalCapabilities()) { |
| 267 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 268 | {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE})); |
| 269 | } else { |
| 270 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 271 | {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR, |
| 272 | RadioError::NONE, RadioError::INVALID_ARGUMENTS})); |
| 273 | } |
| 274 | |
| 275 | sleep(1); |
| 276 | serial = GetRandomSerialNumber(); |
| 277 | |
| 278 | res = radio_data->setDataThrottling(serial, DataThrottlingAction::HOLD, 60000); |
| 279 | ASSERT_OK(res); |
| 280 | |
| 281 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 282 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 283 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 284 | if (getRadioHalCapabilities()) { |
| 285 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 286 | {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE})); |
| 287 | } else { |
| 288 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 289 | {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR, |
| 290 | RadioError::NONE, RadioError::INVALID_ARGUMENTS})); |
| 291 | } |
| 292 | |
| 293 | sleep(1); |
| 294 | serial = GetRandomSerialNumber(); |
| 295 | |
| 296 | res = radio_data->setDataThrottling(serial, DataThrottlingAction::NO_DATA_THROTTLING, 60000); |
| 297 | ASSERT_OK(res); |
| 298 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 299 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 300 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 301 | if (getRadioHalCapabilities()) { |
| 302 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 303 | {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE})); |
| 304 | } else { |
| 305 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 306 | {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR, |
| 307 | RadioError::NONE, RadioError::INVALID_ARGUMENTS})); |
| 308 | } |
| 309 | |
| 310 | sleep(1); |
| 311 | } |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 312 | |
| 313 | /* |
| 314 | * Test IRadioData.setInitialAttachApn() for the response returned. |
| 315 | */ |
| 316 | TEST_P(RadioDataTest, setInitialAttachApn) { |
| 317 | serial = GetRandomSerialNumber(); |
| 318 | |
| 319 | // Create a dataProfileInfo |
| 320 | DataProfileInfo dataProfileInfo; |
| 321 | memset(&dataProfileInfo, 0, sizeof(dataProfileInfo)); |
| 322 | dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT; |
| 323 | dataProfileInfo.apn = std::string("internet"); |
| 324 | dataProfileInfo.protocol = PdpProtocolType::IPV4V6; |
| 325 | dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6; |
| 326 | dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP; |
| 327 | dataProfileInfo.user = std::string("username"); |
| 328 | dataProfileInfo.password = std::string("password"); |
Sarah Chin | ca421a6 | 2022-01-28 15:54:36 -0800 | [diff] [blame^] | 329 | dataProfileInfo.type = DataProfileInfo::TYPE_3GPP; |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 330 | dataProfileInfo.maxConnsTime = 300; |
| 331 | dataProfileInfo.maxConns = 20; |
| 332 | dataProfileInfo.waitTime = 0; |
| 333 | dataProfileInfo.enabled = true; |
| 334 | dataProfileInfo.supportedApnTypesBitmap = 320; |
| 335 | dataProfileInfo.bearerBitmap = 161543; |
| 336 | dataProfileInfo.mtuV4 = 0; |
| 337 | dataProfileInfo.mtuV6 = 0; |
| 338 | dataProfileInfo.preferred = true; |
| 339 | dataProfileInfo.persistent = false; |
| 340 | |
| 341 | radio_data->setInitialAttachApn(serial, dataProfileInfo); |
| 342 | |
| 343 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 344 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 345 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 346 | |
| 347 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 348 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 349 | {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE})); |
| 350 | } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { |
| 351 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 352 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE})); |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | /* |
| 357 | * Test IRadioData.setDataProfile() for the response returned. |
| 358 | */ |
| 359 | TEST_P(RadioDataTest, setDataProfile) { |
| 360 | serial = GetRandomSerialNumber(); |
| 361 | |
| 362 | // Create a dataProfileInfo |
| 363 | DataProfileInfo dataProfileInfo; |
| 364 | memset(&dataProfileInfo, 0, sizeof(dataProfileInfo)); |
| 365 | dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT; |
| 366 | dataProfileInfo.apn = std::string("internet"); |
| 367 | dataProfileInfo.protocol = PdpProtocolType::IPV4V6; |
| 368 | dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6; |
| 369 | dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP; |
| 370 | dataProfileInfo.user = std::string("username"); |
| 371 | dataProfileInfo.password = std::string("password"); |
Sarah Chin | ca421a6 | 2022-01-28 15:54:36 -0800 | [diff] [blame^] | 372 | dataProfileInfo.type = DataProfileInfo::TYPE_3GPP; |
Sarah Chin | 912bdf3 | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 373 | dataProfileInfo.maxConnsTime = 300; |
| 374 | dataProfileInfo.maxConns = 20; |
| 375 | dataProfileInfo.waitTime = 0; |
| 376 | dataProfileInfo.enabled = true; |
| 377 | dataProfileInfo.supportedApnTypesBitmap = 320; |
| 378 | dataProfileInfo.bearerBitmap = 161543; |
| 379 | dataProfileInfo.mtuV4 = 0; |
| 380 | dataProfileInfo.mtuV6 = 0; |
| 381 | dataProfileInfo.preferred = true; |
| 382 | dataProfileInfo.persistent = true; |
| 383 | |
| 384 | // Create a dataProfileInfoList |
| 385 | std::vector<DataProfileInfo> dataProfileInfoList = {dataProfileInfo}; |
| 386 | |
| 387 | radio_data->setDataProfile(serial, dataProfileInfoList); |
| 388 | |
| 389 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 390 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 391 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 392 | |
| 393 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 394 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 395 | {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE})); |
| 396 | } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { |
| 397 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 398 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE})); |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | /* |
| 403 | * Test IRadioData.deactivateDataCall() for the response returned. |
| 404 | */ |
| 405 | TEST_P(RadioDataTest, deactivateDataCall) { |
| 406 | serial = GetRandomSerialNumber(); |
| 407 | int cid = 1; |
| 408 | DataRequestReason reason = DataRequestReason::NORMAL; |
| 409 | |
| 410 | ndk::ScopedAStatus res = radio_data->deactivateDataCall(serial, cid, reason); |
| 411 | ASSERT_OK(res); |
| 412 | |
| 413 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 414 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 415 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 416 | |
| 417 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 418 | ASSERT_TRUE( |
| 419 | CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 420 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, |
| 421 | RadioError::INVALID_CALL_ID, RadioError::INVALID_STATE, |
| 422 | RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED, |
| 423 | RadioError::CANCELLED, RadioError::SIM_ABSENT})); |
| 424 | } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { |
| 425 | ASSERT_TRUE(CheckAnyOfErrors( |
| 426 | radioRsp_data->rspInfo.error, |
| 427 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_CALL_ID, |
| 428 | RadioError::INVALID_STATE, RadioError::INVALID_ARGUMENTS, |
| 429 | RadioError::REQUEST_NOT_SUPPORTED, RadioError::CANCELLED})); |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | /* |
| 434 | * Test IRadioData.startKeepalive() for the response returned. |
| 435 | */ |
| 436 | TEST_P(RadioDataTest, startKeepalive) { |
| 437 | std::vector<KeepaliveRequest> requests = { |
| 438 | { |
| 439 | // Invalid IPv4 source address |
| 440 | KeepaliveRequest::TYPE_NATT_IPV4, |
| 441 | {192, 168, 0 /*, 100*/}, |
| 442 | 1234, |
| 443 | {8, 8, 4, 4}, |
| 444 | 4500, |
| 445 | 20000, |
| 446 | 0xBAD, |
| 447 | }, |
| 448 | { |
| 449 | // Invalid IPv4 destination address |
| 450 | KeepaliveRequest::TYPE_NATT_IPV4, |
| 451 | {192, 168, 0, 100}, |
| 452 | 1234, |
| 453 | {8, 8, 4, 4, 1, 2, 3, 4}, |
| 454 | 4500, |
| 455 | 20000, |
| 456 | 0xBAD, |
| 457 | }, |
| 458 | { |
| 459 | // Invalid Keepalive Type |
| 460 | -1, |
| 461 | {192, 168, 0, 100}, |
| 462 | 1234, |
| 463 | {8, 8, 4, 4}, |
| 464 | 4500, |
| 465 | 20000, |
| 466 | 0xBAD, |
| 467 | }, |
| 468 | { |
| 469 | // Invalid IPv6 source address |
| 470 | KeepaliveRequest::TYPE_NATT_IPV6, |
| 471 | {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, |
| 472 | 0xED, 0xBE, 0xEF, 0xBD}, |
| 473 | 1234, |
| 474 | {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 475 | 0x00, 0x88, 0x44}, |
| 476 | 4500, |
| 477 | 20000, |
| 478 | 0xBAD, |
| 479 | }, |
| 480 | { |
| 481 | // Invalid IPv6 destination address |
| 482 | KeepaliveRequest::TYPE_NATT_IPV6, |
| 483 | {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, |
| 484 | 0xED, 0xBE, 0xEF}, |
| 485 | 1234, |
| 486 | {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 487 | 0x00, 0x88, |
| 488 | /*0x44*/}, |
| 489 | 4500, |
| 490 | 20000, |
| 491 | 0xBAD, |
| 492 | }, |
| 493 | { |
| 494 | // Invalid Context ID (cid), this should survive the initial |
| 495 | // range checking and fail in the modem data layer |
| 496 | KeepaliveRequest::TYPE_NATT_IPV4, |
| 497 | {192, 168, 0, 100}, |
| 498 | 1234, |
| 499 | {8, 8, 4, 4}, |
| 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_IPV6, |
| 508 | {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, |
| 509 | 0xED, 0xBE, 0xEF}, |
| 510 | 1234, |
| 511 | {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 512 | 0x00, 0x88, 0x44}, |
| 513 | 4500, |
| 514 | 20000, |
| 515 | 0xBAD, |
| 516 | }}; |
| 517 | |
| 518 | for (auto req = requests.begin(); req != requests.end(); req++) { |
| 519 | serial = GetRandomSerialNumber(); |
| 520 | radio_data->startKeepalive(serial, *req); |
| 521 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 522 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 523 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 524 | |
| 525 | ASSERT_TRUE(CheckAnyOfErrors( |
| 526 | radioRsp_data->rspInfo.error, |
| 527 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_ARGUMENTS, |
| 528 | RadioError::REQUEST_NOT_SUPPORTED})); |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | /* |
| 533 | * Test IRadioData.stopKeepalive() for the response returned. |
| 534 | */ |
| 535 | TEST_P(RadioDataTest, stopKeepalive) { |
| 536 | serial = GetRandomSerialNumber(); |
| 537 | |
| 538 | radio_data->stopKeepalive(serial, 0xBAD); |
| 539 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 540 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 541 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 542 | |
| 543 | ASSERT_TRUE( |
| 544 | CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 545 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, |
| 546 | RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); |
| 547 | } |
| 548 | |
| 549 | /* |
| 550 | * Test IRadioData.getDataCallList() for the response returned. |
| 551 | */ |
| 552 | TEST_P(RadioDataTest, getDataCallList) { |
| 553 | LOG(DEBUG) << "getDataCallList"; |
| 554 | serial = GetRandomSerialNumber(); |
| 555 | |
| 556 | radio_data->getDataCallList(serial); |
| 557 | |
| 558 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 559 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 560 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 561 | |
| 562 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 563 | ASSERT_TRUE(CheckAnyOfErrors( |
| 564 | radioRsp_data->rspInfo.error, |
| 565 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::SIM_ABSENT})); |
| 566 | } |
| 567 | LOG(DEBUG) << "getDataCallList finished"; |
| 568 | } |
| 569 | |
| 570 | /* |
| 571 | * Test IRadioData.setDataAllowed() for the response returned. |
| 572 | */ |
| 573 | TEST_P(RadioDataTest, setDataAllowed) { |
| 574 | LOG(DEBUG) << "setDataAllowed"; |
| 575 | 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 | } |
| 587 | LOG(DEBUG) << "setDataAllowed finished"; |
| 588 | } |