blob: 20d95ccc38356ca28a2d0e2eb2065eb5d6386a55 [file] [log] [blame]
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -07001/*
Hemant Gupta7aca90f2013-08-19 19:03:51 +05302 * Copyright (C) 2010-2014 The Android Open Source Project
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -07003 *
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
18package android.bluetooth;
19
Tor Norbye2d497522015-04-23 17:10:21 -070020import android.Manifest;
21import android.annotation.RequiresPermission;
22
Jaikumar Ganesh03cd78c2010-10-18 16:41:53 -070023import java.util.List;
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -070024
25/**
26 * Public APIs for the Bluetooth Profiles.
27 *
28 * <p> Clients should call {@link BluetoothAdapter#getProfileProxy},
29 * to get the Profile Proxy. Each public profile implements this
30 * interface.
31 */
32public interface BluetoothProfile {
33
34 /**
35 * Extra for the connection state intents of the individual profiles.
36 *
37 * This extra represents the current connection state of the profile of the
38 * Bluetooth device.
39 */
40 public static final String EXTRA_STATE = "android.bluetooth.profile.extra.STATE";
41
42 /**
43 * Extra for the connection state intents of the individual profiles.
44 *
45 * This extra represents the previous connection state of the profile of the
46 * Bluetooth device.
47 */
48 public static final String EXTRA_PREVIOUS_STATE =
49 "android.bluetooth.profile.extra.PREVIOUS_STATE";
50
51 /** The profile is in disconnected state */
52 public static final int STATE_DISCONNECTED = 0;
53 /** The profile is in connecting state */
54 public static final int STATE_CONNECTING = 1;
55 /** The profile is in connected state */
56 public static final int STATE_CONNECTED = 2;
57 /** The profile is in disconnecting state */
58 public static final int STATE_DISCONNECTING = 3;
59
60 /**
61 * Headset and Handsfree profile
62 */
63 public static final int HEADSET = 1;
Jaikumar Ganesh74ef1192011-02-23 10:22:15 -080064
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -070065 /**
66 * A2DP profile.
67 */
68 public static final int A2DP = 2;
Jaikumar Ganesh74ef1192011-02-23 10:22:15 -080069
Jaikumar Ganesh4ab0e772011-02-18 14:52:32 -080070 /**
Jaikumar Ganesh2ea1e852011-04-01 16:33:09 -070071 * Health Profile
Jaikumar Ganesh2ea1e852011-04-01 16:33:09 -070072 */
73 public static final int HEALTH = 3;
74
75 /**
Jaikumar Ganesh4ab0e772011-02-18 14:52:32 -080076 * Input Device Profile
77 * @hide
78 */
Jaikumar Ganesh2ea1e852011-04-01 16:33:09 -070079 public static final int INPUT_DEVICE = 4;
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -070080
81 /**
Jaikumar Ganesh74ef1192011-02-23 10:22:15 -080082 * PAN Profile
83 * @hide
84 */
Jaikumar Ganesh2ea1e852011-04-01 16:33:09 -070085 public static final int PAN = 5;
Jaikumar Ganesh74ef1192011-02-23 10:22:15 -080086
87 /**
Jaikumar Ganeshcb1d3542011-08-19 10:26:32 -070088 * PBAP
89 * @hide
90 */
91 public static final int PBAP = 6;
92
93 /**
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080094 * GATT
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -080095 */
96 static public final int GATT = 7;
97
98 /**
99 * GATT_SERVER
Ganesh Ganapathi Batta99081122013-02-05 15:28:33 -0800100 */
101 static public final int GATT_SERVER = 8;
102
103 /**
Matthew Xiefe3807a2013-07-18 17:31:50 -0700104 * MAP Profile
105 * @hide
106 */
107 public static final int MAP = 9;
108
Casper Bonde2a5f6082015-03-19 10:36:45 +0100109 /*
110 * SAP Profile
111 * @hide
112 */
113 public static final int SAP = 10;
114
Matthew Xiefe3807a2013-07-18 17:31:50 -0700115 /**
Mike Lockwood0a40ec22014-05-21 10:08:50 -0700116 * A2DP Sink Profile
117 * @hide
118 */
Casper Bonde2a5f6082015-03-19 10:36:45 +0100119 public static final int A2DP_SINK = 11;
Mike Lockwood0a40ec22014-05-21 10:08:50 -0700120
121 /**
Mike Lockwood94b59de2014-06-02 16:20:37 -0700122 * AVRCP Controller Profile
123 * @hide
124 */
Casper Bonde2a5f6082015-03-19 10:36:45 +0100125 public static final int AVRCP_CONTROLLER = 12;
Mike Lockwood94b59de2014-06-02 16:20:37 -0700126
127 /**
Mike Lockwoodcf916d32014-06-12 11:23:40 -0700128 * Headset Client - HFP HF Role
Hemant Gupta7aca90f2013-08-19 19:03:51 +0530129 * @hide
130 */
Mike Lockwoodcf916d32014-06-12 11:23:40 -0700131 public static final int HEADSET_CLIENT = 16;
Hemant Gupta7aca90f2013-08-19 19:03:51 +0530132
133 /**
Joseph Pirozzocfa8a642016-03-04 13:02:54 -0800134 * PBAP Client
135 * @hide
136 */
137 public static final int PBAP_CLIENT = 17;
138
139 /**
Bryce Leeb1301fa2016-10-09 12:54:42 -0700140 * Max profile ID. This value should be updated whenever a new profile is added to match
141 * the largest value assigned to a profile.
142 * @hide
143 */
144 public static final int MAX_PROFILE_ID = 17;
145
146 /**
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700147 * Default priority for devices that we try to auto-connect to and
148 * and allow incoming connections for the profile
149 * @hide
150 **/
151 public static final int PRIORITY_AUTO_CONNECT = 1000;
152
153 /**
154 * Default priority for devices that allow incoming
155 * and outgoing connections for the profile
156 * @hide
157 **/
158 public static final int PRIORITY_ON = 100;
159
160 /**
161 * Default priority for devices that does not allow incoming
162 * connections and outgoing connections for the profile.
163 * @hide
164 **/
165 public static final int PRIORITY_OFF = 0;
166
167 /**
168 * Default priority when not set or when the device is unpaired
169 * @hide
170 * */
171 public static final int PRIORITY_UNDEFINED = -1;
172
173 /**
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700174 * Get connected devices for this specific profile.
175 *
176 * <p> Return the set of devices which are in state {@link #STATE_CONNECTED}
177 *
Jaikumar Ganeshc8fa4ff2011-01-25 16:03:13 -0800178 * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700179 *
Jaikumar Ganesh03cd78c2010-10-18 16:41:53 -0700180 * @return List of devices. The list will be empty on error.
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700181 */
Tor Norbye2d497522015-04-23 17:10:21 -0700182 @RequiresPermission(Manifest.permission.BLUETOOTH)
Jaikumar Ganesh03cd78c2010-10-18 16:41:53 -0700183 public List<BluetoothDevice> getConnectedDevices();
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700184
185 /**
Jaikumar Ganeshc8fa4ff2011-01-25 16:03:13 -0800186 * Get a list of devices that match any of the given connection
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700187 * states.
188 *
Jaikumar Ganeshc8fa4ff2011-01-25 16:03:13 -0800189 * <p> If none of the devices match any of the given states,
190 * an empty list will be returned.
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700191 *
Jaikumar Ganeshc8fa4ff2011-01-25 16:03:13 -0800192 * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700193 *
194 * @param states Array of states. States can be one of
195 * {@link #STATE_CONNECTED}, {@link #STATE_CONNECTING},
196 * {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING},
Jaikumar Ganesh03cd78c2010-10-18 16:41:53 -0700197 * @return List of devices. The list will be empty on error.
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700198 */
Tor Norbye2d497522015-04-23 17:10:21 -0700199 @RequiresPermission(Manifest.permission.BLUETOOTH)
Jaikumar Ganesh03cd78c2010-10-18 16:41:53 -0700200 public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states);
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700201
202 /**
203 * Get the current connection state of the profile
204 *
Jaikumar Ganeshc8fa4ff2011-01-25 16:03:13 -0800205 * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700206 *
207 * @param device Remote bluetooth device.
208 * @return State of the profile connection. One of
209 * {@link #STATE_CONNECTED}, {@link #STATE_CONNECTING},
210 * {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING}
211 */
Tor Norbye2d497522015-04-23 17:10:21 -0700212 @RequiresPermission(Manifest.permission.BLUETOOTH)
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700213 public int getConnectionState(BluetoothDevice device);
214
215 /**
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700216 * An interface for notifying BluetoothProfile IPC clients when they have
217 * been connected or disconnected to the service.
218 */
219 public interface ServiceListener {
220 /**
221 * Called to notify the client when the proxy object has been
222 * connected to the service.
Scott Main2d68a6b2011-09-26 22:59:38 -0700223 * @param profile - One of {@link #HEALTH}, {@link #HEADSET} or
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700224 * {@link #A2DP}
Scott Main2d68a6b2011-09-26 22:59:38 -0700225 * @param proxy - One of {@link BluetoothHealth}, {@link BluetoothHeadset} or
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700226 * {@link BluetoothA2dp}
227 */
228 public void onServiceConnected(int profile, BluetoothProfile proxy);
229
230 /**
231 * Called to notify the client that this proxy object has been
232 * disconnected from the service.
Scott Main2d68a6b2011-09-26 22:59:38 -0700233 * @param profile - One of {@link #HEALTH}, {@link #HEADSET} or
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700234 * {@link #A2DP}
235 */
236 public void onServiceDisconnected(int profile);
237 }
238}