Added in API level 35

BrailleDisplayController


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
abstract

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

Public methods
abstract Unit

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

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

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

abstract Unit

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

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

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

abstract Unit

Disconnects from the currently connected Braille display.

abstract Boolean

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

abstract Unit
write(buffer: ByteArray)

Writes a HID report to the currently connected Braille display.

Public methods

connect

Added in API level 35
abstract fun connect(
    bluetoothDevice: BluetoothDevice,
    callback: BrailleDisplayController.BrailleDisplayCallback
): Unit

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 android.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.
Exceptions
java.lang.IllegalStateException if a Braille display is already connected to this controller.

connect

Added in API level 35
abstract fun connect(
    bluetoothDevice: BluetoothDevice,
    callbackExecutor: Executor,
    callback: BrailleDisplayController.BrailleDisplayCallback
): Unit

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 android.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.
Exceptions
java.lang.IllegalStateException if a Braille display is already connected to this controller.

connect

Added in API level 35
abstract fun connect(
    usbDevice: UsbDevice,
    callback: BrailleDisplayController.BrailleDisplayCallback
): Unit

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 android.hardware.usb.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.
Exceptions
java.lang.SecurityException if the caller does not have USB device approval.
java.lang.IllegalStateException if a Braille display is already connected to this controller.

connect

Added in API level 35
abstract fun connect(
    usbDevice: UsbDevice,
    callbackExecutor: Executor,
    callback: BrailleDisplayController.BrailleDisplayCallback
): Unit

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 android.hardware.usb.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.
Exceptions
java.lang.SecurityException if the caller does not have USB device approval.
java.lang.IllegalStateException if a Braille display is already connected to this controller.

disconnect

Added in API level 35
abstract fun disconnect(): Unit

Disconnects from the currently connected Braille display.

See Also

isConnected

Added in API level 35
abstract fun isConnected(): Boolean

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

See Also

    write

    Added in API level 35
    abstract fun write(buffer: ByteArray): Unit

    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 ByteArray: 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.
    Exceptions
    java.io.IOException if there is no currently connected Braille display.
    java.lang.IllegalArgumentException if the buffer exceeds the maximum safe payload size for binder transactions of IBinder.getSuggestedMaxIpcSizeBytes()