Sarah Chin | d2a4119 | 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 | c9d3b7b | 2021-12-23 16:41:58 -0800 | [diff] [blame] | 17 | #include <aidl/android/hardware/radio/RadioAccessFamily.h> |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 18 | #include <aidl/android/hardware/radio/config/IRadioConfig.h> |
Sarah Chin | c9d3b7b | 2021-12-23 16:41:58 -0800 | [diff] [blame] | 19 | #include <aidl/android/hardware/radio/data/ApnTypes.h> |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 20 | #include <android/binder_manager.h> |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 21 | |
| 22 | #include "radio_data_utils.h" |
| 23 | |
| 24 | #define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk()) |
| 25 | |
| 26 | void RadioDataTest::SetUp() { |
Sarah Chin | bb35a43 | 2023-05-02 21:11:41 -0700 | [diff] [blame] | 27 | RadioServiceTest::SetUp(); |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 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 | |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 42 | 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 Chin | 91997ac | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 47 | // 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 Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 54 | // Assert IRadioConfig exists before testing |
Sarah Chin | 91997ac | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 55 | radio_config = config::IRadioConfig::fromBinder(ndk::SpAIBinder( |
| 56 | AServiceManager_waitForService("android.hardware.radio.config.IRadioConfig/default"))); |
| 57 | ASSERT_NE(nullptr, radio_config.get()); |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | ndk::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 | */ |
| 70 | TEST_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 Chin | f746a91 | 2022-01-28 15:54:36 -0800 | [diff] [blame] | 84 | dataProfileInfo.type = DataProfileInfo::TYPE_3GPP; |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 85 | dataProfileInfo.maxConnsTime = 300; |
| 86 | dataProfileInfo.maxConns = 20; |
| 87 | dataProfileInfo.waitTime = 0; |
| 88 | dataProfileInfo.enabled = true; |
Sarah Chin | c9d3b7b | 2021-12-23 16:41:58 -0800 | [diff] [blame] | 89 | 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 Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 101 | 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 | */ |
| 137 | TEST_P(RadioDataTest, setupDataCall_osAppId) { |
| 138 | serial = GetRandomSerialNumber(); |
| 139 | |
| 140 | AccessNetwork accessNetwork = AccessNetwork::EUTRAN; |
| 141 | |
| 142 | TrafficDescriptor trafficDescriptor; |
| 143 | OsAppId osAppId; |
Sarah Chin | 47213a1 | 2023-01-18 18:28:03 -0800 | [diff] [blame] | 144 | 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 Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 158 | 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 Chin | f746a91 | 2022-01-28 15:54:36 -0800 | [diff] [blame] | 169 | dataProfileInfo.type = DataProfileInfo::TYPE_3GPP; |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 170 | dataProfileInfo.maxConnsTime = 300; |
| 171 | dataProfileInfo.maxConns = 20; |
| 172 | dataProfileInfo.waitTime = 0; |
| 173 | dataProfileInfo.enabled = true; |
Sarah Chin | c9d3b7b | 2021-12-23 16:41:58 -0800 | [diff] [blame] | 174 | 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 Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 186 | 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})); |
Sarah Chin | 35bf8e1 | 2023-09-07 16:16:38 -0700 | [diff] [blame^] | 217 | if (radioRsp_data->setupDataCallResult.trafficDescriptors.size() <= 0 || |
| 218 | !radioRsp_data->setupDataCallResult.trafficDescriptors[0].osAppId.has_value()) { |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 219 | return; |
| 220 | } |
| 221 | EXPECT_EQ(trafficDescriptor.osAppId.value().osAppId, |
| 222 | radioRsp_data->setupDataCallResult.trafficDescriptors[0].osAppId.value().osAppId); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | /* |
| 227 | * Test IRadioData.getSlicingConfig() for the response returned. |
| 228 | */ |
| 229 | TEST_P(RadioDataTest, getSlicingConfig) { |
| 230 | serial = GetRandomSerialNumber(); |
| 231 | radio_data->getSlicingConfig(serial); |
| 232 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 233 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 234 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
Pavan Kumar M | 8b5cf0c | 2023-01-27 12:54:39 +0530 | [diff] [blame] | 235 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 236 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, |
| 237 | RadioError::INTERNAL_ERR, RadioError::MODEM_ERR, |
| 238 | RadioError::REQUEST_NOT_SUPPORTED})); |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | /* |
| 242 | * Test IRadioData.setDataThrottling() for the response returned. |
| 243 | */ |
| 244 | TEST_P(RadioDataTest, setDataThrottling) { |
| 245 | serial = GetRandomSerialNumber(); |
| 246 | |
| 247 | ndk::ScopedAStatus res = radio_data->setDataThrottling( |
| 248 | serial, DataThrottlingAction::THROTTLE_SECONDARY_CARRIER, 60000); |
| 249 | ASSERT_OK(res); |
| 250 | |
| 251 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 252 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 253 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 254 | if (getRadioHalCapabilities()) { |
| 255 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 256 | {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE})); |
| 257 | } else { |
| 258 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 259 | {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR, |
| 260 | RadioError::NONE, RadioError::INVALID_ARGUMENTS})); |
| 261 | } |
| 262 | |
| 263 | sleep(1); |
| 264 | serial = GetRandomSerialNumber(); |
| 265 | |
| 266 | res = radio_data->setDataThrottling(serial, DataThrottlingAction::THROTTLE_ANCHOR_CARRIER, |
| 267 | 60000); |
| 268 | ASSERT_OK(res); |
| 269 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 270 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 271 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 272 | if (getRadioHalCapabilities()) { |
| 273 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 274 | {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE})); |
| 275 | } else { |
| 276 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 277 | {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR, |
| 278 | RadioError::NONE, RadioError::INVALID_ARGUMENTS})); |
| 279 | } |
| 280 | |
| 281 | sleep(1); |
| 282 | serial = GetRandomSerialNumber(); |
| 283 | |
| 284 | res = radio_data->setDataThrottling(serial, DataThrottlingAction::HOLD, 60000); |
| 285 | ASSERT_OK(res); |
| 286 | |
| 287 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 288 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 289 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 290 | if (getRadioHalCapabilities()) { |
| 291 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 292 | {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE})); |
| 293 | } else { |
| 294 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 295 | {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR, |
| 296 | RadioError::NONE, RadioError::INVALID_ARGUMENTS})); |
| 297 | } |
| 298 | |
| 299 | sleep(1); |
| 300 | serial = GetRandomSerialNumber(); |
| 301 | |
| 302 | res = radio_data->setDataThrottling(serial, DataThrottlingAction::NO_DATA_THROTTLING, 60000); |
| 303 | ASSERT_OK(res); |
| 304 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 305 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 306 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 307 | if (getRadioHalCapabilities()) { |
| 308 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 309 | {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE})); |
| 310 | } else { |
| 311 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 312 | {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR, |
| 313 | RadioError::NONE, RadioError::INVALID_ARGUMENTS})); |
| 314 | } |
| 315 | |
| 316 | sleep(1); |
| 317 | } |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 318 | |
| 319 | /* |
| 320 | * Test IRadioData.setInitialAttachApn() for the response returned. |
| 321 | */ |
| 322 | TEST_P(RadioDataTest, setInitialAttachApn) { |
| 323 | serial = GetRandomSerialNumber(); |
| 324 | |
| 325 | // Create a dataProfileInfo |
| 326 | DataProfileInfo dataProfileInfo; |
| 327 | memset(&dataProfileInfo, 0, sizeof(dataProfileInfo)); |
| 328 | dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT; |
| 329 | dataProfileInfo.apn = std::string("internet"); |
| 330 | dataProfileInfo.protocol = PdpProtocolType::IPV4V6; |
| 331 | dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6; |
| 332 | dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP; |
| 333 | dataProfileInfo.user = std::string("username"); |
| 334 | dataProfileInfo.password = std::string("password"); |
Sarah Chin | f746a91 | 2022-01-28 15:54:36 -0800 | [diff] [blame] | 335 | dataProfileInfo.type = DataProfileInfo::TYPE_3GPP; |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 336 | dataProfileInfo.maxConnsTime = 300; |
| 337 | dataProfileInfo.maxConns = 20; |
| 338 | dataProfileInfo.waitTime = 0; |
| 339 | dataProfileInfo.enabled = true; |
| 340 | dataProfileInfo.supportedApnTypesBitmap = 320; |
| 341 | dataProfileInfo.bearerBitmap = 161543; |
| 342 | dataProfileInfo.mtuV4 = 0; |
| 343 | dataProfileInfo.mtuV6 = 0; |
| 344 | dataProfileInfo.preferred = true; |
| 345 | dataProfileInfo.persistent = false; |
| 346 | |
| 347 | radio_data->setInitialAttachApn(serial, dataProfileInfo); |
| 348 | |
| 349 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 350 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 351 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 352 | |
| 353 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 354 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 355 | {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE})); |
| 356 | } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { |
| 357 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 358 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE})); |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | /* |
| 363 | * Test IRadioData.setDataProfile() for the response returned. |
| 364 | */ |
| 365 | TEST_P(RadioDataTest, setDataProfile) { |
| 366 | serial = GetRandomSerialNumber(); |
| 367 | |
| 368 | // Create a dataProfileInfo |
| 369 | DataProfileInfo dataProfileInfo; |
| 370 | memset(&dataProfileInfo, 0, sizeof(dataProfileInfo)); |
| 371 | dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT; |
| 372 | dataProfileInfo.apn = std::string("internet"); |
| 373 | dataProfileInfo.protocol = PdpProtocolType::IPV4V6; |
| 374 | dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6; |
| 375 | dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP; |
| 376 | dataProfileInfo.user = std::string("username"); |
| 377 | dataProfileInfo.password = std::string("password"); |
Sarah Chin | f746a91 | 2022-01-28 15:54:36 -0800 | [diff] [blame] | 378 | dataProfileInfo.type = DataProfileInfo::TYPE_3GPP; |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 379 | dataProfileInfo.maxConnsTime = 300; |
| 380 | dataProfileInfo.maxConns = 20; |
| 381 | dataProfileInfo.waitTime = 0; |
| 382 | dataProfileInfo.enabled = true; |
| 383 | dataProfileInfo.supportedApnTypesBitmap = 320; |
| 384 | dataProfileInfo.bearerBitmap = 161543; |
| 385 | dataProfileInfo.mtuV4 = 0; |
| 386 | dataProfileInfo.mtuV6 = 0; |
| 387 | dataProfileInfo.preferred = true; |
| 388 | dataProfileInfo.persistent = true; |
| 389 | |
| 390 | // Create a dataProfileInfoList |
| 391 | std::vector<DataProfileInfo> dataProfileInfoList = {dataProfileInfo}; |
| 392 | |
| 393 | radio_data->setDataProfile(serial, dataProfileInfoList); |
| 394 | |
| 395 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 396 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 397 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 398 | |
| 399 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 400 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 401 | {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE})); |
| 402 | } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { |
| 403 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 404 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE})); |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | /* |
| 409 | * Test IRadioData.deactivateDataCall() for the response returned. |
| 410 | */ |
| 411 | TEST_P(RadioDataTest, deactivateDataCall) { |
| 412 | serial = GetRandomSerialNumber(); |
| 413 | int cid = 1; |
| 414 | DataRequestReason reason = DataRequestReason::NORMAL; |
| 415 | |
| 416 | ndk::ScopedAStatus res = radio_data->deactivateDataCall(serial, cid, reason); |
| 417 | ASSERT_OK(res); |
| 418 | |
| 419 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 420 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 421 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 422 | |
| 423 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 424 | ASSERT_TRUE( |
| 425 | CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 426 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, |
| 427 | RadioError::INVALID_CALL_ID, RadioError::INVALID_STATE, |
| 428 | RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED, |
| 429 | RadioError::CANCELLED, RadioError::SIM_ABSENT})); |
| 430 | } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { |
| 431 | ASSERT_TRUE(CheckAnyOfErrors( |
| 432 | radioRsp_data->rspInfo.error, |
| 433 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_CALL_ID, |
| 434 | RadioError::INVALID_STATE, RadioError::INVALID_ARGUMENTS, |
| 435 | RadioError::REQUEST_NOT_SUPPORTED, RadioError::CANCELLED})); |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | /* |
| 440 | * Test IRadioData.startKeepalive() for the response returned. |
| 441 | */ |
| 442 | TEST_P(RadioDataTest, startKeepalive) { |
| 443 | std::vector<KeepaliveRequest> requests = { |
| 444 | { |
| 445 | // Invalid IPv4 source address |
| 446 | KeepaliveRequest::TYPE_NATT_IPV4, |
| 447 | {192, 168, 0 /*, 100*/}, |
| 448 | 1234, |
| 449 | {8, 8, 4, 4}, |
| 450 | 4500, |
| 451 | 20000, |
| 452 | 0xBAD, |
| 453 | }, |
| 454 | { |
| 455 | // Invalid IPv4 destination address |
| 456 | KeepaliveRequest::TYPE_NATT_IPV4, |
| 457 | {192, 168, 0, 100}, |
| 458 | 1234, |
| 459 | {8, 8, 4, 4, 1, 2, 3, 4}, |
| 460 | 4500, |
| 461 | 20000, |
| 462 | 0xBAD, |
| 463 | }, |
| 464 | { |
| 465 | // Invalid Keepalive Type |
| 466 | -1, |
| 467 | {192, 168, 0, 100}, |
| 468 | 1234, |
| 469 | {8, 8, 4, 4}, |
| 470 | 4500, |
| 471 | 20000, |
| 472 | 0xBAD, |
| 473 | }, |
| 474 | { |
| 475 | // Invalid IPv6 source address |
| 476 | KeepaliveRequest::TYPE_NATT_IPV6, |
| 477 | {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, |
| 478 | 0xED, 0xBE, 0xEF, 0xBD}, |
| 479 | 1234, |
| 480 | {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 481 | 0x00, 0x88, 0x44}, |
| 482 | 4500, |
| 483 | 20000, |
| 484 | 0xBAD, |
| 485 | }, |
| 486 | { |
| 487 | // Invalid IPv6 destination address |
| 488 | KeepaliveRequest::TYPE_NATT_IPV6, |
| 489 | {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, |
| 490 | 0xED, 0xBE, 0xEF}, |
| 491 | 1234, |
| 492 | {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 493 | 0x00, 0x88, |
| 494 | /*0x44*/}, |
| 495 | 4500, |
| 496 | 20000, |
| 497 | 0xBAD, |
| 498 | }, |
| 499 | { |
| 500 | // Invalid Context ID (cid), this should survive the initial |
| 501 | // range checking and fail in the modem data layer |
| 502 | KeepaliveRequest::TYPE_NATT_IPV4, |
| 503 | {192, 168, 0, 100}, |
| 504 | 1234, |
| 505 | {8, 8, 4, 4}, |
| 506 | 4500, |
| 507 | 20000, |
| 508 | 0xBAD, |
| 509 | }, |
| 510 | { |
| 511 | // Invalid Context ID (cid), this should survive the initial |
| 512 | // range checking and fail in the modem data layer |
| 513 | KeepaliveRequest::TYPE_NATT_IPV6, |
| 514 | {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, |
| 515 | 0xED, 0xBE, 0xEF}, |
| 516 | 1234, |
| 517 | {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 518 | 0x00, 0x88, 0x44}, |
| 519 | 4500, |
| 520 | 20000, |
| 521 | 0xBAD, |
| 522 | }}; |
| 523 | |
| 524 | for (auto req = requests.begin(); req != requests.end(); req++) { |
| 525 | serial = GetRandomSerialNumber(); |
| 526 | radio_data->startKeepalive(serial, *req); |
| 527 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 528 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 529 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 530 | |
| 531 | ASSERT_TRUE(CheckAnyOfErrors( |
| 532 | radioRsp_data->rspInfo.error, |
Sarah Chin | 757a758 | 2023-04-20 16:10:37 -0700 | [diff] [blame] | 533 | {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 534 | } |
| 535 | } |
| 536 | |
| 537 | /* |
| 538 | * Test IRadioData.stopKeepalive() for the response returned. |
| 539 | */ |
| 540 | TEST_P(RadioDataTest, stopKeepalive) { |
| 541 | serial = GetRandomSerialNumber(); |
| 542 | |
| 543 | radio_data->stopKeepalive(serial, 0xBAD); |
| 544 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 545 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 546 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 547 | |
| 548 | ASSERT_TRUE( |
| 549 | CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
Sarah Chin | 757a758 | 2023-04-20 16:10:37 -0700 | [diff] [blame] | 550 | {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 551 | } |
| 552 | |
| 553 | /* |
| 554 | * Test IRadioData.getDataCallList() for the response returned. |
| 555 | */ |
| 556 | TEST_P(RadioDataTest, getDataCallList) { |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 557 | serial = GetRandomSerialNumber(); |
| 558 | |
| 559 | radio_data->getDataCallList(serial); |
| 560 | |
| 561 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 562 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 563 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 564 | |
| 565 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 566 | ASSERT_TRUE(CheckAnyOfErrors( |
| 567 | radioRsp_data->rspInfo.error, |
| 568 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::SIM_ABSENT})); |
| 569 | } |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | /* |
| 573 | * Test IRadioData.setDataAllowed() for the response returned. |
| 574 | */ |
| 575 | TEST_P(RadioDataTest, setDataAllowed) { |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 576 | serial = GetRandomSerialNumber(); |
| 577 | bool allow = true; |
| 578 | |
| 579 | radio_data->setDataAllowed(serial, allow); |
| 580 | |
| 581 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 582 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 583 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 584 | |
| 585 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 586 | EXPECT_EQ(RadioError::NONE, radioRsp_data->rspInfo.error); |
| 587 | } |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 588 | } |