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( // |
| 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 | |
| 66 | ScopedAStatus RadioVoice::exitEmergencyCallbackMode(int32_t serial) { |
| 67 | LOG_CALL << serial; |
| 68 | mHal1_5->exitEmergencyCallbackMode(serial); |
| 69 | return ok(); |
| 70 | } |
| 71 | |
| 72 | ScopedAStatus RadioVoice::explicitCallTransfer(int32_t serial) { |
| 73 | LOG_CALL << serial; |
| 74 | mHal1_5->explicitCallTransfer(serial); |
| 75 | return ok(); |
| 76 | } |
| 77 | |
| 78 | ScopedAStatus 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 | |
| 85 | ScopedAStatus RadioVoice::getCallWaiting(int32_t serial, int32_t serviceClass) { |
| 86 | LOG_CALL << serial; |
| 87 | mHal1_5->getCallWaiting(serial, serviceClass); |
| 88 | return ok(); |
| 89 | } |
| 90 | |
| 91 | ScopedAStatus RadioVoice::getClip(int32_t serial) { |
| 92 | LOG_CALL << serial; |
| 93 | mHal1_5->getClip(serial); |
| 94 | return ok(); |
| 95 | } |
| 96 | |
| 97 | ScopedAStatus RadioVoice::getClir(int32_t serial) { |
| 98 | LOG_CALL << serial; |
| 99 | mHal1_5->getClir(serial); |
| 100 | return ok(); |
| 101 | } |
| 102 | |
| 103 | ScopedAStatus RadioVoice::getCurrentCalls(int32_t serial) { |
| 104 | LOG_CALL << serial; |
| 105 | mHal1_5->getCurrentCalls(serial); |
| 106 | return ok(); |
| 107 | } |
| 108 | |
| 109 | ScopedAStatus RadioVoice::getLastCallFailCause(int32_t serial) { |
| 110 | LOG_CALL << serial; |
| 111 | mHal1_5->getLastCallFailCause(serial); |
| 112 | return ok(); |
| 113 | } |
| 114 | |
| 115 | ScopedAStatus RadioVoice::getMute(int32_t serial) { |
| 116 | LOG_CALL << serial; |
| 117 | mHal1_5->getMute(serial); |
| 118 | return ok(); |
| 119 | } |
| 120 | |
| 121 | ScopedAStatus RadioVoice::getPreferredVoicePrivacy(int32_t serial) { |
| 122 | LOG_CALL << serial; |
| 123 | mHal1_5->getPreferredVoicePrivacy(serial); |
| 124 | return ok(); |
| 125 | } |
| 126 | |
| 127 | ScopedAStatus RadioVoice::getTtyMode(int32_t serial) { |
| 128 | LOG_CALL << serial; |
| 129 | mHal1_5->getTTYMode(serial); |
| 130 | return ok(); |
| 131 | } |
| 132 | |
| 133 | ScopedAStatus RadioVoice::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) { |
| 134 | LOG_CALL << serial; |
| 135 | mHal1_5->handleStkCallSetupRequestFromSim(serial, accept); |
| 136 | return ok(); |
| 137 | } |
| 138 | |
| 139 | ScopedAStatus RadioVoice::hangup(int32_t serial, int32_t gsmIndex) { |
| 140 | LOG_CALL << serial; |
| 141 | mHal1_5->hangup(serial, gsmIndex); |
| 142 | return ok(); |
| 143 | } |
| 144 | |
| 145 | ScopedAStatus RadioVoice::hangupForegroundResumeBackground(int32_t serial) { |
| 146 | LOG_CALL << serial; |
| 147 | mHal1_5->hangupForegroundResumeBackground(serial); |
| 148 | return ok(); |
| 149 | } |
| 150 | |
| 151 | ScopedAStatus RadioVoice::hangupWaitingOrBackground(int32_t serial) { |
| 152 | LOG_CALL << serial; |
| 153 | mHal1_5->hangupWaitingOrBackground(serial); |
| 154 | return ok(); |
| 155 | } |
| 156 | |
| 157 | ScopedAStatus RadioVoice::isVoNrEnabled(int32_t serial) { |
| 158 | LOG_CALL << serial; |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame^] | 159 | respond()->isVoNrEnabledResponse(notSupported(serial), false); |
Tomasz Wasilczyk | 6e08418 | 2021-11-05 10:53:55 -0700 | [diff] [blame] | 160 | return ok(); |
| 161 | } |
| 162 | |
| 163 | ScopedAStatus RadioVoice::rejectCall(int32_t serial) { |
| 164 | LOG_CALL << serial; |
| 165 | mHal1_5->rejectCall(serial); |
| 166 | return ok(); |
| 167 | } |
| 168 | |
| 169 | ScopedAStatus RadioVoice::responseAcknowledgement() { |
| 170 | LOG_CALL; |
| 171 | mHal1_5->responseAcknowledgement(); |
| 172 | return ok(); |
| 173 | } |
| 174 | |
| 175 | ScopedAStatus 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 | |
| 182 | ScopedAStatus RadioVoice::sendCdmaFeatureCode(int32_t serial, const std::string& featureCode) { |
| 183 | LOG_CALL << serial; |
| 184 | mHal1_5->sendCDMAFeatureCode(serial, featureCode); |
| 185 | return ok(); |
| 186 | } |
| 187 | |
| 188 | ScopedAStatus RadioVoice::sendDtmf(int32_t serial, const std::string& s) { |
| 189 | LOG_CALL << serial; |
| 190 | mHal1_5->sendDtmf(serial, s); |
| 191 | return ok(); |
| 192 | } |
| 193 | |
| 194 | ScopedAStatus RadioVoice::separateConnection(int32_t serial, int32_t gsmIndex) { |
| 195 | LOG_CALL << serial; |
| 196 | mHal1_5->separateConnection(serial, gsmIndex); |
| 197 | return ok(); |
| 198 | } |
| 199 | |
| 200 | ScopedAStatus 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 | |
| 206 | ScopedAStatus 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 | |
| 212 | ScopedAStatus RadioVoice::setClir(int32_t serial, int32_t status) { |
| 213 | LOG_CALL << serial; |
| 214 | mHal1_5->setClir(serial, status); |
| 215 | return ok(); |
| 216 | } |
| 217 | |
| 218 | ScopedAStatus RadioVoice::setMute(int32_t serial, bool enable) { |
| 219 | LOG_CALL << serial; |
| 220 | mHal1_5->setMute(serial, enable); |
| 221 | return ok(); |
| 222 | } |
| 223 | |
| 224 | ScopedAStatus RadioVoice::setPreferredVoicePrivacy(int32_t serial, bool enable) { |
| 225 | LOG_CALL << serial; |
| 226 | mHal1_5->setPreferredVoicePrivacy(serial, enable); |
| 227 | return ok(); |
| 228 | } |
| 229 | |
| 230 | ScopedAStatus 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 | |
| 244 | ScopedAStatus 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 | |
| 250 | ndk::ScopedAStatus RadioVoice::setVoNrEnabled(int32_t serial, [[maybe_unused]] bool enable) { |
| 251 | LOG_CALL << serial; |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame^] | 252 | // Note: a workaround for older HALs could also be setting persist.radio.is_vonr_enabled_ |
| 253 | respond()->setVoNrEnabledResponse(notSupported(serial)); |
Tomasz Wasilczyk | 6e08418 | 2021-11-05 10:53:55 -0700 | [diff] [blame] | 254 | return ok(); |
| 255 | } |
| 256 | |
| 257 | ScopedAStatus RadioVoice::startDtmf(int32_t serial, const std::string& s) { |
| 258 | LOG_CALL << serial; |
| 259 | mHal1_5->startDtmf(serial, s); |
| 260 | return ok(); |
| 261 | } |
| 262 | |
| 263 | ScopedAStatus RadioVoice::stopDtmf(int32_t serial) { |
| 264 | LOG_CALL << serial; |
| 265 | mHal1_5->stopDtmf(serial); |
| 266 | return ok(); |
| 267 | } |
| 268 | |
| 269 | ScopedAStatus 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 |