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