blob: e5cbeb46dbd8c738e1a6a7bed2a42ce34041b32c [file] [log] [blame]
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +00001/*
Hunsuk Choid12c2f02022-10-06 01:00:53 +00002 * Copyright (C) 2022 The Android Open Source Project
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +00003 *
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
25void 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 */
56TEST_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 */
84TEST_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;
Hunsuk Choif3ef4ff2022-03-29 03:10:35 +000095 regInfo.regState = ImsRegistrationState::NOT_REGISTERED;
96 regInfo.accessNetworkType = AccessNetwork::EUTRAN;
Hunsuk Choi2c47ce82022-09-22 11:20:18 +000097 regInfo.suggestedAction = SuggestedAction::NONE;
Hunsuk Choif3ef4ff2022-03-29 03:10:35 +000098 regInfo.capabilities = ImsRegistration::IMS_MMTEL_CAPABILITY_NONE;
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +000099
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/*
Hunsuk Choif3ef4ff2022-03-29 03:10:35 +0000114 * Test IRadioIms.startImsTraffic() for the response returned.
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +0000115 */
Hunsuk Choif3ef4ff2022-03-29 03:10:35 +0000116TEST_P(RadioImsTest, startImsTraffic) {
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +0000117 if (!deviceSupportsFeature(FEATURE_TELEPHONY_IMS)) {
Hunsuk Choif3ef4ff2022-03-29 03:10:35 +0000118 ALOGI("Skipping startImsTraffic because ims is not supported in device");
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +0000119 return;
120 } else {
Hunsuk Choif3ef4ff2022-03-29 03:10:35 +0000121 ALOGI("Running startImsTraffic because ims is supported in device");
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +0000122 }
123
124 serial = GetRandomSerialNumber();
125
126 ndk::ScopedAStatus res =
Hunsuk Choif3ef4ff2022-03-29 03:10:35 +0000127 radio_ims->startImsTraffic(serial, std::string("1"),
128 ImsTrafficType::REGISTRATION, AccessNetwork::EUTRAN);
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +0000129 ASSERT_OK(res);
130 EXPECT_EQ(std::cv_status::no_timeout, wait());
131 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_ims->rspInfo.type);
132 EXPECT_EQ(serial, radioRsp_ims->rspInfo.serial);
133
Hunsuk Choif3ef4ff2022-03-29 03:10:35 +0000134 ALOGI("startImsTraffic, rspInfo.error = %s\n",
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +0000135 toString(radioRsp_ims->rspInfo.error).c_str());
136
137 verifyError(radioRsp_ims->rspInfo.error);
138}
139
140/*
Hunsuk Choif3ef4ff2022-03-29 03:10:35 +0000141 * Test IRadioIms.stopImsTraffic() for the response returned.
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +0000142 */
Hunsuk Choif3ef4ff2022-03-29 03:10:35 +0000143TEST_P(RadioImsTest, stopImsTraffic) {
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +0000144 if (!deviceSupportsFeature(FEATURE_TELEPHONY_IMS)) {
Hunsuk Choif3ef4ff2022-03-29 03:10:35 +0000145 ALOGI("Skipping stopImsTraffic because ims is not supported in device");
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +0000146 return;
147 } else {
Hunsuk Choif3ef4ff2022-03-29 03:10:35 +0000148 ALOGI("Running stopImsTraffic because ims is supported in device");
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +0000149 }
150
151 serial = GetRandomSerialNumber();
152
153 ndk::ScopedAStatus res =
Hunsuk Choif3ef4ff2022-03-29 03:10:35 +0000154 radio_ims->stopImsTraffic(serial, std::string("2"));
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +0000155 ASSERT_OK(res);
156 EXPECT_EQ(std::cv_status::no_timeout, wait());
157 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_ims->rspInfo.type);
158 EXPECT_EQ(serial, radioRsp_ims->rspInfo.serial);
159
Hunsuk Choif3ef4ff2022-03-29 03:10:35 +0000160 ALOGI("stopImsTraffic, rspInfo.error = %s\n",
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +0000161 toString(radioRsp_ims->rspInfo.error).c_str());
162
163 verifyError(radioRsp_ims->rspInfo.error);
164}
165
Hwayoung539e1f42021-12-22 08:23:46 +0000166/*
Hunsuk Choi539c9982022-08-01 05:47:36 +0000167 * Test IRadioIms.triggerEpsFallback() for the response returned.
168 */
169TEST_P(RadioImsTest, triggerEpsFallback) {
170 if (!deviceSupportsFeature(FEATURE_TELEPHONY_IMS)) {
171 ALOGI("Skipping triggerEpsFallback because ims is not supported in device");
172 return;
173 } else {
174 ALOGI("Running triggerEpsFallback because ims is supported in device");
175 }
176
177 serial = GetRandomSerialNumber();
178
179 ndk::ScopedAStatus res =
180 radio_ims->triggerEpsFallback(serial, EpsFallbackReason::NO_NETWORK_TRIGGER);
181 ASSERT_OK(res);
182 EXPECT_EQ(std::cv_status::no_timeout, wait());
183 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_ims->rspInfo.type);
184 EXPECT_EQ(serial, radioRsp_ims->rspInfo.serial);
185
186 ALOGI("triggerEpsFallback, rspInfo.error = %s\n",
187 toString(radioRsp_ims->rspInfo.error).c_str());
188
189 verifyError(radioRsp_ims->rspInfo.error);
190}
191
192/*
Hwayoung539e1f42021-12-22 08:23:46 +0000193 * Test IRadioIms.sendAnbrQuery() for the response returned.
194 */
195TEST_P(RadioImsTest, sendAnbrQuery) {
196 if (!deviceSupportsFeature(FEATURE_TELEPHONY_IMS)) {
197 ALOGI("Skipping sendAnbrQuery because ims is not supported in device");
198 return;
199 } else {
200 ALOGI("Running sendAnbrQuery because ims is supported in device");
201 }
202
203 serial = GetRandomSerialNumber();
204
205 ndk::ScopedAStatus res =
Helenc112be12022-04-26 01:02:40 +0000206 radio_ims->sendAnbrQuery(serial, ImsStreamType::AUDIO, ImsStreamDirection::UPLINK, 13200);
Hwayoung539e1f42021-12-22 08:23:46 +0000207 ASSERT_OK(res);
208 EXPECT_EQ(std::cv_status::no_timeout, wait());
209 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp_ims->rspInfo.type);
210 EXPECT_EQ(serial, radioRsp_ims->rspInfo.serial);
211
212 ALOGI("sendAnbrQuery, rspInfo.error = %s\n",
213 toString(radioRsp_ims->rspInfo.error).c_str());
214
215 verifyError(radioRsp_ims->rspInfo.error);
216}
217
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +0000218void RadioImsTest::verifyError(RadioError resp) {
219 switch (resp) {
220 case RadioError::NONE:
221 case RadioError::RADIO_NOT_AVAILABLE:
222 case RadioError::INVALID_STATE:
223 case RadioError::NO_MEMORY:
224 case RadioError::SYSTEM_ERR:
225 case RadioError::MODEM_ERR:
226 case RadioError::INTERNAL_ERR:
227 case RadioError::INVALID_ARGUMENTS:
228 case RadioError::REQUEST_NOT_SUPPORTED:
229 case RadioError::NO_RESOURCES:
230 SUCCEED();
231 break;
232 default:
233 FAIL();
234 break;
235 }
236}