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 /** 17 * @addtogroup Bluetooth 18 * @{ 19 * 20 * @brief Defines a bluetooth system that provides basic bluetooth connection and profile functions, 21 * including A2DP, AVRCP, BLE, GATT, HFP, MAP, PBAP, and SPP, etc. 22 * 23 * @since 6 24 */ 25 26 /** 27 * @file interface_profile_hfp_ag.h 28 * 29 * @brief Declares HFP AG role interface profile functions, including basic and observer functions. 30 * 31 * @since 6 32 */ 33 34 #ifndef INTERFACE_PROFILE_HFP_AG_H 35 #define INTERFACE_PROFILE_HFP_AG_H 36 37 #include "bluetooth_phone_state.h" 38 #include "interface_profile.h" 39 #include <vector> 40 #include <string> 41 42 namespace OHOS { 43 namespace bluetooth { 44 /** 45 * @brief Class for HfpAgServiceObserver functions. 46 * 47 * @since 6 48 */ 49 class HfpAgServiceObserver { 50 public: 51 /** 52 * @brief Destroy the HfpAgServiceObserver Observer object. 53 * 54 * @since 6 55 */ 56 virtual ~HfpAgServiceObserver() = default; 57 58 /** 59 * @brief The observer function to notify connection state changed. 60 * 61 * @param device Remote device object. 62 * @param state Connection state. 63 * @since 6 64 */ OnConnectionStateChanged(const RawAddress & device,int state)65 virtual void OnConnectionStateChanged(const RawAddress &device, int state) 66 {} 67 68 /** 69 * @brief The observer function to notify audio connection state changed. 70 * 71 * @param device Remote device object. 72 * @param state Audio connection state. 73 * @since 6 74 */ 75 virtual void OnScoStateChanged(const RawAddress &device, int state, int reason = 0) 76 {} 77 78 /** 79 * @brief The observer function to notify active device changed. 80 * 81 * @param device Remote active device object. 82 * @since 6 83 */ OnActiveDeviceChanged(const RawAddress & device)84 virtual void OnActiveDeviceChanged(const RawAddress &device) 85 {} 86 87 /** 88 * @brief The observer function to notify enhanced driver safety changed. 89 * 90 * @param device Remote device object. 91 * @param indValue Enhanced driver safety value. 92 * @since 6 93 */ OnHfEnhancedDriverSafetyChanged(const RawAddress & device,int indValue)94 virtual void OnHfEnhancedDriverSafetyChanged(const RawAddress &device, int indValue) 95 {} 96 97 /** 98 * @brief The observer function to notify battery level changed. 99 * 100 * @param device Remote device object. 101 * @param indValue Battery level value. 102 * @since 6 103 */ OnHfBatteryLevelChanged(const RawAddress & device,int indValue)104 virtual void OnHfBatteryLevelChanged(const RawAddress &device, int indValue) 105 {} 106 107 /** 108 * @brief The observer function to notify audio framework the hfp stack changed. 109 * 110 * @param device Remote device object. 111 * @param action Action on the device. 112 * @since 11 113 */ OnHfpStackChanged(const RawAddress & device,int action)114 virtual void OnHfpStackChanged(const RawAddress &device, int action) 115 {} 116 117 /** 118 * @brief virtual device changed observer. 119 * @param action add or remove virtual device. 120 * @param address address on the virtual device. 121 * @since 12.0 122 */ OnVirtualDeviceChanged(int32_t action,std::string address)123 virtual void OnVirtualDeviceChanged(int32_t action, std::string address) {}; 124 }; 125 126 /** 127 * @brief Class for IProfileHfpAg API. 128 * 129 * @since 6 130 */ 131 class IProfileHfpAg : public IProfile { 132 public: 133 /** 134 * @brief Destroy the IProfileHfpAg object as default. 135 * 136 * @since 6 137 */ 138 virtual ~IProfileHfpAg() = default; 139 140 /** 141 * @brief Get remote HF device list which are in the specified states. 142 * 143 * @param states List of remote device states. 144 * @return Returns the list of devices. 145 * @since 6 146 */ 147 virtual std::vector<RawAddress> GetDevicesByStates(std::vector<int> states) = 0; 148 149 /** 150 * @brief Get the connection state of the specified remote HF device. 151 * 152 * @param device Remote device object. 153 * @return Returns the connection state of the remote device. 154 * @since 6 155 */ 156 virtual int GetDeviceState(const RawAddress &device) = 0; 157 158 /** 159 * @brief Get the Audio connection state of the specified remote HF device. 160 * 161 * @param device Remote device object. 162 * @return Returns the Audio connection state. 163 * @since 6 164 */ 165 virtual int GetScoState(const RawAddress &device) = 0; 166 167 /** 168 * @brief Initiate the establishment of an audio connection to remote active HF device. 169 * 170 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 171 * @since 6 172 */ 173 virtual bool ConnectSco() = 0; 174 175 /** 176 * @brief Release the audio connection from remote active HF device. 177 * 178 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 179 * @since 6 180 */ 181 virtual bool DisconnectSco() = 0; 182 183 /** 184 * @brief This function used to Update changed phone call information. 185 * 186 * @param phoneState Bluetooth phone state. 187 * @since 6 188 */ 189 virtual void PhoneStateChanged(Bluetooth::BluetoothPhoneState &phoneState) = 0; 190 191 /** 192 * @brief Send response for querying standard list current calls by remote Hf device. 193 * 194 * @param index Index of the current call. 195 * @param direction Direction of the current call. 196 * @param status Status of the current call. 197 * @param mode Source Mode of the current call. 198 * @param mpty Is this call a member of a conference call. 199 * @param number Phone call number. 200 * @param type Type of phone call number. 201 * @since 6 202 */ 203 virtual void ClccResponse( 204 int index, int direction, int status, int mode, bool mpty, const std::string &number, int type) = 0; 205 206 /** 207 * @brief Open the voice recognition. 208 * 209 * @param device Remote device object. 210 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 211 * @since 6 212 */ 213 virtual bool OpenVoiceRecognition(const RawAddress &device) = 0; 214 215 /** 216 * @brief Close the voice recognition. 217 * 218 * @param device Remote device object. 219 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 220 * @since 6 221 */ 222 virtual bool CloseVoiceRecognition(const RawAddress &device) = 0; 223 224 /** 225 * @brief Set the active device for audio connection. 226 * 227 * @param device Remote device object. 228 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 229 * @since 6 230 */ 231 virtual bool SetActiveDevice(const RawAddress &device) = 0; 232 233 /** 234 * @brief Set mock state. 235 * 236 * @param state mock state. 237 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 238 * @since 9 239 */ 240 virtual bool IntoMock(int state) = 0; 241 242 /** 243 * @brief Set no carrier. 244 * 245 * @param device Remote device object.. 246 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 247 * @since 9 248 */ 249 virtual bool SendNoCarrier(const RawAddress &device) = 0; 250 251 /** 252 * @brief Get the active device object. 253 * 254 * @param device Remote active device object. 255 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 256 * @since 6 257 */ 258 virtual std::string GetActiveDevice() = 0; 259 260 /** 261 * @brief Register HandsFree AudioGateway observer instance. 262 * 263 * @param observer HandsFree AudioGateway observer instance. 264 * @since 6 265 */ 266 virtual void RegisterObserver(HfpAgServiceObserver &observer) = 0; 267 268 /** 269 * @brief Deregister HandsFree AudioGateway observer instance. 270 * 271 * @param observer HandsFree AudioGateway observer instance. 272 * @since 6 273 */ 274 virtual void DeregisterObserver(HfpAgServiceObserver &observer) = 0; 275 276 /** 277 * @brief update hfp virtual device. 278 * 279 * @param actiion 0:add, 1:remove. 280 * @param address address of virtual device 281 * @since 12.0 282 */ UpdateVirtualDevice(int32_t action,const std::string & address)283 virtual void UpdateVirtualDevice(int32_t action, const std::string &address) {}; 284 285 /** 286 * @brief get hfp virtual device list. 287 * 288 * @param devices address of virtual device list. 289 * @since 12.0 290 */ GetVirtualDeviceList(std::vector<std::string> & devices)291 virtual void GetVirtualDeviceList(std::vector<std::string> &devices) {}; 292 }; 293 } // namespace bluetooth 294 } // namespace OHOS 295 #endif // INTERFACE_PROFILE_HFP_AG_H