ProfileBasepublic final class HandsFreeAudioGateway extends Object implements ProfileBase
The static method getProfile(ohos.app.Context) is used to obtain HandsFreeAudioGateway instances.
| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static String |
EVENT_AUDIO_STATE_UPDATE |
The event indicates audio state change.
|
static int |
SCO_STATE_CONNECTED |
Indicates that an SCO link has been set up with the peer device.
|
static int |
SCO_STATE_CONNECTING |
Indicates that an SCO link is being set up with the peer device.
|
static int |
SCO_STATE_DISCONNECTED |
Indicates that no SCO link has been set up with the peer device.
|
A2DP, A2DP_SINK, CONNECT_STRATEGY_ALLOW, CONNECT_STRATEGY_AUTO, CONNECT_STRATEGY_DISALLOW, CONNECT_STRATEGY_UNKNOWN, GATT, GATT_SERVER, HFP, HFP_UNIT, MAP_SERVER, PBAP_CLIENT, PBAP_SERVER, PROFILE_PARAM_CUR_STATE, PROFILE_PARAM_PRE_STATE, SOCKET_MANAGER, STATE_CONNECTED, STATE_CONNECTING, STATE_DISCONNECTED, STATE_DISCONNECTING| 限定符和类型 | 方法 | 说明 |
|---|---|---|
boolean |
closeVoiceRecognition(BluetoothRemoteDevice device) |
Disables Bluetooth voice recognition and the Bluetooth audio channel.
|
boolean |
connectSco() |
Create an audio channel connection.
|
boolean |
disconnectSco() |
Disconnect an audio channel connection.
|
List<BluetoothRemoteDevice> |
getConnectedDevices() |
Obtains the list of connected Bluetooth devices.
|
List<BluetoothRemoteDevice> |
getDevicesByStates(int[] states) |
Obtains the list of devices in the specified status.
|
int |
getDeviceState(BluetoothRemoteDevice device) |
Obtains the connection status of a
BluetoothRemoteDevice in the current profile. |
static HandsFreeAudioGateway |
getProfile(Context context) |
Obtains the default
HandsFreeAudioGateway instance to perform an operation. |
int |
getScoState(BluetoothRemoteDevice device) |
Obtains the status of a HandsFree SCO link between the current device and the peer device.
|
boolean |
openVoiceRecognition(BluetoothRemoteDevice device) |
Enables Bluetooth voice recognition.
|
public static final String EVENT_AUDIO_STATE_UPDATE
public static final int SCO_STATE_CONNECTED
public static final int SCO_STATE_CONNECTING
public static final int SCO_STATE_DISCONNECTED
public static HandsFreeAudioGateway getProfile(Context context)
HandsFreeAudioGateway instance to perform an operation.context - Ability context that contains package nameHandsFreeAudioGateway instance.public List<BluetoothRemoteDevice> getDevicesByStates(int[] states)
ProfileBasegetDevicesByStates 在接口中 ProfileBasestates - Indicates the connection status, which can be ProfileBase.STATE_DISCONNECTED,
ProfileBase.STATE_CONNECTING, ProfileBase.STATE_CONNECTED, or ProfileBase.STATE_DISCONNECTING.BluetoothRemoteDevice matching the specified status.public int getDeviceState(BluetoothRemoteDevice device)
ProfileBaseBluetoothRemoteDevice in the current profile.getDeviceState 在接口中 ProfileBasedevice - Indicates the BluetoothRemoteDevice.ProfileBase.STATE_DISCONNECTED, ProfileBase.STATE_CONNECTING,
ProfileBase.STATE_CONNECTED, or ProfileBase.STATE_DISCONNECTING.public int getScoState(BluetoothRemoteDevice device)
device - Indicates the peer device, which is set by BluetoothRemoteDevice.SCO_STATE_CONNECTED, SCO_STATE_CONNECTING,
or SCO_STATE_DISCONNECTED.public boolean openVoiceRecognition(BluetoothRemoteDevice device)
This method is called to establish a Bluetooth audio channel when the audio gateway receives an AT command for voice recognition from the headset.
device - Indicates the Bluetooth headset.true if Bluetooth voice recognition is enabled; returns false if no headset is
connected, the connected headset does not support voice recognition, or voice recognition
has already been enabled.public boolean closeVoiceRecognition(BluetoothRemoteDevice device)
device - Indicates the Bluetooth headset.true if Bluetooth voice recognition is disabled; returns false if no headset is
connected or voice recognition is not enabled.public boolean connectSco()
Listen event EVENT_AUDIO_STATE_UPDATE to get audio state update after calling this function.
true means the command has been sent, otherwise false.public boolean disconnectSco()
Listen event EVENT_AUDIO_STATE_UPDATE to get audio state update after calling this function.
true means the command has been sent, otherwise false.public List<BluetoothRemoteDevice> getConnectedDevices()