comboctl-base: Add exceptions for disabled and missing Bluetooth adapters
Signed-off-by: Carlos Rafael Giani <crg7475@mailbox.org>
This commit is contained in:
parent
fe1235dbe1
commit
72819cbc53
|
@ -23,3 +23,19 @@ open class BluetoothPermissionException(message: String?, cause: Throwable?) : B
|
|||
constructor(message: String) : this(message, null)
|
||||
constructor(cause: Throwable) : this(null, cause)
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception thrown when trying to use Bluetooth even though the adapter is not enabled.
|
||||
*
|
||||
* Note that unlike [BluetoothNotAvailableException], here, the adapter _does_ exist,
|
||||
* and is just currently turned off.
|
||||
*/
|
||||
open class BluetoothNotEnabledException : BluetoothException("Bluetooth is not enabled")
|
||||
|
||||
/**
|
||||
* Exception thrown when trying to use Bluetooth even though there no adapter available.
|
||||
*
|
||||
* "Not available" typically means that the platform has no Bluetooth hardware, or that
|
||||
* said hardware is inaccessible.
|
||||
*/
|
||||
open class BluetoothNotAvailableException : BluetoothException("Bluetooth is not available - there is no usable adapter")
|
|
@ -140,6 +140,10 @@ interface BluetoothInterface {
|
|||
* a Bluetooth subsystem that has been shut down.
|
||||
* @throws BluetoothPermissionException if discovery fails because
|
||||
* scanning and connection permissions are missing.
|
||||
* @throws BluetoothNotEnabledException if the system's
|
||||
* Bluetooth adapter is currently not enabled.
|
||||
* @throws BluetoothNotAvailableException if the system's
|
||||
* Bluetooth adapter is currently not available.
|
||||
* @throws BluetoothException if discovery fails due to an underlying
|
||||
* Bluetooth issue.
|
||||
*/
|
||||
|
@ -172,6 +176,10 @@ interface BluetoothInterface {
|
|||
*
|
||||
* @return BluetoothDevice instance for the device with the
|
||||
* given address
|
||||
* @throws BluetoothNotEnabledException if the system's
|
||||
* Bluetooth adapter is currently not enabled.
|
||||
* @throws BluetoothNotAvailableException if the system's
|
||||
* Bluetooth adapter is currently not available.
|
||||
* @throws IllegalStateException if the interface is in a state
|
||||
* in which accessing devices is not possible, such as
|
||||
* a Bluetooth subsystem that has been shut down.
|
||||
|
@ -183,6 +191,8 @@ interface BluetoothInterface {
|
|||
*
|
||||
* @throws BluetoothPermissionException if getting the adapter name
|
||||
* fails because connection permissions are missing.
|
||||
* @throws BluetoothNotAvailableException if the system's
|
||||
* Bluetooth adapter is currently not available.
|
||||
* @throws BluetoothException if getting the adapter name fails
|
||||
* due to an underlying Bluetooth issue.
|
||||
*/
|
||||
|
@ -205,6 +215,11 @@ interface BluetoothInterface {
|
|||
* round, it is possible that between the [getPairedDeviceAddresses]
|
||||
* call and the [onDeviceUnpaired] assignment, a device is
|
||||
* unpaired, and thus does not get noticed.
|
||||
*
|
||||
* @throws BluetoothNotEnabledException if the system's
|
||||
* Bluetooth adapter is currently not enabled.
|
||||
* @throws BluetoothNotAvailableException if the system's
|
||||
* Bluetooth adapter is currently not available.
|
||||
*/
|
||||
fun getPairedDeviceAddresses(): Set<BluetoothAddress>
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue