blob: 742fdbe84491533636e1b7015426c3f3f92c10a3 [file] [log] [blame]
Tomasz Wasilczyk6e084182021-11-05 10:53:55 -07001/*
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 <libradiocompat/RadioVoice.h>
18
19#include "commonStructs.h"
20#include "debug.h"
21#include "structs.h"
22
23#include "collections.h"
24
25#define RADIO_MODULE "Voice"
26
27namespace android::hardware::radio::compat {
28
29using ::ndk::ScopedAStatus;
30namespace aidl = ::aidl::android::hardware::radio::voice;
31constexpr auto ok = &ScopedAStatus::ok;
32
Tomasz Wasilczyk60638572021-12-13 17:13:48 -080033std::shared_ptr<aidl::IRadioVoiceResponse> RadioVoice::respond() {
34 return mRadioResponse->voiceCb();
35}
36
Tomasz Wasilczyk6e084182021-11-05 10:53:55 -070037ScopedAStatus RadioVoice::acceptCall(int32_t serial) {
38 LOG_CALL << serial;
39 mHal1_5->acceptCall(serial);
40 return ok();
41}
42
43ScopedAStatus RadioVoice::conference(int32_t serial) {
44 LOG_CALL << serial;
45 mHal1_5->conference(serial);
46 return ok();
47}
48
49ScopedAStatus RadioVoice::dial(int32_t serial, const aidl::Dial& dialInfo) {
50 LOG_CALL << serial;
51 mHal1_5->dial(serial, toHidl(dialInfo));
52 return ok();
53}
54
55ScopedAStatus RadioVoice::emergencyDial( //
Tomasz Wasilczyk571542b2021-12-15 16:15:45 -080056 int32_t serial, const aidl::Dial& info, aidl::EmergencyServiceCategory categories,
Tomasz Wasilczyk6e084182021-11-05 10:53:55 -070057 const std::vector<std::string>& urns, aidl::EmergencyCallRouting routing,
Tomasz Wasilczyk571542b2021-12-15 16:15:45 -080058 bool knownUserIntentEmerg, bool isTesting) {
Tomasz Wasilczyk6e084182021-11-05 10:53:55 -070059 LOG_CALL << serial;
Tomasz Wasilczyk571542b2021-12-15 16:15:45 -080060 if (mHal1_6) {
61 mHal1_6->emergencyDial_1_6( //
62 serial, toHidl(info), toHidlBitfield<V1_4::EmergencyServiceCategory>(categories),
63 toHidl(urns), V1_4::EmergencyCallRouting(routing), knownUserIntentEmerg, isTesting);
64 } else {
65 mHal1_5->emergencyDial( //
66 serial, toHidl(info), toHidlBitfield<V1_4::EmergencyServiceCategory>(categories),
67 toHidl(urns), V1_4::EmergencyCallRouting(routing), knownUserIntentEmerg, isTesting);
68 }
Tomasz Wasilczyk6e084182021-11-05 10:53:55 -070069 return ok();
70}
71
72ScopedAStatus RadioVoice::exitEmergencyCallbackMode(int32_t serial) {
73 LOG_CALL << serial;
74 mHal1_5->exitEmergencyCallbackMode(serial);
75 return ok();
76}
77
78ScopedAStatus RadioVoice::explicitCallTransfer(int32_t serial) {
79 LOG_CALL << serial;
80 mHal1_5->explicitCallTransfer(serial);
81 return ok();
82}
83
84ScopedAStatus RadioVoice::getCallForwardStatus(int32_t serial,
85 const aidl::CallForwardInfo& callInfo) {
86 LOG_CALL << serial;
87 mHal1_5->getCallForwardStatus(serial, toHidl(callInfo));
88 return ok();
89}
90
91ScopedAStatus RadioVoice::getCallWaiting(int32_t serial, int32_t serviceClass) {
92 LOG_CALL << serial;
93 mHal1_5->getCallWaiting(serial, serviceClass);
94 return ok();
95}
96
97ScopedAStatus RadioVoice::getClip(int32_t serial) {
98 LOG_CALL << serial;
99 mHal1_5->getClip(serial);
100 return ok();
101}
102
103ScopedAStatus RadioVoice::getClir(int32_t serial) {
104 LOG_CALL << serial;
105 mHal1_5->getClir(serial);
106 return ok();
107}
108
109ScopedAStatus RadioVoice::getCurrentCalls(int32_t serial) {
110 LOG_CALL << serial;
Tomasz Wasilczyk571542b2021-12-15 16:15:45 -0800111 if (mHal1_6) {
112 mHal1_6->getCurrentCalls_1_6(serial);
113 } else {
114 mHal1_5->getCurrentCalls(serial);
115 }
Tomasz Wasilczyk6e084182021-11-05 10:53:55 -0700116 return ok();
117}
118
119ScopedAStatus RadioVoice::getLastCallFailCause(int32_t serial) {
120 LOG_CALL << serial;
121 mHal1_5->getLastCallFailCause(serial);
122 return ok();
123}
124
125ScopedAStatus RadioVoice::getMute(int32_t serial) {
126 LOG_CALL << serial;
127 mHal1_5->getMute(serial);
128 return ok();
129}
130
131ScopedAStatus RadioVoice::getPreferredVoicePrivacy(int32_t serial) {
132 LOG_CALL << serial;
133 mHal1_5->getPreferredVoicePrivacy(serial);
134 return ok();
135}
136
137ScopedAStatus RadioVoice::getTtyMode(int32_t serial) {
138 LOG_CALL << serial;
139 mHal1_5->getTTYMode(serial);
140 return ok();
141}
142
143ScopedAStatus RadioVoice::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
144 LOG_CALL << serial;
145 mHal1_5->handleStkCallSetupRequestFromSim(serial, accept);
146 return ok();
147}
148
149ScopedAStatus RadioVoice::hangup(int32_t serial, int32_t gsmIndex) {
150 LOG_CALL << serial;
151 mHal1_5->hangup(serial, gsmIndex);
152 return ok();
153}
154
155ScopedAStatus RadioVoice::hangupForegroundResumeBackground(int32_t serial) {
156 LOG_CALL << serial;
157 mHal1_5->hangupForegroundResumeBackground(serial);
158 return ok();
159}
160
161ScopedAStatus RadioVoice::hangupWaitingOrBackground(int32_t serial) {
162 LOG_CALL << serial;
163 mHal1_5->hangupWaitingOrBackground(serial);
164 return ok();
165}
166
167ScopedAStatus RadioVoice::isVoNrEnabled(int32_t serial) {
168 LOG_CALL << serial;
Tomasz Wasilczyk60638572021-12-13 17:13:48 -0800169 respond()->isVoNrEnabledResponse(notSupported(serial), false);
Tomasz Wasilczyk6e084182021-11-05 10:53:55 -0700170 return ok();
171}
172
173ScopedAStatus RadioVoice::rejectCall(int32_t serial) {
174 LOG_CALL << serial;
175 mHal1_5->rejectCall(serial);
176 return ok();
177}
178
179ScopedAStatus RadioVoice::responseAcknowledgement() {
180 LOG_CALL;
181 mHal1_5->responseAcknowledgement();
182 return ok();
183}
184
185ScopedAStatus RadioVoice::sendBurstDtmf(int32_t serial, const std::string& dtmf, int32_t on,
186 int32_t off) {
187 LOG_CALL << serial;
188 mHal1_5->sendBurstDtmf(serial, dtmf, on, off);
189 return ok();
190}
191
192ScopedAStatus RadioVoice::sendCdmaFeatureCode(int32_t serial, const std::string& featureCode) {
193 LOG_CALL << serial;
194 mHal1_5->sendCDMAFeatureCode(serial, featureCode);
195 return ok();
196}
197
198ScopedAStatus RadioVoice::sendDtmf(int32_t serial, const std::string& s) {
199 LOG_CALL << serial;
200 mHal1_5->sendDtmf(serial, s);
201 return ok();
202}
203
204ScopedAStatus RadioVoice::separateConnection(int32_t serial, int32_t gsmIndex) {
205 LOG_CALL << serial;
206 mHal1_5->separateConnection(serial, gsmIndex);
207 return ok();
208}
209
210ScopedAStatus RadioVoice::setCallForward(int32_t serial, const aidl::CallForwardInfo& callInfo) {
211 LOG_CALL << serial;
212 mHal1_5->setCallForward(serial, toHidl(callInfo));
213 return ok();
214}
215
216ScopedAStatus RadioVoice::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
217 LOG_CALL << serial;
218 mHal1_5->setCallWaiting(serial, enable, serviceClass);
219 return ok();
220}
221
222ScopedAStatus RadioVoice::setClir(int32_t serial, int32_t status) {
223 LOG_CALL << serial;
224 mHal1_5->setClir(serial, status);
225 return ok();
226}
227
228ScopedAStatus RadioVoice::setMute(int32_t serial, bool enable) {
229 LOG_CALL << serial;
230 mHal1_5->setMute(serial, enable);
231 return ok();
232}
233
234ScopedAStatus RadioVoice::setPreferredVoicePrivacy(int32_t serial, bool enable) {
235 LOG_CALL << serial;
236 mHal1_5->setPreferredVoicePrivacy(serial, enable);
237 return ok();
238}
239
240ScopedAStatus RadioVoice::setResponseFunctions(
241 const std::shared_ptr<aidl::IRadioVoiceResponse>& voiceResponse,
242 const std::shared_ptr<aidl::IRadioVoiceIndication>& voiceIndication) {
243 LOG_CALL << voiceResponse << ' ' << voiceIndication;
244
245 CHECK(voiceResponse);
246 CHECK(voiceIndication);
247
248 mRadioResponse->setResponseFunction(voiceResponse);
249 mRadioIndication->setResponseFunction(voiceIndication);
250
251 return ok();
252}
253
254ScopedAStatus RadioVoice::setTtyMode(int32_t serial, aidl::TtyMode mode) {
255 LOG_CALL << serial;
256 mHal1_5->setTTYMode(serial, V1_0::TtyMode(mode));
257 return ok();
258}
259
260ndk::ScopedAStatus RadioVoice::setVoNrEnabled(int32_t serial, [[maybe_unused]] bool enable) {
261 LOG_CALL << serial;
Tomasz Wasilczyk60638572021-12-13 17:13:48 -0800262 // Note: a workaround for older HALs could also be setting persist.radio.is_vonr_enabled_
263 respond()->setVoNrEnabledResponse(notSupported(serial));
Tomasz Wasilczyk6e084182021-11-05 10:53:55 -0700264 return ok();
265}
266
267ScopedAStatus RadioVoice::startDtmf(int32_t serial, const std::string& s) {
268 LOG_CALL << serial;
269 mHal1_5->startDtmf(serial, s);
270 return ok();
271}
272
273ScopedAStatus RadioVoice::stopDtmf(int32_t serial) {
274 LOG_CALL << serial;
275 mHal1_5->stopDtmf(serial);
276 return ok();
277}
278
279ScopedAStatus RadioVoice::switchWaitingOrHoldingAndActive(int32_t serial) {
280 LOG_CALL << serial;
281 mHal1_5->switchWaitingOrHoldingAndActive(serial);
282 return ok();
283}
284
285} // namespace android::hardware::radio::compat