lightbulb_outline Help shape the future of the Google Play Console, Android Studio, and Firebase. Start survey

BluetoothConfigManager

public class BluetoothConfigManager
extends Object

java.lang.Object
   ↳ com.google.android.things.bluetooth.BluetoothConfigManager


This class is used to control various configuration options for the Bluetooth stack.

For eg., it can be used to fetch or control the Bluetooth Class of Device

Summary

Constants

int IO_CAPABILITY_IN

Device only has a keyboard for entry but no display.

int IO_CAPABILITY_IO

Device has a display and the ability to input Yes/No.

int IO_CAPABILITY_KBDISP

Device has a display and a full keyboard.

int IO_CAPABILITY_NONE

Device has no Input or Output capability.

int IO_CAPABILITY_OUT

Device only has a display.

int IO_CAPABILITY_UNKNOWN

The Input/Output capability of the device is unknown.

Public methods

BluetoothClass getBluetoothClass()

Get current BluetoothClass (CoD) value of local Bluetooth adapter.

static BluetoothConfigManager getInstance()

Fetch an instance of BluetoothConfigManager

int getIoCapability()

Returns the Input/Output capability of the device for classic Bluetooth.

int getLeIoCapability()

Returns the Input/Output capability of the device for BLE operations.

boolean setBluetoothClass(BluetoothClass bluetoothClass)

Set the Bluetooth Class of Device (CoD) value of local Bluetooth adapter.

boolean setIoCapability(int capability)

Sets the Input/Output capability of the device for classic Bluetooth.

boolean setLeIoCapability(int capability)

Sets the Input/Output capability of the device for BLE operations.

Inherited methods

From class java.lang.Object

Constants

IO_CAPABILITY_IN

int IO_CAPABILITY_IN

Device only has a keyboard for entry but no display.

Constant Value: 2 (0x00000002)

IO_CAPABILITY_IO

int IO_CAPABILITY_IO

Device has a display and the ability to input Yes/No.

Constant Value: 1 (0x00000001)

IO_CAPABILITY_KBDISP

int IO_CAPABILITY_KBDISP

Device has a display and a full keyboard.

Constant Value: 4 (0x00000004)

IO_CAPABILITY_NONE

int IO_CAPABILITY_NONE

Device has no Input or Output capability.

Constant Value: 3 (0x00000003)

IO_CAPABILITY_OUT

int IO_CAPABILITY_OUT

Device only has a display.

Constant Value: 0 (0x00000000)

IO_CAPABILITY_UNKNOWN

int IO_CAPABILITY_UNKNOWN

The Input/Output capability of the device is unknown.

Constant Value: 255 (0x000000ff)

Public methods

getBluetoothClass

BluetoothClass getBluetoothClass ()

Get current BluetoothClass (CoD) value of local Bluetooth adapter.

Returns
BluetoothClass BluetoothClass of local Bluetooth adapter.

Throws
IllegalStateException when the connection to the server has died.

See also:

getInstance

BluetoothConfigManager getInstance ()

Fetch an instance of BluetoothConfigManager

Returns
BluetoothConfigManager

Throws
IllegalStateException if a connection cannot be established to the back-end service.

getIoCapability

int getIoCapability ()

Returns the Input/Output capability of the device for classic Bluetooth.

Returns
int Input/Output capability of the device. One of IO_CAPABILITY_OUT, IO_CAPABILITY_IO, IO_CAPABILITY_IN, IO_CAPABILITY_NONE, IO_CAPABILITY_KBDISP or IO_CAPABILITY_UNKNOWN.

getLeIoCapability

int getLeIoCapability ()

Returns the Input/Output capability of the device for BLE operations.

Returns
int Input/Output capability of the device. One of IO_CAPABILITY_OUT, IO_CAPABILITY_IO, IO_CAPABILITY_IN, IO_CAPABILITY_NONE, IO_CAPABILITY_KBDISP or IO_CAPABILITY_UNKNOWN.

setBluetoothClass

boolean setBluetoothClass (BluetoothClass bluetoothClass)

Set the Bluetooth Class of Device (CoD) value of local Bluetooth adapter.

Parameters
bluetoothClass BluetoothClass: BluetoothClass to set the local adapter to.

Returns
boolean result of operation

Throws
IllegalArgumentException when BluetoothClass is null.
IllegalStateException when the connection to the server has died.

setIoCapability

boolean setIoCapability (int capability)

Sets the Input/Output capability of the device for classic Bluetooth.

Changing the Input/Output capability of a device only takes effect on restarting the Bluetooth stack. You would need to restart the stack using disable() and enable() to see the changes.

Parameters
capability int: Input/Output capability of the device. One of IO_CAPABILITY_OUT, IO_CAPABILITY_IO, IO_CAPABILITY_IN, IO_CAPABILITY_NONE or IO_CAPABILITY_KBDISP.

Returns
boolean result of operation

Throws
IllegalArgumentException when capability is invalid.

setLeIoCapability

boolean setLeIoCapability (int capability)

Sets the Input/Output capability of the device for BLE operations.

Changing the Input/Output capability of a device only takes effect on restarting the Bluetooth stack. You would need to restart the stack using disable() and enable() to see the changes.

Parameters
capability int: Input/Output capability of the device. One of IO_CAPABILITY_OUT, IO_CAPABILITY_IO, IO_CAPABILITY_IN, IO_CAPABILITY_NONE or IO_CAPABILITY_KBDISP.

Returns
boolean result of operation

Throws
IllegalArgumentException when capability is invalid.