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 */ OnScoStateChanged(const RawAddress & device,int state)75 virtual void OnScoStateChanged(const RawAddress &device, int state) 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 /** 119 * @brief Class for IProfileHfpAg API. 120 * 121 * @since 6 122 */ 123 class IProfileHfpAg : public IProfile { 124 public: 125 /** 126 * @brief Destroy the IProfileHfpAg object as default. 127 * 128 * @since 6 129 */ 130 virtual ~IProfileHfpAg() = default; 131 132 /** 133 * @brief Get remote HF device list which are in the specified states. 134 * 135 * @param states List of remote device states. 136 * @return Returns the list of devices. 137 * @since 6 138 */ 139 virtual std::vector<RawAddress> GetDevicesByStates(std::vector<int> states) = 0; 140 141 /** 142 * @brief Get the connection state of the specified remote HF device. 143 * 144 * @param device Remote device object. 145 * @return Returns the connection state of the remote device. 146 * @since 6 147 */ 148 virtual int GetDeviceState(const RawAddress &device) = 0; 149 150 /** 151 * @brief Get the Audio connection state of the specified remote HF device. 152 * 153 * @param device Remote device object. 154 * @return Returns the Audio connection state. 155 * @since 6 156 */ 157 virtual int GetScoState(const RawAddress &device) = 0; 158 159 /** 160 * @brief Initiate the establishment of an audio connection to remote active HF device. 161 * 162 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 163 * @since 6 164 */ 165 virtual bool ConnectSco() = 0; 166 167 /** 168 * @brief Release the audio connection from 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 DisconnectSco() = 0; 174 175 /** 176 * @brief This function used to Update changed phone call information. 177 * 178 * @param phoneState Bluetooth phone state. 179 * @since 6 180 */ 181 virtual void PhoneStateChanged(Bluetooth::BluetoothPhoneState &phoneState) = 0; 182 183 /** 184 * @brief Send response for querying standard list current calls by remote Hf device. 185 * 186 * @param index Index of the current call. 187 * @param direction Direction of the current call. 188 * @param status Status of the current call. 189 * @param mode Source Mode of the current call. 190 * @param mpty Is this call a member of a conference call. 191 * @param number Phone call number. 192 * @param type Type of phone call number. 193 * @since 6 194 */ 195 virtual void ClccResponse( 196 int index, int direction, int status, int mode, bool mpty, const std::string &number, int type) = 0; 197 198 /** 199 * @brief Open the voice recognition. 200 * 201 * @param device Remote device object. 202 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 203 * @since 6 204 */ 205 virtual bool OpenVoiceRecognition(const RawAddress &device) = 0; 206 207 /** 208 * @brief Close the voice recognition. 209 * 210 * @param device Remote device object. 211 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 212 * @since 6 213 */ 214 virtual bool CloseVoiceRecognition(const RawAddress &device) = 0; 215 216 /** 217 * @brief Set the active device for audio connection. 218 * 219 * @param device Remote device object. 220 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 221 * @since 6 222 */ 223 virtual bool SetActiveDevice(const RawAddress &device) = 0; 224 225 /** 226 * @brief Set mock state. 227 * 228 * @param state mock state. 229 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 230 * @since 9 231 */ 232 virtual bool IntoMock(int state) = 0; 233 234 /** 235 * @brief Set no carrier. 236 * 237 * @param device Remote device object.. 238 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 239 * @since 9 240 */ 241 virtual bool SendNoCarrier(const RawAddress &device) = 0; 242 243 /** 244 * @brief Get the active device object. 245 * 246 * @param device Remote active device object. 247 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 248 * @since 6 249 */ 250 virtual std::string GetActiveDevice() = 0; 251 252 /** 253 * @brief Register HandsFree AudioGateway observer instance. 254 * 255 * @param observer HandsFree AudioGateway observer instance. 256 * @since 6 257 */ 258 virtual void RegisterObserver(HfpAgServiceObserver &observer) = 0; 259 260 /** 261 * @brief Deregister HandsFree AudioGateway observer instance. 262 * 263 * @param observer HandsFree AudioGateway observer instance. 264 * @since 6 265 */ 266 virtual void DeregisterObserver(HfpAgServiceObserver &observer) = 0; 267 }; 268 } // namespace bluetooth 269 } // namespace OHOS 270 #endif // INTERFACE_PROFILE_HFP_AG_H