1 /* 2 * Copyright (C) 2021-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef BLUETOOTH_CALL_PROXY_H 17 #define BLUETOOTH_CALL_PROXY_H 18 19 #include <cstdio> 20 #include <string> 21 22 #include "iremote_broker.h" 23 #include "iremote_proxy.h" 24 #include "pac_map.h" 25 26 #include "bluetooth_call_ipc_interface_code.h" 27 #include "call_manager_inner_type.h" 28 #include "i_bluetooth_call.h" 29 #include "telephony_log_wrapper.h" 30 31 namespace OHOS { 32 namespace Telephony { 33 class BluetoothCallProxy : public IRemoteProxy<IBluetoothCall> { 34 public: 35 /** 36 * BluetoothCallProxy 37 * 38 * @param impl 39 */ 40 explicit BluetoothCallProxy(const sptr<IRemoteObject> &impl); 41 virtual ~BluetoothCallProxy() = default; 42 43 /** 44 * AnswerCall 45 * 46 * @brief Answer a phone call 47 * @return Returns 0 on success, others on failure. 48 */ 49 int32_t AnswerCall() override; 50 51 /** 52 * RejectCall 53 * 54 * @brief Reject a phone call 55 * @return Returns 0 on success, others on failure. 56 */ 57 int32_t RejectCall() override; 58 59 /** 60 * HangUpCall 61 * 62 * @brief Hang up the phone 63 * @return Returns 0 on success, others on failure. 64 */ 65 int32_t HangUpCall() override; 66 67 /** 68 * GetCallState 69 * 70 * @brief Obtain the call status of the device 71 * @return Returns 0 on success, others on failure. 72 */ 73 int32_t GetCallState() override; 74 75 /** 76 * HoldCall 77 * 78 * @brief Park a phone call 79 * @return Returns 0 on success, others on failure. 80 */ 81 int32_t HoldCall() override; 82 83 /** 84 * UnHoldCall 85 * 86 * @brief Activate a phone call 87 * @return Returns 0 on success, others on failure. 88 */ 89 int32_t UnHoldCall() override; 90 91 /** 92 * SwitchCall 93 * 94 * @brief Switch the phone 95 * @return Returns 0 on success, others on failure. 96 */ 97 int32_t SwitchCall() override; 98 99 /** 100 * StartDtmf 101 * 102 * @brief Enable and send DTMF 103 * @param str[in], Characters sent 104 * @return Returns 0 on success, others on failure. 105 */ 106 int32_t StartDtmf(char str) override; 107 108 /** 109 * StopDtmf 110 * 111 * @brief Stop the DTMF 112 * @return Returns 0 on success, others on failure. 113 */ 114 int32_t StopDtmf() override; 115 116 /** 117 * CombineConference 118 * 119 * @brief Merge calls to form a conference 120 * @return Returns 0 on success, others on failure. 121 */ 122 int32_t CombineConference() override; 123 124 /** 125 * SeparateConference 126 * 127 * @brief Separates a specified call from a conference call 128 * @return Returns 0 on success, others on failure. 129 */ 130 int32_t SeparateConference() override; 131 132 /** 133 * KickOutFromConference 134 * 135 * @brief Hangup a specified call from a conference call 136 * @return Returns 0 on success, others on failure. 137 */ 138 int32_t KickOutFromConference() override; 139 140 /** 141 * GetCurrentCallList 142 * 143 * @brief Get current call list 144 * @param slotId[in], The slot id 145 * @return Returns call info list. 146 */ 147 std::vector<CallAttributeInfo> GetCurrentCallList(int32_t slotId) override; 148 149 /** 150 * AddAudioDeviceList 151 * 152 * @brief Add an audio device 153 * @param address[in], The device address 154 * @param deviceType[in], The device type 155 * @param name[in], The device name 156 * @return Returns 0 on success, others on failure. 157 */ 158 int32_t AddAudioDeviceList(const std::string &address, int32_t deviceType, const std::string &name) override; 159 160 /** 161 * RemoveAudioDeviceList 162 * 163 * @brief Remove an audio device 164 * @param address[in], The device address 165 * @param deviceType[in], The device type 166 * @return Returns 0 on success, others on failure. 167 */ 168 int32_t RemoveAudioDeviceList(const std::string &address, int32_t deviceType) override; 169 170 /** 171 * ResetNearlinkDeviceList 172 * 173 * @brief Reset all nearlink devices 174 * @return Returns 0 on success, others on failure. 175 */ 176 int32_t ResetNearlinkDeviceList() override; 177 178 /** 179 * ResetBtHearingAidDeviceList 180 * 181 * @brief Reset all bluetooth hearing aid devices 182 * @return Returns 0 on success, others on failure. 183 */ 184 int32_t ResetBtHearingAidDeviceList() override; 185 186 private: 187 int32_t SendRequest(BluetoothCallInterfaceCode code); 188 int32_t SendRequest(BluetoothCallInterfaceCode code, MessageParcel &dataParcel, MessageParcel &replyParcel); 189 190 private: 191 static inline BrokerDelegator<BluetoothCallProxy> delegator_; 192 }; 193 } // namespace Telephony 194 } // namespace OHOS 195 196 #endif // BLUETOOTH_CALL_PROXY_H