1 /* 2 * Copyright (C) 2021 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_CLIENT_H 17 #define BLUETOOTH_CALL_CLIENT_H 18 19 #include "singleton.h" 20 #include "pac_map.h" 21 22 #include "call_manager_callback.h" 23 24 namespace OHOS { 25 namespace Telephony { 26 class BluetoothCallClient : public std::enable_shared_from_this<BluetoothCallClient> { 27 DECLARE_DELAYED_SINGLETON(BluetoothCallClient) 28 public: 29 void Init(); 30 void UnInit(); 31 32 /** 33 * @brief Register callback 34 * 35 * @param callback[in], callback function pointer 36 * @return Returns 0 on success, others on failure. 37 */ 38 int32_t RegisterCallBack(std::unique_ptr<CallManagerCallback> callback); 39 40 /** 41 * @brief unregister callback 42 * 43 * @return Returns 0 on success, others on failure. 44 */ 45 int32_t UnRegisterCallBack(); 46 47 /** 48 * @brief Make a phone call 49 * 50 * @param number[in], dial param. 51 * @param extras[in], extras date. 52 * @return Returns callId when the value is greater than zero, others on failure. 53 */ 54 int32_t DialCall(std::u16string number, AppExecFwk::PacMap &extras); 55 56 /** 57 * @brief Answer a phone call 58 * 59 * @return Returns 0 on success, others on failure. 60 */ 61 int32_t AnswerCall(); 62 63 /** 64 * @brief Reject a phone call 65 * 66 * @return Returns 0 on success, others on failure. 67 */ 68 int32_t RejectCall(); 69 70 /** 71 * @brief Hang up the phone 72 * 73 * @return Returns 0 on success, others on failure. 74 */ 75 int32_t HangUpCall(); 76 77 /** 78 * @brief Obtain the call status of the device 79 * 80 * @return Returns 0 on success, others on failure. 81 */ 82 int32_t GetCallState(); 83 84 /** 85 * @brief Park a phone call 86 * 87 * @return Returns 0 on success, others on failure. 88 */ 89 int32_t HoldCall(); 90 91 /** 92 * @brief Activate a phone call 93 * 94 * @return Returns 0 on success, others on failure. 95 */ 96 int32_t UnHoldCall(); 97 98 /** 99 * @brief Switch the phone 100 * 101 * @return Returns 0 on success, others on failure. 102 */ 103 int32_t SwitchCall(); 104 105 /** 106 * @brief Merge calls to form a conference 107 * 108 * @return Returns 0 on success, others on failure. 109 */ 110 int32_t CombineConference(); 111 112 /** 113 * @brief Separates a specified call from a conference call 114 * 115 * @return Returns 0 on success, others on failure. 116 */ 117 int32_t SeparateConference(); 118 119 /** 120 * @brief Kick out a specified call from a conference call 121 * 122 * @return Returns 0 on success, others on failure. 123 */ 124 int32_t KickOutFromConference(); 125 126 /** 127 * @brief Enable and send DTMF 128 * 129 * @param str[in], Characters sent 130 * @return Returns 0 on success, others on failure. 131 */ 132 int32_t StartDtmf(char str); 133 134 /** 135 * @brief Stop the DTMF 136 * 137 * @return Returns 0 on success, others on failure. 138 */ 139 int32_t StopDtmf(); 140 141 /** 142 * @brief Whether the ringing 143 * 144 * @param enabled[out], true on ringing, false on there is no ringing 145 * @return Returns interface processing results. 146 */ 147 int32_t IsRinging(bool &enabled); 148 149 /** 150 * @brief Is there Call 151 * 152 * @return Returns true on has call, others on there is no call. 153 */ 154 bool HasCall(); 155 156 /** 157 * @brief Checks whether a new call is allowed. 158 * 159 * @param enabled[out], whether allow new calls 160 * @return Returns interface processing results. 161 */ 162 int32_t IsNewCallAllowed(bool &enabled); 163 164 /** 165 * @brief Is there an emergency call 166 * 167 * @param enabled[out], true on emergency call, false on no emergency call 168 * @return Returns interface processing results. 169 */ 170 int32_t IsInEmergencyCall(bool &enabled); 171 172 /** 173 * @brief Mute the Microphone 174 * 175 * @param isMute[in], mute state 176 * @return Returns 0 on success, others on failure. 177 */ 178 int32_t SetMuted(bool isMute); 179 180 /** 181 * @brief Call mute 182 * 183 * @return Returns 0 on success, others on failure. 184 */ 185 int32_t MuteRinger(); 186 187 /** 188 * @brief Setting the Audio Channel 189 * 190 * @param deviceType[in], audioDeviceType 191 * @param bluetoothAddress[in], audio device address 192 * @return Returns 0 on success, others on failure. 193 */ 194 int32_t SetAudioDevice(AudioDeviceType deviceType, const std::string &bluetoothAddress); 195 196 /** 197 * @brief Get current call list 198 * 199 * @param slotId[in], The slot id 200 * @return Returns call info list. 201 */ 202 std::vector<CallAttributeInfo> GetCurrentCallList(int32_t slotId); 203 }; 204 } // namespace Telephony 205 } // namespace OHOS 206 207 #endif