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 "interface_profile.h" 38 #include <vector> 39 #include <string> 40 41 namespace OHOS { 42 namespace bluetooth { 43 /** 44 * @brief Class for HfpAgServiceObserver functions. 45 * 46 * @since 6 47 */ 48 class HfpAgServiceObserver { 49 public: 50 /** 51 * @brief Destroy the HfpAgServiceObserver Observer object. 52 * 53 * @since 6 54 */ 55 virtual ~HfpAgServiceObserver() = default; 56 57 /** 58 * @brief The observer function to notify connection state changed. 59 * 60 * @param device Remote device object. 61 * @param state Connection state. 62 * @since 6 63 */ OnConnectionStateChanged(const RawAddress & device,int state)64 virtual void OnConnectionStateChanged(const RawAddress &device, int state) 65 {} 66 67 /** 68 * @brief The observer function to notify audio connection state changed. 69 * 70 * @param device Remote device object. 71 * @param state Audio connection state. 72 * @since 6 73 */ OnScoStateChanged(const RawAddress & device,int state)74 virtual void OnScoStateChanged(const RawAddress &device, int state) 75 {} 76 77 /** 78 * @brief The observer function to notify active device changed. 79 * 80 * @param device Remote active device object. 81 * @since 6 82 */ OnActiveDeviceChanged(const RawAddress & device)83 virtual void OnActiveDeviceChanged(const RawAddress &device) 84 {} 85 86 /** 87 * @brief The observer function to notify enhanced driver safety changed. 88 * 89 * @param device Remote device object. 90 * @param indValue Enhanced driver safety value. 91 * @since 6 92 */ OnHfEnhancedDriverSafetyChanged(const RawAddress & device,int indValue)93 virtual void OnHfEnhancedDriverSafetyChanged(const RawAddress &device, int indValue) 94 {} 95 96 /** 97 * @brief The observer function to notify battery level changed. 98 * 99 * @param device Remote device object. 100 * @param indValue Battery level value. 101 * @since 6 102 */ OnHfBatteryLevelChanged(const RawAddress & device,int indValue)103 virtual void OnHfBatteryLevelChanged(const RawAddress &device, int indValue) 104 {} 105 }; 106 107 /** 108 * @brief Class for IProfileHfpAg API. 109 * 110 * @since 6 111 */ 112 class IProfileHfpAg : public IProfile { 113 public: 114 /** 115 * @brief Destroy the IProfileHfpAg object as default. 116 * 117 * @since 6 118 */ 119 virtual ~IProfileHfpAg() = default; 120 121 /** 122 * @brief Get remote HF device list which are in the specified states. 123 * 124 * @param states List of remote device states. 125 * @return Returns the list of devices. 126 * @since 6 127 */ 128 virtual std::vector<RawAddress> GetDevicesByStates(std::vector<int> states) = 0; 129 130 /** 131 * @brief Get the connection state of the specified remote HF device. 132 * 133 * @param device Remote device object. 134 * @return Returns the connection state of the remote device. 135 * @since 6 136 */ 137 virtual int GetDeviceState(const RawAddress &device) = 0; 138 139 /** 140 * @brief Get the Audio connection state of the specified remote HF device. 141 * 142 * @param device Remote device object. 143 * @return Returns the Audio connection state. 144 * @since 6 145 */ 146 virtual int GetScoState(const RawAddress &device) = 0; 147 148 /** 149 * @brief Initiate the establishment of an audio connection to remote active HF device. 150 * 151 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 152 * @since 6 153 */ 154 virtual bool ConnectSco() = 0; 155 156 /** 157 * @brief Release the audio connection from remote active HF device. 158 * 159 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 160 * @since 6 161 */ 162 virtual bool DisconnectSco() = 0; 163 164 /** 165 * @brief This function used to Update changed phone call information. 166 * 167 * @param numActive Active call number. 168 * @param numHeld Held call number. 169 * @param callState Current call state. 170 * @param number Phone call number. 171 * @param type Type of phone call number. 172 * @param name Name of phone call number. 173 * @since 6 174 */ 175 virtual void PhoneStateChanged( 176 int numActive, int numHeld, int callState, const std::string &number, int type, const std::string &name) = 0; 177 178 /** 179 * @brief Send response for querying standard list current calls by remote Hf device. 180 * 181 * @param index Index of the current call. 182 * @param direction Direction of the current call. 183 * @param status Status of the current call. 184 * @param mode Source Mode of the current call. 185 * @param mpty Is this call a member of a conference call. 186 * @param number Phone call number. 187 * @param type Type of phone call number. 188 * @since 6 189 */ 190 virtual void ClccResponse( 191 int index, int direction, int status, int mode, bool mpty, const std::string &number, int type) = 0; 192 193 /** 194 * @brief Open the voice recognition. 195 * 196 * @param device Remote device object. 197 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 198 * @since 6 199 */ 200 virtual bool OpenVoiceRecognition(const RawAddress &device) = 0; 201 202 /** 203 * @brief Close the voice recognition. 204 * 205 * @param device Remote device object. 206 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 207 * @since 6 208 */ 209 virtual bool CloseVoiceRecognition(const RawAddress &device) = 0; 210 211 /** 212 * @brief Set the active device for audio connection. 213 * 214 * @param device Remote device object. 215 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 216 * @since 6 217 */ 218 virtual bool SetActiveDevice(const RawAddress &device) = 0; 219 220 /** 221 * @brief Set mock state. 222 * 223 * @param state mock state. 224 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 225 * @since 9 226 */ 227 virtual bool IntoMock(int state) = 0; 228 229 /** 230 * @brief Set no carrier. 231 * 232 * @param device Remote device object.. 233 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 234 * @since 9 235 */ 236 virtual bool SendNoCarrier(const RawAddress &device) = 0; 237 238 /** 239 * @brief Get the active device object. 240 * 241 * @param device Remote active device object. 242 * @return Returns <b>true</b> if the operation is successful; returns <b>false</b> if the operation fails. 243 * @since 6 244 */ 245 virtual std::string GetActiveDevice() = 0; 246 247 /** 248 * @brief Register HandsFree AudioGateway observer instance. 249 * 250 * @param observer HandsFree AudioGateway observer instance. 251 * @since 6 252 */ 253 virtual void RegisterObserver(HfpAgServiceObserver &observer) = 0; 254 255 /** 256 * @brief Deregister HandsFree AudioGateway observer instance. 257 * 258 * @param observer HandsFree AudioGateway observer instance. 259 * @since 6 260 */ 261 virtual void DeregisterObserver(HfpAgServiceObserver &observer) = 0; 262 }; 263 } // namespace bluetooth 264 } // namespace OHOS 265 #endif // INTERFACE_PROFILE_HFP_AG_H