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) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame^] | 71 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 72 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) { |
| 73 | GTEST_SKIP() << "setupDataCall : required FEATURE_TELEPHONY_DATA"; |
| 74 | } |
| 75 | } |
| 76 | |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 77 | serial = GetRandomSerialNumber(); |
| 78 | |
| 79 | AccessNetwork accessNetwork = AccessNetwork::EUTRAN; |
| 80 | |
| 81 | DataProfileInfo dataProfileInfo; |
| 82 | memset(&dataProfileInfo, 0, sizeof(dataProfileInfo)); |
| 83 | dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT; |
| 84 | dataProfileInfo.apn = std::string("internet"); |
| 85 | dataProfileInfo.protocol = PdpProtocolType::IP; |
| 86 | dataProfileInfo.roamingProtocol = PdpProtocolType::IP; |
| 87 | dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP; |
| 88 | dataProfileInfo.user = std::string("username"); |
| 89 | dataProfileInfo.password = std::string("password"); |
Sarah Chin | f746a91 | 2022-01-28 15:54:36 -0800 | [diff] [blame] | 90 | dataProfileInfo.type = DataProfileInfo::TYPE_3GPP; |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 91 | dataProfileInfo.maxConnsTime = 300; |
| 92 | dataProfileInfo.maxConns = 20; |
| 93 | dataProfileInfo.waitTime = 0; |
| 94 | dataProfileInfo.enabled = true; |
Sarah Chin | c9d3b7b | 2021-12-23 16:41:58 -0800 | [diff] [blame] | 95 | dataProfileInfo.supportedApnTypesBitmap = |
| 96 | static_cast<int32_t>(ApnTypes::IMS) | static_cast<int32_t>(ApnTypes::IA); |
| 97 | dataProfileInfo.bearerBitmap = static_cast<int32_t>(RadioAccessFamily::GPRS) | |
| 98 | static_cast<int32_t>(RadioAccessFamily::EDGE) | |
| 99 | static_cast<int32_t>(RadioAccessFamily::UMTS) | |
| 100 | static_cast<int32_t>(RadioAccessFamily::HSDPA) | |
| 101 | static_cast<int32_t>(RadioAccessFamily::HSUPA) | |
| 102 | static_cast<int32_t>(RadioAccessFamily::HSPA) | |
| 103 | static_cast<int32_t>(RadioAccessFamily::EHRPD) | |
| 104 | static_cast<int32_t>(RadioAccessFamily::LTE) | |
| 105 | static_cast<int32_t>(RadioAccessFamily::HSPAP) | |
| 106 | static_cast<int32_t>(RadioAccessFamily::IWLAN); |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 107 | dataProfileInfo.mtuV4 = 0; |
| 108 | dataProfileInfo.mtuV6 = 0; |
| 109 | dataProfileInfo.preferred = true; |
| 110 | dataProfileInfo.persistent = false; |
| 111 | |
| 112 | bool roamingAllowed = false; |
| 113 | |
| 114 | std::vector<LinkAddress> addresses = {}; |
| 115 | std::vector<std::string> dnses = {}; |
| 116 | |
| 117 | DataRequestReason reason = DataRequestReason::NORMAL; |
| 118 | SliceInfo sliceInfo; |
| 119 | bool matchAllRuleAllowed = true; |
| 120 | |
| 121 | ndk::ScopedAStatus res = |
| 122 | radio_data->setupDataCall(serial, accessNetwork, dataProfileInfo, roamingAllowed, |
| 123 | reason, addresses, dnses, -1, sliceInfo, matchAllRuleAllowed); |
| 124 | ASSERT_OK(res); |
| 125 | |
| 126 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 127 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 128 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 129 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 130 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 131 | {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE, |
| 132 | RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW})); |
| 133 | } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { |
| 134 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 135 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, |
| 136 | RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW})); |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | /* |
| 141 | * Test IRadioData.setupDataCall() with osAppId for the response returned. |
| 142 | */ |
| 143 | TEST_P(RadioDataTest, setupDataCall_osAppId) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame^] | 144 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 145 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) { |
| 146 | GTEST_SKIP() << "Skipping setupDataCall_osAppId " |
| 147 | "due to undefined FEATURE_TELEPHONY_DATA"; |
| 148 | } |
| 149 | } |
| 150 | |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 151 | serial = GetRandomSerialNumber(); |
| 152 | |
| 153 | AccessNetwork accessNetwork = AccessNetwork::EUTRAN; |
| 154 | |
| 155 | TrafficDescriptor trafficDescriptor; |
| 156 | OsAppId osAppId; |
Sarah Chin | 47213a1 | 2023-01-18 18:28:03 -0800 | [diff] [blame] | 157 | osAppId.osAppId = {static_cast<unsigned char>(-105), static_cast<unsigned char>(-92), |
| 158 | static_cast<unsigned char>(-104), static_cast<unsigned char>(-29), |
| 159 | static_cast<unsigned char>(-4), static_cast<unsigned char>(-110), |
| 160 | static_cast<unsigned char>(92), static_cast<unsigned char>(-108), |
| 161 | static_cast<unsigned char>(-119), static_cast<unsigned char>(-122), |
| 162 | static_cast<unsigned char>(3), static_cast<unsigned char>(51), |
| 163 | static_cast<unsigned char>(-48), static_cast<unsigned char>(110), |
| 164 | static_cast<unsigned char>(78), static_cast<unsigned char>(71), |
| 165 | static_cast<unsigned char>(10), static_cast<unsigned char>(69), |
| 166 | static_cast<unsigned char>(78), static_cast<unsigned char>(84), |
| 167 | static_cast<unsigned char>(69), static_cast<unsigned char>(82), |
| 168 | static_cast<unsigned char>(80), static_cast<unsigned char>(82), |
| 169 | static_cast<unsigned char>(73), static_cast<unsigned char>(83), |
| 170 | static_cast<unsigned char>(69)}; |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 171 | trafficDescriptor.osAppId = osAppId; |
| 172 | |
| 173 | DataProfileInfo dataProfileInfo; |
| 174 | memset(&dataProfileInfo, 0, sizeof(dataProfileInfo)); |
| 175 | dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT; |
| 176 | dataProfileInfo.apn = std::string("internet"); |
| 177 | dataProfileInfo.protocol = PdpProtocolType::IP; |
| 178 | dataProfileInfo.roamingProtocol = PdpProtocolType::IP; |
| 179 | dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP; |
| 180 | dataProfileInfo.user = std::string("username"); |
| 181 | dataProfileInfo.password = std::string("password"); |
Sarah Chin | f746a91 | 2022-01-28 15:54:36 -0800 | [diff] [blame] | 182 | dataProfileInfo.type = DataProfileInfo::TYPE_3GPP; |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 183 | dataProfileInfo.maxConnsTime = 300; |
| 184 | dataProfileInfo.maxConns = 20; |
| 185 | dataProfileInfo.waitTime = 0; |
| 186 | dataProfileInfo.enabled = true; |
Sarah Chin | c9d3b7b | 2021-12-23 16:41:58 -0800 | [diff] [blame] | 187 | dataProfileInfo.supportedApnTypesBitmap = |
| 188 | static_cast<int32_t>(ApnTypes::IMS) | static_cast<int32_t>(ApnTypes::IA); |
| 189 | dataProfileInfo.bearerBitmap = static_cast<int32_t>(RadioAccessFamily::GPRS) | |
| 190 | static_cast<int32_t>(RadioAccessFamily::EDGE) | |
| 191 | static_cast<int32_t>(RadioAccessFamily::UMTS) | |
| 192 | static_cast<int32_t>(RadioAccessFamily::HSDPA) | |
| 193 | static_cast<int32_t>(RadioAccessFamily::HSUPA) | |
| 194 | static_cast<int32_t>(RadioAccessFamily::HSPA) | |
| 195 | static_cast<int32_t>(RadioAccessFamily::EHRPD) | |
| 196 | static_cast<int32_t>(RadioAccessFamily::LTE) | |
| 197 | static_cast<int32_t>(RadioAccessFamily::HSPAP) | |
| 198 | static_cast<int32_t>(RadioAccessFamily::IWLAN); |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 199 | dataProfileInfo.mtuV4 = 0; |
| 200 | dataProfileInfo.mtuV6 = 0; |
| 201 | dataProfileInfo.preferred = true; |
| 202 | dataProfileInfo.persistent = false; |
| 203 | dataProfileInfo.trafficDescriptor = trafficDescriptor; |
| 204 | |
| 205 | bool roamingAllowed = false; |
| 206 | |
| 207 | std::vector<LinkAddress> addresses = {}; |
| 208 | std::vector<std::string> dnses = {}; |
| 209 | |
| 210 | DataRequestReason reason = DataRequestReason::NORMAL; |
| 211 | SliceInfo sliceInfo; |
| 212 | bool matchAllRuleAllowed = true; |
| 213 | |
| 214 | ndk::ScopedAStatus res = |
| 215 | radio_data->setupDataCall(serial, accessNetwork, dataProfileInfo, roamingAllowed, |
| 216 | reason, addresses, dnses, -1, sliceInfo, matchAllRuleAllowed); |
| 217 | ASSERT_OK(res); |
| 218 | |
| 219 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 220 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 221 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 222 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 223 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 224 | {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE, |
| 225 | RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW})); |
| 226 | } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { |
| 227 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 228 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, |
| 229 | RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW})); |
Sarah Chin | 35bf8e1 | 2023-09-07 16:16:38 -0700 | [diff] [blame] | 230 | if (radioRsp_data->setupDataCallResult.trafficDescriptors.size() <= 0 || |
| 231 | !radioRsp_data->setupDataCallResult.trafficDescriptors[0].osAppId.has_value()) { |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 232 | return; |
| 233 | } |
| 234 | EXPECT_EQ(trafficDescriptor.osAppId.value().osAppId, |
| 235 | radioRsp_data->setupDataCallResult.trafficDescriptors[0].osAppId.value().osAppId); |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | /* |
| 240 | * Test IRadioData.getSlicingConfig() for the response returned. |
| 241 | */ |
| 242 | TEST_P(RadioDataTest, getSlicingConfig) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame^] | 243 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 244 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) { |
| 245 | GTEST_SKIP() << "Skipping getSlicingConfig " |
| 246 | "due to undefined FEATURE_TELEPHONY_DATA"; |
| 247 | } |
| 248 | } |
| 249 | |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 250 | serial = GetRandomSerialNumber(); |
| 251 | radio_data->getSlicingConfig(serial); |
| 252 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 253 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 254 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
Pavan Kumar M | 8b5cf0c | 2023-01-27 12:54:39 +0530 | [diff] [blame] | 255 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 256 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, |
| 257 | RadioError::INTERNAL_ERR, RadioError::MODEM_ERR, |
| 258 | RadioError::REQUEST_NOT_SUPPORTED})); |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | /* |
| 262 | * Test IRadioData.setDataThrottling() for the response returned. |
| 263 | */ |
| 264 | TEST_P(RadioDataTest, setDataThrottling) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame^] | 265 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 266 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) { |
| 267 | GTEST_SKIP() << "Skipping setDataThrottling " |
| 268 | "due to undefined FEATURE_TELEPHONY_DATA"; |
| 269 | } |
| 270 | } |
| 271 | |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 272 | serial = GetRandomSerialNumber(); |
| 273 | |
| 274 | ndk::ScopedAStatus res = radio_data->setDataThrottling( |
| 275 | serial, DataThrottlingAction::THROTTLE_SECONDARY_CARRIER, 60000); |
| 276 | ASSERT_OK(res); |
| 277 | |
| 278 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 279 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 280 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 281 | if (getRadioHalCapabilities()) { |
| 282 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 283 | {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE})); |
| 284 | } else { |
| 285 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 286 | {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR, |
| 287 | RadioError::NONE, RadioError::INVALID_ARGUMENTS})); |
| 288 | } |
| 289 | |
| 290 | sleep(1); |
| 291 | serial = GetRandomSerialNumber(); |
| 292 | |
| 293 | res = radio_data->setDataThrottling(serial, DataThrottlingAction::THROTTLE_ANCHOR_CARRIER, |
| 294 | 60000); |
| 295 | ASSERT_OK(res); |
| 296 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 297 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 298 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 299 | if (getRadioHalCapabilities()) { |
| 300 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 301 | {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE})); |
| 302 | } else { |
| 303 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 304 | {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR, |
| 305 | RadioError::NONE, RadioError::INVALID_ARGUMENTS})); |
| 306 | } |
| 307 | |
| 308 | sleep(1); |
| 309 | serial = GetRandomSerialNumber(); |
| 310 | |
| 311 | res = radio_data->setDataThrottling(serial, DataThrottlingAction::HOLD, 60000); |
| 312 | ASSERT_OK(res); |
| 313 | |
| 314 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 315 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 316 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 317 | if (getRadioHalCapabilities()) { |
| 318 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 319 | {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE})); |
| 320 | } else { |
| 321 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 322 | {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR, |
| 323 | RadioError::NONE, RadioError::INVALID_ARGUMENTS})); |
| 324 | } |
| 325 | |
| 326 | sleep(1); |
| 327 | serial = GetRandomSerialNumber(); |
| 328 | |
| 329 | res = radio_data->setDataThrottling(serial, DataThrottlingAction::NO_DATA_THROTTLING, 60000); |
| 330 | ASSERT_OK(res); |
| 331 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 332 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 333 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 334 | if (getRadioHalCapabilities()) { |
| 335 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 336 | {RadioError::REQUEST_NOT_SUPPORTED, RadioError::NONE})); |
| 337 | } else { |
| 338 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 339 | {RadioError::RADIO_NOT_AVAILABLE, RadioError::MODEM_ERR, |
| 340 | RadioError::NONE, RadioError::INVALID_ARGUMENTS})); |
| 341 | } |
| 342 | |
| 343 | sleep(1); |
| 344 | } |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 345 | |
| 346 | /* |
| 347 | * Test IRadioData.setInitialAttachApn() for the response returned. |
| 348 | */ |
| 349 | TEST_P(RadioDataTest, setInitialAttachApn) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame^] | 350 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 351 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) { |
| 352 | GTEST_SKIP() << "Skipping setInitialAttachApn " |
| 353 | "due to undefined FEATURE_TELEPHONY_DATA"; |
| 354 | } |
| 355 | } |
| 356 | |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 357 | serial = GetRandomSerialNumber(); |
| 358 | |
| 359 | // Create a dataProfileInfo |
| 360 | DataProfileInfo dataProfileInfo; |
| 361 | memset(&dataProfileInfo, 0, sizeof(dataProfileInfo)); |
| 362 | dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT; |
| 363 | dataProfileInfo.apn = std::string("internet"); |
| 364 | dataProfileInfo.protocol = PdpProtocolType::IPV4V6; |
| 365 | dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6; |
| 366 | dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP; |
| 367 | dataProfileInfo.user = std::string("username"); |
| 368 | dataProfileInfo.password = std::string("password"); |
Sarah Chin | f746a91 | 2022-01-28 15:54:36 -0800 | [diff] [blame] | 369 | dataProfileInfo.type = DataProfileInfo::TYPE_3GPP; |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 370 | dataProfileInfo.maxConnsTime = 300; |
| 371 | dataProfileInfo.maxConns = 20; |
| 372 | dataProfileInfo.waitTime = 0; |
| 373 | dataProfileInfo.enabled = true; |
| 374 | dataProfileInfo.supportedApnTypesBitmap = 320; |
| 375 | dataProfileInfo.bearerBitmap = 161543; |
| 376 | dataProfileInfo.mtuV4 = 0; |
| 377 | dataProfileInfo.mtuV6 = 0; |
| 378 | dataProfileInfo.preferred = true; |
| 379 | dataProfileInfo.persistent = false; |
| 380 | |
| 381 | radio_data->setInitialAttachApn(serial, dataProfileInfo); |
| 382 | |
| 383 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 384 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 385 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 386 | |
| 387 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 388 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 389 | {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE})); |
| 390 | } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { |
| 391 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 392 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE})); |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | /* |
| 397 | * Test IRadioData.setDataProfile() for the response returned. |
| 398 | */ |
| 399 | TEST_P(RadioDataTest, setDataProfile) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame^] | 400 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 401 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) { |
| 402 | GTEST_SKIP() << "Skipping setDataProfile " |
| 403 | "due to undefined FEATURE_TELEPHONY_DATA"; |
| 404 | } |
| 405 | } |
| 406 | |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 407 | serial = GetRandomSerialNumber(); |
| 408 | |
| 409 | // Create a dataProfileInfo |
| 410 | DataProfileInfo dataProfileInfo; |
| 411 | memset(&dataProfileInfo, 0, sizeof(dataProfileInfo)); |
| 412 | dataProfileInfo.profileId = DataProfileInfo::ID_DEFAULT; |
| 413 | dataProfileInfo.apn = std::string("internet"); |
| 414 | dataProfileInfo.protocol = PdpProtocolType::IPV4V6; |
| 415 | dataProfileInfo.roamingProtocol = PdpProtocolType::IPV4V6; |
| 416 | dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP; |
| 417 | dataProfileInfo.user = std::string("username"); |
| 418 | dataProfileInfo.password = std::string("password"); |
Sarah Chin | f746a91 | 2022-01-28 15:54:36 -0800 | [diff] [blame] | 419 | dataProfileInfo.type = DataProfileInfo::TYPE_3GPP; |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 420 | dataProfileInfo.maxConnsTime = 300; |
| 421 | dataProfileInfo.maxConns = 20; |
| 422 | dataProfileInfo.waitTime = 0; |
| 423 | dataProfileInfo.enabled = true; |
| 424 | dataProfileInfo.supportedApnTypesBitmap = 320; |
| 425 | dataProfileInfo.bearerBitmap = 161543; |
| 426 | dataProfileInfo.mtuV4 = 0; |
| 427 | dataProfileInfo.mtuV6 = 0; |
| 428 | dataProfileInfo.preferred = true; |
| 429 | dataProfileInfo.persistent = true; |
| 430 | |
| 431 | // Create a dataProfileInfoList |
| 432 | std::vector<DataProfileInfo> dataProfileInfoList = {dataProfileInfo}; |
| 433 | |
| 434 | radio_data->setDataProfile(serial, dataProfileInfoList); |
| 435 | |
| 436 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 437 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 438 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 439 | |
| 440 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 441 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 442 | {RadioError::SIM_ABSENT, RadioError::RADIO_NOT_AVAILABLE})); |
| 443 | } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { |
| 444 | ASSERT_TRUE(CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 445 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE})); |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | /* |
| 450 | * Test IRadioData.deactivateDataCall() for the response returned. |
| 451 | */ |
| 452 | TEST_P(RadioDataTest, deactivateDataCall) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame^] | 453 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 454 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) { |
| 455 | GTEST_SKIP() << "Skipping deactivateDataCall " |
| 456 | "due to undefined FEATURE_TELEPHONY_DATA"; |
| 457 | } |
| 458 | } |
| 459 | |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 460 | serial = GetRandomSerialNumber(); |
| 461 | int cid = 1; |
| 462 | DataRequestReason reason = DataRequestReason::NORMAL; |
| 463 | |
| 464 | ndk::ScopedAStatus res = radio_data->deactivateDataCall(serial, cid, reason); |
| 465 | ASSERT_OK(res); |
| 466 | |
| 467 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 468 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 469 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 470 | |
| 471 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 472 | ASSERT_TRUE( |
| 473 | CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
| 474 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, |
| 475 | RadioError::INVALID_CALL_ID, RadioError::INVALID_STATE, |
| 476 | RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED, |
| 477 | RadioError::CANCELLED, RadioError::SIM_ABSENT})); |
| 478 | } else if (cardStatus.cardState == CardStatus::STATE_PRESENT) { |
| 479 | ASSERT_TRUE(CheckAnyOfErrors( |
| 480 | radioRsp_data->rspInfo.error, |
| 481 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::INVALID_CALL_ID, |
| 482 | RadioError::INVALID_STATE, RadioError::INVALID_ARGUMENTS, |
| 483 | RadioError::REQUEST_NOT_SUPPORTED, RadioError::CANCELLED})); |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | /* |
| 488 | * Test IRadioData.startKeepalive() for the response returned. |
| 489 | */ |
| 490 | TEST_P(RadioDataTest, startKeepalive) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame^] | 491 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 492 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) { |
| 493 | GTEST_SKIP() << "Skipping startKeepalive " |
| 494 | "due to undefined FEATURE_TELEPHONY_DATA"; |
| 495 | } |
| 496 | } |
| 497 | |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 498 | std::vector<KeepaliveRequest> requests = { |
| 499 | { |
| 500 | // Invalid IPv4 source address |
| 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 IPv4 destination address |
| 511 | KeepaliveRequest::TYPE_NATT_IPV4, |
| 512 | {192, 168, 0, 100}, |
| 513 | 1234, |
| 514 | {8, 8, 4, 4, 1, 2, 3, 4}, |
| 515 | 4500, |
| 516 | 20000, |
| 517 | 0xBAD, |
| 518 | }, |
| 519 | { |
| 520 | // Invalid Keepalive Type |
| 521 | -1, |
| 522 | {192, 168, 0, 100}, |
| 523 | 1234, |
| 524 | {8, 8, 4, 4}, |
| 525 | 4500, |
| 526 | 20000, |
| 527 | 0xBAD, |
| 528 | }, |
| 529 | { |
| 530 | // Invalid IPv6 source address |
| 531 | KeepaliveRequest::TYPE_NATT_IPV6, |
| 532 | {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, |
| 533 | 0xED, 0xBE, 0xEF, 0xBD}, |
| 534 | 1234, |
| 535 | {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 536 | 0x00, 0x88, 0x44}, |
| 537 | 4500, |
| 538 | 20000, |
| 539 | 0xBAD, |
| 540 | }, |
| 541 | { |
| 542 | // Invalid IPv6 destination address |
| 543 | KeepaliveRequest::TYPE_NATT_IPV6, |
| 544 | {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, |
| 545 | 0xED, 0xBE, 0xEF}, |
| 546 | 1234, |
| 547 | {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 548 | 0x00, 0x88, |
| 549 | /*0x44*/}, |
| 550 | 4500, |
| 551 | 20000, |
| 552 | 0xBAD, |
| 553 | }, |
| 554 | { |
| 555 | // Invalid Context ID (cid), this should survive the initial |
| 556 | // range checking and fail in the modem data layer |
| 557 | KeepaliveRequest::TYPE_NATT_IPV4, |
| 558 | {192, 168, 0, 100}, |
| 559 | 1234, |
| 560 | {8, 8, 4, 4}, |
| 561 | 4500, |
| 562 | 20000, |
| 563 | 0xBAD, |
| 564 | }, |
| 565 | { |
| 566 | // Invalid Context ID (cid), this should survive the initial |
| 567 | // range checking and fail in the modem data layer |
| 568 | KeepaliveRequest::TYPE_NATT_IPV6, |
| 569 | {0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, |
| 570 | 0xED, 0xBE, 0xEF}, |
| 571 | 1234, |
| 572 | {0x20, 0x01, 0x48, 0x60, 0x48, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 573 | 0x00, 0x88, 0x44}, |
| 574 | 4500, |
| 575 | 20000, |
| 576 | 0xBAD, |
| 577 | }}; |
| 578 | |
| 579 | for (auto req = requests.begin(); req != requests.end(); req++) { |
| 580 | serial = GetRandomSerialNumber(); |
| 581 | radio_data->startKeepalive(serial, *req); |
| 582 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 583 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 584 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 585 | |
| 586 | ASSERT_TRUE(CheckAnyOfErrors( |
| 587 | radioRsp_data->rspInfo.error, |
Sarah Chin | 757a758 | 2023-04-20 16:10:37 -0700 | [diff] [blame] | 588 | {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 589 | } |
| 590 | } |
| 591 | |
| 592 | /* |
| 593 | * Test IRadioData.stopKeepalive() for the response returned. |
| 594 | */ |
| 595 | TEST_P(RadioDataTest, stopKeepalive) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame^] | 596 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 597 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) { |
| 598 | GTEST_SKIP() << "Skipping stopKeepalive " |
| 599 | "due to undefined FEATURE_TELEPHONY_DATA"; |
| 600 | } |
| 601 | } |
| 602 | |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 603 | serial = GetRandomSerialNumber(); |
| 604 | |
| 605 | radio_data->stopKeepalive(serial, 0xBAD); |
| 606 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 607 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 608 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 609 | |
| 610 | ASSERT_TRUE( |
| 611 | CheckAnyOfErrors(radioRsp_data->rspInfo.error, |
Sarah Chin | 757a758 | 2023-04-20 16:10:37 -0700 | [diff] [blame] | 612 | {RadioError::INVALID_ARGUMENTS, RadioError::REQUEST_NOT_SUPPORTED})); |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 613 | } |
| 614 | |
| 615 | /* |
| 616 | * Test IRadioData.getDataCallList() for the response returned. |
| 617 | */ |
| 618 | TEST_P(RadioDataTest, getDataCallList) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame^] | 619 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 620 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) { |
| 621 | GTEST_SKIP() << "Skipping getDataCallList " |
| 622 | "due to undefined FEATURE_TELEPHONY_DATA"; |
| 623 | } |
| 624 | } |
| 625 | |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 626 | serial = GetRandomSerialNumber(); |
| 627 | |
| 628 | radio_data->getDataCallList(serial); |
| 629 | |
| 630 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 631 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 632 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 633 | |
| 634 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 635 | ASSERT_TRUE(CheckAnyOfErrors( |
| 636 | radioRsp_data->rspInfo.error, |
| 637 | {RadioError::NONE, RadioError::RADIO_NOT_AVAILABLE, RadioError::SIM_ABSENT})); |
| 638 | } |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 639 | } |
| 640 | |
| 641 | /* |
| 642 | * Test IRadioData.setDataAllowed() for the response returned. |
| 643 | */ |
| 644 | TEST_P(RadioDataTest, setDataAllowed) { |
joonhunshin | d519aea | 2023-10-31 03:06:54 +0000 | [diff] [blame^] | 645 | if (telephony_flags::enforce_telephony_feature_mapping()) { |
| 646 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_DATA)) { |
| 647 | GTEST_SKIP() << "Skipping setDataAllowed " |
| 648 | "due to undefined FEATURE_TELEPHONY_DATA"; |
| 649 | } |
| 650 | } |
| 651 | |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 652 | serial = GetRandomSerialNumber(); |
| 653 | bool allow = true; |
| 654 | |
| 655 | radio_data->setDataAllowed(serial, allow); |
| 656 | |
| 657 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 658 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_data->rspInfo.type); |
| 659 | EXPECT_EQ(serial, radioRsp_data->rspInfo.serial); |
| 660 | |
| 661 | if (cardStatus.cardState == CardStatus::STATE_ABSENT) { |
| 662 | EXPECT_EQ(RadioError::NONE, radioRsp_data->rspInfo.error); |
| 663 | } |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame] | 664 | } |