blob: 58b38683879937165a079649021c7726d1954571 [file] [log] [blame]
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -07001/*
2 * Copyright (C) 2010 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
18package android.bluetooth;
19
Jaikumar Ganesh03cd78c2010-10-18 16:41:53 -070020import java.util.List;
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -070021
22/**
23 * Public APIs for the Bluetooth Profiles.
24 *
25 * <p> Clients should call {@link BluetoothAdapter#getProfileProxy},
26 * to get the Profile Proxy. Each public profile implements this
27 * interface.
28 */
29public interface BluetoothProfile {
30
31 /**
32 * Extra for the connection state intents of the individual profiles.
33 *
34 * This extra represents the current connection state of the profile of the
35 * Bluetooth device.
36 */
37 public static final String EXTRA_STATE = "android.bluetooth.profile.extra.STATE";
38
39 /**
40 * Extra for the connection state intents of the individual profiles.
41 *
42 * This extra represents the previous connection state of the profile of the
43 * Bluetooth device.
44 */
45 public static final String EXTRA_PREVIOUS_STATE =
46 "android.bluetooth.profile.extra.PREVIOUS_STATE";
47
48 /** The profile is in disconnected state */
49 public static final int STATE_DISCONNECTED = 0;
50 /** The profile is in connecting state */
51 public static final int STATE_CONNECTING = 1;
52 /** The profile is in connected state */
53 public static final int STATE_CONNECTED = 2;
54 /** The profile is in disconnecting state */
55 public static final int STATE_DISCONNECTING = 3;
56
57 /**
58 * Headset and Handsfree profile
59 */
60 public static final int HEADSET = 1;
Jaikumar Ganesh74ef1192011-02-23 10:22:15 -080061
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -070062 /**
63 * A2DP profile.
64 */
65 public static final int A2DP = 2;
Jaikumar Ganesh74ef1192011-02-23 10:22:15 -080066
Jaikumar Ganesh4ab0e772011-02-18 14:52:32 -080067 /**
Jaikumar Ganesh2ea1e852011-04-01 16:33:09 -070068 * Health Profile
69 * @hide
70 */
71 public static final int HEALTH = 3;
72
73 /**
Jaikumar Ganesh4ab0e772011-02-18 14:52:32 -080074 * Input Device Profile
75 * @hide
76 */
Jaikumar Ganesh2ea1e852011-04-01 16:33:09 -070077 public static final int INPUT_DEVICE = 4;
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -070078
79 /**
Jaikumar Ganesh74ef1192011-02-23 10:22:15 -080080 * PAN Profile
81 * @hide
82 */
Jaikumar Ganesh2ea1e852011-04-01 16:33:09 -070083 public static final int PAN = 5;
Jaikumar Ganesh74ef1192011-02-23 10:22:15 -080084
85 /**
Jaikumar Ganeshcb1d3542011-08-19 10:26:32 -070086 * PBAP
87 * @hide
88 */
89 public static final int PBAP = 6;
90
91 /**
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -070092 * Default priority for devices that we try to auto-connect to and
93 * and allow incoming connections for the profile
94 * @hide
95 **/
96 public static final int PRIORITY_AUTO_CONNECT = 1000;
97
98 /**
99 * Default priority for devices that allow incoming
100 * and outgoing connections for the profile
101 * @hide
102 **/
103 public static final int PRIORITY_ON = 100;
104
105 /**
106 * Default priority for devices that does not allow incoming
107 * connections and outgoing connections for the profile.
108 * @hide
109 **/
110 public static final int PRIORITY_OFF = 0;
111
112 /**
113 * Default priority when not set or when the device is unpaired
114 * @hide
115 * */
116 public static final int PRIORITY_UNDEFINED = -1;
117
118 /**
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700119 * Get connected devices for this specific profile.
120 *
121 * <p> Return the set of devices which are in state {@link #STATE_CONNECTED}
122 *
Jaikumar Ganeshc8fa4ff2011-01-25 16:03:13 -0800123 * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700124 *
Jaikumar Ganesh03cd78c2010-10-18 16:41:53 -0700125 * @return List of devices. The list will be empty on error.
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700126 */
Jaikumar Ganesh03cd78c2010-10-18 16:41:53 -0700127 public List<BluetoothDevice> getConnectedDevices();
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700128
129 /**
Jaikumar Ganeshc8fa4ff2011-01-25 16:03:13 -0800130 * Get a list of devices that match any of the given connection
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700131 * states.
132 *
Jaikumar Ganeshc8fa4ff2011-01-25 16:03:13 -0800133 * <p> If none of the devices match any of the given states,
134 * an empty list will be returned.
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700135 *
Jaikumar Ganeshc8fa4ff2011-01-25 16:03:13 -0800136 * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700137 *
138 * @param states Array of states. States can be one of
139 * {@link #STATE_CONNECTED}, {@link #STATE_CONNECTING},
140 * {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING},
Jaikumar Ganesh03cd78c2010-10-18 16:41:53 -0700141 * @return List of devices. The list will be empty on error.
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700142 */
Jaikumar Ganesh03cd78c2010-10-18 16:41:53 -0700143 public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states);
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700144
145 /**
146 * Get the current connection state of the profile
147 *
Jaikumar Ganeshc8fa4ff2011-01-25 16:03:13 -0800148 * <p>Requires {@link android.Manifest.permission#BLUETOOTH} permission.
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700149 *
150 * @param device Remote bluetooth device.
151 * @return State of the profile connection. One of
152 * {@link #STATE_CONNECTED}, {@link #STATE_CONNECTING},
153 * {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING}
154 */
155 public int getConnectionState(BluetoothDevice device);
156
157 /**
Jaikumar Ganesh62c37ef2010-08-24 17:36:13 -0700158 * An interface for notifying BluetoothProfile IPC clients when they have
159 * been connected or disconnected to the service.
160 */
161 public interface ServiceListener {
162 /**
163 * Called to notify the client when the proxy object has been
164 * connected to the service.
165 * @param profile - One of {@link #HEADSET} or
166 * {@link #A2DP}
167 * @param proxy - One of {@link BluetoothHeadset} or
168 * {@link BluetoothA2dp}
169 */
170 public void onServiceConnected(int profile, BluetoothProfile proxy);
171
172 /**
173 * Called to notify the client that this proxy object has been
174 * disconnected from the service.
175 * @param profile - One of {@link #HEADSET} or
176 * {@link #A2DP}
177 */
178 public void onServiceDisconnected(int profile);
179 }
180}