blob: d4c0c92e3a1baba68d9b51e44e5a537a2adc17de [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( //
56 int32_t serial, const aidl::Dial& dialInfo, aidl::EmergencyServiceCategory categories,
57 const std::vector<std::string>& urns, aidl::EmergencyCallRouting routing,
58 bool hasKnownUserIntentEmerg, bool isTesting) {
59 LOG_CALL << serial;
60 mHal1_5->emergencyDial(serial, toHidl(dialInfo),
61 toHidlBitfield<V1_4::EmergencyServiceCategory>(categories), toHidl(urns),
62 V1_4::EmergencyCallRouting(routing), hasKnownUserIntentEmerg, isTesting);
63 return ok();
64}
65
66ScopedAStatus RadioVoice::exitEmergencyCallbackMode(int32_t serial) {
67 LOG_CALL << serial;
68 mHal1_5->exitEmergencyCallbackMode(serial);
69 return ok();
70}
71
72ScopedAStatus RadioVoice::explicitCallTransfer(int32_t serial) {
73 LOG_CALL << serial;
74 mHal1_5->explicitCallTransfer(serial);
75 return ok();
76}
77
78ScopedAStatus RadioVoice::getCallForwardStatus(int32_t serial,
79 const aidl::CallForwardInfo& callInfo) {
80 LOG_CALL << serial;
81 mHal1_5->getCallForwardStatus(serial, toHidl(callInfo));
82 return ok();
83}
84
85ScopedAStatus RadioVoice::getCallWaiting(int32_t serial, int32_t serviceClass) {
86 LOG_CALL << serial;
87 mHal1_5->getCallWaiting(serial, serviceClass);
88 return ok();
89}
90
91ScopedAStatus RadioVoice::getClip(int32_t serial) {
92 LOG_CALL << serial;
93 mHal1_5->getClip(serial);
94 return ok();
95}
96
97ScopedAStatus RadioVoice::getClir(int32_t serial) {
98 LOG_CALL << serial;
99 mHal1_5->getClir(serial);
100 return ok();
101}
102
103ScopedAStatus RadioVoice::getCurrentCalls(int32_t serial) {
104 LOG_CALL << serial;
105 mHal1_5->getCurrentCalls(serial);
106 return ok();
107}
108
109ScopedAStatus RadioVoice::getLastCallFailCause(int32_t serial) {
110 LOG_CALL << serial;
111 mHal1_5->getLastCallFailCause(serial);
112 return ok();
113}
114
115ScopedAStatus RadioVoice::getMute(int32_t serial) {
116 LOG_CALL << serial;
117 mHal1_5->getMute(serial);
118 return ok();
119}
120
121ScopedAStatus RadioVoice::getPreferredVoicePrivacy(int32_t serial) {
122 LOG_CALL << serial;
123 mHal1_5->getPreferredVoicePrivacy(serial);
124 return ok();
125}
126
127ScopedAStatus RadioVoice::getTtyMode(int32_t serial) {
128 LOG_CALL << serial;
129 mHal1_5->getTTYMode(serial);
130 return ok();
131}
132
133ScopedAStatus RadioVoice::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) {
134 LOG_CALL << serial;
135 mHal1_5->handleStkCallSetupRequestFromSim(serial, accept);
136 return ok();
137}
138
139ScopedAStatus RadioVoice::hangup(int32_t serial, int32_t gsmIndex) {
140 LOG_CALL << serial;
141 mHal1_5->hangup(serial, gsmIndex);
142 return ok();
143}
144
145ScopedAStatus RadioVoice::hangupForegroundResumeBackground(int32_t serial) {
146 LOG_CALL << serial;
147 mHal1_5->hangupForegroundResumeBackground(serial);
148 return ok();
149}
150
151ScopedAStatus RadioVoice::hangupWaitingOrBackground(int32_t serial) {
152 LOG_CALL << serial;
153 mHal1_5->hangupWaitingOrBackground(serial);
154 return ok();
155}
156
157ScopedAStatus RadioVoice::isVoNrEnabled(int32_t serial) {
158 LOG_CALL << serial;
Tomasz Wasilczyk60638572021-12-13 17:13:48 -0800159 respond()->isVoNrEnabledResponse(notSupported(serial), false);
Tomasz Wasilczyk6e084182021-11-05 10:53:55 -0700160 return ok();
161}
162
163ScopedAStatus RadioVoice::rejectCall(int32_t serial) {
164 LOG_CALL << serial;
165 mHal1_5->rejectCall(serial);
166 return ok();
167}
168
169ScopedAStatus RadioVoice::responseAcknowledgement() {
170 LOG_CALL;
171 mHal1_5->responseAcknowledgement();
172 return ok();
173}
174
175ScopedAStatus RadioVoice::sendBurstDtmf(int32_t serial, const std::string& dtmf, int32_t on,
176 int32_t off) {
177 LOG_CALL << serial;
178 mHal1_5->sendBurstDtmf(serial, dtmf, on, off);
179 return ok();
180}
181
182ScopedAStatus RadioVoice::sendCdmaFeatureCode(int32_t serial, const std::string& featureCode) {
183 LOG_CALL << serial;
184 mHal1_5->sendCDMAFeatureCode(serial, featureCode);
185 return ok();
186}
187
188ScopedAStatus RadioVoice::sendDtmf(int32_t serial, const std::string& s) {
189 LOG_CALL << serial;
190 mHal1_5->sendDtmf(serial, s);
191 return ok();
192}
193
194ScopedAStatus RadioVoice::separateConnection(int32_t serial, int32_t gsmIndex) {
195 LOG_CALL << serial;
196 mHal1_5->separateConnection(serial, gsmIndex);
197 return ok();
198}
199
200ScopedAStatus RadioVoice::setCallForward(int32_t serial, const aidl::CallForwardInfo& callInfo) {
201 LOG_CALL << serial;
202 mHal1_5->setCallForward(serial, toHidl(callInfo));
203 return ok();
204}
205
206ScopedAStatus RadioVoice::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) {
207 LOG_CALL << serial;
208 mHal1_5->setCallWaiting(serial, enable, serviceClass);
209 return ok();
210}
211
212ScopedAStatus RadioVoice::setClir(int32_t serial, int32_t status) {
213 LOG_CALL << serial;
214 mHal1_5->setClir(serial, status);
215 return ok();
216}
217
218ScopedAStatus RadioVoice::setMute(int32_t serial, bool enable) {
219 LOG_CALL << serial;
220 mHal1_5->setMute(serial, enable);
221 return ok();
222}
223
224ScopedAStatus RadioVoice::setPreferredVoicePrivacy(int32_t serial, bool enable) {
225 LOG_CALL << serial;
226 mHal1_5->setPreferredVoicePrivacy(serial, enable);
227 return ok();
228}
229
230ScopedAStatus RadioVoice::setResponseFunctions(
231 const std::shared_ptr<aidl::IRadioVoiceResponse>& voiceResponse,
232 const std::shared_ptr<aidl::IRadioVoiceIndication>& voiceIndication) {
233 LOG_CALL << voiceResponse << ' ' << voiceIndication;
234
235 CHECK(voiceResponse);
236 CHECK(voiceIndication);
237
238 mRadioResponse->setResponseFunction(voiceResponse);
239 mRadioIndication->setResponseFunction(voiceIndication);
240
241 return ok();
242}
243
244ScopedAStatus RadioVoice::setTtyMode(int32_t serial, aidl::TtyMode mode) {
245 LOG_CALL << serial;
246 mHal1_5->setTTYMode(serial, V1_0::TtyMode(mode));
247 return ok();
248}
249
250ndk::ScopedAStatus RadioVoice::setVoNrEnabled(int32_t serial, [[maybe_unused]] bool enable) {
251 LOG_CALL << serial;
Tomasz Wasilczyk60638572021-12-13 17:13:48 -0800252 // Note: a workaround for older HALs could also be setting persist.radio.is_vonr_enabled_
253 respond()->setVoNrEnabledResponse(notSupported(serial));
Tomasz Wasilczyk6e084182021-11-05 10:53:55 -0700254 return ok();
255}
256
257ScopedAStatus RadioVoice::startDtmf(int32_t serial, const std::string& s) {
258 LOG_CALL << serial;
259 mHal1_5->startDtmf(serial, s);
260 return ok();
261}
262
263ScopedAStatus RadioVoice::stopDtmf(int32_t serial) {
264 LOG_CALL << serial;
265 mHal1_5->stopDtmf(serial);
266 return ok();
267}
268
269ScopedAStatus RadioVoice::switchWaitingOrHoldingAndActive(int32_t serial) {
270 LOG_CALL << serial;
271 mHal1_5->switchWaitingOrHoldingAndActive(serial);
272 return ok();
273}
274
275} // namespace android::hardware::radio::compat