Hunsuk Choi | 9d4f38c | 2021-12-16 21:50:04 +0000 | [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 | |
| 17 | #include <aidl/android/hardware/radio/config/IRadioConfig.h> |
| 18 | #include <android-base/logging.h> |
| 19 | #include <android/binder_manager.h> |
| 20 | |
| 21 | #include "radio_ims_utils.h" |
| 22 | |
| 23 | #define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk()) |
| 24 | |
| 25 | void RadioImsTest::SetUp() { |
| 26 | std::string serviceName = GetParam(); |
| 27 | |
| 28 | if (!isServiceValidForDeviceConfiguration(serviceName)) { |
| 29 | ALOGI("Skipped the test due to device configuration."); |
| 30 | GTEST_SKIP(); |
| 31 | } |
| 32 | |
| 33 | radio_ims = IRadioIms::fromBinder( |
| 34 | ndk::SpAIBinder(AServiceManager_waitForService(GetParam().c_str()))); |
| 35 | ASSERT_NE(nullptr, radio_ims.get()); |
| 36 | |
| 37 | radioRsp_ims = ndk::SharedRefBase::make<RadioImsResponse>(*this); |
| 38 | ASSERT_NE(nullptr, radioRsp_ims.get()); |
| 39 | |
| 40 | count_ = 0; |
| 41 | |
| 42 | radioInd_ims = ndk::SharedRefBase::make<RadioImsIndication>(*this); |
| 43 | ASSERT_NE(nullptr, radioInd_ims.get()); |
| 44 | |
| 45 | radio_ims->setResponseFunctions(radioRsp_ims, radioInd_ims); |
| 46 | |
| 47 | // Assert IRadioConfig exists before testing |
| 48 | radio_config = config::IRadioConfig::fromBinder(ndk::SpAIBinder( |
| 49 | AServiceManager_waitForService("android.hardware.radio.config.IRadioConfig/default"))); |
| 50 | ASSERT_NE(nullptr, radio_config.get()); |
| 51 | } |
| 52 | |
| 53 | /* |
| 54 | * Test IRadioIms.setSrvccCallInfo() for the response returned. |
| 55 | */ |
| 56 | TEST_P(RadioImsTest, setSrvccCallInfo) { |
| 57 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_IMS)) { |
| 58 | ALOGI("Skipping setSrvccCallInfo because ims is not supported in device"); |
| 59 | return; |
| 60 | } else { |
| 61 | ALOGI("Running setSrvccCallInfo because ims is supported in device"); |
| 62 | } |
| 63 | |
| 64 | serial = GetRandomSerialNumber(); |
| 65 | |
| 66 | SrvccCall srvccCall; |
| 67 | |
| 68 | ndk::ScopedAStatus res = |
| 69 | radio_ims->setSrvccCallInfo(serial, { srvccCall }); |
| 70 | ASSERT_OK(res); |
| 71 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 72 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_ims->rspInfo.type); |
| 73 | EXPECT_EQ(serial, radioRsp_ims->rspInfo.serial); |
| 74 | |
| 75 | ALOGI("setSrvccCallInfo, rspInfo.error = %s\n", |
| 76 | toString(radioRsp_ims->rspInfo.error).c_str()); |
| 77 | |
| 78 | verifyError(radioRsp_ims->rspInfo.error); |
| 79 | } |
| 80 | |
| 81 | /* |
| 82 | * Test IRadioIms.updateImsRegistrationInfo() for the response returned. |
| 83 | */ |
| 84 | TEST_P(RadioImsTest, updateImsRegistrationInfo) { |
| 85 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_IMS)) { |
| 86 | ALOGI("Skipping updateImsRegistrationInfo because ims is not supported in device"); |
| 87 | return; |
| 88 | } else { |
| 89 | ALOGI("Running updateImsRegistrationInfo because ims is supported in device"); |
| 90 | } |
| 91 | |
| 92 | serial = GetRandomSerialNumber(); |
| 93 | |
| 94 | ImsRegistration regInfo; |
| 95 | regInfo.state = ImsRegistration::State::NOT_REGISTERED; |
| 96 | regInfo.ipcan = ImsRegistration::ImsAccessNetwork::NONE; |
| 97 | regInfo.reason = ImsRegistration::FailureReason::NONE; |
| 98 | regInfo.features = ImsRegistration::FEATURE_NONE; |
| 99 | |
| 100 | ndk::ScopedAStatus res = |
| 101 | radio_ims->updateImsRegistrationInfo(serial, regInfo); |
| 102 | ASSERT_OK(res); |
| 103 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 104 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_ims->rspInfo.type); |
| 105 | EXPECT_EQ(serial, radioRsp_ims->rspInfo.serial); |
| 106 | |
| 107 | ALOGI("updateImsRegistrationInfo, rspInfo.error = %s\n", |
| 108 | toString(radioRsp_ims->rspInfo.error).c_str()); |
| 109 | |
| 110 | verifyError(radioRsp_ims->rspInfo.error); |
| 111 | } |
| 112 | |
| 113 | /* |
| 114 | * Test IRadioIms.notifyImsTraffic() for the response returned. |
| 115 | */ |
| 116 | TEST_P(RadioImsTest, notifyImsTraffic) { |
| 117 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_IMS)) { |
| 118 | ALOGI("Skipping notifyImsTraffic because ims is not supported in device"); |
| 119 | return; |
| 120 | } else { |
| 121 | ALOGI("Running notifyImsTraffic because ims is supported in device"); |
| 122 | } |
| 123 | |
| 124 | serial = GetRandomSerialNumber(); |
| 125 | |
| 126 | ndk::ScopedAStatus res = |
| 127 | radio_ims->notifyImsTraffic(serial, 1, ImsTrafficType::REGISTRATION, false); |
| 128 | ASSERT_OK(res); |
| 129 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 130 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_ims->rspInfo.type); |
| 131 | EXPECT_EQ(serial, radioRsp_ims->rspInfo.serial); |
| 132 | |
| 133 | ALOGI("notifyImsTraffic, rspInfo.error = %s\n", |
| 134 | toString(radioRsp_ims->rspInfo.error).c_str()); |
| 135 | |
| 136 | verifyError(radioRsp_ims->rspInfo.error); |
| 137 | } |
| 138 | |
| 139 | /* |
| 140 | * Test IRadioIms.performAcbCheck() for the response returned. |
| 141 | */ |
| 142 | TEST_P(RadioImsTest, performAcbCheck) { |
| 143 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_IMS)) { |
| 144 | ALOGI("Skipping performAcbCheck because ims is not supported in device"); |
| 145 | return; |
| 146 | } else { |
| 147 | ALOGI("Running performAcbCheck because ims is supported in device"); |
| 148 | } |
| 149 | |
| 150 | serial = GetRandomSerialNumber(); |
| 151 | |
| 152 | ndk::ScopedAStatus res = |
| 153 | radio_ims->performAcbCheck(serial, 1, ImsTrafficType::REGISTRATION); |
| 154 | ASSERT_OK(res); |
| 155 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 156 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_ims->rspInfo.type); |
| 157 | EXPECT_EQ(serial, radioRsp_ims->rspInfo.serial); |
| 158 | |
| 159 | ALOGI("performAcbCheck, rspInfo.error = %s\n", |
| 160 | toString(radioRsp_ims->rspInfo.error).c_str()); |
| 161 | |
| 162 | verifyError(radioRsp_ims->rspInfo.error); |
| 163 | } |
| 164 | |
Hwayoung | 539e1f4 | 2021-12-22 08:23:46 +0000 | [diff] [blame^] | 165 | /* |
| 166 | * Test IRadioIms.setAnbrEnabled() for the response returned. |
| 167 | */ |
| 168 | TEST_P(RadioImsTest, setAnbrEnabled) { |
| 169 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_IMS)) { |
| 170 | ALOGI("Skipping setAnbrEnabled because ims is not supported in device"); |
| 171 | return; |
| 172 | } else { |
| 173 | ALOGI("Running setAnbrEnabled because ims is supported in device"); |
| 174 | } |
| 175 | |
| 176 | serial = GetRandomSerialNumber(); |
| 177 | |
| 178 | ndk::ScopedAStatus res = |
| 179 | radio_ims->setAnbrEnabled(serial, 1, true); |
| 180 | ASSERT_OK(res); |
| 181 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 182 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_ims->rspInfo.type); |
| 183 | EXPECT_EQ(serial, radioRsp_ims->rspInfo.serial); |
| 184 | |
| 185 | ALOGI("setAnbrEnabled, rspInfo.error = %s\n", |
| 186 | toString(radioRsp_ims->rspInfo.error).c_str()); |
| 187 | |
| 188 | verifyError(radioRsp_ims->rspInfo.error); |
| 189 | } |
| 190 | |
| 191 | /* |
| 192 | * Test IRadioIms.sendAnbrQuery() for the response returned. |
| 193 | */ |
| 194 | TEST_P(RadioImsTest, sendAnbrQuery) { |
| 195 | if (!deviceSupportsFeature(FEATURE_TELEPHONY_IMS)) { |
| 196 | ALOGI("Skipping sendAnbrQuery because ims is not supported in device"); |
| 197 | return; |
| 198 | } else { |
| 199 | ALOGI("Running sendAnbrQuery because ims is supported in device"); |
| 200 | } |
| 201 | |
| 202 | serial = GetRandomSerialNumber(); |
| 203 | |
| 204 | ndk::ScopedAStatus res = |
| 205 | radio_ims->sendAnbrQuery(serial, 1, 0, 13200); |
| 206 | ASSERT_OK(res); |
| 207 | EXPECT_EQ(std::cv_status::no_timeout, wait()); |
| 208 | EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_ims->rspInfo.type); |
| 209 | EXPECT_EQ(serial, radioRsp_ims->rspInfo.serial); |
| 210 | |
| 211 | ALOGI("sendAnbrQuery, rspInfo.error = %s\n", |
| 212 | toString(radioRsp_ims->rspInfo.error).c_str()); |
| 213 | |
| 214 | verifyError(radioRsp_ims->rspInfo.error); |
| 215 | } |
| 216 | |
Hunsuk Choi | 9d4f38c | 2021-12-16 21:50:04 +0000 | [diff] [blame] | 217 | void RadioImsTest::verifyError(RadioError resp) { |
| 218 | switch (resp) { |
| 219 | case RadioError::NONE: |
| 220 | case RadioError::RADIO_NOT_AVAILABLE: |
| 221 | case RadioError::INVALID_STATE: |
| 222 | case RadioError::NO_MEMORY: |
| 223 | case RadioError::SYSTEM_ERR: |
| 224 | case RadioError::MODEM_ERR: |
| 225 | case RadioError::INTERNAL_ERR: |
| 226 | case RadioError::INVALID_ARGUMENTS: |
| 227 | case RadioError::REQUEST_NOT_SUPPORTED: |
| 228 | case RadioError::NO_RESOURCES: |
| 229 | SUCCEED(); |
| 230 | break; |
| 231 | default: |
| 232 | FAIL(); |
| 233 | break; |
| 234 | } |
| 235 | } |