| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 1 | /* |
| Joseph Pirozzo | 54d4b66 | 2016-09-01 14:19:28 -0700 | [diff] [blame] | 2 | * Copyright (C) 2010-2016 The Android Open Source Project |
| Jaikumar Ganesh | 2af0776 | 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 | |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 17 | package android.bluetooth; |
| 18 | |
| Stanley Tng | a76ec8b | 2019-03-14 16:18:29 -0700 | [diff] [blame] | 19 | import android.annotation.IntDef; |
| Jeff Sharkey | 5ba8bfc | 2021-04-16 09:53:23 -0600 | [diff] [blame] | 20 | import android.annotation.RequiresNoPermission; |
| Rahul Sabnis | eeccce5 | 2019-11-19 14:54:25 -0800 | [diff] [blame] | 21 | import android.annotation.SuppressLint; |
| Selim Gurun | 9e6b35b | 2018-01-09 14:35:19 -0800 | [diff] [blame] | 22 | import android.annotation.SystemApi; |
| Artur Satayev | 3625be4 | 2019-12-10 17:47:52 +0000 | [diff] [blame] | 23 | import android.compat.annotation.UnsupportedAppUsage; |
| Mathew Inwood | 049f0f5 | 2020-11-04 09:29:36 +0000 | [diff] [blame] | 24 | import android.os.Build; |
| Tor Norbye | 27ce6cf | 2015-04-23 17:10:21 -0700 | [diff] [blame] | 25 | |
| Stanley Tng | a76ec8b | 2019-03-14 16:18:29 -0700 | [diff] [blame] | 26 | import java.lang.annotation.Retention; |
| 27 | import java.lang.annotation.RetentionPolicy; |
| Jaikumar Ganesh | d8fc4dd | 2010-10-18 16:41:53 -0700 | [diff] [blame] | 28 | import java.util.List; |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 29 | |
| 30 | /** |
| 31 | * Public APIs for the Bluetooth Profiles. |
| 32 | * |
| 33 | * <p> Clients should call {@link BluetoothAdapter#getProfileProxy}, |
| 34 | * to get the Profile Proxy. Each public profile implements this |
| 35 | * interface. |
| 36 | */ |
| 37 | public interface BluetoothProfile { |
| 38 | |
| 39 | /** |
| 40 | * Extra for the connection state intents of the individual profiles. |
| 41 | * |
| 42 | * This extra represents the current connection state of the profile of the |
| 43 | * Bluetooth device. |
| 44 | */ |
| Rahul Sabnis | eeccce5 | 2019-11-19 14:54:25 -0800 | [diff] [blame] | 45 | @SuppressLint("ActionValue") |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 46 | String EXTRA_STATE = "android.bluetooth.profile.extra.STATE"; |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 47 | |
| 48 | /** |
| 49 | * Extra for the connection state intents of the individual profiles. |
| 50 | * |
| 51 | * This extra represents the previous connection state of the profile of the |
| 52 | * Bluetooth device. |
| 53 | */ |
| Rahul Sabnis | eeccce5 | 2019-11-19 14:54:25 -0800 | [diff] [blame] | 54 | @SuppressLint("ActionValue") |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 55 | String EXTRA_PREVIOUS_STATE = |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 56 | "android.bluetooth.profile.extra.PREVIOUS_STATE"; |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 57 | |
| 58 | /** The profile is in disconnected state */ |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 59 | int STATE_DISCONNECTED = 0; |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 60 | /** The profile is in connecting state */ |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 61 | int STATE_CONNECTING = 1; |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 62 | /** The profile is in connected state */ |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 63 | int STATE_CONNECTED = 2; |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 64 | /** The profile is in disconnecting state */ |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 65 | int STATE_DISCONNECTING = 3; |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 66 | |
| Stanley Tng | a76ec8b | 2019-03-14 16:18:29 -0700 | [diff] [blame] | 67 | /** @hide */ |
| 68 | @IntDef({ |
| 69 | STATE_DISCONNECTED, |
| 70 | STATE_CONNECTING, |
| 71 | STATE_CONNECTED, |
| 72 | STATE_DISCONNECTING, |
| 73 | }) |
| 74 | @Retention(RetentionPolicy.SOURCE) |
| 75 | public @interface BtProfileState {} |
| 76 | |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 77 | /** |
| 78 | * Headset and Handsfree profile |
| 79 | */ |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 80 | int HEADSET = 1; |
| Jaikumar Ganesh | 97f8ec4 | 2011-02-23 10:22:15 -0800 | [diff] [blame] | 81 | |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 82 | /** |
| 83 | * A2DP profile. |
| 84 | */ |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 85 | int A2DP = 2; |
| Jaikumar Ganesh | 97f8ec4 | 2011-02-23 10:22:15 -0800 | [diff] [blame] | 86 | |
| Jaikumar Ganesh | ad5d9c0 | 2011-02-18 14:52:32 -0800 | [diff] [blame] | 87 | /** |
| Jaikumar Ganesh | bf981ca | 2011-04-01 16:33:09 -0700 | [diff] [blame] | 88 | * Health Profile |
| Jack He | 8bb9c7d | 2019-01-03 16:23:41 -0800 | [diff] [blame] | 89 | * |
| 90 | * @deprecated Health Device Profile (HDP) and MCAP protocol are no longer used. New |
| 91 | * apps should use Bluetooth Low Energy based solutions such as {@link BluetoothGatt}, |
| 92 | * {@link BluetoothAdapter#listenUsingL2capChannel()}, or |
| 93 | * {@link BluetoothDevice#createL2capChannel(int)} |
| Jaikumar Ganesh | bf981ca | 2011-04-01 16:33:09 -0700 | [diff] [blame] | 94 | */ |
| Jack He | 8bb9c7d | 2019-01-03 16:23:41 -0800 | [diff] [blame] | 95 | @Deprecated |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 96 | int HEALTH = 3; |
| Jaikumar Ganesh | bf981ca | 2011-04-01 16:33:09 -0700 | [diff] [blame] | 97 | |
| 98 | /** |
| Hansong Zhang | f076158 | 2017-10-20 15:55:59 -0700 | [diff] [blame] | 99 | * HID Host |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 100 | * |
| Jaikumar Ganesh | ad5d9c0 | 2011-02-18 14:52:32 -0800 | [diff] [blame] | 101 | * @hide |
| 102 | */ |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 103 | int HID_HOST = 4; |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 104 | |
| 105 | /** |
| Jaikumar Ganesh | 97f8ec4 | 2011-02-23 10:22:15 -0800 | [diff] [blame] | 106 | * PAN Profile |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 107 | * |
| Jaikumar Ganesh | 97f8ec4 | 2011-02-23 10:22:15 -0800 | [diff] [blame] | 108 | * @hide |
| 109 | */ |
| Rahul Sabnis | eeccce5 | 2019-11-19 14:54:25 -0800 | [diff] [blame] | 110 | @SystemApi |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 111 | int PAN = 5; |
| Jaikumar Ganesh | 97f8ec4 | 2011-02-23 10:22:15 -0800 | [diff] [blame] | 112 | |
| 113 | /** |
| Jaikumar Ganesh | 5317842 | 2011-08-19 10:26:32 -0700 | [diff] [blame] | 114 | * PBAP |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 115 | * |
| Jaikumar Ganesh | 5317842 | 2011-08-19 10:26:32 -0700 | [diff] [blame] | 116 | * @hide |
| 117 | */ |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 118 | int PBAP = 6; |
| Jaikumar Ganesh | 5317842 | 2011-08-19 10:26:32 -0700 | [diff] [blame] | 119 | |
| 120 | /** |
| Ganesh Ganapathi Batta | 40b9895 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 121 | * GATT |
| Ganesh Ganapathi Batta | 40b9895 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 122 | */ |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 123 | int GATT = 7; |
| Ganesh Ganapathi Batta | 40b9895 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 124 | |
| 125 | /** |
| 126 | * GATT_SERVER |
| Ganesh Ganapathi Batta | 40b9895 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 127 | */ |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 128 | int GATT_SERVER = 8; |
| Ganesh Ganapathi Batta | 40b9895 | 2013-02-05 15:28:33 -0800 | [diff] [blame] | 129 | |
| 130 | /** |
| Matthew Xie | ce14522 | 2013-07-18 17:31:50 -0700 | [diff] [blame] | 131 | * MAP Profile |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 132 | * |
| Matthew Xie | ce14522 | 2013-07-18 17:31:50 -0700 | [diff] [blame] | 133 | * @hide |
| 134 | */ |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 135 | int MAP = 9; |
| Matthew Xie | ce14522 | 2013-07-18 17:31:50 -0700 | [diff] [blame] | 136 | |
| Casper Bonde | d8355fb | 2015-03-19 10:36:45 +0100 | [diff] [blame] | 137 | /* |
| 138 | * SAP Profile |
| 139 | * @hide |
| 140 | */ |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 141 | int SAP = 10; |
| Casper Bonde | d8355fb | 2015-03-19 10:36:45 +0100 | [diff] [blame] | 142 | |
| Matthew Xie | ce14522 | 2013-07-18 17:31:50 -0700 | [diff] [blame] | 143 | /** |
| Mike Lockwood | a5e51db | 2014-05-21 10:08:50 -0700 | [diff] [blame] | 144 | * A2DP Sink Profile |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 145 | * |
| Mike Lockwood | a5e51db | 2014-05-21 10:08:50 -0700 | [diff] [blame] | 146 | * @hide |
| 147 | */ |
| Rahul Sabnis | 07f4803 | 2020-01-21 15:11:22 -0800 | [diff] [blame] | 148 | @SystemApi |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 149 | int A2DP_SINK = 11; |
| Mike Lockwood | a5e51db | 2014-05-21 10:08:50 -0700 | [diff] [blame] | 150 | |
| 151 | /** |
| Mike Lockwood | 517b04f | 2014-06-02 16:20:37 -0700 | [diff] [blame] | 152 | * AVRCP Controller Profile |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 153 | * |
| Mike Lockwood | 517b04f | 2014-06-02 16:20:37 -0700 | [diff] [blame] | 154 | * @hide |
| 155 | */ |
| Rahul Sabnis | 07f4803 | 2020-01-21 15:11:22 -0800 | [diff] [blame] | 156 | @SystemApi |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 157 | int AVRCP_CONTROLLER = 12; |
| 158 | |
| 159 | /** |
| 160 | * AVRCP Target Profile |
| 161 | * |
| 162 | * @hide |
| 163 | */ |
| 164 | int AVRCP = 13; |
| Mike Lockwood | 517b04f | 2014-06-02 16:20:37 -0700 | [diff] [blame] | 165 | |
| 166 | /** |
| Mike Lockwood | f48a727 | 2014-06-12 11:23:40 -0700 | [diff] [blame] | 167 | * Headset Client - HFP HF Role |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 168 | * |
| Hemant Gupta | 67a995a | 2013-08-19 19:03:51 +0530 | [diff] [blame] | 169 | * @hide |
| 170 | */ |
| Rahul Sabnis | 07f4803 | 2020-01-21 15:11:22 -0800 | [diff] [blame] | 171 | @SystemApi |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 172 | int HEADSET_CLIENT = 16; |
| Hemant Gupta | 67a995a | 2013-08-19 19:03:51 +0530 | [diff] [blame] | 173 | |
| 174 | /** |
| Joseph Pirozzo | 6f56b0f | 2016-03-04 13:02:54 -0800 | [diff] [blame] | 175 | * PBAP Client |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 176 | * |
| Joseph Pirozzo | 6f56b0f | 2016-03-04 13:02:54 -0800 | [diff] [blame] | 177 | * @hide |
| 178 | */ |
| Rahul Sabnis | 07f4803 | 2020-01-21 15:11:22 -0800 | [diff] [blame] | 179 | @SystemApi |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 180 | int PBAP_CLIENT = 17; |
| Joseph Pirozzo | 6f56b0f | 2016-03-04 13:02:54 -0800 | [diff] [blame] | 181 | |
| 182 | /** |
| Joseph Pirozzo | 54d4b66 | 2016-09-01 14:19:28 -0700 | [diff] [blame] | 183 | * MAP Messaging Client Equipment (MCE) |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 184 | * |
| Joseph Pirozzo | 54d4b66 | 2016-09-01 14:19:28 -0700 | [diff] [blame] | 185 | * @hide |
| 186 | */ |
| Joseph Pirozzo | 1db9bd4 | 2021-01-21 11:22:44 -0800 | [diff] [blame] | 187 | @SystemApi |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 188 | int MAP_CLIENT = 18; |
| Joseph Pirozzo | 54d4b66 | 2016-09-01 14:19:28 -0700 | [diff] [blame] | 189 | |
| 190 | /** |
| Hansong Zhang | f076158 | 2017-10-20 15:55:59 -0700 | [diff] [blame] | 191 | * HID Device |
| Hemant Gupta | 7d82a61 | 2014-04-18 11:22:45 +0530 | [diff] [blame] | 192 | */ |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 193 | int HID_DEVICE = 19; |
| Hemant Gupta | 7d82a61 | 2014-04-18 11:22:45 +0530 | [diff] [blame] | 194 | |
| 195 | /** |
| Myles Watson | 3131897 | 2018-01-05 13:54:34 -0800 | [diff] [blame] | 196 | * Object Push Profile (OPP) |
| 197 | * |
| 198 | * @hide |
| 199 | */ |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 200 | int OPP = 20; |
| Myles Watson | 3131897 | 2018-01-05 13:54:34 -0800 | [diff] [blame] | 201 | |
| 202 | /** |
| Jakub Pawlowski | 3f23873 | 2017-11-22 11:02:34 -0800 | [diff] [blame] | 203 | * Hearing Aid Device |
| 204 | * |
| Jakub Pawlowski | 3f23873 | 2017-11-22 11:02:34 -0800 | [diff] [blame] | 205 | */ |
| 206 | int HEARING_AID = 21; |
| 207 | |
| 208 | /** |
| Grzegorz Kołodziejczyk | 3b98ee1 | 2020-11-16 11:43:45 +0000 | [diff] [blame] | 209 | * LE Audio Device |
| 210 | * |
| Grzegorz Kołodziejczyk | 3b98ee1 | 2020-11-16 11:43:45 +0000 | [diff] [blame] | 211 | */ |
| 212 | int LE_AUDIO = 22; |
| 213 | |
| 214 | /** |
| Łukasz Rymanowski | 1b3ac77 | 2021-01-26 06:39:08 +0000 | [diff] [blame] | 215 | * Volume Control profile |
| 216 | * |
| Jakub Pawlowski | 807fd1c | 2021-06-18 00:09:00 +0200 | [diff] [blame] | 217 | * @hide |
| Łukasz Rymanowski | 1b3ac77 | 2021-01-26 06:39:08 +0000 | [diff] [blame] | 218 | */ |
| Jakub Pawlowski | 807fd1c | 2021-06-18 00:09:00 +0200 | [diff] [blame] | 219 | @SystemApi |
| Łukasz Rymanowski | 1b3ac77 | 2021-01-26 06:39:08 +0000 | [diff] [blame] | 220 | int VOLUME_CONTROL = 23; |
| 221 | |
| 222 | /** |
| Jakub Tyszkowski | bedd831 | 2021-03-01 13:02:25 +0000 | [diff] [blame] | 223 | * @hide |
| 224 | * Media Control Profile server |
| 225 | * |
| 226 | */ |
| 227 | int MCP_SERVER = 24; |
| 228 | |
| 229 | /** |
| Łukasz Rymanowski | fd45c86 | 2021-08-23 12:01:47 +0000 | [diff] [blame] | 230 | * Coordinated Set Identification Profile set coordinator |
| 231 | * |
| 232 | */ |
| 233 | int CSIP_SET_COORDINATOR = 25; |
| 234 | |
| 235 | /** |
| Qasim Javed | 2eb043e | 2021-11-04 12:57:33 -0700 | [diff] [blame^] | 236 | * LE Audio Broadcast Source |
| 237 | * |
| 238 | * @hide |
| 239 | */ |
| 240 | int LE_AUDIO_BROADCAST = 26; |
| 241 | |
| 242 | /** |
| Bryce Lee | ff5093b | 2016-10-09 12:54:42 -0700 | [diff] [blame] | 243 | * Max profile ID. This value should be updated whenever a new profile is added to match |
| 244 | * the largest value assigned to a profile. |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 245 | * |
| Bryce Lee | ff5093b | 2016-10-09 12:54:42 -0700 | [diff] [blame] | 246 | * @hide |
| 247 | */ |
| Qasim Javed | 2eb043e | 2021-11-04 12:57:33 -0700 | [diff] [blame^] | 248 | int MAX_PROFILE_ID = 26; |
| Bryce Lee | ff5093b | 2016-10-09 12:54:42 -0700 | [diff] [blame] | 249 | |
| 250 | /** |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 251 | * Default priority for devices that we try to auto-connect to and |
| 252 | * and allow incoming connections for the profile |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 253 | * |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 254 | * @hide |
| 255 | **/ |
| Mathew Inwood | 049f0f5 | 2020-11-04 09:29:36 +0000 | [diff] [blame] | 256 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 257 | int PRIORITY_AUTO_CONNECT = 1000; |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 258 | |
| 259 | /** |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 260 | * Default priority for devices that allow incoming |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 261 | * and outgoing connections for the profile |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 262 | * |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 263 | * @hide |
| Rahul Sabnis | e8bac9b | 2019-11-27 18:09:33 -0800 | [diff] [blame] | 264 | * @deprecated Replaced with {@link #CONNECTION_POLICY_ALLOWED} |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 265 | **/ |
| Rahul Sabnis | e8bac9b | 2019-11-27 18:09:33 -0800 | [diff] [blame] | 266 | @Deprecated |
| Selim Gurun | 9e6b35b | 2018-01-09 14:35:19 -0800 | [diff] [blame] | 267 | @SystemApi |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 268 | int PRIORITY_ON = 100; |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 269 | |
| 270 | /** |
| 271 | * Default priority for devices that does not allow incoming |
| 272 | * connections and outgoing connections for the profile. |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 273 | * |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 274 | * @hide |
| Rahul Sabnis | e8bac9b | 2019-11-27 18:09:33 -0800 | [diff] [blame] | 275 | * @deprecated Replaced with {@link #CONNECTION_POLICY_FORBIDDEN} |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 276 | **/ |
| Rahul Sabnis | e8bac9b | 2019-11-27 18:09:33 -0800 | [diff] [blame] | 277 | @Deprecated |
| Selim Gurun | 9e6b35b | 2018-01-09 14:35:19 -0800 | [diff] [blame] | 278 | @SystemApi |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 279 | int PRIORITY_OFF = 0; |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 280 | |
| 281 | /** |
| 282 | * Default priority when not set or when the device is unpaired |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 283 | * |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 284 | * @hide |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 285 | */ |
| Mathew Inwood | 7d54389 | 2018-08-01 15:07:20 +0100 | [diff] [blame] | 286 | @UnsupportedAppUsage |
| Ajay Panicker | bfcc00d | 2018-03-16 04:00:27 -0700 | [diff] [blame] | 287 | int PRIORITY_UNDEFINED = -1; |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 288 | |
| Rahul Sabnis | e8bac9b | 2019-11-27 18:09:33 -0800 | [diff] [blame] | 289 | /** @hide */ |
| 290 | @IntDef(prefix = "CONNECTION_POLICY_", value = {CONNECTION_POLICY_ALLOWED, |
| 291 | CONNECTION_POLICY_FORBIDDEN, CONNECTION_POLICY_UNKNOWN}) |
| 292 | @Retention(RetentionPolicy.SOURCE) |
| 293 | public @interface ConnectionPolicy{} |
| 294 | |
| 295 | /** |
| 296 | * Default connection policy for devices that allow incoming and outgoing connections |
| 297 | * for the profile |
| 298 | * |
| 299 | * @hide |
| 300 | **/ |
| 301 | @SystemApi |
| 302 | int CONNECTION_POLICY_ALLOWED = 100; |
| 303 | |
| 304 | /** |
| 305 | * Default connection policy for devices that do not allow incoming or outgoing connections |
| 306 | * for the profile. |
| 307 | * |
| 308 | * @hide |
| 309 | **/ |
| 310 | @SystemApi |
| 311 | int CONNECTION_POLICY_FORBIDDEN = 0; |
| 312 | |
| 313 | /** |
| 314 | * Default connection policy when not set or when the device is unpaired |
| 315 | * |
| 316 | * @hide |
| 317 | */ |
| 318 | @SystemApi |
| 319 | int CONNECTION_POLICY_UNKNOWN = -1; |
| 320 | |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 321 | /** |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 322 | * Get connected devices for this specific profile. |
| 323 | * |
| 324 | * <p> Return the set of devices which are in state {@link #STATE_CONNECTED} |
| 325 | * |
| Jaikumar Ganesh | d8fc4dd | 2010-10-18 16:41:53 -0700 | [diff] [blame] | 326 | * @return List of devices. The list will be empty on error. |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 327 | */ |
| Jaikumar Ganesh | d8fc4dd | 2010-10-18 16:41:53 -0700 | [diff] [blame] | 328 | public List<BluetoothDevice> getConnectedDevices(); |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 329 | |
| 330 | /** |
| Jaikumar Ganesh | b342757 | 2011-01-25 16:03:13 -0800 | [diff] [blame] | 331 | * Get a list of devices that match any of the given connection |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 332 | * states. |
| 333 | * |
| Jaikumar Ganesh | b342757 | 2011-01-25 16:03:13 -0800 | [diff] [blame] | 334 | * <p> If none of the devices match any of the given states, |
| 335 | * an empty list will be returned. |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 336 | * |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 337 | * @param states Array of states. States can be one of {@link #STATE_CONNECTED}, {@link |
| 338 | * #STATE_CONNECTING}, {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING}, |
| Jaikumar Ganesh | d8fc4dd | 2010-10-18 16:41:53 -0700 | [diff] [blame] | 339 | * @return List of devices. The list will be empty on error. |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 340 | */ |
| Jaikumar Ganesh | d8fc4dd | 2010-10-18 16:41:53 -0700 | [diff] [blame] | 341 | public List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states); |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 342 | |
| 343 | /** |
| 344 | * Get the current connection state of the profile |
| 345 | * |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 346 | * @param device Remote bluetooth device. |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 347 | * @return State of the profile connection. One of {@link #STATE_CONNECTED}, {@link |
| 348 | * #STATE_CONNECTING}, {@link #STATE_DISCONNECTED}, {@link #STATE_DISCONNECTING} |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 349 | */ |
| Stanley Tng | a76ec8b | 2019-03-14 16:18:29 -0700 | [diff] [blame] | 350 | @BtProfileState int getConnectionState(BluetoothDevice device); |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 351 | |
| 352 | /** |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 353 | * An interface for notifying BluetoothProfile IPC clients when they have |
| 354 | * been connected or disconnected to the service. |
| 355 | */ |
| 356 | public interface ServiceListener { |
| 357 | /** |
| 358 | * Called to notify the client when the proxy object has been |
| 359 | * connected to the service. |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 360 | * |
| Jack He | 8bb9c7d | 2019-01-03 16:23:41 -0800 | [diff] [blame] | 361 | * @param profile - One of {@link #HEADSET} or {@link #A2DP} |
| 362 | * @param proxy - One of {@link BluetoothHeadset} or {@link BluetoothA2dp} |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 363 | */ |
| Jeff Sharkey | 5ba8bfc | 2021-04-16 09:53:23 -0600 | [diff] [blame] | 364 | @RequiresNoPermission |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 365 | public void onServiceConnected(int profile, BluetoothProfile proxy); |
| 366 | |
| 367 | /** |
| 368 | * Called to notify the client that this proxy object has been |
| 369 | * disconnected from the service. |
| Jack He | 910201b | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 370 | * |
| Jack He | 8bb9c7d | 2019-01-03 16:23:41 -0800 | [diff] [blame] | 371 | * @param profile - One of {@link #HEADSET} or {@link #A2DP} |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 372 | */ |
| Jeff Sharkey | 5ba8bfc | 2021-04-16 09:53:23 -0600 | [diff] [blame] | 373 | @RequiresNoPermission |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 374 | public void onServiceDisconnected(int profile); |
| 375 | } |
| Jack He | 93df940 | 2017-12-11 13:11:20 -0800 | [diff] [blame] | 376 | |
| 377 | /** |
| 378 | * Convert an integer value of connection state into human readable string |
| 379 | * |
| 380 | * @param connectionState - One of {@link #STATE_DISCONNECTED}, {@link #STATE_CONNECTING}, |
| 381 | * {@link #STATE_CONNECTED}, or {@link #STATE_DISCONNECTED} |
| 382 | * @return a string representation of the connection state, STATE_UNKNOWN if the state |
| 383 | * is not defined |
| 384 | * @hide |
| 385 | */ |
| 386 | static String getConnectionStateName(int connectionState) { |
| 387 | switch (connectionState) { |
| 388 | case STATE_DISCONNECTED: |
| 389 | return "STATE_DISCONNECTED"; |
| 390 | case STATE_CONNECTING: |
| 391 | return "STATE_CONNECTING"; |
| 392 | case STATE_CONNECTED: |
| 393 | return "STATE_CONNECTED"; |
| 394 | case STATE_DISCONNECTING: |
| 395 | return "STATE_DISCONNECTING"; |
| 396 | default: |
| 397 | return "STATE_UNKNOWN"; |
| 398 | } |
| 399 | } |
| Ugo Yu | e521618 | 2019-07-22 15:56:23 +0800 | [diff] [blame] | 400 | |
| 401 | /** |
| 402 | * Convert an integer value of profile ID into human readable string |
| 403 | * |
| 404 | * @param profile profile ID |
| 405 | * @return profile name as String, UNKOWN_PROFILE if the profile ID is not defined. |
| 406 | * @hide |
| 407 | */ |
| 408 | static String getProfileName(int profile) { |
| 409 | switch(profile) { |
| 410 | case HEADSET: |
| 411 | return "HEADSET"; |
| 412 | case A2DP: |
| 413 | return "A2DP"; |
| 414 | case HID_HOST: |
| 415 | return "HID_HOST"; |
| 416 | case PAN: |
| 417 | return "PAN"; |
| 418 | case PBAP: |
| 419 | return "PBAP"; |
| 420 | case GATT: |
| 421 | return "GATT"; |
| 422 | case GATT_SERVER: |
| 423 | return "GATT_SERVER"; |
| 424 | case MAP: |
| 425 | return "MAP"; |
| 426 | case SAP: |
| 427 | return "SAP"; |
| 428 | case A2DP_SINK: |
| 429 | return "A2DP_SINK"; |
| 430 | case AVRCP_CONTROLLER: |
| 431 | return "AVRCP_CONTROLLER"; |
| 432 | case AVRCP: |
| 433 | return "AVRCP"; |
| 434 | case HEADSET_CLIENT: |
| 435 | return "HEADSET_CLIENT"; |
| 436 | case PBAP_CLIENT: |
| 437 | return "PBAP_CLIENT"; |
| 438 | case MAP_CLIENT: |
| 439 | return "MAP_CLIENT"; |
| 440 | case HID_DEVICE: |
| 441 | return "HID_DEVICE"; |
| 442 | case OPP: |
| 443 | return "OPP"; |
| 444 | case HEARING_AID: |
| 445 | return "HEARING_AID"; |
| 446 | default: |
| 447 | return "UNKNOWN_PROFILE"; |
| 448 | } |
| 449 | } |
| Jaikumar Ganesh | 2af0776 | 2010-08-24 17:36:13 -0700 | [diff] [blame] | 450 | } |