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