1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.bluetooth; 18 19 import android.annotation.SystemApi; 20 21 /** 22 * A class with constants representing possible return values for Bluetooth APIs. General return 23 * values occupy the range 0 to 199. Profile-specific return values occupy the range 200-999. 24 * API-specific return values start at 1000. The exception to this is the "UNKNOWN" error code which 25 * occupies the max integer value. 26 */ 27 public final class BluetoothStatusCodes { BluetoothStatusCodes()28 private BluetoothStatusCodes() {} 29 30 /** Indicates that the API call was successful. */ 31 public static final int SUCCESS = 0; 32 33 /** Error code indicating that Bluetooth is not enabled. */ 34 public static final int ERROR_BLUETOOTH_NOT_ENABLED = 1; 35 36 /** 37 * Error code indicating that the API call was initiated by neither the system nor the active 38 * user. 39 */ 40 public static final int ERROR_BLUETOOTH_NOT_ALLOWED = 2; 41 42 /** Error code indicating that the Bluetooth Device specified is not bonded. */ 43 public static final int ERROR_DEVICE_NOT_BONDED = 3; 44 45 /** 46 * Error code indicating that the Bluetooth Device specified is not connected, but is bonded. 47 * 48 * @hide 49 */ 50 public static final int ERROR_DEVICE_NOT_CONNECTED = 4; 51 52 /** 53 * Error code indicating that the caller does not have the {@link 54 * android.Manifest.permission#BLUETOOTH_CONNECT} permission. 55 */ 56 public static final int ERROR_MISSING_BLUETOOTH_CONNECT_PERMISSION = 6; 57 58 /** 59 * Error code indicating that the caller does not have the {@link 60 * android.Manifest.permission#BLUETOOTH_SCAN} permission. 61 * 62 * @hide 63 */ 64 public static final int ERROR_MISSING_BLUETOOTH_SCAN_PERMISSION = 7; 65 66 /** 67 * Error code indicating that the profile service is not bound. You can bind a profile service 68 * by calling {@link BluetoothAdapter#getProfileProxy}. 69 */ 70 public static final int ERROR_PROFILE_SERVICE_NOT_BOUND = 9; 71 72 /** Indicates that the feature is supported. */ 73 public static final int FEATURE_SUPPORTED = 10; 74 75 /** Indicates that the feature is not supported. */ 76 public static final int FEATURE_NOT_SUPPORTED = 11; 77 78 /** 79 * Error code indicating that the device is not the active device for this profile. 80 * 81 * @hide 82 */ 83 @SystemApi public static final int ERROR_NOT_ACTIVE_DEVICE = 12; 84 85 /** 86 * Error code indicating that there are no active devices for the profile. 87 * 88 * @hide 89 */ 90 @SystemApi public static final int ERROR_NO_ACTIVE_DEVICES = 13; 91 92 /** 93 * Indicates that the Bluetooth profile is not connected to this device. 94 * 95 * @hide 96 */ 97 @SystemApi public static final int ERROR_PROFILE_NOT_CONNECTED = 14; 98 99 /** 100 * Error code indicating that the requested operation timed out. 101 * 102 * @hide 103 */ 104 @SystemApi public static final int ERROR_TIMEOUT = 15; 105 106 /** 107 * Indicates that some local application caused the event. 108 * 109 * @hide 110 */ 111 @SystemApi public static final int REASON_LOCAL_APP_REQUEST = 16; 112 113 /** 114 * Indicate that this change was initiated by the Bluetooth implementation on this device 115 * 116 * @hide 117 */ 118 @SystemApi public static final int REASON_LOCAL_STACK_REQUEST = 17; 119 120 /** 121 * Indicate that this change was initiated by the remote device. 122 * 123 * @hide 124 */ 125 @SystemApi public static final int REASON_REMOTE_REQUEST = 18; 126 127 /** 128 * Indicates that the local system policy caused the change, such as privacy policy, power 129 * management policy, permission changes, and more. 130 * 131 * @hide 132 */ 133 @SystemApi public static final int REASON_SYSTEM_POLICY = 19; 134 135 /** 136 * Indicates that an underlying hardware incurred some error maybe try again later or toggle the 137 * hardware state. 138 * 139 * @hide 140 */ 141 @SystemApi public static final int ERROR_HARDWARE_GENERIC = 20; 142 143 /** 144 * Indicates that the operation failed due to bad API input parameter that is not covered by 145 * other more detailed error code 146 * 147 * @hide 148 */ 149 @SystemApi public static final int ERROR_BAD_PARAMETERS = 21; 150 151 /** 152 * Indicate that there is not enough local resource to perform the requested operation 153 * 154 * @hide 155 */ 156 @SystemApi public static final int ERROR_LOCAL_NOT_ENOUGH_RESOURCES = 22; 157 158 /** 159 * Indicate that a remote device does not have enough resource to perform the requested 160 * operation 161 * 162 * @hide 163 */ 164 @SystemApi public static final int ERROR_REMOTE_NOT_ENOUGH_RESOURCES = 23; 165 166 /** 167 * Indicates that the remote rejected this operation for reasons not covered above 168 * 169 * @hide 170 */ 171 @SystemApi public static final int ERROR_REMOTE_OPERATION_REJECTED = 24; 172 173 /** 174 * Indicates that there is an underlying link error between the local and remote devices. 175 * 176 * <p>Maybe try again later or disconnect and retry. 177 * 178 * @hide 179 */ 180 @SystemApi public static final int ERROR_REMOTE_LINK_ERROR = 25; 181 182 /** 183 * A generic error code to indicate that the system is already in a target state that an API 184 * tries to request. 185 * 186 * <p>For example, this error code will be delivered if someone tries to stop scanning when scan 187 * has already stopped, or start scanning when scan has already started. 188 * 189 * @hide 190 */ 191 @SystemApi public static final int ERROR_ALREADY_IN_TARGET_STATE = 26; 192 193 /** 194 * Indicates that the requested operation is not supported by the remote device 195 * 196 * <p>Caller should stop trying this operation 197 * 198 * @hide 199 */ 200 @SystemApi public static final int ERROR_REMOTE_OPERATION_NOT_SUPPORTED = 27; 201 202 /** 203 * Indicates that the callback is not registered and therefore, this operation is not allowed. 204 * 205 * @hide 206 */ 207 @SystemApi public static final int ERROR_CALLBACK_NOT_REGISTERED = 28; 208 209 /** 210 * Indicates that there is another active request and therefore, this operation is not allowed. 211 * 212 * @hide 213 */ 214 @SystemApi public static final int ERROR_ANOTHER_ACTIVE_REQUEST = 29; 215 216 /** Indicates that the feature status is not configured yet. */ 217 public static final int FEATURE_NOT_CONFIGURED = 30; 218 219 /** A GATT writeCharacteristic request is not permitted on the remote device. */ 220 public static final int ERROR_GATT_WRITE_NOT_ALLOWED = 200; 221 222 /** A GATT writeCharacteristic request is issued to a busy remote device. */ 223 public static final int ERROR_GATT_WRITE_REQUEST_BUSY = 201; 224 225 /** 226 * Indicates that the operation is allowed. 227 * 228 * @hide 229 */ 230 @SystemApi public static final int ALLOWED = 400; 231 232 /** 233 * Indicates that the operation is not allowed. 234 * 235 * @hide 236 */ 237 @SystemApi public static final int NOT_ALLOWED = 401; 238 239 /** 240 * If another application has already requested {@link OobData} then another fetch will be 241 * disallowed until the callback is removed. 242 * 243 * @hide 244 */ 245 @SystemApi public static final int ERROR_ANOTHER_ACTIVE_OOB_REQUEST = 1000; 246 247 /** 248 * Indicates that the ACL disconnected due to an explicit request from the local device. 249 * 250 * <p>Example cause: This is a normal disconnect reason, e.g., user/app initiates disconnection. 251 * 252 * @hide 253 */ 254 public static final int ERROR_DISCONNECT_REASON_LOCAL_REQUEST = 1100; 255 256 /** 257 * Indicates that the ACL disconnected due to an explicit request from the remote device. 258 * 259 * <p>Example cause: This is a normal disconnect reason, e.g., user/app initiates disconnection. 260 * 261 * <p>Example solution: The app can also prompt the user to check their remote device. 262 * 263 * @hide 264 */ 265 public static final int ERROR_DISCONNECT_REASON_REMOTE_REQUEST = 1101; 266 267 /** 268 * Generic disconnect reason indicating the ACL disconnected due to an error on the local 269 * device. 270 * 271 * <p>Example solution: Prompt the user to check their local device (e.g., phone, car headunit). 272 * 273 * @hide 274 */ 275 public static final int ERROR_DISCONNECT_REASON_LOCAL = 1102; 276 277 /** 278 * Generic disconnect reason indicating the ACL disconnected due to an error on the remote 279 * device. 280 * 281 * <p>Example solution: Prompt the user to check their remote device (e.g., headset, car 282 * headunit, watch). 283 * 284 * @hide 285 */ 286 public static final int ERROR_DISCONNECT_REASON_REMOTE = 1103; 287 288 /** 289 * Indicates that the ACL disconnected due to a timeout. 290 * 291 * <p>Example cause: remote device might be out of range. 292 * 293 * <p>Example solution: Prompt user to verify their remote device is on or in connection/pairing 294 * mode. 295 * 296 * @hide 297 */ 298 public static final int ERROR_DISCONNECT_REASON_TIMEOUT = 1104; 299 300 /** 301 * Indicates that the ACL disconnected due to link key issues. 302 * 303 * <p>Example cause: Devices are either unpaired or remote device is refusing our pairing 304 * request. 305 * 306 * <p>Example solution: Prompt user to unpair and pair again. 307 * 308 * @hide 309 */ 310 public static final int ERROR_DISCONNECT_REASON_SECURITY = 1105; 311 312 /** 313 * Indicates that the ACL disconnected due to the local device's system policy. 314 * 315 * <p>Example cause: privacy policy, power management policy, permissions, etc. 316 * 317 * <p>Example solution: Prompt the user to check settings, or check with their system 318 * administrator (e.g. some corp-managed devices do not allow OPP connection). 319 * 320 * @hide 321 */ 322 public static final int ERROR_DISCONNECT_REASON_SYSTEM_POLICY = 1106; 323 324 /** 325 * Indicates that the ACL disconnected due to resource constraints, either on the local device 326 * or the remote device. 327 * 328 * <p>Example cause: controller is busy, memory limit reached, maximum number of connections 329 * reached. 330 * 331 * <p>Example solution: The app should wait and try again. If still failing, prompt the user to 332 * disconnect some devices, or toggle Bluetooth on the local and/or the remote device. 333 * 334 * @hide 335 */ 336 public static final int ERROR_DISCONNECT_REASON_RESOURCE_LIMIT_REACHED = 1107; 337 338 /** 339 * Indicates that the ACL disconnected because another ACL connection already exists. 340 * 341 * @hide 342 */ 343 public static final int ERROR_DISCONNECT_REASON_CONNECTION_ALREADY_EXISTS = 1108; 344 345 /** 346 * Indicates that the ACL disconnected due to incorrect parameters passed in from the app. 347 * 348 * <p>Example solution: Change parameters and try again. If error persists, the app can report 349 * telemetry and/or log the error in a bugreport. 350 * 351 * @hide 352 */ 353 public static final int ERROR_DISCONNECT_REASON_BAD_PARAMETERS = 1109; 354 355 /** 356 * Indicates that there is already one device for which SCO audio is connected or connecting. 357 * 358 * @hide 359 */ 360 @SystemApi public static final int ERROR_AUDIO_DEVICE_ALREADY_CONNECTED = 1116; 361 362 /** 363 * Indicates that SCO audio was already not connected for this device. 364 * 365 * @hide 366 */ 367 @SystemApi public static final int ERROR_AUDIO_DEVICE_ALREADY_DISCONNECTED = 1117; 368 369 /** 370 * Indicates that there audio route is currently blocked by the system. 371 * 372 * @hide 373 */ 374 @SystemApi public static final int ERROR_AUDIO_ROUTE_BLOCKED = 1118; 375 376 /** 377 * Indicates that there is an active call preventing this operation from succeeding. 378 * 379 * @hide 380 */ 381 @SystemApi public static final int ERROR_CALL_ACTIVE = 1119; 382 383 // LE audio related return codes reserved from 1200 to 1300 384 385 /** 386 * Indicates that the broadcast ID cannot be found among existing Broadcast Sources. 387 * 388 * @hide 389 */ 390 @SystemApi public static final int ERROR_LE_BROADCAST_INVALID_BROADCAST_ID = 1200; 391 392 /** 393 * Indicates that encryption code entered does not meet the specification requirement 394 * 395 * @hide 396 */ 397 @SystemApi public static final int ERROR_LE_BROADCAST_INVALID_CODE = 1201; 398 399 /** 400 * Indicates that the source ID cannot be found in the given Broadcast sink device 401 * 402 * @hide 403 */ 404 @SystemApi public static final int ERROR_LE_BROADCAST_ASSISTANT_INVALID_SOURCE_ID = 1202; 405 406 /** 407 * Indicates that the same Broadcast Source is already added to the Broadcast Sink 408 * 409 * <p>Broadcast Source is identified by their advertising SID and broadcast ID 410 * 411 * @hide 412 */ 413 @SystemApi public static final int ERROR_LE_BROADCAST_ASSISTANT_DUPLICATE_ADDITION = 1203; 414 415 /** 416 * Indicates that the program info in a {@link BluetoothLeAudioContentMetadata} is not valid 417 * 418 * @hide 419 */ 420 @SystemApi public static final int ERROR_LE_CONTENT_METADATA_INVALID_PROGRAM_INFO = 1204; 421 422 /** 423 * Indicates that the language code in a {@link BluetoothLeAudioContentMetadata} is not valid 424 * 425 * @hide 426 */ 427 @SystemApi public static final int ERROR_LE_CONTENT_METADATA_INVALID_LANGUAGE = 1205; 428 429 /** 430 * Indicates that operation failed due to other {@link BluetoothLeAudioContentMetadata} related 431 * issues not covered by other reason codes. 432 * 433 * @hide 434 */ 435 @SystemApi public static final int ERROR_LE_CONTENT_METADATA_INVALID_OTHER = 1206; 436 437 /** 438 * Indicates that provided group ID is invalid for the coordinated set 439 * 440 * @hide 441 */ 442 @SystemApi public static final int ERROR_CSIP_INVALID_GROUP_ID = 1207; 443 444 /** 445 * Indicating that CSIP group locked failed due to group member being already locked. 446 * 447 * @hide 448 */ 449 @SystemApi public static final int ERROR_CSIP_GROUP_LOCKED_BY_OTHER = 1208; 450 451 /** 452 * Indicating that CSIP device has been lost while being locked. 453 * 454 * @hide 455 */ 456 @SystemApi public static final int ERROR_CSIP_LOCKED_GROUP_MEMBER_LOST = 1209; 457 458 /** 459 * Indicates that the set preset name is too long. 460 * 461 * <p>Example solution: Try using shorter name. 462 * 463 * @hide 464 */ 465 @SystemApi public static final int ERROR_HAP_PRESET_NAME_TOO_LONG = 1210; 466 467 /** 468 * Indicates that provided preset index parameters is invalid 469 * 470 * <p>Example solution: Use preset index of a known existing preset. 471 * 472 * @hide 473 */ 474 @SystemApi public static final int ERROR_HAP_INVALID_PRESET_INDEX = 1211; 475 476 /** 477 * Indicates that LE connection is required but not exist or disconnected. 478 * 479 * <p>Example solution: create LE connection then retry again. 480 * 481 * @hide 482 */ 483 @SystemApi public static final int ERROR_NO_LE_CONNECTION = 1300; 484 485 /** 486 * Indicates internal error of distance measurement, such as read RSSI data fail. 487 * 488 * @hide 489 */ 490 @SystemApi public static final int ERROR_DISTANCE_MEASUREMENT_INTERNAL = 1301; 491 492 /** 493 * Indicates that the RFCOMM listener could not be started due to the requested UUID already 494 * being in use. 495 * 496 * @hide 497 */ 498 @SystemApi public static final int RFCOMM_LISTENER_START_FAILED_UUID_IN_USE = 2000; 499 500 /** 501 * Indicates that the operation could not be competed because the service record on which the 502 * operation was requested on does not exist. 503 * 504 * @hide 505 */ 506 @SystemApi 507 public static final int RFCOMM_LISTENER_OPERATION_FAILED_NO_MATCHING_SERVICE_RECORD = 2001; 508 509 /** 510 * Indicates that the operation could not be completed because the application requesting the 511 * operation on the RFCOMM listener was not the one which registered it. 512 * 513 * @hide 514 */ 515 @SystemApi public static final int RFCOMM_LISTENER_OPERATION_FAILED_DIFFERENT_APP = 2002; 516 517 /** 518 * Indicates that the creation of the underlying BluetoothServerSocket failed. 519 * 520 * @hide 521 */ 522 @SystemApi public static final int RFCOMM_LISTENER_FAILED_TO_CREATE_SERVER_SOCKET = 2003; 523 524 /** 525 * Indicates that closing the underlying BluetoothServerSocket failed. 526 * 527 * @hide 528 */ 529 @SystemApi public static final int RFCOMM_LISTENER_FAILED_TO_CLOSE_SERVER_SOCKET = 2004; 530 531 /** 532 * Indicates that there is no socket available to retrieve from the given listener. 533 * 534 * @hide 535 */ 536 @SystemApi public static final int RFCOMM_LISTENER_NO_SOCKET_AVAILABLE = 2005; 537 538 /** 539 * Error code indicating that this operation is not allowed because the remote device does not 540 * support both BR/EDR audio and BLE Audio. 541 * 542 * @hide 543 */ 544 @SystemApi public static final int ERROR_NOT_DUAL_MODE_AUDIO_DEVICE = 3000; 545 546 /** Indicates that an unknown error has occurred. */ 547 public static final int ERROR_UNKNOWN = Integer.MAX_VALUE; 548 } 549