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