From a014314c9490a18fd4b900302d873206df09a3e0 Mon Sep 17 00:00:00 2001 From: Jack He Date: Wed, 15 Dec 2021 15:40:34 -0800 Subject: Introduce LE audio broadcast system APIs * Rename BluetoothLeBroadcastSourceInfo to BluetoothLeBroadcastReceiveState so that it matches the name in the Bluetooth specification * Added callbacks to BluetoothLeBroadcast so that caller that wait for asynchronouze operations with reason code in the hope to reduce potential race conditions * Allow multiple broadcast to be set up on the same deivce if the device supports it * Added ScanFilter to searchForSources() method and removed selectSources() method for BluetoothLeBroadcastAssistant so that the Bluetooth stack can automatically handle periodic sync after a Broadcast source is found and only do this for a limited number of devices * Added structural APIs to store Broadcast Source and Group information * Added unknown address type in BluetoothDevice Bug: 208222281 Test: make Tag: #feature Ignore-AOSP-First: Merge conflict in master Change-Id: If4c3af658b5bc1283d76e5d1899485a487ab7626 Merged-In: If4c3af658b5bc1283d76e5d1899485a487ab7626 (cherry picked from commit 4f9d902028fbe271167547884c33fb9ec7601080) --- .../android/bluetooth/BluetoothStatusCodes.java | 155 ++++++++++++++++----- 1 file changed, 119 insertions(+), 36 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothStatusCodes.java') diff --git a/framework/java/android/bluetooth/BluetoothStatusCodes.java b/framework/java/android/bluetooth/BluetoothStatusCodes.java index 0425220c8d..5f90d7ed48 100644 --- a/framework/java/android/bluetooth/BluetoothStatusCodes.java +++ b/framework/java/android/bluetooth/BluetoothStatusCodes.java @@ -103,6 +103,94 @@ public final class BluetoothStatusCodes { @SystemApi public static final int ERROR_TIMEOUT = 15; + /** + * Indicates that some local application caused the event. + * @hide + */ + @SystemApi + public static final int REASON_LOCAL_APP_REQUEST = 16; + + /** + * Indicate that this change was initiated by the Bluetooth implementation on this device + * @hide + */ + @SystemApi + public static final int REASON_LOCAL_STACK_REQUEST = 17; + + /** + * Indicate that this change was initiated by the remote device. + * @hide + */ + @SystemApi + public static final int REASON_REMOTE_REQUEST = 18; + + /** + * Indicates that the local system policy caused the change, such as privacy policy, power + * management policy, permission changes, and more. + * @hide + */ + @SystemApi + public static final int REASON_SYSTEM_POLICY = 19; + + /** + * Indicates that an underlying hardware incurred some error maybe try again later or toggle + * the hardware state. + * @hide + */ + @SystemApi + public static final int ERROR_HARDWARE_GENERIC = 20; + + /** + * Indicates that the operation failed due to bad API input parameter that is not covered + * by other more detailed error code + * @hide + */ + @SystemApi + public static final int ERROR_BAD_PARAMETERS = 21; + + /** + * Indicate that there is not enough local resource to perform the requested operation + * @hide + */ + @SystemApi + public static final int ERROR_LOCAL_NOT_ENOUGH_RESOURCES = 22; + + /** + * Indicate that a remote device does not have enough resource to perform the requested + * operation + * @hide + */ + @SystemApi + public static final int ERROR_REMOTE_NOT_ENOUGH_RESOURCES = 23; + + /** + * Indicates that the remote rejected this operation for reasons not covered above + * @hide + */ + @SystemApi + public static final int ERROR_REMOTE_OPERATION_REJECTED = 24; + + /** + * Indicates that there is an underlying link error between the local and remote devices. + * + * Maybe try again later or disconnect and retry. + * @hide + */ + @SystemApi + public static final int ERROR_REMOTE_LINK_ERROR = 25; + + /** + * A generic error code to indicate that the system is already in a target state that an API + * tries to request. + * + * For example, this error code will be delivered if someone tries to stop scanning when + * scan has already stopped, or start scanning when scan has already started. + * + * @hide + */ + @SystemApi + public static final int ERROR_ALREADY_IN_TARGET_STATE = 26; + /** * A GATT writeCharacteristic request is not permitted on the remote device. */ @@ -249,65 +337,60 @@ public final class BluetoothStatusCodes { */ public static final int ERROR_DISCONNECT_REASON_BAD_PARAMETERS = 1109; + // LE audio related return codes reserved from 1200 to 1300 + /** - * Indicates that setting the LE Audio Broadcast mode failed. - *

