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_HF_PROFILE_EVENT_SENDER_H 17 #define HFP_HF_PROFILE_EVENT_SENDER_H 18 19 #include <cstdint> 20 #include <string> 21 22 #include "hfp_hf_message.h" 23 #include "hfp_hf_service.h" 24 #include "message.h" 25 26 namespace OHOS { 27 namespace bluetooth { 28 /** 29 * @brief This class provides a set of methods that is used to sent the event to service. 30 */ 31 class HfpHfProfileEventSender { 32 public: 33 /** 34 * @brief Get the instance of the HfpHfProfileEventSender. 35 * 36 * @return Returns the quote of the HfpHfProfileEventSender instance. 37 */ 38 static HfpHfProfileEventSender &GetInstance(); 39 40 /** 41 * @brief Send the event of the network state change. 42 * 43 * @param address The device address. 44 * @param state The state of the network. 45 */ 46 void NetworkStateChanged(const std::string &address, int state) const; 47 48 /** 49 * @brief Send the event of the network roam change. 50 * 51 * @param address The device address. 52 * @param state The state of the roam. 53 */ 54 void NetworkRoamingChanged(const std::string &address, int state) const; 55 56 /** 57 * @brief Send the event of the signal strength change. 58 * 59 * @param address The device address. 60 * @param signal The signal strength. 61 */ 62 void NetworkSignalChanged(const std::string &address, int signal) const; 63 64 /** 65 * @brief Send the event of the battery level change. 66 * 67 * @param address The device address. 68 * @param level The battery level. 69 */ 70 void BatteryLevelChanged(const std::string &address, int level) const; 71 72 /** 73 * @brief Send the event of the network operator. 74 * 75 * @param address The device address. 76 * @param name The network operator name. 77 */ 78 void CurrentOperatorReply(const std::string &address, const std::string &name) const; 79 80 /** 81 * @brief Send the event of the call state. 82 * 83 * @param address The device address. 84 * @param call The state of call. 85 */ 86 void CallStateNotify(const std::string &address, int call) const; 87 88 /** 89 * @brief Send the setup state of the call. 90 * 91 * @param address The device address. 92 * @param callsetup The state of call setup. 93 */ 94 void CallSetupStateNotify(const std::string &address, int callsetup) const; 95 96 /** 97 * @brief Send the held state of the call. 98 * 99 * @param address The device address. 100 * @param callheld The state of call held. 101 */ 102 void CallHeldStateNotify(const std::string &address, int callheld) const; 103 104 /** 105 * @brief Send the hold result. 106 * 107 * @param address The device address. 108 * @param respAndHold The result of the hold. 109 */ 110 void HoldResultReply(const std::string &address, int respAndHold) const; 111 112 /** 113 * @brief Send the calling line identification. 114 * 115 * @param address The device address. 116 * @param number The number of incoming call. 117 */ 118 void Callinglineidentification(const std::string &address, const std::string &number) const; 119 120 /** 121 * @brief Send the call waiting. 122 * 123 * @param address The device address. 124 * @param number The number of the waiting call. 125 */ 126 void CallWaitingNotify(const std::string &address, const std::string &number) const; 127 128 /** 129 * @brief Send the current call. 130 * 131 * @param address The device address. 132 * @param call The current call. 133 */ 134 void CurrentCallsReply(const std::string &address, const HfpHfCurrentCallData &call) const; 135 136 /** 137 * @brief Set the hf volume. 138 * 139 * @param address The device address. 140 * @param type The type of the volume. 141 * @param volume The value of the volume. 142 */ 143 void SetVolume(const std::string &address, int type, int volume) const; 144 145 /** 146 * @brief Send the result of the at cmd. 147 * 148 * @param address The device address. 149 * @param type The type of cmd. 150 * @param cme The result of cmd. 151 */ 152 void AtCmdResultReply(const std::string &address, int type, int cme) const; 153 154 /** 155 * @brief Send the subscriber number. 156 * 157 * @param address The device address. 158 * @param number The subscriber number 159 * @param type The type of the number. 160 */ 161 void SubscriberNumberReply(const std::string &address, const std::string &number, int type) const; 162 163 /** 164 * @brief Set the in-banding ring 165 * 166 * @param address The device address. 167 * @param inBand the value of the in-banding ring. 168 */ 169 void SetInBandRing(const std::string &address, int inBand, bool isFirstTime) const; 170 171 /** 172 * @brief Send the indicator of the ring. 173 * 174 * @param address The device address. 175 */ 176 void RingIndicationNotify(const std::string &address) const; 177 178 /** 179 * @brief Send the unknown event. 180 * 181 * @param address The device address. 182 * @param eventString The event string. 183 */ 184 void UnknownEventNotify(const std::string &address, const std::string &eventString) const; 185 186 /** 187 * @brief Transfer connect request. 188 * 189 * @param device Remote bluetooth device address. 190 * @param handle Rfcomm handle. 191 * @param what Event tag. 192 */ 193 void ConnectRequest(const std::string &device, int handle, int what) const; 194 195 /** 196 * @brief Update the state of the slc connection. 197 * 198 * @param address Remote bluetooth device address. 199 * @param what Event tag. 200 */ 201 void UpdateConnectState(const std::string &device, int what) const; 202 203 /** 204 * @brief Transfer sco connect request. 205 * 206 * @param device remote bluetooth address. 207 * @param what the event tag. 208 * @param linkType sco link type 209 */ 210 void ScoConnectRequest(const std::string &device, int what, uint8_t linkType) const; 211 212 /** 213 * @brief Update the state of the sco connection. 214 * 215 * @param device: remote bluetooth address. 216 * @param what: the event tag. 217 */ 218 void UpdateScoConnectState(const std::string &device, int what) const; 219 220 /** 221 * @brief Process the result of the sdp discovery. 222 * 223 * @param address Remote bluetooth device address. 224 * @param what Event tag. 225 */ 226 void ProcessSdpDiscoveryResult(const std::string &device, int what) const; 227 228 /** 229 * @brief Report the current call list reply done. 230 * 231 * @param address Remote bluetooth address 232 */ 233 void CurrentCallsReplyDone(const std::string &address) const; 234 235 /** 236 * @brief Report remove state machine. 237 * 238 * @param address Remote bluetooth address. 239 */ 240 void RemoveSateMachine(const std::string &address) const; 241 242 /** 243 * @brief Notify the result of opening voice recognition. 244 * 245 * @param address The bluetooth device address. 246 * @param result the result of opening voice recognition. 247 */ 248 void OpenVoiceRecognitionResult(const std::string &address, int result) const; 249 250 /** 251 * @brief Notify the result of closing voice recognition. 252 * 253 * @param address The bluetooth device address. 254 * @param result The result of closing voice recognition. 255 */ 256 void CloseVoiceRecognitionResult(const std::string &address, int result) const; 257 258 /** 259 * @brief notify the voice recognition change. 260 * 261 * @param address The bluetooth device address. 262 * @param status The status of the the voice recognition. 263 */ 264 void VoiceRecognitionChanged(const std::string &address, int status) const; 265 266 /** 267 * @brief Get service dispatcher. 268 * 269 * @return service dispatcher. 270 */ 271 utility::Dispatcher *GetDispatchter() const; 272 273 private: 274 /** 275 * @brief Construct a new HfpHfProfileEventSender object. 276 */ 277 HfpHfProfileEventSender() = default; 278 279 /** 280 * @brief Destroy the HfpHfProfileEventSender object. 281 */ 282 ~HfpHfProfileEventSender() = default; 283 284 /** 285 * @brief Send message to HandsfreeUnit service. 286 * 287 * @param event HandsfreeUnit message. 288 */ 289 static void SendMessageToService(const HfpHfMessage &event); 290 }; 291 } // namespace bluetooth 292 } // namespace OHOS 293 #endif // HFP_HF_PROFILE_EVENT_SENDER_H 294