blob: 260e2fb1b80ca294f407ef6a2b6901a5b3eb1445 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2008 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
17package android.bluetooth;
18
Ralph Nathan29335fd2018-07-23 09:35:18 -070019import android.annotation.TestApi;
Mathew Inwood4dc66d32018-08-01 15:07:20 +010020import android.annotation.UnsupportedAppUsage;
Mathew Inwood31755f92018-12-20 13:53:36 +000021import android.os.Build;
Nick Pelly005b2282009-09-10 10:21:56 -070022import android.os.Parcel;
23import android.os.Parcelable;
24
Pulkit Bhuwalka66d61232017-08-16 21:52:04 -070025import java.nio.ByteBuffer;
26import java.nio.ByteOrder;
27import java.util.Arrays;
28
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029/**
Scott Main9fab0ae2009-11-03 18:17:59 -080030 * Represents a Bluetooth class, which describes general characteristics
31 * and capabilities of a device. For example, a Bluetooth class will
32 * specify the general device type such as a phone, a computer, or
33 * headset, and whether it's capable of services such as audio or telephony.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034 *
Scott Main9fab0ae2009-11-03 18:17:59 -080035 * <p>Every Bluetooth class is composed of zero or more service classes, and
Nick Pelly005b2282009-09-10 10:21:56 -070036 * exactly one device class. The device class is further broken down into major
37 * and minor device class components.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038 *
Scott Main9fab0ae2009-11-03 18:17:59 -080039 * <p>{@link BluetoothClass} is useful as a hint to roughly describe a device
40 * (for example to show an icon in the UI), but does not reliably describe which
41 * Bluetooth profiles or services are actually supported by a device. Accurate
42 * service discovery is done through SDP requests, which are automatically
43 * performed when creating an RFCOMM socket with {@link
Jake Hambyf51eada2010-09-21 13:39:53 -070044 * BluetoothDevice#createRfcommSocketToServiceRecord} and {@link
45 * BluetoothAdapter#listenUsingRfcommWithServiceRecord}</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046 *
Nick Pelly005b2282009-09-10 10:21:56 -070047 * <p>Use {@link BluetoothDevice#getBluetoothClass} to retrieve the class for
48 * a remote device.
Scott Main9fab0ae2009-11-03 18:17:59 -080049 *
50 * <!--
51 * The Bluetooth class is a 32 bit field. The format of these bits is defined at
52 * http://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm
53 * (login required). This class contains that 32 bit field, and provides
54 * constants and methods to determine which Service Class(es) and Device Class
55 * are encoded in that field.
56 * -->
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080057 */
Nick Pelly005b2282009-09-10 10:21:56 -070058public final class BluetoothClass implements Parcelable {
59 /**
60 * Legacy error value. Applications should use null instead.
Jack Hea355e5e2017-08-22 16:06:54 -070061 *
Nick Pelly005b2282009-09-10 10:21:56 -070062 * @hide
63 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080064 public static final int ERROR = 0xFF000000;
65
Nick Pelly005b2282009-09-10 10:21:56 -070066 private final int mClass;
Yue Lixina4433af2009-07-09 16:56:43 +080067
Nick Pelly005b2282009-09-10 10:21:56 -070068 /** @hide */
Mathew Inwood31755f92018-12-20 13:53:36 +000069 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
Nick Pelly005b2282009-09-10 10:21:56 -070070 public BluetoothClass(int classInt) {
71 mClass = classInt;
72 }
73
74 @Override
75 public boolean equals(Object o) {
76 if (o instanceof BluetoothClass) {
Jack Hea355e5e2017-08-22 16:06:54 -070077 return mClass == ((BluetoothClass) o).mClass;
Nick Pelly005b2282009-09-10 10:21:56 -070078 }
79 return false;
80 }
81
82 @Override
83 public int hashCode() {
84 return mClass;
85 }
86
87 @Override
88 public String toString() {
89 return Integer.toHexString(mClass);
90 }
91
Jack He2992cd02017-08-22 21:21:23 -070092 @Override
Nick Pelly005b2282009-09-10 10:21:56 -070093 public int describeContents() {
94 return 0;
95 }
96
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070097 public static final @android.annotation.NonNull Parcelable.Creator<BluetoothClass> CREATOR =
Nick Pelly005b2282009-09-10 10:21:56 -070098 new Parcelable.Creator<BluetoothClass>() {
Jack Hea355e5e2017-08-22 16:06:54 -070099 public BluetoothClass createFromParcel(Parcel in) {
100 return new BluetoothClass(in.readInt());
101 }
102
103 public BluetoothClass[] newArray(int size) {
104 return new BluetoothClass[size];
105 }
106 };
Nick Pelly005b2282009-09-10 10:21:56 -0700107
Jack He2992cd02017-08-22 21:21:23 -0700108 @Override
Nick Pelly005b2282009-09-10 10:21:56 -0700109 public void writeToParcel(Parcel out, int flags) {
110 out.writeInt(mClass);
111 }
112
113 /**
Scott Main9fab0ae2009-11-03 18:17:59 -0800114 * Defines all service class constants.
Nick Pelly005b2282009-09-10 10:21:56 -0700115 * <p>Each {@link BluetoothClass} encodes zero or more service classes.
116 */
117 public static final class Service {
Jack Hea355e5e2017-08-22 16:06:54 -0700118 private static final int BITMASK = 0xFFE000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800119
120 public static final int LIMITED_DISCOVERABILITY = 0x002000;
Jack Hea355e5e2017-08-22 16:06:54 -0700121 public static final int POSITIONING = 0x010000;
122 public static final int NETWORKING = 0x020000;
123 public static final int RENDER = 0x040000;
124 public static final int CAPTURE = 0x080000;
125 public static final int OBJECT_TRANSFER = 0x100000;
126 public static final int AUDIO = 0x200000;
127 public static final int TELEPHONY = 0x400000;
128 public static final int INFORMATION = 0x800000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800129 }
130
Nick Pelly005b2282009-09-10 10:21:56 -0700131 /**
Scott Main9fab0ae2009-11-03 18:17:59 -0800132 * Return true if the specified service class is supported by this
133 * {@link BluetoothClass}.
Nick Pelly005b2282009-09-10 10:21:56 -0700134 * <p>Valid service classes are the public constants in
135 * {@link BluetoothClass.Service}. For example, {@link
136 * BluetoothClass.Service#AUDIO}.
137 *
138 * @param service valid service class
139 * @return true if the service class is supported
140 */
141 public boolean hasService(int service) {
142 return ((mClass & Service.BITMASK & service) != 0);
143 }
144
145 /**
Scott Main9fab0ae2009-11-03 18:17:59 -0800146 * Defines all device class constants.
Nick Pelly005b2282009-09-10 10:21:56 -0700147 * <p>Each {@link BluetoothClass} encodes exactly one device class, with
148 * major and minor components.
149 * <p>The constants in {@link
150 * BluetoothClass.Device} represent a combination of major and minor
Scott Main9fab0ae2009-11-03 18:17:59 -0800151 * device components (the complete device class). The constants in {@link
152 * BluetoothClass.Device.Major} represent only major device classes.
153 * <p>See {@link BluetoothClass.Service} for service class constants.
Nick Pelly005b2282009-09-10 10:21:56 -0700154 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800155 public static class Device {
Jack Hea355e5e2017-08-22 16:06:54 -0700156 private static final int BITMASK = 0x1FFC;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800157
Scott Main9fab0ae2009-11-03 18:17:59 -0800158 /**
159 * Defines all major device class constants.
160 * <p>See {@link BluetoothClass.Device} for minor classes.
161 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800162 public static class Major {
Jack Hea355e5e2017-08-22 16:06:54 -0700163 private static final int BITMASK = 0x1F00;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800164
Jack Hea355e5e2017-08-22 16:06:54 -0700165 public static final int MISC = 0x0000;
166 public static final int COMPUTER = 0x0100;
167 public static final int PHONE = 0x0200;
168 public static final int NETWORKING = 0x0300;
169 public static final int AUDIO_VIDEO = 0x0400;
170 public static final int PERIPHERAL = 0x0500;
171 public static final int IMAGING = 0x0600;
172 public static final int WEARABLE = 0x0700;
173 public static final int TOY = 0x0800;
174 public static final int HEALTH = 0x0900;
175 public static final int UNCATEGORIZED = 0x1F00;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800176 }
177
178 // Devices in the COMPUTER major class
Jack Hea355e5e2017-08-22 16:06:54 -0700179 public static final int COMPUTER_UNCATEGORIZED = 0x0100;
180 public static final int COMPUTER_DESKTOP = 0x0104;
181 public static final int COMPUTER_SERVER = 0x0108;
182 public static final int COMPUTER_LAPTOP = 0x010C;
183 public static final int COMPUTER_HANDHELD_PC_PDA = 0x0110;
184 public static final int COMPUTER_PALM_SIZE_PC_PDA = 0x0114;
185 public static final int COMPUTER_WEARABLE = 0x0118;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800186
187 // Devices in the PHONE major class
Jack Hea355e5e2017-08-22 16:06:54 -0700188 public static final int PHONE_UNCATEGORIZED = 0x0200;
189 public static final int PHONE_CELLULAR = 0x0204;
190 public static final int PHONE_CORDLESS = 0x0208;
191 public static final int PHONE_SMART = 0x020C;
192 public static final int PHONE_MODEM_OR_GATEWAY = 0x0210;
193 public static final int PHONE_ISDN = 0x0214;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800194
195 // Minor classes for the AUDIO_VIDEO major class
Jack Hea355e5e2017-08-22 16:06:54 -0700196 public static final int AUDIO_VIDEO_UNCATEGORIZED = 0x0400;
197 public static final int AUDIO_VIDEO_WEARABLE_HEADSET = 0x0404;
198 public static final int AUDIO_VIDEO_HANDSFREE = 0x0408;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800199 //public static final int AUDIO_VIDEO_RESERVED = 0x040C;
Jack Hea355e5e2017-08-22 16:06:54 -0700200 public static final int AUDIO_VIDEO_MICROPHONE = 0x0410;
201 public static final int AUDIO_VIDEO_LOUDSPEAKER = 0x0414;
202 public static final int AUDIO_VIDEO_HEADPHONES = 0x0418;
203 public static final int AUDIO_VIDEO_PORTABLE_AUDIO = 0x041C;
204 public static final int AUDIO_VIDEO_CAR_AUDIO = 0x0420;
205 public static final int AUDIO_VIDEO_SET_TOP_BOX = 0x0424;
206 public static final int AUDIO_VIDEO_HIFI_AUDIO = 0x0428;
207 public static final int AUDIO_VIDEO_VCR = 0x042C;
208 public static final int AUDIO_VIDEO_VIDEO_CAMERA = 0x0430;
209 public static final int AUDIO_VIDEO_CAMCORDER = 0x0434;
210 public static final int AUDIO_VIDEO_VIDEO_MONITOR = 0x0438;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800211 public static final int AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x043C;
Jack Hea355e5e2017-08-22 16:06:54 -0700212 public static final int AUDIO_VIDEO_VIDEO_CONFERENCING = 0x0440;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800213 //public static final int AUDIO_VIDEO_RESERVED = 0x0444;
Jack Hea355e5e2017-08-22 16:06:54 -0700214 public static final int AUDIO_VIDEO_VIDEO_GAMING_TOY = 0x0448;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800215
216 // Devices in the WEARABLE major class
Jack Hea355e5e2017-08-22 16:06:54 -0700217 public static final int WEARABLE_UNCATEGORIZED = 0x0700;
218 public static final int WEARABLE_WRIST_WATCH = 0x0704;
219 public static final int WEARABLE_PAGER = 0x0708;
220 public static final int WEARABLE_JACKET = 0x070C;
221 public static final int WEARABLE_HELMET = 0x0710;
222 public static final int WEARABLE_GLASSES = 0x0714;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800223
224 // Devices in the TOY major class
Jack Hea355e5e2017-08-22 16:06:54 -0700225 public static final int TOY_UNCATEGORIZED = 0x0800;
226 public static final int TOY_ROBOT = 0x0804;
227 public static final int TOY_VEHICLE = 0x0808;
228 public static final int TOY_DOLL_ACTION_FIGURE = 0x080C;
229 public static final int TOY_CONTROLLER = 0x0810;
230 public static final int TOY_GAME = 0x0814;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800231
232 // Devices in the HEALTH major class
Jack Hea355e5e2017-08-22 16:06:54 -0700233 public static final int HEALTH_UNCATEGORIZED = 0x0900;
234 public static final int HEALTH_BLOOD_PRESSURE = 0x0904;
235 public static final int HEALTH_THERMOMETER = 0x0908;
236 public static final int HEALTH_WEIGHING = 0x090C;
237 public static final int HEALTH_GLUCOSE = 0x0910;
238 public static final int HEALTH_PULSE_OXIMETER = 0x0914;
239 public static final int HEALTH_PULSE_RATE = 0x0918;
240 public static final int HEALTH_DATA_DISPLAY = 0x091C;
Jaikumar Ganeshc88b0c62011-01-05 13:49:00 -0800241
242 // Devices in PERIPHERAL major class
243 /**
244 * @hide
245 */
246 public static final int PERIPHERAL_NON_KEYBOARD_NON_POINTING = 0x0500;
247 /**
248 * @hide
249 */
Jack Hea355e5e2017-08-22 16:06:54 -0700250 public static final int PERIPHERAL_KEYBOARD = 0x0540;
Jaikumar Ganeshc88b0c62011-01-05 13:49:00 -0800251 /**
252 * @hide
253 */
Jack Hea355e5e2017-08-22 16:06:54 -0700254 public static final int PERIPHERAL_POINTING = 0x0580;
Jaikumar Ganeshc88b0c62011-01-05 13:49:00 -0800255 /**
256 * @hide
257 */
Jack Hea355e5e2017-08-22 16:06:54 -0700258 public static final int PERIPHERAL_KEYBOARD_POINTING = 0x05C0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800259 }
Yue Lixina4433af2009-07-09 16:56:43 +0800260
261 /**
Scott Main9fab0ae2009-11-03 18:17:59 -0800262 * Return the major device class component of this {@link BluetoothClass}.
Nick Pelly005b2282009-09-10 10:21:56 -0700263 * <p>Values returned from this function can be compared with the
264 * public constants in {@link BluetoothClass.Device.Major} to determine
265 * which major class is encoded in this Bluetooth class.
266 *
267 * @return major device class component
268 */
269 public int getMajorDeviceClass() {
270 return (mClass & Device.Major.BITMASK);
271 }
272
273 /**
274 * Return the (major and minor) device class component of this
275 * {@link BluetoothClass}.
276 * <p>Values returned from this function can be compared with the
277 * public constants in {@link BluetoothClass.Device} to determine which
278 * device class is encoded in this Bluetooth class.
279 *
280 * @return device class component
281 */
282 public int getDeviceClass() {
283 return (mClass & Device.BITMASK);
284 }
285
Pulkit Bhuwalka66d61232017-08-16 21:52:04 -0700286 /**
287 * Return the Bluetooth Class of Device (CoD) value including the
288 * {@link BluetoothClass.Service}, {@link BluetoothClass.Device.Major} and
289 * minor device fields.
290 *
291 * <p>This value is an integer representation of Bluetooth CoD as in
292 * Bluetooth specification.
293 *
294 * @see <a href="Bluetooth CoD">https://www.bluetooth.com/specifications/assigned-numbers/baseband</a>
295 *
296 * @hide
297 */
Ralph Nathan29335fd2018-07-23 09:35:18 -0700298 @TestApi
Pulkit Bhuwalka66d61232017-08-16 21:52:04 -0700299 public int getClassOfDevice() {
300 return mClass;
301 }
302
303 /**
304 * Return the Bluetooth Class of Device (CoD) value including the
305 * {@link BluetoothClass.Service}, {@link BluetoothClass.Device.Major} and
306 * minor device fields.
307 *
308 * <p>This value is a byte array representation of Bluetooth CoD as in
309 * Bluetooth specification.
310 *
311 * <p>Bluetooth COD information is 3 bytes, but stored as an int. Hence the
312 * MSB is useless and needs to be thrown away. The lower 3 bytes are
313 * converted into a byte array MSB to LSB. Hence, using BIG_ENDIAN.
314 *
315 * @see <a href="Bluetooth CoD">https://www.bluetooth.com/specifications/assigned-numbers/baseband</a>
316 *
317 * @hide
318 */
319 public byte[] getClassOfDeviceBytes() {
320 byte[] bytes = ByteBuffer.allocate(4)
321 .order(ByteOrder.BIG_ENDIAN)
322 .putInt(mClass)
323 .array();
324
325 // Discard the top byte
326 return Arrays.copyOfRange(bytes, 1, bytes.length);
327 }
328
Nick Pelly005b2282009-09-10 10:21:56 -0700329 /** @hide */
Mathew Inwood4dc66d32018-08-01 15:07:20 +0100330 @UnsupportedAppUsage
Nick Pelly005b2282009-09-10 10:21:56 -0700331 public static final int PROFILE_HEADSET = 0;
332 /** @hide */
Mathew Inwood4dc66d32018-08-01 15:07:20 +0100333 @UnsupportedAppUsage
Nick Pelly005b2282009-09-10 10:21:56 -0700334 public static final int PROFILE_A2DP = 1;
335 /** @hide */
336 public static final int PROFILE_OPP = 2;
Adam Powelldf7627d2010-06-21 16:23:42 -0700337 /** @hide */
338 public static final int PROFILE_HID = 3;
Jaikumar Ganesh33205802010-08-23 11:49:36 -0700339 /** @hide */
340 public static final int PROFILE_PANU = 4;
341 /** @hide */
342 public static final int PROFILE_NAP = 5;
Sanket Agarwal1bec6a52015-10-21 18:23:27 -0700343 /** @hide */
344 public static final int PROFILE_A2DP_SINK = 6;
Nick Pelly005b2282009-09-10 10:21:56 -0700345
346 /**
Yue Lixina4433af2009-07-09 16:56:43 +0800347 * Check class bits for possible bluetooth profile support.
348 * This is a simple heuristic that tries to guess if a device with the
349 * given class bits might support specified profile. It is not accurate for all
350 * devices. It tries to err on the side of false positives.
Jack Hea355e5e2017-08-22 16:06:54 -0700351 *
Yue Lixina4433af2009-07-09 16:56:43 +0800352 * @param profile The profile to be checked
353 * @return True if this device might support specified profile.
Nick Pelly005b2282009-09-10 10:21:56 -0700354 * @hide
Yue Lixina4433af2009-07-09 16:56:43 +0800355 */
Mathew Inwood4dc66d32018-08-01 15:07:20 +0100356 @UnsupportedAppUsage
Nick Pelly005b2282009-09-10 10:21:56 -0700357 public boolean doesClassMatch(int profile) {
Yue Lixina4433af2009-07-09 16:56:43 +0800358 if (profile == PROFILE_A2DP) {
Nick Pelly005b2282009-09-10 10:21:56 -0700359 if (hasService(Service.RENDER)) {
Yue Lixina4433af2009-07-09 16:56:43 +0800360 return true;
361 }
362 // By the A2DP spec, sinks must indicate the RENDER service.
363 // However we found some that do not (Chordette). So lets also
364 // match on some other class bits.
Nick Pelly005b2282009-09-10 10:21:56 -0700365 switch (getDeviceClass()) {
366 case Device.AUDIO_VIDEO_HIFI_AUDIO:
367 case Device.AUDIO_VIDEO_HEADPHONES:
368 case Device.AUDIO_VIDEO_LOUDSPEAKER:
369 case Device.AUDIO_VIDEO_CAR_AUDIO:
Yue Lixina4433af2009-07-09 16:56:43 +0800370 return true;
371 default:
372 return false;
373 }
Sanket Agarwal1bec6a52015-10-21 18:23:27 -0700374 } else if (profile == PROFILE_A2DP_SINK) {
375 if (hasService(Service.CAPTURE)) {
376 return true;
377 }
378 // By the A2DP spec, srcs must indicate the CAPTURE service.
379 // However if some device that do not, we try to
380 // match on some other class bits.
381 switch (getDeviceClass()) {
382 case Device.AUDIO_VIDEO_HIFI_AUDIO:
383 case Device.AUDIO_VIDEO_SET_TOP_BOX:
Jack Hea355e5e2017-08-22 16:06:54 -0700384 case Device.AUDIO_VIDEO_VCR:
Sanket Agarwal1bec6a52015-10-21 18:23:27 -0700385 return true;
386 default:
387 return false;
388 }
Yue Lixina4433af2009-07-09 16:56:43 +0800389 } else if (profile == PROFILE_HEADSET) {
390 // The render service class is required by the spec for HFP, so is a
391 // pretty good signal
Nick Pelly005b2282009-09-10 10:21:56 -0700392 if (hasService(Service.RENDER)) {
Yue Lixina4433af2009-07-09 16:56:43 +0800393 return true;
394 }
395 // Just in case they forgot the render service class
Nick Pelly005b2282009-09-10 10:21:56 -0700396 switch (getDeviceClass()) {
397 case Device.AUDIO_VIDEO_HANDSFREE:
398 case Device.AUDIO_VIDEO_WEARABLE_HEADSET:
399 case Device.AUDIO_VIDEO_CAR_AUDIO:
Yue Lixina4433af2009-07-09 16:56:43 +0800400 return true;
401 default:
402 return false;
403 }
404 } else if (profile == PROFILE_OPP) {
Nick Pelly005b2282009-09-10 10:21:56 -0700405 if (hasService(Service.OBJECT_TRANSFER)) {
Yue Lixina4433af2009-07-09 16:56:43 +0800406 return true;
407 }
408
Nick Pelly005b2282009-09-10 10:21:56 -0700409 switch (getDeviceClass()) {
410 case Device.COMPUTER_UNCATEGORIZED:
411 case Device.COMPUTER_DESKTOP:
412 case Device.COMPUTER_SERVER:
413 case Device.COMPUTER_LAPTOP:
414 case Device.COMPUTER_HANDHELD_PC_PDA:
415 case Device.COMPUTER_PALM_SIZE_PC_PDA:
416 case Device.COMPUTER_WEARABLE:
417 case Device.PHONE_UNCATEGORIZED:
418 case Device.PHONE_CELLULAR:
419 case Device.PHONE_CORDLESS:
420 case Device.PHONE_SMART:
421 case Device.PHONE_MODEM_OR_GATEWAY:
422 case Device.PHONE_ISDN:
Yue Lixina4433af2009-07-09 16:56:43 +0800423 return true;
424 default:
425 return false;
426 }
Adam Powelldf7627d2010-06-21 16:23:42 -0700427 } else if (profile == PROFILE_HID) {
428 return (getDeviceClass() & Device.Major.PERIPHERAL) == Device.Major.PERIPHERAL;
Jack Hea355e5e2017-08-22 16:06:54 -0700429 } else if (profile == PROFILE_PANU || profile == PROFILE_NAP) {
Jaikumar Ganesh33205802010-08-23 11:49:36 -0700430 // No good way to distinguish between the two, based on class bits.
431 if (hasService(Service.NETWORKING)) {
432 return true;
433 }
434 return (getDeviceClass() & Device.Major.NETWORKING) == Device.Major.NETWORKING;
Yue Lixina4433af2009-07-09 16:56:43 +0800435 } else {
436 return false;
437 }
438 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800439}