Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 1 | /* |
Joseph Pirozzo | 631768d | 2016-09-01 14:19:28 -0700 | [diff] [blame] | 2 | * Copyright (C) 2010-2016 The Android Open Source Project |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 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 | |
| 18 | package android.bluetooth; |
| 19 | |
Tor Norbye | 2d49752 | 2015-04-23 17:10:21 -0700 | [diff] [blame] | 20 | import android.Manifest; |
| 21 | import android.annotation.RequiresPermission; |
Selim Gurun | 17a26c7 | 2018-01-09 14:35:19 -0800 | [diff] [blame] | 22 | import android.annotation.SystemApi; |
Mathew Inwood | 4dc66d3 | 2018-08-01 15:07:20 +0100 | [diff] [blame] | 23 | import android.annotation.UnsupportedAppUsage; |
Mathew Inwood | 45d2c25 | 2018-09-14 12:35:36 +0100 | [diff] [blame] | 24 | import android.os.Build; |
Tor Norbye | 2d49752 | 2015-04-23 17:10:21 -0700 | [diff] [blame] | 25 | |
Jaikumar Ganesh | 03cd78c | 2010-10-18 16:41:53 -0700 | [diff] [blame] | 26 | import java.util.List; |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * Public APIs for the Bluetooth Profiles. |
| 30 | * |
| 31 | * <p> Clients should call {@link BluetoothAdapter#getProfileProxy}, |
| 32 | * to get the Profile Proxy. Each public profile implements this |
| 33 | * interface. |
| 34 | */ |
| 35 | public interface BluetoothProfile { |
| 36 | |
| 37 | /** |
| 38 | * Extra for the connection state intents of the individual profiles. |
| 39 | * |
| 40 | * This extra represents the current connection state of the profile of the |
| 41 | * Bluetooth device. |
| 42 | */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 43 | String EXTRA_STATE = "android.bluetooth.profile.extra.STATE"; |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 44 | |
| 45 | /** |
| 46 | * Extra for the connection state intents of the individual profiles. |
| 47 | * |
| 48 | * This extra represents the previous connection state of the profile of the |
| 49 | * Bluetooth device. |
| 50 | */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 51 | String EXTRA_PREVIOUS_STATE = |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 52 | "android.bluetooth.profile.extra.PREVIOUS_STATE"; |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 53 | |
| 54 | /** The profile is in disconnected state */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 55 | int STATE_DISCONNECTED = 0; |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 56 | /** The profile is in connecting state */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 57 | int STATE_CONNECTING = 1; |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 58 | /** The profile is in connected state */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 59 | int STATE_CONNECTED = 2; |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 60 | /** The profile is in disconnecting state */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 61 | int STATE_DISCONNECTING = 3; |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 62 | |
| 63 | /** |
| 64 | * Headset and Handsfree profile |
| 65 | */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 66 | int HEADSET = 1; |
Jaikumar Ganesh | 74ef119 | 2011-02-23 10:22:15 -0800 | [diff] [blame] | 67 | |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 68 | /** |
| 69 | * A2DP profile. |
| 70 | */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 71 | int A2DP = 2; |
Jaikumar Ganesh | 74ef119 | 2011-02-23 10:22:15 -0800 | [diff] [blame] | 72 | |
Jaikumar Ganesh | 4ab0e77 | 2011-02-18 14:52:32 -0800 | [diff] [blame] | 73 | /** |
Jaikumar Ganesh | 2ea1e85 | 2011-04-01 16:33:09 -0700 | [diff] [blame] | 74 | * Health Profile |
Jack He | 6b73b32 | 2019-01-03 16:23:41 -0800 | [diff] [blame] | 75 | * |
| 76 | * @deprecated Health Device Profile (HDP) and MCAP protocol are no longer used. New |
| 77 | * apps should use Bluetooth Low Energy based solutions such as {@link BluetoothGatt}, |
| 78 | * {@link BluetoothAdapter#listenUsingL2capChannel()}, or |
| 79 | * {@link BluetoothDevice#createL2capChannel(int)} |
Jaikumar Ganesh | 2ea1e85 | 2011-04-01 16:33:09 -0700 | [diff] [blame] | 80 | */ |
Jack He | 6b73b32 | 2019-01-03 16:23:41 -0800 | [diff] [blame] | 81 | @Deprecated |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 82 | int HEALTH = 3; |
Jaikumar Ganesh | 2ea1e85 | 2011-04-01 16:33:09 -0700 | [diff] [blame] | 83 | |
| 84 | /** |
Hansong Zhang | 0edf754 | 2017-10-20 15:55:59 -0700 | [diff] [blame] | 85 | * HID Host |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 86 | * |
Jaikumar Ganesh | 4ab0e77 | 2011-02-18 14:52:32 -0800 | [diff] [blame] | 87 | * @hide |
| 88 | */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 89 | int HID_HOST = 4; |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 90 | |
| 91 | /** |
Jaikumar Ganesh | 74ef119 | 2011-02-23 10:22:15 -0800 | [diff] [blame] | 92 | * PAN Profile |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 93 | * |
Jaikumar Ganesh | 74ef119 | 2011-02-23 10:22:15 -0800 | [diff] [blame] | 94 | * @hide |
| 95 | */ |
Mathew Inwood | 45d2c25 | 2018-09-14 12:35:36 +0100 | [diff] [blame] | 96 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 97 | int PAN = 5; |
Jaikumar Ganesh | 74ef119 | 2011-02-23 10:22:15 -0800 | [diff] [blame] | 98 | |
| 99 | /** |
Jaikumar Ganesh | cb1d354 | 2011-08-19 10:26:32 -0700 | [diff] [blame] | 100 | * PBAP |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 101 | * |
Jaikumar Ganesh | cb1d354 | 2011-08-19 10:26:32 -0700 | [diff] [blame] | 102 | * @hide |
| 103 | */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 104 | int PBAP = 6; |
Jaikumar Ganesh | cb1d354 | 2011-08-19 10:26:32 -0700 | [diff] [blame] | 105 | |
| 106 | /** |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 107 | * GATT |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 108 | */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 109 | int GATT = 7; |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 110 | |
| 111 | /** |
| 112 | * GATT_SERVER |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 113 | */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 114 | int GATT_SERVER = 8; |
Ganesh Ganapathi Batta | 9908112 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 115 | |
| 116 | /** |
Matthew Xie | fe3807a | 2013-07-18 17:31:50 -0700 | [diff] [blame] | 117 | * MAP Profile |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 118 | * |
Matthew Xie | fe3807a | 2013-07-18 17:31:50 -0700 | [diff] [blame] | 119 | * @hide |
| 120 | */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 121 | int MAP = 9; |
Matthew Xie | fe3807a | 2013-07-18 17:31:50 -0700 | [diff] [blame] | 122 | |
Casper Bonde | 2a5f608 | 2015-03-19 10:36:45 +0100 | [diff] [blame] | 123 | /* |
| 124 | * SAP Profile |
| 125 | * @hide |
| 126 | */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 127 | int SAP = 10; |
Casper Bonde | 2a5f608 | 2015-03-19 10:36:45 +0100 | [diff] [blame] | 128 | |
Matthew Xie | fe3807a | 2013-07-18 17:31:50 -0700 | [diff] [blame] | 129 | /** |
Mike Lockwood | 0a40ec2 | 2014-05-21 10:08:50 -0700 | [diff] [blame] | 130 | * A2DP Sink Profile |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 131 | * |
Mike Lockwood | 0a40ec2 | 2014-05-21 10:08:50 -0700 | [diff] [blame] | 132 | * @hide |
| 133 | */ |
Mathew Inwood | 4dc66d3 | 2018-08-01 15:07:20 +0100 | [diff] [blame] | 134 | @UnsupportedAppUsage |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 135 | int A2DP_SINK = 11; |
Mike Lockwood | 0a40ec2 | 2014-05-21 10:08:50 -0700 | [diff] [blame] | 136 | |
| 137 | /** |
Mike Lockwood | 94b59de | 2014-06-02 16:20:37 -0700 | [diff] [blame] | 138 | * AVRCP Controller Profile |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 139 | * |
Mike Lockwood | 94b59de | 2014-06-02 16:20:37 -0700 | [diff] [blame] | 140 | * @hide |
| 141 | */ |
Mathew Inwood | 4dc66d3 | 2018-08-01 15:07:20 +0100 | [diff] [blame] | 142 | @UnsupportedAppUsage |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 143 | int AVRCP_CONTROLLER = 12; |
| 144 | |
| 145 | /** |
| 146 | * AVRCP Target Profile |
| 147 | * |
| 148 | * @hide |
| 149 | */ |
| 150 | int AVRCP = 13; |
Mike Lockwood | 94b59de | 2014-06-02 16:20:37 -0700 | [diff] [blame] | 151 | |
| 152 | /** |
Mike Lockwood | cf916d3 | 2014-06-12 11:23:40 -0700 | [diff] [blame] | 153 | * Headset Client - HFP HF Role |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 154 | * |
Hemant Gupta | 7aca90f | 2013-08-19 19:03:51 +0530 | [diff] [blame] | 155 | * @hide |
| 156 | */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 157 | int HEADSET_CLIENT = 16; |
Hemant Gupta | 7aca90f | 2013-08-19 19:03:51 +0530 | [diff] [blame] | 158 | |
| 159 | /** |
Joseph Pirozzo | cfa8a64 | 2016-03-04 13:02:54 -0800 | [diff] [blame] | 160 | * PBAP Client |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 161 | * |
Joseph Pirozzo | cfa8a64 | 2016-03-04 13:02:54 -0800 | [diff] [blame] | 162 | * @hide |
| 163 | */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 164 | int PBAP_CLIENT = 17; |
Joseph Pirozzo | cfa8a64 | 2016-03-04 13:02:54 -0800 | [diff] [blame] | 165 | |
| 166 | /** |
Joseph Pirozzo | 631768d | 2016-09-01 14:19:28 -0700 | [diff] [blame] | 167 | * MAP Messaging Client Equipment (MCE) |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 168 | * |
Joseph Pirozzo | 631768d | 2016-09-01 14:19:28 -0700 | [diff] [blame] | 169 | * @hide |
| 170 | */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 171 | int MAP_CLIENT = 18; |
Joseph Pirozzo | 631768d | 2016-09-01 14:19:28 -0700 | [diff] [blame] | 172 | |
| 173 | /** |
Hansong Zhang | 0edf754 | 2017-10-20 15:55:59 -0700 | [diff] [blame] | 174 | * HID Device |
Hemant Gupta | e88fd4b | 2014-04-18 11:22:45 +0530 | [diff] [blame] | 175 | */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 176 | int HID_DEVICE = 19; |
Hemant Gupta | e88fd4b | 2014-04-18 11:22:45 +0530 | [diff] [blame] | 177 | |
| 178 | /** |
Myles Watson | fa792b9 | 2018-01-05 13:54:34 -0800 | [diff] [blame] | 179 | * Object Push Profile (OPP) |
| 180 | * |
| 181 | * @hide |
| 182 | */ |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 183 | int OPP = 20; |
Myles Watson | fa792b9 | 2018-01-05 13:54:34 -0800 | [diff] [blame] | 184 | |
| 185 | /** |
Jakub Pawlowski | ea580fa | 2017-11-22 11:02:34 -0800 | [diff] [blame] | 186 | * Hearing Aid Device |
| 187 | * |
| 188 | * @hide |
| 189 | */ |
| 190 | int HEARING_AID = 21; |
| 191 | |
| 192 | /** |
Bryce Lee | f6b74de | 2016-10-09 12:54:42 -0700 | [diff] [blame] | 193 | * Max profile ID. This value should be updated whenever a new profile is added to match |
| 194 | * the largest value assigned to a profile. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 195 | * |
Bryce Lee | f6b74de | 2016-10-09 12:54:42 -0700 | [diff] [blame] | 196 | * @hide |
| 197 | */ |
Jakub Pawlowski | ea580fa | 2017-11-22 11:02:34 -0800 | [diff] [blame] | 198 | int MAX_PROFILE_ID = 21; |
Bryce Lee | f6b74de | 2016-10-09 12:54:42 -0700 | [diff] [blame] | 199 | |
| 200 | /** |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 201 | * Default priority for devices that we try to auto-connect to and |
| 202 | * and allow incoming connections for the profile |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 203 | * |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 204 | * @hide |
| 205 | **/ |
Mathew Inwood | 4dc66d3 | 2018-08-01 15:07:20 +0100 | [diff] [blame] | 206 | @UnsupportedAppUsage |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 207 | int PRIORITY_AUTO_CONNECT = 1000; |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 208 | |
| 209 | /** |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 210 | * Default priority for devices that allow incoming |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 211 | * and outgoing connections for the profile |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 212 | * |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 213 | * @hide |
| 214 | **/ |
Selim Gurun | 17a26c7 | 2018-01-09 14:35:19 -0800 | [diff] [blame] | 215 | @SystemApi |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 216 | int PRIORITY_ON = 100; |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 217 | |
| 218 | /** |
| 219 | * Default priority for devices that does not allow incoming |
| 220 | * connections and outgoing connections for the profile. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 221 | * |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 222 | * @hide |
| 223 | **/ |
Selim Gurun | 17a26c7 | 2018-01-09 14:35:19 -0800 | [diff] [blame] | 224 | @SystemApi |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 225 | int PRIORITY_OFF = 0; |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 226 | |
| 227 | /** |
| 228 | * Default priority when not set or when the device is unpaired |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 229 | * |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 230 | * @hide |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 231 | */ |
Mathew Inwood | 4dc66d3 | 2018-08-01 15:07:20 +0100 | [diff] [blame] | 232 | @UnsupportedAppUsage |
Ajay Panicker | 38c3073 | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 233 | int PRIORITY_UNDEFINED = -1; |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 234 | |
| 235 | /** |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 236 | * Get connected devices for this specific profile. |
| 237 | * |
| 238 | * <p> Return the set of devices which are in state {@link #STATE_CONNECTED} |
| 239 | * |
Jaikumar Ganesh | 03cd78c | 2010-10-18 16:41:53 -0700 | [diff] [blame] | 240 | * @return List of devices. The list will be empty on error. |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 241 | */ |
Tor Norbye | 2d49752 | 2015-04-23 17:10:21 -0700 | [diff] [blame] | 242 | @RequiresPermission(Manifest.permission.BLUETOOTH) |
Jaikumar Ganesh | 03cd78c | 2010-10-18 16:41:53 -0700 | [diff] [blame] | 243 | public List<BluetoothDevice> getConnectedDevices(); |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 244 | |
| 245 | /** |
Jaikumar Ganesh | c8fa4ff | 2011-01-25 16:03:13 -0800 | [diff] [blame] | 246 | * Get a list of devices that match any of the given connection |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 247 | * states. |
| 248 | * |
Jaikumar Ganesh | c8fa4ff | 2011-01-25 16:03:13 -0800 | [diff] [blame] | 249 | * <p> If none of the devices match any of the given states, |
| 250 | * an empty list will be returned. |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 251 | * |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 252 | * @param states Array of states. States can be one of {@link #STATE_CONNECTED}, {@link |
| 253 | * #STATE_CONNECTING}, {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING}, |
Jaikumar Ganesh | 03cd78c | 2010-10-18 16:41:53 -0700 | [diff] [blame] | 254 | * @return List of devices. The list will be empty on error. |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 255 | */ |
Tor Norbye | 2d49752 | 2015-04-23 17:10:21 -0700 | [diff] [blame] | 256 | @RequiresPermission(Manifest.permission.BLUETOOTH) |
Jaikumar Ganesh | 03cd78c | 2010-10-18 16:41:53 -0700 | [diff] [blame] | 257 | public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states); |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 258 | |
| 259 | /** |
| 260 | * Get the current connection state of the profile |
| 261 | * |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 262 | * @param device Remote bluetooth device. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 263 | * @return State of the profile connection. One of {@link #STATE_CONNECTED}, {@link |
| 264 | * #STATE_CONNECTING}, {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING} |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 265 | */ |
Tor Norbye | 2d49752 | 2015-04-23 17:10:21 -0700 | [diff] [blame] | 266 | @RequiresPermission(Manifest.permission.BLUETOOTH) |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 267 | public int getConnectionState(BluetoothDevice device); |
| 268 | |
| 269 | /** |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 270 | * An interface for notifying BluetoothProfile IPC clients when they have |
| 271 | * been connected or disconnected to the service. |
| 272 | */ |
| 273 | public interface ServiceListener { |
| 274 | /** |
| 275 | * Called to notify the client when the proxy object has been |
| 276 | * connected to the service. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 277 | * |
Jack He | 6b73b32 | 2019-01-03 16:23:41 -0800 | [diff] [blame] | 278 | * @param profile - One of {@link #HEADSET} or {@link #A2DP} |
| 279 | * @param proxy - One of {@link BluetoothHeadset} or {@link BluetoothA2dp} |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 280 | */ |
| 281 | public void onServiceConnected(int profile, BluetoothProfile proxy); |
| 282 | |
| 283 | /** |
| 284 | * Called to notify the client that this proxy object has been |
| 285 | * disconnected from the service. |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 286 | * |
Jack He | 6b73b32 | 2019-01-03 16:23:41 -0800 | [diff] [blame] | 287 | * @param profile - One of {@link #HEADSET} or {@link #A2DP} |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 288 | */ |
| 289 | public void onServiceDisconnected(int profile); |
| 290 | } |
Jack He | 5252b97 | 2017-12-11 13:11:20 -0800 | [diff] [blame] | 291 | |
| 292 | /** |
| 293 | * Convert an integer value of connection state into human readable string |
| 294 | * |
| 295 | * @param connectionState - One of {@link #STATE_DISCONNECTED}, {@link #STATE_CONNECTING}, |
| 296 | * {@link #STATE_CONNECTED}, or {@link #STATE_DISCONNECTED} |
| 297 | * @return a string representation of the connection state, STATE_UNKNOWN if the state |
| 298 | * is not defined |
| 299 | * @hide |
| 300 | */ |
| 301 | static String getConnectionStateName(int connectionState) { |
| 302 | switch (connectionState) { |
| 303 | case STATE_DISCONNECTED: |
| 304 | return "STATE_DISCONNECTED"; |
| 305 | case STATE_CONNECTING: |
| 306 | return "STATE_CONNECTING"; |
| 307 | case STATE_CONNECTED: |
| 308 | return "STATE_CONNECTED"; |
| 309 | case STATE_DISCONNECTING: |
| 310 | return "STATE_DISCONNECTING"; |
| 311 | default: |
| 312 | return "STATE_UNKNOWN"; |
| 313 | } |
| 314 | } |
Jaikumar Ganesh | 62c37ef | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 315 | } |