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 HFP_AG_PROFILE_EVENT_SENDER_H 17 #define HFP_AG_PROFILE_EVENT_SENDER_H 18 19 #include <cstdint> 20 #include <string> 21 22 #include "dispatcher.h" 23 #include "hfp_ag_message.h" 24 25 namespace OHOS { 26 namespace bluetooth { 27 /** 28 * @brief This class provides a set of methods that is used to sent the event to service. 29 */ 30 class HfpAgProfileEventSender { 31 public: 32 /** 33 * @brief Get the instance of the HfpAgProfileEventSender. 34 * 35 * @return Returns the quote of the HfpAgProfileEventSender instance. 36 */ 37 static HfpAgProfileEventSender &GetInstance(); 38 39 /** 40 * @brief Answer the call. 41 * 42 * @param device Remote bluetooth address. 43 */ 44 void AnswerCall(const std::string &device) const; 45 46 /** 47 * @brief Hangup the call. 48 * 49 * @param device Remote bluetooth address. 50 */ 51 void HangupCall(const std::string &device) const; 52 53 /** 54 * @brief Hf notify the volume changed. 55 * 56 * @param device Remote bluetooth address. 57 * @param type Speaker or microphone. 58 * @param volume The value of the volume. 59 */ 60 void HfVolumeChanged(const std::string &device, int type, int volume) const; 61 62 /** 63 * @brief Dial out the call. 64 * 65 * @param device Remote bluetooth address. 66 * @param number The number of the call. 67 */ 68 void DialOutCall(const std::string &device, const std::string &number, int dialType) const; 69 70 /** 71 * @brief send the DTMF. 72 * 73 * @param device Remote bluetooth address. 74 * @param dtmf Code of DTMF. 75 */ 76 void SendDtmf(const std::string &device, int dtmf) const; 77 78 /** 79 * @brief Enable the noise reduction. 80 * 81 * @param device Remote bluetooth address. 82 * @param enable True or false. 83 */ 84 void EnableNoiseReduction(const std::string &device, bool enable) const; 85 86 /** 87 * @brief hold the call. 88 * 89 * @param device Remote bluetooth address. 90 * @param chld Value of the CHLD. 91 */ 92 void HoldCall(const std::string &device, int chld) const; 93 94 /** 95 * @brief Get the number of the phone. 96 * 97 * @param device Remote bluetooth address. 98 */ 99 void GetSubscriberNumber(const std::string &device) const; 100 101 /** 102 * @brief Get the indicator of the AG. 103 * 104 * @param device Remote bluetooth address. 105 */ 106 void GetAgIndicator(const std::string &device) const; 107 108 /** 109 * @brief Get the network operater. 110 * 111 * @param device Remote bluetooth address. 112 */ 113 void GetNetworkOperater(const std::string &device) const; 114 115 /** 116 * @brief Get the current call list. 117 * 118 * @param device Remote bluetooth address. 119 */ 120 void GetCurrentCalls(const std::string &device) const; 121 122 /** 123 * @brief Process the indicator of the HF. 124 * 125 * @param device Remote bluetooth address. 126 * @param atString AT command. 127 */ 128 void ProcessATBind(const std::string &device, const std::string &atString) const; 129 130 /** 131 * @brief Process Audio Connection Setup by HF event. 132 * 133 * @param device Remote bluetooth address. 134 */ 135 void ProcessAtBcc(const std::string &device) const; 136 137 /** 138 * @brief Process codec negotiation completed event. 139 * 140 * @param device Remote bluetooth address. 141 */ 142 void ProcessAtBcs(const std::string &device) const; 143 144 /** 145 * @brief Send the indicator of the HF. 146 * 147 * @param device Remote bluetooth address. 148 * @param indId Id of hf indicator. 149 * @param indValue Value of hf indicator. 150 */ 151 void SendHfIndicator(const std::string &device, int indId, int indValue) const; 152 153 /** 154 * @brief Update the state of the ag indictor enable. 155 * 156 * @param device Remote bluetooth address. 157 * @param data The enable tag of the ag indictor 158 */ 159 void ProcessAtBia(const std::string &device, const HfpAgTransferData &data) const; 160 161 /** 162 * @brief Transfer connect request. 163 * 164 * @param device Remote bluetooth address. 165 * @param handle rfcomm handle. 166 * @param what The event tag. 167 */ 168 void ConnectRequest(const std::string &device, int handle, int what) const; 169 170 /** 171 * @brief Update the state of the slc connection. 172 * 173 * @param device Remote bluetooth address. 174 * @param what The event tag. 175 */ 176 void UpdateConnectState(const std::string &device, int what) const; 177 178 /** 179 * @brief Transfer sco connect request. 180 * 181 * @param device Remote bluetooth address. 182 * @param what The event tag. 183 * @param linkType Sco link type. 184 */ 185 void ScoConnectRequest(const std::string &device, int what, uint8_t linkType) const; 186 187 /** 188 * @brief Update the state of the sco connection. 189 * 190 * @param device Remote bluetooth address. 191 * @param what The event tag. 192 */ 193 void UpdateScoConnectState(const std::string &device, int what) const; 194 195 /** 196 * @brief Get response and hold state. 197 * 198 * @param device Remote bluetooth address. 199 * @param what The event tag. 200 */ 201 void GetResponseHoldState(const std::string &device, int what) const; 202 203 /** 204 * @brief Get response and hold state. 205 * 206 * @param device Remote bluetooth address. 207 * @param what The event tag. 208 */ 209 void SetResponseHoldState(const std::string &device, int what, int btrh) const; 210 211 /** 212 * @brief Process the result of the sdp discovery. 213 * 214 * @param device Remote bluetooth address. 215 * @param what The event tag. 216 */ 217 void ProcessSdpDiscoveryResult(const std::string &device, int what) const; 218 219 /** 220 * @brief Remove the state machine. 221 * 222 * @param device Remote bluetooth address. 223 */ 224 void RemoveStateMachine(const std::string &device) const; 225 226 /** 227 * @brief The status of the voice recognition change. 228 * 229 * @param device Remote bluetooth address. 230 * @param status The status of the voice recognition 231 */ 232 void VoiceRecognitionStateChanged(const std::string &device, int status) const; 233 234 /** 235 * @brief Set active device success event. 236 * 237 * @param device Remote bluetooth address. 238 */ 239 void SetActiveDeviceSuccess(const std::string &device) const; 240 241 /** 242 * @brief Set ring and clip event. 243 * 244 * @param device Remote bluetooth address. 245 */ 246 void SendRingAndClip(const std::string &device) const; 247 248 /** 249 * @brief Get voice number. 250 * 251 * @param device Remote bluetooth address. 252 */ 253 void GetVoiceTagNumber(const std::string &device) const; 254 255 /** 256 * @brief Process CKpd Event. 257 * 258 * @param device Remote bluetooth address. 259 */ 260 void ProcessCKpdEvent(const std::string &device) const; 261 262 /** 263 * @brief Get service dispatcher. 264 * 265 * @return service dispatcher. 266 */ 267 utility::Dispatcher *GetDispatchter() const; 268 269 private: 270 /** 271 * @brief Send the message to the service. 272 * 273 * @param msg The message object. 274 */ 275 static void SendMessageToService(const HfpAgMessage &msg); 276 277 /** 278 * @brief Construct a new HfpAgProfileEventSender object. 279 */ 280 HfpAgProfileEventSender() = default; 281 282 /** 283 * @brief Destroy the HfpAgProfileEventSender object. 284 */ 285 ~HfpAgProfileEventSender() = default; 286 }; 287 } // namespace bluetooth 288 } // namespace OHOS 289 #endif // HFP_AG_PROFILE_EVENT_SENDER_H 290