Added in API level 35

BrailleDisplayController


public interface BrailleDisplayController

android.accessibilityservice.BrailleDisplayController


Used to communicate with a Braille display that supports the Braille display HID standard (usage page 0x41).

Only one Braille display may be connected at a time.

Summary

Nested classes

interface BrailleDisplayController.BrailleDisplayCallback

Interface provided to BrailleDisplayController connection methods to receive callbacks from the system. 

Public methods

abstract void connect(BluetoothDevice bluetoothDevice, BrailleDisplayController.BrailleDisplayCallback callback)

Connects to the requested bluetooth Braille display using the Braille display HID standard (usage page 0x41).

abstract void connect(UsbDevice usbDevice, BrailleDisplayController.BrailleDisplayCallback callback)

Connects to the requested USB Braille display using the Braille display HID standard (usage page 0x41).

abstract void connect(BluetoothDevice bluetoothDevice, Executor callbackExecutor, BrailleDisplayController.BrailleDisplayCallback callback)

Connects to the requested bluetooth Braille display using the Braille display HID standard (usage page 0x41).

abstract void connect(UsbDevice usbDevice, Executor callbackExecutor, BrailleDisplayController.BrailleDisplayCallback callback)

Connects to the requested USB Braille display using the Braille display HID standard (usage page 0x41).

abstract void disconnect()

Disconnects from the currently connected Braille display.

abstract boolean isConnected()

Returns true if a Braille display is currently connected, otherwise false.

abstract void write(byte[] buffer)

Writes a HID report to the currently connected Braille display.

Public methods

connect

Added in API level 35
public abstract void connect (BluetoothDevice bluetoothDevice, 
                BrailleDisplayController.BrailleDisplayCallback callback)

Connects to the requested bluetooth Braille display using the Braille display HID standard (usage page 0x41).

If successful then the HID report descriptor will be provided to BrailleDisplayCallback.onConnected and the Braille display will start sending incoming input bytes to BrailleDisplayCallback.onInput. If there is an error in reading input then the system will disconnect the Braille display.

Note that the callbacks will be executed on the main thread using AccessibilityService.getMainExecutor(). To specify the execution thread, use connect(android.bluetooth.BluetoothDevice, java.util.concurrent.Executor, android.accessibilityservice.BrailleDisplayController.BrailleDisplayCallback).
Requires Manifest.permission.BLUETOOTH_CONNECT

Parameters
bluetoothDevice BluetoothDevice: The Braille display device. This value cannot be null.

callback BrailleDisplayController.BrailleDisplayCallback: Callbacks used to provide connection results. This value cannot be null.

Throws
IllegalStateException if a Braille display is already connected to this controller.

connect

Added in API level 35
public abstract void connect (UsbDevice usbDevice, 
                BrailleDisplayController.BrailleDisplayCallback callback)

Connects to the requested USB Braille display using the Braille display HID standard (usage page 0x41).

If successful then the HID report descriptor will be provided to BrailleDisplayCallback.onConnected and the Braille display will start sending incoming input bytes to BrailleDisplayCallback.onInput. If there is an error in reading input then the system will disconnect the Braille display.

The accessibility service app must already have approval to access the USB device from the standard UsbManager access approval process.

Note that the callbacks will be executed on the main thread using AccessibilityService.getMainExecutor(). To specify the execution thread, use connect(android.hardware.usb.UsbDevice, java.util.concurrent.Executor, android.accessibilityservice.BrailleDisplayController.BrailleDisplayCallback).

Parameters
usbDevice UsbDevice: The Braille display device. This value cannot be null.

callback BrailleDisplayController.BrailleDisplayCallback: Callbacks used to provide connection results. This value cannot be null.

Throws
SecurityException if the caller does not have USB device approval.
IllegalStateException if a Braille display is already connected to this controller.

connect

Added in API level 35
public abstract void connect (BluetoothDevice bluetoothDevice, 
                Executor callbackExecutor, 
                BrailleDisplayController.BrailleDisplayCallback callback)

Connects to the requested bluetooth Braille display using the Braille display HID standard (usage page 0x41).

If successful then the HID report descriptor will be provided to BrailleDisplayCallback.onConnected and the Braille display will start sending incoming input bytes to BrailleDisplayCallback.onInput. If there is an error in reading input then the system will disconnect the Braille display.
Requires Manifest.permission.BLUETOOTH_CONNECT

Parameters
bluetoothDevice BluetoothDevice: The Braille display device. This value cannot be null.

callbackExecutor Executor: Executor for executing the provided callbacks. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

callback BrailleDisplayController.BrailleDisplayCallback: Callbacks used to provide connection results. This value cannot be null.

Throws
IllegalStateException if a Braille display is already connected to this controller.

connect

Added in API level 35
public abstract void connect (UsbDevice usbDevice, 
                Executor callbackExecutor, 
                BrailleDisplayController.BrailleDisplayCallback callback)

Connects to the requested USB Braille display using the Braille display HID standard (usage page 0x41).

If successful then the HID report descriptor will be provided to BrailleDisplayCallback.onConnected and the Braille display will start sending incoming input bytes to BrailleDisplayCallback.onInput. If there is an error in reading input then the system will disconnect the Braille display.

The accessibility service app must already have approval to access the USB device from the standard UsbManager access approval process.

Parameters
usbDevice UsbDevice: The Braille display device. This value cannot be null.

callbackExecutor Executor: Executor for executing the provided callbacks. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.

callback BrailleDisplayController.BrailleDisplayCallback: Callbacks used to provide connection results. This value cannot be null.

Throws
SecurityException if the caller does not have USB device approval.
IllegalStateException if a Braille display is already connected to this controller.

disconnect

Added in API level 35
public abstract void disconnect ()

Disconnects from the currently connected Braille display.

See also:

isConnected

Added in API level 35
public abstract boolean isConnected ()

Returns true if a Braille display is currently connected, otherwise false.

Returns
boolean

write

Added in API level 35
public abstract void write (byte[] buffer)

Writes a HID report to the currently connected Braille display.

This method returns immediately after dispatching the write request to the system. If the system experiences an error in writing output (e.g. the Braille display is unplugged after the system receives the write request but before writing the bytes to the Braille display) then the system will disconnect the Braille display, which calls BrailleDisplayCallback.onDisconnected().

Parameters
buffer byte: The bytes to write to the Braille display. These bytes should be formatted according to the HID report descriptor and the HIDRAW kernel driver. This value cannot be null.

Throws
IOException if there is no currently connected Braille display.
IllegalArgumentException if the buffer exceeds the maximum safe payload size for binder transactions of IBinder.getSuggestedMaxIpcSizeBytes()