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