blob: d3bdd4bbea30455b520e36bb07392a7d524e2307 [file] [log] [blame]
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +00001/*
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
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;
97 regInfo.reason = ImsFailureReason::NONE;
98 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/*
Hwayoung539e1f42021-12-22 08:23:46 +0000167 * Test IRadioIms.sendAnbrQuery() for the response returned.
168 */
169TEST_P(RadioImsTest, sendAnbrQuery) {
170 if (!deviceSupportsFeature(FEATURE_TELEPHONY_IMS)) {
171 ALOGI("Skipping sendAnbrQuery because ims is not supported in device");
172 return;
173 } else {
174 ALOGI("Running sendAnbrQuery because ims is supported in device");
175 }
176
177 serial = GetRandomSerialNumber();
178
179 ndk::ScopedAStatus res =
Helenc112be12022-04-26 01:02:40 +0000180 radio_ims->sendAnbrQuery(serial, ImsStreamType::AUDIO, ImsStreamDirection::UPLINK, 13200);
Hwayoung539e1f42021-12-22 08:23:46 +0000181 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("sendAnbrQuery, rspInfo.error = %s\n",
187 toString(radioRsp_ims->rspInfo.error).c_str());
188
189 verifyError(radioRsp_ims->rspInfo.error);
190}
191
Hunsuk Choi9d4f38c2021-12-16 21:50:04 +0000192void RadioImsTest::verifyError(RadioError resp) {
193 switch (resp) {
194 case RadioError::NONE:
195 case RadioError::RADIO_NOT_AVAILABLE:
196 case RadioError::INVALID_STATE:
197 case RadioError::NO_MEMORY:
198 case RadioError::SYSTEM_ERR:
199 case RadioError::MODEM_ERR:
200 case RadioError::INTERNAL_ERR:
201 case RadioError::INVALID_ARGUMENTS:
202 case RadioError::REQUEST_NOT_SUPPORTED:
203 case RadioError::NO_RESOURCES:
204 SUCCEED();
205 break;
206 default:
207 FAIL();
208 break;
209 }
210}