• 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 99. Profile-specific return values occupy the range 100-999.
24  * API-specific return values start at 1000. The exception to this is the "other" 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      * Zuser
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_ADVERTISE} permission
62      *
63      * @hide
64      */
65     public static final int ERROR_MISSING_BLUETOOTH_ADVERTISE_PERMISSION = 5;
66 
67     /**
68      * Error code indicating that the caller does not have the
69      * {@link android.Manifest.permission#BLUETOOTH_CONNECT} permission
70      */
71     public static final int ERROR_MISSING_BLUETOOTH_CONNECT_PERMISSION = 6;
72 
73     /**
74      * Error code indicating that the caller does not have the
75      * {@link android.Manifest.permission#BLUETOOTH_SCAN} permission
76      *
77      * @hide
78      */
79     public static final int ERROR_MISSING_BLUETOOTH_SCAN_PERMISSION = 7;
80 
81     /**
82      * If another application has already requested {@link OobData} then another fetch will be
83      * disallowed until the callback is removed.
84      *
85      * @hide
86      */
87     @SystemApi
88     public static final int ERROR_ANOTHER_ACTIVE_OOB_REQUEST = 1000;
89 
90     /**
91      * Indicates that the ACL disconnected due to an explicit request from the local device.
92      * <p>
93      * Example cause: This is a normal disconnect reason, e.g., user/app initiates
94      * disconnection.
95      *
96      * @hide
97      */
98     public static final int ERROR_DISCONNECT_REASON_LOCAL_REQUEST = 1100;
99 
100     /**
101      * Indicates that the ACL disconnected due to an explicit request from the remote device.
102      * <p>
103      * Example cause: This is a normal disconnect reason, e.g., user/app initiates
104      * disconnection.
105      * <p>
106      * Example solution: The app can also prompt the user to check their remote device.
107      *
108      * @hide
109      */
110     public static final int ERROR_DISCONNECT_REASON_REMOTE_REQUEST = 1101;
111 
112     /**
113      * Generic disconnect reason indicating the ACL disconnected due to an error on the local
114      * device.
115      * <p>
116      * Example solution: Prompt the user to check their local device (e.g., phone, car
117      * headunit).
118      *
119      * @hide
120      */
121     public static final int ERROR_DISCONNECT_REASON_LOCAL = 1102;
122 
123     /**
124      * Generic disconnect reason indicating the ACL disconnected due to an error on the remote
125      * device.
126      * <p>
127      * Example solution: Prompt the user to check their remote device (e.g., headset, car
128      * headunit, watch).
129      *
130      * @hide
131      */
132     public static final int ERROR_DISCONNECT_REASON_REMOTE = 1103;
133 
134     /**
135      * Indicates that the ACL disconnected due to a timeout.
136      * <p>
137      * Example cause: remote device might be out of range.
138      * <p>
139      * Example solution: Prompt user to verify their remote device is on or in
140      * connection/pairing mode.
141      *
142      * @hide
143      */
144     public static final int ERROR_DISCONNECT_REASON_TIMEOUT = 1104;
145 
146     /**
147      * Indicates that the ACL disconnected due to link key issues.
148      * <p>
149      * Example cause: Devices are either unpaired or remote device is refusing our pairing
150      * request.
151      * <p>
152      * Example solution: Prompt user to unpair and pair again.
153      *
154      * @hide
155      */
156     public static final int ERROR_DISCONNECT_REASON_SECURITY = 1105;
157 
158     /**
159      * Indicates that the ACL disconnected due to the local device's system policy.
160      * <p>
161      * Example cause: privacy policy, power management policy, permissions, etc.
162      * <p>
163      * Example solution: Prompt the user to check settings, or check with their system
164      * administrator (e.g. some corp-managed devices do not allow OPP connection).
165      *
166      * @hide
167      */
168     public static final int ERROR_DISCONNECT_REASON_SYSTEM_POLICY = 1106;
169 
170     /**
171      * Indicates that the ACL disconnected due to resource constraints, either on the local
172      * device or the remote device.
173      * <p>
174      * Example cause: controller is busy, memory limit reached, maximum number of connections
175      * reached.
176      * <p>
177      * Example solution: The app should wait and try again. If still failing, prompt the user
178      * to disconnect some devices, or toggle Bluetooth on the local and/or the remote device.
179      *
180      * @hide
181      */
182     public static final int ERROR_DISCONNECT_REASON_RESOURCE_LIMIT_REACHED = 1107;
183 
184     /**
185      * Indicates that the ACL disconnected because another ACL connection already exists.
186      *
187      * @hide
188      */
189     public static final int ERROR_DISCONNECT_REASON_CONNECTION_ALREADY_EXISTS = 1108;
190 
191     /**
192      * Indicates that the ACL disconnected due to incorrect parameters passed in from the app.
193      * <p>
194      * Example solution: Change parameters and try again. If error persists, the app can report
195      * telemetry and/or log the error in a bugreport.
196      *
197      * @hide
198      */
199     public static final int ERROR_DISCONNECT_REASON_BAD_PARAMETERS = 1109;
200 
201     /**
202      * Indicates that an unknown error has occurred has occurred.
203      */
204     public static final int ERROR_UNKNOWN = Integer.MAX_VALUE;
205 }
206