- * Example solution: Change parameters and try again. If error persists, the app can report - * telemetry and/or log the error in a bugreport. - * + * Indicates that the broadcast ID cannot be found among existing Broadcast Sources. * @hide */ - public static final int ERROR_LE_AUDIO_BROADCAST_SOURCE_SET_BROADCAST_MODE_FAILED = 1110; + @SystemApi + public static final int ERROR_LE_BROADCAST_INVALID_BROADCAST_ID = 1200; /** - * Indicates that setting a new encryption key for Bluetooth LE Audio Broadcast Source failed. - *

- * Example solution: Change parameters and try again. If error persists, the app can report - * telemetry and/or log the error in a bugreport. - * + * Indicates that encryption code entered does not meet the specification requirement * @hide */ - public static final int ERROR_LE_AUDIO_BROADCAST_SOURCE_SET_ENCRYPTION_KEY_FAILED = 1111; + @SystemApi + public static final int ERROR_LE_BROADCAST_INVALID_CODE = 1201; /** - * Indicates that connecting to a remote Broadcast Audio Scan Service failed. - *

- * Example solution: Change parameters and try again. If error persists, the app can report - * telemetry and/or log the error in a bugreport. - * + * Indicates that the source ID cannot be found in the given Broadcast sink device * @hide */ - public static final int ERROR_LE_AUDIO_BROADCAST_AUDIO_SCAN_SERVICE_CONNECT_FAILED = 1112; + @SystemApi + public static final int ERROR_LE_BROADCAST_ASSISTANT_INVALID_SOURCE_ID = 1202; /** - * Indicates that disconnecting from a remote Broadcast Audio Scan Service failed. - *

- * Example solution: Change parameters and try again. If error persists, the app can report - * telemetry and/or log the error in a bugreport. + * Indicates that the same Broadcast Source is already added to the Broadcast Sink * + * Broadcast Source is identified by their advertising SID and broadcast ID * @hide */ - public static final int ERROR_LE_AUDIO_BROADCAST_AUDIO_SCAN_SERVICE_DISCONNECT_FAILED = 1113; + @SystemApi + public static final int ERROR_LE_BROADCAST_ASSISTANT_DUPLICATE_ADDITION = 1203; + /** - * Indicates that enabling LE Audio Broadcast encryption failed - *

- * Example solution: Change parameters and try again. If error persists, the app can report - * telemetry and/or log the error in a bugreport. - * + * Indicates that the program info in a {@link BluetoothLeAudioContentMetadata} is not valid * @hide */ - public static final int ERROR_LE_AUDIO_BROADCAST_SOURCE_ENABLE_ENCRYPTION_FAILED = 1114; + @SystemApi + public static final int ERROR_LE_CONTENT_METADATA_INVALID_PROGRAM_INFO = 1204; /** - * Indicates that disabling LE Audio Broadcast encryption failed - *

- * Example solution: Change parameters and try again. If error persists, the app can report - * telemetry and/or log the error in a bugreport. - * + * Indicates that the language code in a {@link BluetoothLeAudioContentMetadata} is not valid * @hide */ - public static final int ERROR_LE_AUDIO_BROADCAST_SOURCE_DISABLE_ENCRYPTION_FAILED = 1115; + @SystemApi + public static final int ERROR_LE_CONTENT_METADATA_INVALID_LANGUAGE = 1205; + + /** + * Indicates that operation failed due to other {@link BluetoothLeAudioContentMetadata} related + * issues not covered by other reason codes. + * @hide + */ + @SystemApi + public static final int ERROR_LE_CONTENT_METADATA_INVALID_OTHER = 1206; /** * Indicates that the RFCOMM listener could not be started due to the requested UUID already @@ -361,7 +444,7 @@ public final class BluetoothStatusCodes { public static final int RFCOMM_LISTENER_NO_SOCKET_AVAILABLE = 2005; /** - * Indicates that an unknown error has occurred has occurred. + * Indicates that an unknown error has occurred. */ public static final int ERROR_UNKNOWN = Integer.MAX_VALUE; } -- cgit v1.2.3