Tomasz Wasilczyk | 6e08418 | 2021-11-05 10:53:55 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 27 | namespace android::hardware::radio::compat { |
| 28 | |
| 29 | using ::ndk::ScopedAStatus; |
| 30 | namespace aidl = ::aidl::android::hardware::radio::voice; |
| 31 | constexpr auto ok = &ScopedAStatus::ok; |
| 32 | |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 33 | std::shared_ptr<aidl::IRadioVoiceResponse> RadioVoice::respond() { |
| 34 | return mRadioResponse->voiceCb(); |
| 35 | } |
| 36 | |
Tomasz Wasilczyk | 6e08418 | 2021-11-05 10:53:55 -0700 | [diff] [blame] | 37 | ScopedAStatus RadioVoice::acceptCall(int32_t serial) { |
| 38 | LOG_CALL << serial; |
| 39 | mHal1_5->acceptCall(serial); |
| 40 | return ok(); |
| 41 | } |
| 42 | |
| 43 | ScopedAStatus RadioVoice::conference(int32_t serial) { |
| 44 | LOG_CALL << serial; |
| 45 | mHal1_5->conference(serial); |
| 46 | return ok(); |
| 47 | } |
| 48 | |
| 49 | ScopedAStatus 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 | |
| 55 | ScopedAStatus RadioVoice::emergencyDial( // |
Tomasz Wasilczyk | 571542b | 2021-12-15 16:15:45 -0800 | [diff] [blame^] | 56 | int32_t serial, const aidl::Dial& info, aidl::EmergencyServiceCategory categories, |
Tomasz Wasilczyk | 6e08418 | 2021-11-05 10:53:55 -0700 | [diff] [blame] | 57 | const std::vector<std::string>& urns, aidl::EmergencyCallRouting routing, |
Tomasz Wasilczyk | 571542b | 2021-12-15 16:15:45 -0800 | [diff] [blame^] | 58 | bool knownUserIntentEmerg, bool isTesting) { |
Tomasz Wasilczyk | 6e08418 | 2021-11-05 10:53:55 -0700 | [diff] [blame] | 59 | LOG_CALL << serial; |
Tomasz Wasilczyk | 571542b | 2021-12-15 16:15:45 -0800 | [diff] [blame^] | 60 | 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 Wasilczyk | 6e08418 | 2021-11-05 10:53:55 -0700 | [diff] [blame] | 69 | return ok(); |
| 70 | } |
| 71 | |
| 72 | ScopedAStatus RadioVoice::exitEmergencyCallbackMode(int32_t serial) { |
| 73 | LOG_CALL << serial; |
| 74 | mHal1_5->exitEmergencyCallbackMode(serial); |
| 75 | return ok(); |
| 76 | } |
| 77 | |
| 78 | ScopedAStatus RadioVoice::explicitCallTransfer(int32_t serial) { |
| 79 | LOG_CALL << serial; |
| 80 | mHal1_5->explicitCallTransfer(serial); |
| 81 | return ok(); |
| 82 | } |
| 83 | |
| 84 | ScopedAStatus 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 | |
| 91 | ScopedAStatus RadioVoice::getCallWaiting(int32_t serial, int32_t serviceClass) { |
| 92 | LOG_CALL << serial; |
| 93 | mHal1_5->getCallWaiting(serial, serviceClass); |
| 94 | return ok(); |
| 95 | } |
| 96 | |
| 97 | ScopedAStatus RadioVoice::getClip(int32_t serial) { |
| 98 | LOG_CALL << serial; |
| 99 | mHal1_5->getClip(serial); |
| 100 | return ok(); |
| 101 | } |
| 102 | |
| 103 | ScopedAStatus RadioVoice::getClir(int32_t serial) { |
| 104 | LOG_CALL << serial; |
| 105 | mHal1_5->getClir(serial); |
| 106 | return ok(); |
| 107 | } |
| 108 | |
| 109 | ScopedAStatus RadioVoice::getCurrentCalls(int32_t serial) { |
| 110 | LOG_CALL << serial; |
Tomasz Wasilczyk | 571542b | 2021-12-15 16:15:45 -0800 | [diff] [blame^] | 111 | if (mHal1_6) { |
| 112 | mHal1_6->getCurrentCalls_1_6(serial); |
| 113 | } else { |
| 114 | mHal1_5->getCurrentCalls(serial); |
| 115 | } |
Tomasz Wasilczyk | 6e08418 | 2021-11-05 10:53:55 -0700 | [diff] [blame] | 116 | return ok(); |
| 117 | } |
| 118 | |
| 119 | ScopedAStatus RadioVoice::getLastCallFailCause(int32_t serial) { |
| 120 | LOG_CALL << serial; |
| 121 | mHal1_5->getLastCallFailCause(serial); |
| 122 | return ok(); |
| 123 | } |
| 124 | |
| 125 | ScopedAStatus RadioVoice::getMute(int32_t serial) { |
| 126 | LOG_CALL << serial; |
| 127 | mHal1_5->getMute(serial); |
| 128 | return ok(); |
| 129 | } |
| 130 | |
| 131 | ScopedAStatus RadioVoice::getPreferredVoicePrivacy(int32_t serial) { |
| 132 | LOG_CALL << serial; |
| 133 | mHal1_5->getPreferredVoicePrivacy(serial); |
| 134 | return ok(); |
| 135 | } |
| 136 | |
| 137 | ScopedAStatus RadioVoice::getTtyMode(int32_t serial) { |
| 138 | LOG_CALL << serial; |
| 139 | mHal1_5->getTTYMode(serial); |
| 140 | return ok(); |
| 141 | } |
| 142 | |
| 143 | ScopedAStatus RadioVoice::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) { |
| 144 | LOG_CALL << serial; |
| 145 | mHal1_5->handleStkCallSetupRequestFromSim(serial, accept); |
| 146 | return ok(); |
| 147 | } |
| 148 | |
| 149 | ScopedAStatus RadioVoice::hangup(int32_t serial, int32_t gsmIndex) { |
| 150 | LOG_CALL << serial; |
| 151 | mHal1_5->hangup(serial, gsmIndex); |
| 152 | return ok(); |
| 153 | } |
| 154 | |
| 155 | ScopedAStatus RadioVoice::hangupForegroundResumeBackground(int32_t serial) { |
| 156 | LOG_CALL << serial; |
| 157 | mHal1_5->hangupForegroundResumeBackground(serial); |
| 158 | return ok(); |
| 159 | } |
| 160 | |
| 161 | ScopedAStatus RadioVoice::hangupWaitingOrBackground(int32_t serial) { |
| 162 | LOG_CALL << serial; |
| 163 | mHal1_5->hangupWaitingOrBackground(serial); |
| 164 | return ok(); |
| 165 | } |
| 166 | |
| 167 | ScopedAStatus RadioVoice::isVoNrEnabled(int32_t serial) { |
| 168 | LOG_CALL << serial; |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 169 | respond()->isVoNrEnabledResponse(notSupported(serial), false); |
Tomasz Wasilczyk | 6e08418 | 2021-11-05 10:53:55 -0700 | [diff] [blame] | 170 | return ok(); |
| 171 | } |
| 172 | |
| 173 | ScopedAStatus RadioVoice::rejectCall(int32_t serial) { |
| 174 | LOG_CALL << serial; |
| 175 | mHal1_5->rejectCall(serial); |
| 176 | return ok(); |
| 177 | } |
| 178 | |
| 179 | ScopedAStatus RadioVoice::responseAcknowledgement() { |
| 180 | LOG_CALL; |
| 181 | mHal1_5->responseAcknowledgement(); |
| 182 | return ok(); |
| 183 | } |
| 184 | |
| 185 | ScopedAStatus 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 | |
| 192 | ScopedAStatus RadioVoice::sendCdmaFeatureCode(int32_t serial, const std::string& featureCode) { |
| 193 | LOG_CALL << serial; |
| 194 | mHal1_5->sendCDMAFeatureCode(serial, featureCode); |
| 195 | return ok(); |
| 196 | } |
| 197 | |
| 198 | ScopedAStatus RadioVoice::sendDtmf(int32_t serial, const std::string& s) { |
| 199 | LOG_CALL << serial; |
| 200 | mHal1_5->sendDtmf(serial, s); |
| 201 | return ok(); |
| 202 | } |
| 203 | |
| 204 | ScopedAStatus RadioVoice::separateConnection(int32_t serial, int32_t gsmIndex) { |
| 205 | LOG_CALL << serial; |
| 206 | mHal1_5->separateConnection(serial, gsmIndex); |
| 207 | return ok(); |
| 208 | } |
| 209 | |
| 210 | ScopedAStatus 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 | |
| 216 | ScopedAStatus 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 | |
| 222 | ScopedAStatus RadioVoice::setClir(int32_t serial, int32_t status) { |
| 223 | LOG_CALL << serial; |
| 224 | mHal1_5->setClir(serial, status); |
| 225 | return ok(); |
| 226 | } |
| 227 | |
| 228 | ScopedAStatus RadioVoice::setMute(int32_t serial, bool enable) { |
| 229 | LOG_CALL << serial; |
| 230 | mHal1_5->setMute(serial, enable); |
| 231 | return ok(); |
| 232 | } |
| 233 | |
| 234 | ScopedAStatus RadioVoice::setPreferredVoicePrivacy(int32_t serial, bool enable) { |
| 235 | LOG_CALL << serial; |
| 236 | mHal1_5->setPreferredVoicePrivacy(serial, enable); |
| 237 | return ok(); |
| 238 | } |
| 239 | |
| 240 | ScopedAStatus 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 | |
| 254 | ScopedAStatus 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 | |
| 260 | ndk::ScopedAStatus RadioVoice::setVoNrEnabled(int32_t serial, [[maybe_unused]] bool enable) { |
| 261 | LOG_CALL << serial; |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 262 | // Note: a workaround for older HALs could also be setting persist.radio.is_vonr_enabled_ |
| 263 | respond()->setVoNrEnabledResponse(notSupported(serial)); |
Tomasz Wasilczyk | 6e08418 | 2021-11-05 10:53:55 -0700 | [diff] [blame] | 264 | return ok(); |
| 265 | } |
| 266 | |
| 267 | ScopedAStatus RadioVoice::startDtmf(int32_t serial, const std::string& s) { |
| 268 | LOG_CALL << serial; |
| 269 | mHal1_5->startDtmf(serial, s); |
| 270 | return ok(); |
| 271 | } |
| 272 | |
| 273 | ScopedAStatus RadioVoice::stopDtmf(int32_t serial) { |
| 274 | LOG_CALL << serial; |
| 275 | mHal1_5->stopDtmf(serial); |
| 276 | return ok(); |
| 277 | } |
| 278 | |
| 279 | ScopedAStatus 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 |