blob: 3a78cbdd4d0af55f0ac295b455b1b054787c623f [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;
Nick Pelly005b2282009-09-10 10:21:56 -070021import android.os.Parcel;
22import android.os.Parcelable;
23
Pulkit Bhuwalka66d61232017-08-16 21:52:04 -070024import java.nio.ByteBuffer;
25import java.nio.ByteOrder;
26import java.util.Arrays;
27
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080028/**
Scott Main9fab0ae2009-11-03 18:17:59 -080029 * Represents a Bluetooth class, which describes general characteristics
30 * and capabilities of a device. For example, a Bluetooth class will
31 * specify the general device type such as a phone, a computer, or
32 * headset, and whether it's capable of services such as audio or telephony.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033 *
Scott Main9fab0ae2009-11-03 18:17:59 -080034 * <p>Every Bluetooth class is composed of zero or more service classes, and
Nick Pelly005b2282009-09-10 10:21:56 -070035 * exactly one device class. The device class is further broken down into major
36 * and minor device class components.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080037 *
Scott Main9fab0ae2009-11-03 18:17:59 -080038 * <p>{@link BluetoothClass} is useful as a hint to roughly describe a device
39 * (for example to show an icon in the UI), but does not reliably describe which
40 * Bluetooth profiles or services are actually supported by a device. Accurate
41 * service discovery is done through SDP requests, which are automatically
42 * performed when creating an RFCOMM socket with {@link
Jake Hambyf51eada2010-09-21 13:39:53 -070043 * BluetoothDevice#createRfcommSocketToServiceRecord} and {@link
44 * BluetoothAdapter#listenUsingRfcommWithServiceRecord}</p>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045 *
Nick Pelly005b2282009-09-10 10:21:56 -070046 * <p>Use {@link BluetoothDevice#getBluetoothClass} to retrieve the class for
47 * a remote device.
Scott Main9fab0ae2009-11-03 18:17:59 -080048 *
49 * <!--
50 * The Bluetooth class is a 32 bit field. The format of these bits is defined at
51 * http://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm
52 * (login required). This class contains that 32 bit field, and provides
53 * constants and methods to determine which Service Class(es) and Device Class
54 * are encoded in that field.
55 * -->
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080056 */
Nick Pelly005b2282009-09-10 10:21:56 -070057public final class BluetoothClass implements Parcelable {
58 /**
59 * Legacy error value. Applications should use null instead.
Jack Hea355e5e2017-08-22 16:06:54 -070060 *
Nick Pelly005b2282009-09-10 10:21:56 -070061 * @hide
62 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080063 public static final int ERROR = 0xFF000000;
64
Nick Pelly005b2282009-09-10 10:21:56 -070065 private final int mClass;
Yue Lixina4433af2009-07-09 16:56:43 +080066
Nick Pelly005b2282009-09-10 10:21:56 -070067 /** @hide */
Mathew Inwood4dc66d32018-08-01 15:07:20 +010068 @UnsupportedAppUsage
Nick Pelly005b2282009-09-10 10:21:56 -070069 public BluetoothClass(int classInt) {
70 mClass = classInt;
71 }
72
73 @Override
74 public boolean equals(Object o) {
75 if (o instanceof BluetoothClass) {
Jack Hea355e5e2017-08-22 16:06:54 -070076 return mClass == ((BluetoothClass) o).mClass;
Nick Pelly005b2282009-09-10 10:21:56 -070077 }
78 return false;
79 }
80
81 @Override
82 public int hashCode() {
83 return mClass;
84 }
85
86 @Override
87 public String toString() {
88 return Integer.toHexString(mClass);
89 }
90
Jack He2992cd02017-08-22 21:21:23 -070091 @Override
Nick Pelly005b2282009-09-10 10:21:56 -070092 public int describeContents() {
93 return 0;
94 }
95
Nick Pelly005b2282009-09-10 10:21:56 -070096 public static final Parcelable.Creator<BluetoothClass> CREATOR =
97 new Parcelable.Creator<BluetoothClass>() {
Jack Hea355e5e2017-08-22 16:06:54 -070098 public BluetoothClass createFromParcel(Parcel in) {
99 return new BluetoothClass(in.readInt());
100 }
101
102 public BluetoothClass[] newArray(int size) {
103 return new BluetoothClass[size];
104 }
105 };
Nick Pelly005b2282009-09-10 10:21:56 -0700106
Jack He2992cd02017-08-22 21:21:23 -0700107 @Override
Nick Pelly005b2282009-09-10 10:21:56 -0700108 public void writeToParcel(Parcel out, int flags) {
109 out.writeInt(mClass);
110 }
111
112 /**
Scott Main9fab0ae2009-11-03 18:17:59 -0800113 * Defines all service class constants.
Nick Pelly005b2282009-09-10 10:21:56 -0700114 * <p>Each {@link BluetoothClass} encodes zero or more service classes.
115 */
116 public static final class Service {
Jack Hea355e5e2017-08-22 16:06:54 -0700117 private static final int BITMASK = 0xFFE000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800118
119 public static final int LIMITED_DISCOVERABILITY = 0x002000;
Jack Hea355e5e2017-08-22 16:06:54 -0700120 public static final int POSITIONING = 0x010000;
121 public static final int NETWORKING = 0x020000;
122 public static final int RENDER = 0x040000;
123 public static final int CAPTURE = 0x080000;
124 public static final int OBJECT_TRANSFER = 0x100000;
125 public static final int AUDIO = 0x200000;
126 public static final int TELEPHONY = 0x400000;
127 public static final int INFORMATION = 0x800000;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800128 }
129
Nick Pelly005b2282009-09-10 10:21:56 -0700130 /**
Scott Main9fab0ae2009-11-03 18:17:59 -0800131 * Return true if the specified service class is supported by this
132 * {@link BluetoothClass}.
Nick Pelly005b2282009-09-10 10:21:56 -0700133 * <p>Valid service classes are the public constants in
134 * {@link BluetoothClass.Service}. For example, {@link
135 * BluetoothClass.Service#AUDIO}.
136 *
137 * @param service valid service class
138 * @return true if the service class is supported
139 */
140 public boolean hasService(int service) {
141 return ((mClass & Service.BITMASK & service) != 0);
142 }
143
144 /**
Scott Main9fab0ae2009-11-03 18:17:59 -0800145 * Defines all device class constants.
Nick Pelly005b2282009-09-10 10:21:56 -0700146 * <p>Each {@link BluetoothClass} encodes exactly one device class, with
147 * major and minor components.
148 * <p>The constants in {@link
149 * BluetoothClass.Device} represent a combination of major and minor
Scott Main9fab0ae2009-11-03 18:17:59 -0800150 * device components (the complete device class). The constants in {@link
151 * BluetoothClass.Device.Major} represent only major device classes.
152 * <p>See {@link BluetoothClass.Service} for service class constants.
Nick Pelly005b2282009-09-10 10:21:56 -0700153 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800154 public static class Device {
Jack Hea355e5e2017-08-22 16:06:54 -0700155 private static final int BITMASK = 0x1FFC;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800156
Scott Main9fab0ae2009-11-03 18:17:59 -0800157 /**
158 * Defines all major device class constants.
159 * <p>See {@link BluetoothClass.Device} for minor classes.
160 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800161 public static class Major {
Jack Hea355e5e2017-08-22 16:06:54 -0700162 private static final int BITMASK = 0x1F00;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800163
Jack Hea355e5e2017-08-22 16:06:54 -0700164 public static final int MISC = 0x0000;
165 public static final int COMPUTER = 0x0100;
166 public static final int PHONE = 0x0200;
167 public static final int NETWORKING = 0x0300;
168 public static final int AUDIO_VIDEO = 0x0400;
169 public static final int PERIPHERAL = 0x0500;
170 public static final int IMAGING = 0x0600;
171 public static final int WEARABLE = 0x0700;
172 public static final int TOY = 0x0800;
173 public static final int HEALTH = 0x0900;
174 public static final int UNCATEGORIZED = 0x1F00;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800175 }
176
177 // Devices in the COMPUTER major class
Jack Hea355e5e2017-08-22 16:06:54 -0700178 public static final int COMPUTER_UNCATEGORIZED = 0x0100;
179 public static final int COMPUTER_DESKTOP = 0x0104;
180 public static final int COMPUTER_SERVER = 0x0108;
181 public static final int COMPUTER_LAPTOP = 0x010C;
182 public static final int COMPUTER_HANDHELD_PC_PDA = 0x0110;
183 public static final int COMPUTER_PALM_SIZE_PC_PDA = 0x0114;
184 public static final int COMPUTER_WEARABLE = 0x0118;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800185
186 // Devices in the PHONE major class
Jack Hea355e5e2017-08-22 16:06:54 -0700187 public static final int PHONE_UNCATEGORIZED = 0x0200;
188 public static final int PHONE_CELLULAR = 0x0204;
189 public static final int PHONE_CORDLESS = 0x0208;
190 public static final int PHONE_SMART = 0x020C;
191 public static final int PHONE_MODEM_OR_GATEWAY = 0x0210;
192 public static final int PHONE_ISDN = 0x0214;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800193
194 // Minor classes for the AUDIO_VIDEO major class
Jack Hea355e5e2017-08-22 16:06:54 -0700195 public static final int AUDIO_VIDEO_UNCATEGORIZED = 0x0400;
196 public static final int AUDIO_VIDEO_WEARABLE_HEADSET = 0x0404;
197 public static final int AUDIO_VIDEO_HANDSFREE = 0x0408;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800198 //public static final int AUDIO_VIDEO_RESERVED = 0x040C;
Jack Hea355e5e2017-08-22 16:06:54 -0700199 public static final int AUDIO_VIDEO_MICROPHONE = 0x0410;
200 public static final int AUDIO_VIDEO_LOUDSPEAKER = 0x0414;
201 public static final int AUDIO_VIDEO_HEADPHONES = 0x0418;
202 public static final int AUDIO_VIDEO_PORTABLE_AUDIO = 0x041C;
203 public static final int AUDIO_VIDEO_CAR_AUDIO = 0x0420;
204 public static final int AUDIO_VIDEO_SET_TOP_BOX = 0x0424;
205 public static final int AUDIO_VIDEO_HIFI_AUDIO = 0x0428;
206 public static final int AUDIO_VIDEO_VCR = 0x042C;
207 public static final int AUDIO_VIDEO_VIDEO_CAMERA = 0x0430;
208 public static final int AUDIO_VIDEO_CAMCORDER = 0x0434;
209 public static final int AUDIO_VIDEO_VIDEO_MONITOR = 0x0438;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800210 public static final int AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x043C;
Jack Hea355e5e2017-08-22 16:06:54 -0700211 public static final int AUDIO_VIDEO_VIDEO_CONFERENCING = 0x0440;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800212 //public static final int AUDIO_VIDEO_RESERVED = 0x0444;
Jack Hea355e5e2017-08-22 16:06:54 -0700213 public static final int AUDIO_VIDEO_VIDEO_GAMING_TOY = 0x0448;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800214
215 // Devices in the WEARABLE major class
Jack Hea355e5e2017-08-22 16:06:54 -0700216 public static final int WEARABLE_UNCATEGORIZED = 0x0700;
217 public static final int WEARABLE_WRIST_WATCH = 0x0704;
218 public static final int WEARABLE_PAGER = 0x0708;
219 public static final int WEARABLE_JACKET = 0x070C;
220 public static final int WEARABLE_HELMET = 0x0710;
221 public static final int WEARABLE_GLASSES = 0x0714;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800222
223 // Devices in the TOY major class
Jack Hea355e5e2017-08-22 16:06:54 -0700224 public static final int TOY_UNCATEGORIZED = 0x0800;
225 public static final int TOY_ROBOT = 0x0804;
226 public static final int TOY_VEHICLE = 0x0808;
227 public static final int TOY_DOLL_ACTION_FIGURE = 0x080C;
228 public static final int TOY_CONTROLLER = 0x0810;
229 public static final int TOY_GAME = 0x0814;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800230
231 // Devices in the HEALTH major class
Jack Hea355e5e2017-08-22 16:06:54 -0700232 public static final int HEALTH_UNCATEGORIZED = 0x0900;
233 public static final int HEALTH_BLOOD_PRESSURE = 0x0904;
234 public static final int HEALTH_THERMOMETER = 0x0908;
235 public static final int HEALTH_WEIGHING = 0x090C;
236 public static final int HEALTH_GLUCOSE = 0x0910;
237 public static final int HEALTH_PULSE_OXIMETER = 0x0914;
238 public static final int HEALTH_PULSE_RATE = 0x0918;
239 public static final int HEALTH_DATA_DISPLAY = 0x091C;
Jaikumar Ganeshc88b0c62011-01-05 13:49:00 -0800240
241 // Devices in PERIPHERAL major class
242 /**
243 * @hide
244 */
245 public static final int PERIPHERAL_NON_KEYBOARD_NON_POINTING = 0x0500;
246 /**
247 * @hide
248 */
Jack Hea355e5e2017-08-22 16:06:54 -0700249 public static final int PERIPHERAL_KEYBOARD = 0x0540;
Jaikumar Ganeshc88b0c62011-01-05 13:49:00 -0800250 /**
251 * @hide
252 */
Jack Hea355e5e2017-08-22 16:06:54 -0700253 public static final int PERIPHERAL_POINTING = 0x0580;
Jaikumar Ganeshc88b0c62011-01-05 13:49:00 -0800254 /**
255 * @hide
256 */
Jack Hea355e5e2017-08-22 16:06:54 -0700257 public static final int PERIPHERAL_KEYBOARD_POINTING = 0x05C0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800258 }
Yue Lixina4433af2009-07-09 16:56:43 +0800259
260 /**
Scott Main9fab0ae2009-11-03 18:17:59 -0800261 * Return the major device class component of this {@link BluetoothClass}.
Nick Pelly005b2282009-09-10 10:21:56 -0700262 * <p>Values returned from this function can be compared with the
263 * public constants in {@link BluetoothClass.Device.Major} to determine
264 * which major class is encoded in this Bluetooth class.
265 *
266 * @return major device class component
267 */
268 public int getMajorDeviceClass() {
269 return (mClass & Device.Major.BITMASK);
270 }
271
272 /**
273 * Return the (major and minor) device class component of this
274 * {@link BluetoothClass}.
275 * <p>Values returned from this function can be compared with the
276 * public constants in {@link BluetoothClass.Device} to determine which
277 * device class is encoded in this Bluetooth class.
278 *
279 * @return device class component
280 */
281 public int getDeviceClass() {
282 return (mClass & Device.BITMASK);
283 }
284
Pulkit Bhuwalka66d61232017-08-16 21:52:04 -0700285 /**
286 * Return the Bluetooth Class of Device (CoD) value including the
287 * {@link BluetoothClass.Service}, {@link BluetoothClass.Device.Major} and
288 * minor device fields.
289 *
290 * <p>This value is an integer representation of Bluetooth CoD as in
291 * Bluetooth specification.
292 *
293 * @see <a href="Bluetooth CoD">https://www.bluetooth.com/specifications/assigned-numbers/baseband</a>
294 *
295 * @hide
296 */
Ralph Nathan29335fd2018-07-23 09:35:18 -0700297 @TestApi
Pulkit Bhuwalka66d61232017-08-16 21:52:04 -0700298 public int getClassOfDevice() {
299 return mClass;
300 }
301
302 /**
303 * Return the Bluetooth Class of Device (CoD) value including the
304 * {@link BluetoothClass.Service}, {@link BluetoothClass.Device.Major} and
305 * minor device fields.
306 *
307 * <p>This value is a byte array representation of Bluetooth CoD as in
308 * Bluetooth specification.
309 *
310 * <p>Bluetooth COD information is 3 bytes, but stored as an int. Hence the
311 * MSB is useless and needs to be thrown away. The lower 3 bytes are
312 * converted into a byte array MSB to LSB. Hence, using BIG_ENDIAN.
313 *
314 * @see <a href="Bluetooth CoD">https://www.bluetooth.com/specifications/assigned-numbers/baseband</a>
315 *
316 * @hide
317 */
318 public byte[] getClassOfDeviceBytes() {
319 byte[] bytes = ByteBuffer.allocate(4)
320 .order(ByteOrder.BIG_ENDIAN)
321 .putInt(mClass)
322 .array();
323
324 // Discard the top byte
325 return Arrays.copyOfRange(bytes, 1, bytes.length);
326 }
327
Nick Pelly005b2282009-09-10 10:21:56 -0700328 /** @hide */
Mathew Inwood4dc66d32018-08-01 15:07:20 +0100329 @UnsupportedAppUsage
Nick Pelly005b2282009-09-10 10:21:56 -0700330 public static final int PROFILE_HEADSET = 0;
331 /** @hide */
Mathew Inwood4dc66d32018-08-01 15:07:20 +0100332 @UnsupportedAppUsage
Nick Pelly005b2282009-09-10 10:21:56 -0700333 public static final int PROFILE_A2DP = 1;
334 /** @hide */
335 public static final int PROFILE_OPP = 2;
Adam Powelldf7627d2010-06-21 16:23:42 -0700336 /** @hide */
337 public static final int PROFILE_HID = 3;
Jaikumar Ganesh33205802010-08-23 11:49:36 -0700338 /** @hide */
339 public static final int PROFILE_PANU = 4;
340 /** @hide */
341 public static final int PROFILE_NAP = 5;
Sanket Agarwal1bec6a52015-10-21 18:23:27 -0700342 /** @hide */
343 public static final int PROFILE_A2DP_SINK = 6;
Nick Pelly005b2282009-09-10 10:21:56 -0700344
345 /**
Yue Lixina4433af2009-07-09 16:56:43 +0800346 * Check class bits for possible bluetooth profile support.
347 * This is a simple heuristic that tries to guess if a device with the
348 * given class bits might support specified profile. It is not accurate for all
349 * devices. It tries to err on the side of false positives.
Jack Hea355e5e2017-08-22 16:06:54 -0700350 *
Yue Lixina4433af2009-07-09 16:56:43 +0800351 * @param profile The profile to be checked
352 * @return True if this device might support specified profile.
Nick Pelly005b2282009-09-10 10:21:56 -0700353 * @hide
Yue Lixina4433af2009-07-09 16:56:43 +0800354 */
Mathew Inwood4dc66d32018-08-01 15:07:20 +0100355 @UnsupportedAppUsage
Nick Pelly005b2282009-09-10 10:21:56 -0700356 public boolean doesClassMatch(int profile) {
Yue Lixina4433af2009-07-09 16:56:43 +0800357 if (profile == PROFILE_A2DP) {
Nick Pelly005b2282009-09-10 10:21:56 -0700358 if (hasService(Service.RENDER)) {
Yue Lixina4433af2009-07-09 16:56:43 +0800359 return true;
360 }
361 // By the A2DP spec, sinks must indicate the RENDER service.
362 // However we found some that do not (Chordette). So lets also
363 // match on some other class bits.
Nick Pelly005b2282009-09-10 10:21:56 -0700364 switch (getDeviceClass()) {
365 case Device.AUDIO_VIDEO_HIFI_AUDIO:
366 case Device.AUDIO_VIDEO_HEADPHONES:
367 case Device.AUDIO_VIDEO_LOUDSPEAKER:
368 case Device.AUDIO_VIDEO_CAR_AUDIO:
Yue Lixina4433af2009-07-09 16:56:43 +0800369 return true;
370 default:
371 return false;
372 }
Sanket Agarwal1bec6a52015-10-21 18:23:27 -0700373 } else if (profile == PROFILE_A2DP_SINK) {
374 if (hasService(Service.CAPTURE)) {
375 return true;
376 }
377 // By the A2DP spec, srcs must indicate the CAPTURE service.
378 // However if some device that do not, we try to
379 // match on some other class bits.
380 switch (getDeviceClass()) {
381 case Device.AUDIO_VIDEO_HIFI_AUDIO:
382 case Device.AUDIO_VIDEO_SET_TOP_BOX:
Jack Hea355e5e2017-08-22 16:06:54 -0700383 case Device.AUDIO_VIDEO_VCR:
Sanket Agarwal1bec6a52015-10-21 18:23:27 -0700384 return true;
385 default:
386 return false;
387 }
Yue Lixina4433af2009-07-09 16:56:43 +0800388 } else if (profile == PROFILE_HEADSET) {
389 // The render service class is required by the spec for HFP, so is a
390 // pretty good signal
Nick Pelly005b2282009-09-10 10:21:56 -0700391 if (hasService(Service.RENDER)) {
Yue Lixina4433af2009-07-09 16:56:43 +0800392 return true;
393 }
394 // Just in case they forgot the render service class
Nick Pelly005b2282009-09-10 10:21:56 -0700395 switch (getDeviceClass()) {
396 case Device.AUDIO_VIDEO_HANDSFREE:
397 case Device.AUDIO_VIDEO_WEARABLE_HEADSET:
398 case Device.AUDIO_VIDEO_CAR_AUDIO:
Yue Lixina4433af2009-07-09 16:56:43 +0800399 return true;
400 default:
401 return false;
402 }
403 } else if (profile == PROFILE_OPP) {
Nick Pelly005b2282009-09-10 10:21:56 -0700404 if (hasService(Service.OBJECT_TRANSFER)) {
Yue Lixina4433af2009-07-09 16:56:43 +0800405 return true;
406 }
407
Nick Pelly005b2282009-09-10 10:21:56 -0700408 switch (getDeviceClass()) {
409 case Device.COMPUTER_UNCATEGORIZED:
410 case Device.COMPUTER_DESKTOP:
411 case Device.COMPUTER_SERVER:
412 case Device.COMPUTER_LAPTOP:
413 case Device.COMPUTER_HANDHELD_PC_PDA:
414 case Device.COMPUTER_PALM_SIZE_PC_PDA:
415 case Device.COMPUTER_WEARABLE:
416 case Device.PHONE_UNCATEGORIZED:
417 case Device.PHONE_CELLULAR:
418 case Device.PHONE_CORDLESS:
419 case Device.PHONE_SMART:
420 case Device.PHONE_MODEM_OR_GATEWAY:
421 case Device.PHONE_ISDN:
Yue Lixina4433af2009-07-09 16:56:43 +0800422 return true;
423 default:
424 return false;
425 }
Adam Powelldf7627d2010-06-21 16:23:42 -0700426 } else if (profile == PROFILE_HID) {
427 return (getDeviceClass() & Device.Major.PERIPHERAL) == Device.Major.PERIPHERAL;
Jack Hea355e5e2017-08-22 16:06:54 -0700428 } else if (profile == PROFILE_PANU || profile == PROFILE_NAP) {
Jaikumar Ganesh33205802010-08-23 11:49:36 -0700429 // No good way to distinguish between the two, based on class bits.
430 if (hasService(Service.NETWORKING)) {
431 return true;
432 }
433 return (getDeviceClass() & Device.Major.NETWORKING) == Device.Major.NETWORKING;
Yue Lixina4433af2009-07-09 16:56:43 +0800434 } else {
435 return false;
436 }
437 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800438}