From 9b9a933e8411c52725a2946ad6c71fc351c09052 Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Wed, 17 Dec 2008 18:05:43 -0800 Subject: Code drop from //branches/cupcake/...@124589 --- .../java/android/bluetooth/BluetoothClass.java | 191 +++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 framework/java/android/bluetooth/BluetoothClass.java (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java new file mode 100644 index 0000000000..88ce18b457 --- /dev/null +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -0,0 +1,191 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.bluetooth; + +/** + * The Android Bluetooth API is not finalized, and *will* change. Use at your + * own risk. + * + * Static helper methods and constants to decode the device class bit vector + * returned by the Bluetooth API. + * + * The Android Bluetooth API returns a 32-bit integer to represent the class. + * The format of these bits is defined at + * http://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm + * (login required). This class provides static helper methods and constants to + * determine what Service Class(es) and Device Class are encoded in the 32-bit + * class. + * + * Devices typically have zero or more service classes, and exactly one device + * class. The device class is encoded as a major and minor device class, the + * minor being a subset of the major. + * + * Class is useful to describe a device (for example to show an icon), + * but does not reliably describe what profiles a device supports. To determine + * profile support you usually need to perform SDP queries. + * + * Each of these helper methods takes the 32-bit integer class as an argument. + * + * @hide + */ +public class BluetoothClass { + /** Indicates the Bluetooth API could not retrieve the class */ + public static final int ERROR = 0xFF000000; + + /** Every Bluetooth device has zero or more service classes */ + public static class Service { + public static final int BITMASK = 0xFFE000; + + public static final int LIMITED_DISCOVERABILITY = 0x002000; + public static final int POSITIONING = 0x010000; + public static final int NETWORKING = 0x020000; + public static final int RENDER = 0x040000; + public static final int CAPTURE = 0x080000; + public static final int OBJECT_TRANSFER = 0x100000; + public static final int AUDIO = 0x200000; + public static final int TELEPHONY = 0x400000; + public static final int INFORMATION = 0x800000; + + /** Returns true if the given class supports the given Service Class. + * A bluetooth device can claim to support zero or more service classes. + * @param btClass The bluetooth class. + * @param serviceClass The service class constant to test for. For + * example, Service.AUDIO. Must be one of the + * Service.FOO constants. + * @return True if the service class is supported. + */ + public static boolean hasService(int btClass, int serviceClass) { + if (btClass == ERROR) { + return false; + } + return ((btClass & Service.BITMASK & serviceClass) != 0); + } + } + + /** Every Bluetooth device has exactly one device class, comprimised of + * major and minor components. We have not included the minor classes for + * major classes: NETWORKING, PERIPHERAL and IMAGING yet because they work + * a little differently. */ + public static class Device { + public static final int BITMASK = 0x1FFC; + + public static class Major { + public static final int BITMASK = 0x1F00; + + public static final int MISC = 0x0000; + public static final int COMPUTER = 0x0100; + public static final int PHONE = 0x0200; + public static final int NETWORKING = 0x0300; + public static final int AUDIO_VIDEO = 0x0400; + public static final int PERIPHERAL = 0x0500; + public static final int IMAGING = 0x0600; + public static final int WEARABLE = 0x0700; + public static final int TOY = 0x0800; + public static final int HEALTH = 0x0900; + public static final int UNCATEGORIZED = 0x1F00; + + /** Returns the Major Device Class component of a bluetooth class. + * Values returned from this function can be compared with the constants + * Device.Major.FOO. A bluetooth device can only be associated + * with one major class. + */ + public static int getDeviceMajor(int btClass) { + if (btClass == ERROR) { + return ERROR; + } + return (btClass & Device.Major.BITMASK); + } + } + + // Devices in the COMPUTER major class + public static final int COMPUTER_UNCATEGORIZED = 0x0100; + public static final int COMPUTER_DESKTOP = 0x0104; + public static final int COMPUTER_SERVER = 0x0108; + public static final int COMPUTER_LAPTOP = 0x010C; + public static final int COMPUTER_HANDHELD_PC_PDA = 0x0110; + public static final int COMPUTER_PALM_SIZE_PC_PDA = 0x0114; + public static final int COMPUTER_WEARABLE = 0x0118; + + // Devices in the PHONE major class + public static final int PHONE_UNCATEGORIZED = 0x0200; + public static final int PHONE_CELLULAR = 0x0204; + public static final int PHONE_CORDLESS = 0x0208; + public static final int PHONE_SMART = 0x020C; + public static final int PHONE_MODEM_OR_GATEWAY = 0x0210; + public static final int PHONE_ISDN = 0x0214; + + // Minor classes for the AUDIO_VIDEO major class + public static final int AUDIO_VIDEO_UNCATEGORIZED = 0x0400; + public static final int AUDIO_VIDEO_WEARABLE_HEADSET = 0x0404; + public static final int AUDIO_VIDEO_HANDSFREE = 0x0408; + //public static final int AUDIO_VIDEO_RESERVED = 0x040C; + public static final int AUDIO_VIDEO_MICROPHONE = 0x0410; + public static final int AUDIO_VIDEO_LOUDSPEAKER = 0x0414; + public static final int AUDIO_VIDEO_HEADPHONES = 0x0418; + public static final int AUDIO_VIDEO_PORTABLE_AUDIO = 0x041C; + public static final int AUDIO_VIDEO_CAR_AUDIO = 0x0420; + public static final int AUDIO_VIDEO_SET_TOP_BOX = 0x0424; + public static final int AUDIO_VIDEO_HIFI_AUDIO = 0x0428; + public static final int AUDIO_VIDEO_VCR = 0x042C; + public static final int AUDIO_VIDEO_VIDEO_CAMERA = 0x0430; + public static final int AUDIO_VIDEO_CAMCORDER = 0x0434; + public static final int AUDIO_VIDEO_VIDEO_MONITOR = 0x0438; + public static final int AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x043C; + public static final int AUDIO_VIDEO_VIDEO_CONFERENCING = 0x0440; + //public static final int AUDIO_VIDEO_RESERVED = 0x0444; + public static final int AUDIO_VIDEO_VIDEO_GAMING_TOY = 0x0448; + + // Devices in the WEARABLE major class + public static final int WEARABLE_UNCATEGORIZED = 0x0700; + public static final int WEARABLE_WRIST_WATCH = 0x0704; + public static final int WEARABLE_PAGER = 0x0708; + public static final int WEARABLE_JACKET = 0x070C; + public static final int WEARABLE_HELMET = 0x0710; + public static final int WEARABLE_GLASSES = 0x0714; + + // Devices in the TOY major class + public static final int TOY_UNCATEGORIZED = 0x0800; + public static final int TOY_ROBOT = 0x0804; + public static final int TOY_VEHICLE = 0x0808; + public static final int TOY_DOLL_ACTION_FIGURE = 0x080C; + public static final int TOY_CONTROLLER = 0x0810; + public static final int TOY_GAME = 0x0814; + + // Devices in the HEALTH major class + public static final int HEALTH_UNCATEGORIZED = 0x0900; + public static final int HEALTH_BLOOD_PRESSURE = 0x0904; + public static final int HEALTH_THERMOMETER = 0x0908; + public static final int HEALTH_WEIGHING = 0x090C; + public static final int HEALTH_GLUCOSE = 0x0910; + public static final int HEALTH_PULSE_OXIMETER = 0x0914; + public static final int HEALTH_PULSE_RATE = 0x0918; + public static final int HEALTH_DATA_DISPLAY = 0x091C; + + /** Returns the Device Class component of a bluetooth class. This includes + * both the major and minor device components. Values returned from this + * function can be compared with the constants Device.FOO. A bluetooth + * device can only be associated with one device class. + */ + public static int getDevice(int btClass) { + if (btClass == ERROR) { + return ERROR; + } + return (btClass & Device.BITMASK); + } + } +} + -- cgit v1.2.3 From 3679e12ef106a04d71cda31dea9d7bd87a2523a5 Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Tue, 3 Mar 2009 18:28:45 -0800 Subject: auto import from //depot/cupcake/@135843 --- .../java/android/bluetooth/BluetoothClass.java | 191 --------------------- 1 file changed, 191 deletions(-) delete mode 100644 framework/java/android/bluetooth/BluetoothClass.java (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java deleted file mode 100644 index 88ce18b457..0000000000 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.bluetooth; - -/** - * The Android Bluetooth API is not finalized, and *will* change. Use at your - * own risk. - * - * Static helper methods and constants to decode the device class bit vector - * returned by the Bluetooth API. - * - * The Android Bluetooth API returns a 32-bit integer to represent the class. - * The format of these bits is defined at - * http://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm - * (login required). This class provides static helper methods and constants to - * determine what Service Class(es) and Device Class are encoded in the 32-bit - * class. - * - * Devices typically have zero or more service classes, and exactly one device - * class. The device class is encoded as a major and minor device class, the - * minor being a subset of the major. - * - * Class is useful to describe a device (for example to show an icon), - * but does not reliably describe what profiles a device supports. To determine - * profile support you usually need to perform SDP queries. - * - * Each of these helper methods takes the 32-bit integer class as an argument. - * - * @hide - */ -public class BluetoothClass { - /** Indicates the Bluetooth API could not retrieve the class */ - public static final int ERROR = 0xFF000000; - - /** Every Bluetooth device has zero or more service classes */ - public static class Service { - public static final int BITMASK = 0xFFE000; - - public static final int LIMITED_DISCOVERABILITY = 0x002000; - public static final int POSITIONING = 0x010000; - public static final int NETWORKING = 0x020000; - public static final int RENDER = 0x040000; - public static final int CAPTURE = 0x080000; - public static final int OBJECT_TRANSFER = 0x100000; - public static final int AUDIO = 0x200000; - public static final int TELEPHONY = 0x400000; - public static final int INFORMATION = 0x800000; - - /** Returns true if the given class supports the given Service Class. - * A bluetooth device can claim to support zero or more service classes. - * @param btClass The bluetooth class. - * @param serviceClass The service class constant to test for. For - * example, Service.AUDIO. Must be one of the - * Service.FOO constants. - * @return True if the service class is supported. - */ - public static boolean hasService(int btClass, int serviceClass) { - if (btClass == ERROR) { - return false; - } - return ((btClass & Service.BITMASK & serviceClass) != 0); - } - } - - /** Every Bluetooth device has exactly one device class, comprimised of - * major and minor components. We have not included the minor classes for - * major classes: NETWORKING, PERIPHERAL and IMAGING yet because they work - * a little differently. */ - public static class Device { - public static final int BITMASK = 0x1FFC; - - public static class Major { - public static final int BITMASK = 0x1F00; - - public static final int MISC = 0x0000; - public static final int COMPUTER = 0x0100; - public static final int PHONE = 0x0200; - public static final int NETWORKING = 0x0300; - public static final int AUDIO_VIDEO = 0x0400; - public static final int PERIPHERAL = 0x0500; - public static final int IMAGING = 0x0600; - public static final int WEARABLE = 0x0700; - public static final int TOY = 0x0800; - public static final int HEALTH = 0x0900; - public static final int UNCATEGORIZED = 0x1F00; - - /** Returns the Major Device Class component of a bluetooth class. - * Values returned from this function can be compared with the constants - * Device.Major.FOO. A bluetooth device can only be associated - * with one major class. - */ - public static int getDeviceMajor(int btClass) { - if (btClass == ERROR) { - return ERROR; - } - return (btClass & Device.Major.BITMASK); - } - } - - // Devices in the COMPUTER major class - public static final int COMPUTER_UNCATEGORIZED = 0x0100; - public static final int COMPUTER_DESKTOP = 0x0104; - public static final int COMPUTER_SERVER = 0x0108; - public static final int COMPUTER_LAPTOP = 0x010C; - public static final int COMPUTER_HANDHELD_PC_PDA = 0x0110; - public static final int COMPUTER_PALM_SIZE_PC_PDA = 0x0114; - public static final int COMPUTER_WEARABLE = 0x0118; - - // Devices in the PHONE major class - public static final int PHONE_UNCATEGORIZED = 0x0200; - public static final int PHONE_CELLULAR = 0x0204; - public static final int PHONE_CORDLESS = 0x0208; - public static final int PHONE_SMART = 0x020C; - public static final int PHONE_MODEM_OR_GATEWAY = 0x0210; - public static final int PHONE_ISDN = 0x0214; - - // Minor classes for the AUDIO_VIDEO major class - public static final int AUDIO_VIDEO_UNCATEGORIZED = 0x0400; - public static final int AUDIO_VIDEO_WEARABLE_HEADSET = 0x0404; - public static final int AUDIO_VIDEO_HANDSFREE = 0x0408; - //public static final int AUDIO_VIDEO_RESERVED = 0x040C; - public static final int AUDIO_VIDEO_MICROPHONE = 0x0410; - public static final int AUDIO_VIDEO_LOUDSPEAKER = 0x0414; - public static final int AUDIO_VIDEO_HEADPHONES = 0x0418; - public static final int AUDIO_VIDEO_PORTABLE_AUDIO = 0x041C; - public static final int AUDIO_VIDEO_CAR_AUDIO = 0x0420; - public static final int AUDIO_VIDEO_SET_TOP_BOX = 0x0424; - public static final int AUDIO_VIDEO_HIFI_AUDIO = 0x0428; - public static final int AUDIO_VIDEO_VCR = 0x042C; - public static final int AUDIO_VIDEO_VIDEO_CAMERA = 0x0430; - public static final int AUDIO_VIDEO_CAMCORDER = 0x0434; - public static final int AUDIO_VIDEO_VIDEO_MONITOR = 0x0438; - public static final int AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x043C; - public static final int AUDIO_VIDEO_VIDEO_CONFERENCING = 0x0440; - //public static final int AUDIO_VIDEO_RESERVED = 0x0444; - public static final int AUDIO_VIDEO_VIDEO_GAMING_TOY = 0x0448; - - // Devices in the WEARABLE major class - public static final int WEARABLE_UNCATEGORIZED = 0x0700; - public static final int WEARABLE_WRIST_WATCH = 0x0704; - public static final int WEARABLE_PAGER = 0x0708; - public static final int WEARABLE_JACKET = 0x070C; - public static final int WEARABLE_HELMET = 0x0710; - public static final int WEARABLE_GLASSES = 0x0714; - - // Devices in the TOY major class - public static final int TOY_UNCATEGORIZED = 0x0800; - public static final int TOY_ROBOT = 0x0804; - public static final int TOY_VEHICLE = 0x0808; - public static final int TOY_DOLL_ACTION_FIGURE = 0x080C; - public static final int TOY_CONTROLLER = 0x0810; - public static final int TOY_GAME = 0x0814; - - // Devices in the HEALTH major class - public static final int HEALTH_UNCATEGORIZED = 0x0900; - public static final int HEALTH_BLOOD_PRESSURE = 0x0904; - public static final int HEALTH_THERMOMETER = 0x0908; - public static final int HEALTH_WEIGHING = 0x090C; - public static final int HEALTH_GLUCOSE = 0x0910; - public static final int HEALTH_PULSE_OXIMETER = 0x0914; - public static final int HEALTH_PULSE_RATE = 0x0918; - public static final int HEALTH_DATA_DISPLAY = 0x091C; - - /** Returns the Device Class component of a bluetooth class. This includes - * both the major and minor device components. Values returned from this - * function can be compared with the constants Device.FOO. A bluetooth - * device can only be associated with one device class. - */ - public static int getDevice(int btClass) { - if (btClass == ERROR) { - return ERROR; - } - return (btClass & Device.BITMASK); - } - } -} - -- cgit v1.2.3 From 33897767e12e0e099d9bb4839eea1c275e7be40d Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Tue, 3 Mar 2009 19:31:44 -0800 Subject: auto import from //depot/cupcake/@135843 --- .../java/android/bluetooth/BluetoothClass.java | 191 +++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 framework/java/android/bluetooth/BluetoothClass.java (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java new file mode 100644 index 0000000000..88ce18b457 --- /dev/null +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -0,0 +1,191 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.bluetooth; + +/** + * The Android Bluetooth API is not finalized, and *will* change. Use at your + * own risk. + * + * Static helper methods and constants to decode the device class bit vector + * returned by the Bluetooth API. + * + * The Android Bluetooth API returns a 32-bit integer to represent the class. + * The format of these bits is defined at + * http://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm + * (login required). This class provides static helper methods and constants to + * determine what Service Class(es) and Device Class are encoded in the 32-bit + * class. + * + * Devices typically have zero or more service classes, and exactly one device + * class. The device class is encoded as a major and minor device class, the + * minor being a subset of the major. + * + * Class is useful to describe a device (for example to show an icon), + * but does not reliably describe what profiles a device supports. To determine + * profile support you usually need to perform SDP queries. + * + * Each of these helper methods takes the 32-bit integer class as an argument. + * + * @hide + */ +public class BluetoothClass { + /** Indicates the Bluetooth API could not retrieve the class */ + public static final int ERROR = 0xFF000000; + + /** Every Bluetooth device has zero or more service classes */ + public static class Service { + public static final int BITMASK = 0xFFE000; + + public static final int LIMITED_DISCOVERABILITY = 0x002000; + public static final int POSITIONING = 0x010000; + public static final int NETWORKING = 0x020000; + public static final int RENDER = 0x040000; + public static final int CAPTURE = 0x080000; + public static final int OBJECT_TRANSFER = 0x100000; + public static final int AUDIO = 0x200000; + public static final int TELEPHONY = 0x400000; + public static final int INFORMATION = 0x800000; + + /** Returns true if the given class supports the given Service Class. + * A bluetooth device can claim to support zero or more service classes. + * @param btClass The bluetooth class. + * @param serviceClass The service class constant to test for. For + * example, Service.AUDIO. Must be one of the + * Service.FOO constants. + * @return True if the service class is supported. + */ + public static boolean hasService(int btClass, int serviceClass) { + if (btClass == ERROR) { + return false; + } + return ((btClass & Service.BITMASK & serviceClass) != 0); + } + } + + /** Every Bluetooth device has exactly one device class, comprimised of + * major and minor components. We have not included the minor classes for + * major classes: NETWORKING, PERIPHERAL and IMAGING yet because they work + * a little differently. */ + public static class Device { + public static final int BITMASK = 0x1FFC; + + public static class Major { + public static final int BITMASK = 0x1F00; + + public static final int MISC = 0x0000; + public static final int COMPUTER = 0x0100; + public static final int PHONE = 0x0200; + public static final int NETWORKING = 0x0300; + public static final int AUDIO_VIDEO = 0x0400; + public static final int PERIPHERAL = 0x0500; + public static final int IMAGING = 0x0600; + public static final int WEARABLE = 0x0700; + public static final int TOY = 0x0800; + public static final int HEALTH = 0x0900; + public static final int UNCATEGORIZED = 0x1F00; + + /** Returns the Major Device Class component of a bluetooth class. + * Values returned from this function can be compared with the constants + * Device.Major.FOO. A bluetooth device can only be associated + * with one major class. + */ + public static int getDeviceMajor(int btClass) { + if (btClass == ERROR) { + return ERROR; + } + return (btClass & Device.Major.BITMASK); + } + } + + // Devices in the COMPUTER major class + public static final int COMPUTER_UNCATEGORIZED = 0x0100; + public static final int COMPUTER_DESKTOP = 0x0104; + public static final int COMPUTER_SERVER = 0x0108; + public static final int COMPUTER_LAPTOP = 0x010C; + public static final int COMPUTER_HANDHELD_PC_PDA = 0x0110; + public static final int COMPUTER_PALM_SIZE_PC_PDA = 0x0114; + public static final int COMPUTER_WEARABLE = 0x0118; + + // Devices in the PHONE major class + public static final int PHONE_UNCATEGORIZED = 0x0200; + public static final int PHONE_CELLULAR = 0x0204; + public static final int PHONE_CORDLESS = 0x0208; + public static final int PHONE_SMART = 0x020C; + public static final int PHONE_MODEM_OR_GATEWAY = 0x0210; + public static final int PHONE_ISDN = 0x0214; + + // Minor classes for the AUDIO_VIDEO major class + public static final int AUDIO_VIDEO_UNCATEGORIZED = 0x0400; + public static final int AUDIO_VIDEO_WEARABLE_HEADSET = 0x0404; + public static final int AUDIO_VIDEO_HANDSFREE = 0x0408; + //public static final int AUDIO_VIDEO_RESERVED = 0x040C; + public static final int AUDIO_VIDEO_MICROPHONE = 0x0410; + public static final int AUDIO_VIDEO_LOUDSPEAKER = 0x0414; + public static final int AUDIO_VIDEO_HEADPHONES = 0x0418; + public static final int AUDIO_VIDEO_PORTABLE_AUDIO = 0x041C; + public static final int AUDIO_VIDEO_CAR_AUDIO = 0x0420; + public static final int AUDIO_VIDEO_SET_TOP_BOX = 0x0424; + public static final int AUDIO_VIDEO_HIFI_AUDIO = 0x0428; + public static final int AUDIO_VIDEO_VCR = 0x042C; + public static final int AUDIO_VIDEO_VIDEO_CAMERA = 0x0430; + public static final int AUDIO_VIDEO_CAMCORDER = 0x0434; + public static final int AUDIO_VIDEO_VIDEO_MONITOR = 0x0438; + public static final int AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x043C; + public static final int AUDIO_VIDEO_VIDEO_CONFERENCING = 0x0440; + //public static final int AUDIO_VIDEO_RESERVED = 0x0444; + public static final int AUDIO_VIDEO_VIDEO_GAMING_TOY = 0x0448; + + // Devices in the WEARABLE major class + public static final int WEARABLE_UNCATEGORIZED = 0x0700; + public static final int WEARABLE_WRIST_WATCH = 0x0704; + public static final int WEARABLE_PAGER = 0x0708; + public static final int WEARABLE_JACKET = 0x070C; + public static final int WEARABLE_HELMET = 0x0710; + public static final int WEARABLE_GLASSES = 0x0714; + + // Devices in the TOY major class + public static final int TOY_UNCATEGORIZED = 0x0800; + public static final int TOY_ROBOT = 0x0804; + public static final int TOY_VEHICLE = 0x0808; + public static final int TOY_DOLL_ACTION_FIGURE = 0x080C; + public static final int TOY_CONTROLLER = 0x0810; + public static final int TOY_GAME = 0x0814; + + // Devices in the HEALTH major class + public static final int HEALTH_UNCATEGORIZED = 0x0900; + public static final int HEALTH_BLOOD_PRESSURE = 0x0904; + public static final int HEALTH_THERMOMETER = 0x0908; + public static final int HEALTH_WEIGHING = 0x090C; + public static final int HEALTH_GLUCOSE = 0x0910; + public static final int HEALTH_PULSE_OXIMETER = 0x0914; + public static final int HEALTH_PULSE_RATE = 0x0918; + public static final int HEALTH_DATA_DISPLAY = 0x091C; + + /** Returns the Device Class component of a bluetooth class. This includes + * both the major and minor device components. Values returned from this + * function can be compared with the constants Device.FOO. A bluetooth + * device can only be associated with one device class. + */ + public static int getDevice(int btClass) { + if (btClass == ERROR) { + return ERROR; + } + return (btClass & Device.BITMASK); + } + } +} + -- cgit v1.2.3 From efc6e07d40fd0505d9c8bf14f84ef8262bf1f0bb Mon Sep 17 00:00:00 2001 From: Yue Lixin Date: Thu, 9 Jul 2009 16:56:43 +0800 Subject: Add Bluetooth device picker support - add Intent and Extra definition - move profile filter into BluetoothClass --- .../java/android/bluetooth/BluetoothClass.java | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index 88ce18b457..0061f10d45 100644 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -46,6 +46,10 @@ public class BluetoothClass { /** Indicates the Bluetooth API could not retrieve the class */ public static final int ERROR = 0xFF000000; + public static final int PROFILE_HEADSET = 0; + public static final int PROFILE_A2DP = 1; + public static final int PROFILE_OPP = 2; + /** Every Bluetooth device has zero or more service classes */ public static class Service { public static final int BITMASK = 0xFFE000; @@ -187,5 +191,74 @@ public class BluetoothClass { return (btClass & Device.BITMASK); } } + + /** + * Check class bits for possible bluetooth profile support. + * This is a simple heuristic that tries to guess if a device with the + * given class bits might support specified profile. It is not accurate for all + * devices. It tries to err on the side of false positives. + * @param btClass The class + * @param profile The profile to be checked + * @return True if this device might support specified profile. + */ + public static boolean doesClassMatch(int btClass, int profile) { + if (profile == PROFILE_A2DP) { + if (BluetoothClass.Service.hasService(btClass, BluetoothClass.Service.RENDER)) { + return true; + } + // By the A2DP spec, sinks must indicate the RENDER service. + // However we found some that do not (Chordette). So lets also + // match on some other class bits. + switch (BluetoothClass.Device.getDevice(btClass)) { + case BluetoothClass.Device.AUDIO_VIDEO_HIFI_AUDIO: + case BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES: + case BluetoothClass.Device.AUDIO_VIDEO_LOUDSPEAKER: + case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO: + return true; + default: + return false; + } + } else if (profile == PROFILE_HEADSET) { + // The render service class is required by the spec for HFP, so is a + // pretty good signal + if (BluetoothClass.Service.hasService(btClass, BluetoothClass.Service.RENDER)) { + return true; + } + // Just in case they forgot the render service class + switch (BluetoothClass.Device.getDevice(btClass)) { + case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE: + case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET: + case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO: + return true; + default: + return false; + } + } else if (profile == PROFILE_OPP) { + if (BluetoothClass.Service.hasService(btClass, BluetoothClass.Service.OBJECT_TRANSFER)) { + return true; + } + + switch (BluetoothClass.Device.getDevice(btClass)) { + case BluetoothClass.Device.COMPUTER_UNCATEGORIZED: + case BluetoothClass.Device.COMPUTER_DESKTOP: + case BluetoothClass.Device.COMPUTER_SERVER: + case BluetoothClass.Device.COMPUTER_LAPTOP: + case BluetoothClass.Device.COMPUTER_HANDHELD_PC_PDA: + case BluetoothClass.Device.COMPUTER_PALM_SIZE_PC_PDA: + case BluetoothClass.Device.COMPUTER_WEARABLE: + case BluetoothClass.Device.PHONE_UNCATEGORIZED: + case BluetoothClass.Device.PHONE_CELLULAR: + case BluetoothClass.Device.PHONE_CORDLESS: + case BluetoothClass.Device.PHONE_SMART: + case BluetoothClass.Device.PHONE_MODEM_OR_GATEWAY: + case BluetoothClass.Device.PHONE_ISDN: + return true; + default: + return false; + } + } else { + return false; + } + } } -- cgit v1.2.3 From dac4c0d7c3ac27746fb8feaf8fc74221972ff5f2 Mon Sep 17 00:00:00 2001 From: Nick Pelly Date: Thu, 10 Sep 2009 10:21:56 -0700 Subject: API_CHANGE: Cleanup, javadoc and unhide more Bluetooth API. This is a large batch, and covers: -- Bluetooth Device Discovery -- BluetoothAdapter.ACTION_DISCOVERY_STARTED BluetoothAdapter.ACTION_DISCOVERY_FINISHED BluetoothAdapter.startDiscovery() BluetoothAdapter.cancelDiscovery() BluetoothAdapter.isDiscovering() -- Bluetooth bonding (pairing) -- BluetoothAdapter.getBondedDevices() BluetoothDevice.ACTION_BOND_STATE_CHANGED BluetoothDevice.EXTRA_BOND_STATE BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE BluetoothDevice.BOND_NONE BluetoothDevice.BOND_BONDING BluetoothDevice.BOND_BONDED BluetoothDevice.getBondState() BluetoothDevice.createBond() BluetoothDevice.cancelBondProcess() BluetoothDevice.removeBond() -- BluetoothClass -- BluetoothDevice.ACTION_CLASS_CHANGED BluetoothDevice.EXTRA_CLASS BluetoothDevice.getBluetoothClass() BluetoothClass.Service.* BluetoothClass.Device.Major.* BluetoothClass.Device.* BluetoothClass.getDeviceClass() BluetoothClass.getMajorDeviceClass() BluetoothClass.hasService() -- Misc BluetoothDevice -- BluetoothDevice.ACTION_ACL_CONNECTED BluetoothDevice.ACTION_ACL_DISCONNECTED_REQUESTED BluetoothDevice.ACTION_ACL_DISCONNECTED BluetoothDevice.ACTION_DISCOVERED BluetoothDevice.ACTION_NAME_CHANGED BluetoothDevice.EXTRA_DEVICE BluetoothDevice.EXTRA_NAME BluetoothDevice.EXTRA_RSSI -- Misc BluetoothAdapter -- BluetoothAdapter.ACTION_LOCAL_NAME_CHANGED BluetoothAdapter.EXTRA_LOCAL_NAME BluetoothAdapter.checkBluetoothAddress() I deprecated BluetoothIntent and moved each intent into the class it relates to. Change-Id: I877b1280428ab46278b2bc25668bb44cda22dc36 --- .../java/android/bluetooth/BluetoothClass.java | 254 +++++++++++++-------- 1 file changed, 155 insertions(+), 99 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index 0061f10d45..1fbbf78946 100644 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -16,43 +16,89 @@ package android.bluetooth; +import android.os.Parcel; +import android.os.Parcelable; + /** - * The Android Bluetooth API is not finalized, and *will* change. Use at your - * own risk. - * - * Static helper methods and constants to decode the device class bit vector - * returned by the Bluetooth API. + * Represents a Bluetooth class. * - * The Android Bluetooth API returns a 32-bit integer to represent the class. - * The format of these bits is defined at + *

Bluetooth Class is a 32 bit field. The format of these bits is defined at * http://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm - * (login required). This class provides static helper methods and constants to - * determine what Service Class(es) and Device Class are encoded in the 32-bit - * class. + * (login required). This class contains that 32 bit field, and provides + * constants and methods to determine which Service Class(es) and Device Class + * are encoded in that field. * - * Devices typically have zero or more service classes, and exactly one device - * class. The device class is encoded as a major and minor device class, the - * minor being a subset of the major. + *

Every Bluetooth Class is composed of zero or more service classes, and + * exactly one device class. The device class is further broken down into major + * and minor device class components. * - * Class is useful to describe a device (for example to show an icon), - * but does not reliably describe what profiles a device supports. To determine - * profile support you usually need to perform SDP queries. + *

Class is useful as a hint to roughly describe a device (for example to + * show an icon in the UI), but does not reliably describe which Bluetooth + * profiles or services are actually supported by a device. Accurate service + * discovery is done through SDP requests. * - * Each of these helper methods takes the 32-bit integer class as an argument. - * - * @hide + *

Use {@link BluetoothDevice#getBluetoothClass} to retrieve the class for + * a remote device. */ -public class BluetoothClass { - /** Indicates the Bluetooth API could not retrieve the class */ +public final class BluetoothClass implements Parcelable { + /** + * Legacy error value. Applications should use null instead. + * @hide + */ public static final int ERROR = 0xFF000000; - public static final int PROFILE_HEADSET = 0; - public static final int PROFILE_A2DP = 1; - public static final int PROFILE_OPP = 2; + private final int mClass; + + /** @hide */ + public BluetoothClass(int classInt) { + mClass = classInt; + } - /** Every Bluetooth device has zero or more service classes */ - public static class Service { - public static final int BITMASK = 0xFFE000; + @Override + public boolean equals(Object o) { + if (o instanceof BluetoothClass) { + return mClass == ((BluetoothClass)o).mClass; + } + return false; + } + + @Override + public int hashCode() { + return mClass; + } + + @Override + public String toString() { + return Integer.toHexString(mClass); + } + + /** @hide */ + public int describeContents() { + return 0; + } + + /** @hide */ + public static final Parcelable.Creator CREATOR = + new Parcelable.Creator() { + public BluetoothClass createFromParcel(Parcel in) { + return new BluetoothClass(in.readInt()); + } + public BluetoothClass[] newArray(int size) { + return new BluetoothClass[size]; + } + }; + + /** @hide */ + public void writeToParcel(Parcel out, int flags) { + out.writeInt(mClass); + } + + /** + * Bluetooth service classes. + *

Each {@link BluetoothClass} encodes zero or more service classes. + */ + public static final class Service { + private static final int BITMASK = 0xFFE000; public static final int LIMITED_DISCOVERABILITY = 0x002000; public static final int POSITIONING = 0x010000; @@ -63,32 +109,35 @@ public class BluetoothClass { public static final int AUDIO = 0x200000; public static final int TELEPHONY = 0x400000; public static final int INFORMATION = 0x800000; + } - /** Returns true if the given class supports the given Service Class. - * A bluetooth device can claim to support zero or more service classes. - * @param btClass The bluetooth class. - * @param serviceClass The service class constant to test for. For - * example, Service.AUDIO. Must be one of the - * Service.FOO constants. - * @return True if the service class is supported. - */ - public static boolean hasService(int btClass, int serviceClass) { - if (btClass == ERROR) { - return false; - } - return ((btClass & Service.BITMASK & serviceClass) != 0); - } + /** + * Return true if the specified service class is supported by this class. + *

Valid service classes are the public constants in + * {@link BluetoothClass.Service}. For example, {@link + * BluetoothClass.Service#AUDIO}. + * + * @param service valid service class + * @return true if the service class is supported + */ + public boolean hasService(int service) { + return ((mClass & Service.BITMASK & service) != 0); } - /** Every Bluetooth device has exactly one device class, comprimised of - * major and minor components. We have not included the minor classes for - * major classes: NETWORKING, PERIPHERAL and IMAGING yet because they work - * a little differently. */ + /** + * Bluetooth device classes. + *

Each {@link BluetoothClass} encodes exactly one device class, with + * major and minor components. + *

The constants in {@link + * BluetoothClass.Device} represent a combination of major and minor + * components (the complete device class). The constants in {@link + * BluetoothClass.Device.Major} represent just the major device classes. + */ public static class Device { - public static final int BITMASK = 0x1FFC; + private static final int BITMASK = 0x1FFC; public static class Major { - public static final int BITMASK = 0x1F00; + private static final int BITMASK = 0x1F00; public static final int MISC = 0x0000; public static final int COMPUTER = 0x0100; @@ -101,18 +150,6 @@ public class BluetoothClass { public static final int TOY = 0x0800; public static final int HEALTH = 0x0900; public static final int UNCATEGORIZED = 0x1F00; - - /** Returns the Major Device Class component of a bluetooth class. - * Values returned from this function can be compared with the constants - * Device.Major.FOO. A bluetooth device can only be associated - * with one major class. - */ - public static int getDeviceMajor(int btClass) { - if (btClass == ERROR) { - return ERROR; - } - return (btClass & Device.Major.BITMASK); - } } // Devices in the COMPUTER major class @@ -178,42 +215,62 @@ public class BluetoothClass { public static final int HEALTH_PULSE_OXIMETER = 0x0914; public static final int HEALTH_PULSE_RATE = 0x0918; public static final int HEALTH_DATA_DISPLAY = 0x091C; + } - /** Returns the Device Class component of a bluetooth class. This includes - * both the major and minor device components. Values returned from this - * function can be compared with the constants Device.FOO. A bluetooth - * device can only be associated with one device class. - */ - public static int getDevice(int btClass) { - if (btClass == ERROR) { - return ERROR; - } - return (btClass & Device.BITMASK); - } + /** + * Return the major device class component of this Bluetooth class. + *

Values returned from this function can be compared with the + * public constants in {@link BluetoothClass.Device.Major} to determine + * which major class is encoded in this Bluetooth class. + * + * @return major device class component + */ + public int getMajorDeviceClass() { + return (mClass & Device.Major.BITMASK); + } + + /** + * Return the (major and minor) device class component of this + * {@link BluetoothClass}. + *

Values returned from this function can be compared with the + * public constants in {@link BluetoothClass.Device} to determine which + * device class is encoded in this Bluetooth class. + * + * @return device class component + */ + public int getDeviceClass() { + return (mClass & Device.BITMASK); } + /** @hide */ + public static final int PROFILE_HEADSET = 0; + /** @hide */ + public static final int PROFILE_A2DP = 1; + /** @hide */ + public static final int PROFILE_OPP = 2; + /** * Check class bits for possible bluetooth profile support. * This is a simple heuristic that tries to guess if a device with the * given class bits might support specified profile. It is not accurate for all * devices. It tries to err on the side of false positives. - * @param btClass The class * @param profile The profile to be checked * @return True if this device might support specified profile. + * @hide */ - public static boolean doesClassMatch(int btClass, int profile) { + public boolean doesClassMatch(int profile) { if (profile == PROFILE_A2DP) { - if (BluetoothClass.Service.hasService(btClass, BluetoothClass.Service.RENDER)) { + if (hasService(Service.RENDER)) { return true; } // By the A2DP spec, sinks must indicate the RENDER service. // However we found some that do not (Chordette). So lets also // match on some other class bits. - switch (BluetoothClass.Device.getDevice(btClass)) { - case BluetoothClass.Device.AUDIO_VIDEO_HIFI_AUDIO: - case BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES: - case BluetoothClass.Device.AUDIO_VIDEO_LOUDSPEAKER: - case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO: + switch (getDeviceClass()) { + case Device.AUDIO_VIDEO_HIFI_AUDIO: + case Device.AUDIO_VIDEO_HEADPHONES: + case Device.AUDIO_VIDEO_LOUDSPEAKER: + case Device.AUDIO_VIDEO_CAR_AUDIO: return true; default: return false; @@ -221,37 +278,37 @@ public class BluetoothClass { } else if (profile == PROFILE_HEADSET) { // The render service class is required by the spec for HFP, so is a // pretty good signal - if (BluetoothClass.Service.hasService(btClass, BluetoothClass.Service.RENDER)) { + if (hasService(Service.RENDER)) { return true; } // Just in case they forgot the render service class - switch (BluetoothClass.Device.getDevice(btClass)) { - case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE: - case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET: - case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO: + switch (getDeviceClass()) { + case Device.AUDIO_VIDEO_HANDSFREE: + case Device.AUDIO_VIDEO_WEARABLE_HEADSET: + case Device.AUDIO_VIDEO_CAR_AUDIO: return true; default: return false; } } else if (profile == PROFILE_OPP) { - if (BluetoothClass.Service.hasService(btClass, BluetoothClass.Service.OBJECT_TRANSFER)) { + if (hasService(Service.OBJECT_TRANSFER)) { return true; } - switch (BluetoothClass.Device.getDevice(btClass)) { - case BluetoothClass.Device.COMPUTER_UNCATEGORIZED: - case BluetoothClass.Device.COMPUTER_DESKTOP: - case BluetoothClass.Device.COMPUTER_SERVER: - case BluetoothClass.Device.COMPUTER_LAPTOP: - case BluetoothClass.Device.COMPUTER_HANDHELD_PC_PDA: - case BluetoothClass.Device.COMPUTER_PALM_SIZE_PC_PDA: - case BluetoothClass.Device.COMPUTER_WEARABLE: - case BluetoothClass.Device.PHONE_UNCATEGORIZED: - case BluetoothClass.Device.PHONE_CELLULAR: - case BluetoothClass.Device.PHONE_CORDLESS: - case BluetoothClass.Device.PHONE_SMART: - case BluetoothClass.Device.PHONE_MODEM_OR_GATEWAY: - case BluetoothClass.Device.PHONE_ISDN: + switch (getDeviceClass()) { + case Device.COMPUTER_UNCATEGORIZED: + case Device.COMPUTER_DESKTOP: + case Device.COMPUTER_SERVER: + case Device.COMPUTER_LAPTOP: + case Device.COMPUTER_HANDHELD_PC_PDA: + case Device.COMPUTER_PALM_SIZE_PC_PDA: + case Device.COMPUTER_WEARABLE: + case Device.PHONE_UNCATEGORIZED: + case Device.PHONE_CELLULAR: + case Device.PHONE_CORDLESS: + case Device.PHONE_SMART: + case Device.PHONE_MODEM_OR_GATEWAY: + case Device.PHONE_ISDN: return true; default: return false; @@ -261,4 +318,3 @@ public class BluetoothClass { } } } - -- cgit v1.2.3 From f1288ced9e09172825f63644b1b548420f3ac7ea Mon Sep 17 00:00:00 2001 From: Nick Pelly Date: Wed, 16 Sep 2009 16:50:11 -0700 Subject: Do not @hide Parcelable implementations in BluetoothClass and BluetoothDevice. Change-Id: I92389c53a9b99c9507f78898329ff87b631c7aa3 --- framework/java/android/bluetooth/BluetoothClass.java | 3 --- 1 file changed, 3 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index 1fbbf78946..6210380595 100644 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -72,12 +72,10 @@ public final class BluetoothClass implements Parcelable { return Integer.toHexString(mClass); } - /** @hide */ public int describeContents() { return 0; } - /** @hide */ public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { public BluetoothClass createFromParcel(Parcel in) { @@ -88,7 +86,6 @@ public final class BluetoothClass implements Parcelable { } }; - /** @hide */ public void writeToParcel(Parcel out, int flags) { out.writeInt(mClass); } -- cgit v1.2.3 From beef809fa89a5e7955a4c25cf70e00adbcf2e24e Mon Sep 17 00:00:00 2001 From: Scott Main Date: Tue, 3 Nov 2009 18:17:59 -0800 Subject: docs: add more documentation for the bluetooth apis. more descriptions for some of the classes and a new overview and pseudo-code example for using BT APIs in the package summary. --- .../java/android/bluetooth/BluetoothClass.java | 52 +++++++++++++++------- 1 file changed, 35 insertions(+), 17 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index 6210380595..bc06713058 100644 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -20,25 +20,37 @@ import android.os.Parcel; import android.os.Parcelable; /** - * Represents a Bluetooth class. + * Represents a Bluetooth class, which describes general characteristics + * and capabilities of a device. For example, a Bluetooth class will + * specify the general device type such as a phone, a computer, or + * headset, and whether it's capable of services such as audio or telephony. * - *

Bluetooth Class is a 32 bit field. The format of these bits is defined at - * http://www.bluetooth.org/Technical/AssignedNumbers/baseband.htm - * (login required). This class contains that 32 bit field, and provides - * constants and methods to determine which Service Class(es) and Device Class - * are encoded in that field. + *

The Bluetooth class is useful as a hint to roughly describe a device (for example to + * show an icon in the UI), but does not reliably describe which Bluetooth + * profiles or services are actually supported by a device. * - *

Every Bluetooth Class is composed of zero or more service classes, and + *

Every Bluetooth class is composed of zero or more service classes, and * exactly one device class. The device class is further broken down into major * and minor device class components. * - *

Class is useful as a hint to roughly describe a device (for example to - * show an icon in the UI), but does not reliably describe which Bluetooth - * profiles or services are actually supported by a device. Accurate service - * discovery is done through SDP requests. + *

{@link BluetoothClass} is useful as a hint to roughly describe a device + * (for example to show an icon in the UI), but does not reliably describe which + * Bluetooth profiles or services are actually supported by a device. Accurate + * service discovery is done through SDP requests, which are automatically + * performed when creating an RFCOMM socket with {@link + * BluetoothDevice#createRfcommSocketToServiceRecord(UUID)} and {@link + * BluetoothAdapter#listenUsingRfcommWithServiceRecord(String,UUID)}

* *

Use {@link BluetoothDevice#getBluetoothClass} to retrieve the class for * a remote device. + * + * */ public final class BluetoothClass implements Parcelable { /** @@ -91,7 +103,7 @@ public final class BluetoothClass implements Parcelable { } /** - * Bluetooth service classes. + * Defines all service class constants. *

Each {@link BluetoothClass} encodes zero or more service classes. */ public static final class Service { @@ -109,7 +121,8 @@ public final class BluetoothClass implements Parcelable { } /** - * Return true if the specified service class is supported by this class. + * Return true if the specified service class is supported by this + * {@link BluetoothClass}. *

Valid service classes are the public constants in * {@link BluetoothClass.Service}. For example, {@link * BluetoothClass.Service#AUDIO}. @@ -122,17 +135,22 @@ public final class BluetoothClass implements Parcelable { } /** - * Bluetooth device classes. + * Defines all device class constants. *

Each {@link BluetoothClass} encodes exactly one device class, with * major and minor components. *

The constants in {@link * BluetoothClass.Device} represent a combination of major and minor - * components (the complete device class). The constants in {@link - * BluetoothClass.Device.Major} represent just the major device classes. + * device components (the complete device class). The constants in {@link + * BluetoothClass.Device.Major} represent only major device classes. + *

See {@link BluetoothClass.Service} for service class constants. */ public static class Device { private static final int BITMASK = 0x1FFC; + /** + * Defines all major device class constants. + *

See {@link BluetoothClass.Device} for minor classes. + */ public static class Major { private static final int BITMASK = 0x1F00; @@ -215,7 +233,7 @@ public final class BluetoothClass implements Parcelable { } /** - * Return the major device class component of this Bluetooth class. + * Return the major device class component of this {@link BluetoothClass}. *

Values returned from this function can be compared with the * public constants in {@link BluetoothClass.Device.Major} to determine * which major class is encoded in this Bluetooth class. -- cgit v1.2.3 From cdd8b7ec707d0005c3176b4481cab730a92df236 Mon Sep 17 00:00:00 2001 From: Scott Main Date: Wed, 9 Dec 2009 16:07:39 -0800 Subject: docs: add the Bluetooth developer guide, and make some revisions to the BT javadocs --- framework/java/android/bluetooth/BluetoothClass.java | 4 ---- 1 file changed, 4 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index bc06713058..c7fea9e1da 100644 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -25,10 +25,6 @@ import android.os.Parcelable; * specify the general device type such as a phone, a computer, or * headset, and whether it's capable of services such as audio or telephony. * - *

The Bluetooth class is useful as a hint to roughly describe a device (for example to - * show an icon in the UI), but does not reliably describe which Bluetooth - * profiles or services are actually supported by a device. - * *

Every Bluetooth class is composed of zero or more service classes, and * exactly one device class. The device class is further broken down into major * and minor device class components. -- cgit v1.2.3 From 026e857303f0a6b0d1e4175790b148b8824b2b87 Mon Sep 17 00:00:00 2001 From: Adam Powell Date: Mon, 21 Jun 2010 16:23:42 -0700 Subject: Changes for bluetooth keyboard support. Add device class constant for PROFILE_HID and check for Device.Major.PERIPHERAL when checking for class matches. Change UUID for HID support. Fix bug in BluetoothService. Change-Id: Ie5361257d90fd749249e915824564bc3d79fb95d --- framework/java/android/bluetooth/BluetoothClass.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index c7fea9e1da..0c9bab2496 100644 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -259,6 +259,8 @@ public final class BluetoothClass implements Parcelable { public static final int PROFILE_A2DP = 1; /** @hide */ public static final int PROFILE_OPP = 2; + /** @hide */ + public static final int PROFILE_HID = 3; /** * Check class bits for possible bluetooth profile support. @@ -324,6 +326,8 @@ public final class BluetoothClass implements Parcelable { default: return false; } + } else if (profile == PROFILE_HID) { + return (getDeviceClass() & Device.Major.PERIPHERAL) == Device.Major.PERIPHERAL; } else { return false; } -- cgit v1.2.3 From c7ab7b06af4ae8a165c4ee2b6229453156add50c Mon Sep 17 00:00:00 2001 From: Jaikumar Ganesh Date: Mon, 23 Aug 2010 11:49:36 -0700 Subject: Add Tethering class bit check. Change-Id: Iaa87c91c4b3db3b77c2e6c4f559fa2e438c9c247 --- framework/java/android/bluetooth/BluetoothClass.java | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index 0c9bab2496..c8381c96a3 100644 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -261,6 +261,10 @@ public final class BluetoothClass implements Parcelable { public static final int PROFILE_OPP = 2; /** @hide */ public static final int PROFILE_HID = 3; + /** @hide */ + public static final int PROFILE_PANU = 4; + /** @hide */ + public static final int PROFILE_NAP = 5; /** * Check class bits for possible bluetooth profile support. @@ -328,6 +332,12 @@ public final class BluetoothClass implements Parcelable { } } else if (profile == PROFILE_HID) { return (getDeviceClass() & Device.Major.PERIPHERAL) == Device.Major.PERIPHERAL; + } else if (profile == PROFILE_PANU || profile == PROFILE_NAP){ + // No good way to distinguish between the two, based on class bits. + if (hasService(Service.NETWORKING)) { + return true; + } + return (getDeviceClass() & Device.Major.NETWORKING) == Device.Major.NETWORKING; } else { return false; } -- cgit v1.2.3 From 04c7138c7c1f36d54fbe33c40644e197248166b9 Mon Sep 17 00:00:00 2001 From: Jake Hamby Date: Tue, 21 Sep 2010 13:39:53 -0700 Subject: Typo fixes in comments and minor code cleanups. * Fix some typos in Javadoc and log messages. * Remove redundant initializer in BluetoothAdapter.readOutOfBandData() * Use canonical "UTF-8" charset name instead of "UTF8" in BluetoothDevice.convertPinToBytes() Change-Id: I58cd5dc48a7ad0053d204c5f590b4b3d438d8672 --- framework/java/android/bluetooth/BluetoothClass.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index c7fea9e1da..6a878d73e2 100644 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -34,8 +34,8 @@ import android.os.Parcelable; * Bluetooth profiles or services are actually supported by a device. Accurate * service discovery is done through SDP requests, which are automatically * performed when creating an RFCOMM socket with {@link - * BluetoothDevice#createRfcommSocketToServiceRecord(UUID)} and {@link - * BluetoothAdapter#listenUsingRfcommWithServiceRecord(String,UUID)}

+ * BluetoothDevice#createRfcommSocketToServiceRecord} and {@link + * BluetoothAdapter#listenUsingRfcommWithServiceRecord}

* *

Use {@link BluetoothDevice#getBluetoothClass} to retrieve the class for * a remote device. -- cgit v1.2.3 From 7524e6b9e25a460034700acfeca15d14d4774ede Mon Sep 17 00:00:00 2001 From: Jaikumar Ganesh Date: Wed, 5 Jan 2011 13:49:00 -0800 Subject: Follow the spec recommendation for keyboard pairing. Generate a variable pin and show it to the user. Change-Id: Id4aae7a16f25c67d6c6ead6fd936cb14087f3c7a --- framework/java/android/bluetooth/BluetoothClass.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index e604e6becc..54bf4afa93 100644 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -226,6 +226,24 @@ public final class BluetoothClass implements Parcelable { public static final int HEALTH_PULSE_OXIMETER = 0x0914; public static final int HEALTH_PULSE_RATE = 0x0918; public static final int HEALTH_DATA_DISPLAY = 0x091C; + + // Devices in PERIPHERAL major class + /** + * @hide + */ + public static final int PERIPHERAL_NON_KEYBOARD_NON_POINTING = 0x0500; + /** + * @hide + */ + public static final int PERIPHERAL_KEYBOARD = 0x0540; + /** + * @hide + */ + public static final int PERIPHERAL_POINTING = 0x0580; + /** + * @hide + */ + public static final int PERIPHERAL_KEYBOARD_POINTING = 0x05C0; } /** -- cgit v1.2.3 From 25e84d4f5d76fdb421c597752117089b6c73e5b7 Mon Sep 17 00:00:00 2001 From: Sanket Agarwal Date: Wed, 21 Oct 2015 18:23:27 -0700 Subject: Add support for AVRCP 1.3. * Add metadata support. * Add player settings support. * Add playback support. A2DP Settings App support. Bluetooth: A2DP Sink support for Settings App - add support for A2DP Sink in Settings App. This will enable connection initiation and updation on Settings App - add framework Apis to support A2DP Sink. Any third party Apps can access A2DP Sink priority of device and playing state of device - add support for key to set priority. This manages priority of device for A2DP Sink profile Change-Id: If5f9139f37cdb9d200387877c7801075205c78a0 --- framework/java/android/bluetooth/BluetoothClass.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) mode change 100644 => 100755 framework/java/android/bluetooth/BluetoothClass.java (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java old mode 100644 new mode 100755 index 54bf4afa93..4a38287e7c --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -283,6 +283,8 @@ public final class BluetoothClass implements Parcelable { public static final int PROFILE_PANU = 4; /** @hide */ public static final int PROFILE_NAP = 5; + /** @hide */ + public static final int PROFILE_A2DP_SINK = 6; /** * Check class bits for possible bluetooth profile support. @@ -310,6 +312,21 @@ public final class BluetoothClass implements Parcelable { default: return false; } + } else if (profile == PROFILE_A2DP_SINK) { + if (hasService(Service.CAPTURE)) { + return true; + } + // By the A2DP spec, srcs must indicate the CAPTURE service. + // However if some device that do not, we try to + // match on some other class bits. + switch (getDeviceClass()) { + case Device.AUDIO_VIDEO_HIFI_AUDIO: + case Device.AUDIO_VIDEO_SET_TOP_BOX: + case Device.AUDIO_VIDEO_VCR : + return true; + default: + return false; + } } else if (profile == PROFILE_HEADSET) { // The render service class is required by the spec for HFP, so is a // pretty good signal -- cgit v1.2.3 From 910201beb0bde1dcf6b33e4ec5d1eb60042419d8 Mon Sep 17 00:00:00 2001 From: Jack He Date: Tue, 22 Aug 2017 16:06:54 -0700 Subject: Fix checkstyle errors (1/2) * Automatic style corrections through IDE Bug: 63596319 Test: make checkbuild, no manual changes, no functional changes Change-Id: I2397d55abc34c9b7a9b748bec6137778df3421a7 --- .../java/android/bluetooth/BluetoothClass.java | 171 +++++++++++---------- 1 file changed, 87 insertions(+), 84 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index 4a38287e7c..2f6a79352b 100755 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -51,6 +51,7 @@ import android.os.Parcelable; public final class BluetoothClass implements Parcelable { /** * Legacy error value. Applications should use null instead. + * * @hide */ public static final int ERROR = 0xFF000000; @@ -65,7 +66,7 @@ public final class BluetoothClass implements Parcelable { @Override public boolean equals(Object o) { if (o instanceof BluetoothClass) { - return mClass == ((BluetoothClass)o).mClass; + return mClass == ((BluetoothClass) o).mClass; } return false; } @@ -86,13 +87,14 @@ public final class BluetoothClass implements Parcelable { public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public BluetoothClass createFromParcel(Parcel in) { - return new BluetoothClass(in.readInt()); - } - public BluetoothClass[] newArray(int size) { - return new BluetoothClass[size]; - } - }; + public BluetoothClass createFromParcel(Parcel in) { + return new BluetoothClass(in.readInt()); + } + + public BluetoothClass[] newArray(int size) { + return new BluetoothClass[size]; + } + }; public void writeToParcel(Parcel out, int flags) { out.writeInt(mClass); @@ -103,17 +105,17 @@ public final class BluetoothClass implements Parcelable { *

Each {@link BluetoothClass} encodes zero or more service classes. */ public static final class Service { - private static final int BITMASK = 0xFFE000; + private static final int BITMASK = 0xFFE000; public static final int LIMITED_DISCOVERABILITY = 0x002000; - public static final int POSITIONING = 0x010000; - public static final int NETWORKING = 0x020000; - public static final int RENDER = 0x040000; - public static final int CAPTURE = 0x080000; - public static final int OBJECT_TRANSFER = 0x100000; - public static final int AUDIO = 0x200000; - public static final int TELEPHONY = 0x400000; - public static final int INFORMATION = 0x800000; + public static final int POSITIONING = 0x010000; + public static final int NETWORKING = 0x020000; + public static final int RENDER = 0x040000; + public static final int CAPTURE = 0x080000; + public static final int OBJECT_TRANSFER = 0x100000; + public static final int AUDIO = 0x200000; + public static final int TELEPHONY = 0x400000; + public static final int INFORMATION = 0x800000; } /** @@ -141,91 +143,91 @@ public final class BluetoothClass implements Parcelable { *

See {@link BluetoothClass.Service} for service class constants. */ public static class Device { - private static final int BITMASK = 0x1FFC; + private static final int BITMASK = 0x1FFC; /** * Defines all major device class constants. *

See {@link BluetoothClass.Device} for minor classes. */ public static class Major { - private static final int BITMASK = 0x1F00; + private static final int BITMASK = 0x1F00; - public static final int MISC = 0x0000; - public static final int COMPUTER = 0x0100; - public static final int PHONE = 0x0200; - public static final int NETWORKING = 0x0300; - public static final int AUDIO_VIDEO = 0x0400; - public static final int PERIPHERAL = 0x0500; - public static final int IMAGING = 0x0600; - public static final int WEARABLE = 0x0700; - public static final int TOY = 0x0800; - public static final int HEALTH = 0x0900; - public static final int UNCATEGORIZED = 0x1F00; + public static final int MISC = 0x0000; + public static final int COMPUTER = 0x0100; + public static final int PHONE = 0x0200; + public static final int NETWORKING = 0x0300; + public static final int AUDIO_VIDEO = 0x0400; + public static final int PERIPHERAL = 0x0500; + public static final int IMAGING = 0x0600; + public static final int WEARABLE = 0x0700; + public static final int TOY = 0x0800; + public static final int HEALTH = 0x0900; + public static final int UNCATEGORIZED = 0x1F00; } // Devices in the COMPUTER major class - public static final int COMPUTER_UNCATEGORIZED = 0x0100; - public static final int COMPUTER_DESKTOP = 0x0104; - public static final int COMPUTER_SERVER = 0x0108; - public static final int COMPUTER_LAPTOP = 0x010C; - public static final int COMPUTER_HANDHELD_PC_PDA = 0x0110; - public static final int COMPUTER_PALM_SIZE_PC_PDA = 0x0114; - public static final int COMPUTER_WEARABLE = 0x0118; + public static final int COMPUTER_UNCATEGORIZED = 0x0100; + public static final int COMPUTER_DESKTOP = 0x0104; + public static final int COMPUTER_SERVER = 0x0108; + public static final int COMPUTER_LAPTOP = 0x010C; + public static final int COMPUTER_HANDHELD_PC_PDA = 0x0110; + public static final int COMPUTER_PALM_SIZE_PC_PDA = 0x0114; + public static final int COMPUTER_WEARABLE = 0x0118; // Devices in the PHONE major class - public static final int PHONE_UNCATEGORIZED = 0x0200; - public static final int PHONE_CELLULAR = 0x0204; - public static final int PHONE_CORDLESS = 0x0208; - public static final int PHONE_SMART = 0x020C; - public static final int PHONE_MODEM_OR_GATEWAY = 0x0210; - public static final int PHONE_ISDN = 0x0214; + public static final int PHONE_UNCATEGORIZED = 0x0200; + public static final int PHONE_CELLULAR = 0x0204; + public static final int PHONE_CORDLESS = 0x0208; + public static final int PHONE_SMART = 0x020C; + public static final int PHONE_MODEM_OR_GATEWAY = 0x0210; + public static final int PHONE_ISDN = 0x0214; // Minor classes for the AUDIO_VIDEO major class - public static final int AUDIO_VIDEO_UNCATEGORIZED = 0x0400; - public static final int AUDIO_VIDEO_WEARABLE_HEADSET = 0x0404; - public static final int AUDIO_VIDEO_HANDSFREE = 0x0408; + public static final int AUDIO_VIDEO_UNCATEGORIZED = 0x0400; + public static final int AUDIO_VIDEO_WEARABLE_HEADSET = 0x0404; + public static final int AUDIO_VIDEO_HANDSFREE = 0x0408; //public static final int AUDIO_VIDEO_RESERVED = 0x040C; - public static final int AUDIO_VIDEO_MICROPHONE = 0x0410; - public static final int AUDIO_VIDEO_LOUDSPEAKER = 0x0414; - public static final int AUDIO_VIDEO_HEADPHONES = 0x0418; - public static final int AUDIO_VIDEO_PORTABLE_AUDIO = 0x041C; - public static final int AUDIO_VIDEO_CAR_AUDIO = 0x0420; - public static final int AUDIO_VIDEO_SET_TOP_BOX = 0x0424; - public static final int AUDIO_VIDEO_HIFI_AUDIO = 0x0428; - public static final int AUDIO_VIDEO_VCR = 0x042C; - public static final int AUDIO_VIDEO_VIDEO_CAMERA = 0x0430; - public static final int AUDIO_VIDEO_CAMCORDER = 0x0434; - public static final int AUDIO_VIDEO_VIDEO_MONITOR = 0x0438; + public static final int AUDIO_VIDEO_MICROPHONE = 0x0410; + public static final int AUDIO_VIDEO_LOUDSPEAKER = 0x0414; + public static final int AUDIO_VIDEO_HEADPHONES = 0x0418; + public static final int AUDIO_VIDEO_PORTABLE_AUDIO = 0x041C; + public static final int AUDIO_VIDEO_CAR_AUDIO = 0x0420; + public static final int AUDIO_VIDEO_SET_TOP_BOX = 0x0424; + public static final int AUDIO_VIDEO_HIFI_AUDIO = 0x0428; + public static final int AUDIO_VIDEO_VCR = 0x042C; + public static final int AUDIO_VIDEO_VIDEO_CAMERA = 0x0430; + public static final int AUDIO_VIDEO_CAMCORDER = 0x0434; + public static final int AUDIO_VIDEO_VIDEO_MONITOR = 0x0438; public static final int AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x043C; - public static final int AUDIO_VIDEO_VIDEO_CONFERENCING = 0x0440; + public static final int AUDIO_VIDEO_VIDEO_CONFERENCING = 0x0440; //public static final int AUDIO_VIDEO_RESERVED = 0x0444; - public static final int AUDIO_VIDEO_VIDEO_GAMING_TOY = 0x0448; + public static final int AUDIO_VIDEO_VIDEO_GAMING_TOY = 0x0448; // Devices in the WEARABLE major class - public static final int WEARABLE_UNCATEGORIZED = 0x0700; - public static final int WEARABLE_WRIST_WATCH = 0x0704; - public static final int WEARABLE_PAGER = 0x0708; - public static final int WEARABLE_JACKET = 0x070C; - public static final int WEARABLE_HELMET = 0x0710; - public static final int WEARABLE_GLASSES = 0x0714; + public static final int WEARABLE_UNCATEGORIZED = 0x0700; + public static final int WEARABLE_WRIST_WATCH = 0x0704; + public static final int WEARABLE_PAGER = 0x0708; + public static final int WEARABLE_JACKET = 0x070C; + public static final int WEARABLE_HELMET = 0x0710; + public static final int WEARABLE_GLASSES = 0x0714; // Devices in the TOY major class - public static final int TOY_UNCATEGORIZED = 0x0800; - public static final int TOY_ROBOT = 0x0804; - public static final int TOY_VEHICLE = 0x0808; - public static final int TOY_DOLL_ACTION_FIGURE = 0x080C; - public static final int TOY_CONTROLLER = 0x0810; - public static final int TOY_GAME = 0x0814; + public static final int TOY_UNCATEGORIZED = 0x0800; + public static final int TOY_ROBOT = 0x0804; + public static final int TOY_VEHICLE = 0x0808; + public static final int TOY_DOLL_ACTION_FIGURE = 0x080C; + public static final int TOY_CONTROLLER = 0x0810; + public static final int TOY_GAME = 0x0814; // Devices in the HEALTH major class - public static final int HEALTH_UNCATEGORIZED = 0x0900; - public static final int HEALTH_BLOOD_PRESSURE = 0x0904; - public static final int HEALTH_THERMOMETER = 0x0908; - public static final int HEALTH_WEIGHING = 0x090C; - public static final int HEALTH_GLUCOSE = 0x0910; - public static final int HEALTH_PULSE_OXIMETER = 0x0914; - public static final int HEALTH_PULSE_RATE = 0x0918; - public static final int HEALTH_DATA_DISPLAY = 0x091C; + public static final int HEALTH_UNCATEGORIZED = 0x0900; + public static final int HEALTH_BLOOD_PRESSURE = 0x0904; + public static final int HEALTH_THERMOMETER = 0x0908; + public static final int HEALTH_WEIGHING = 0x090C; + public static final int HEALTH_GLUCOSE = 0x0910; + public static final int HEALTH_PULSE_OXIMETER = 0x0914; + public static final int HEALTH_PULSE_RATE = 0x0918; + public static final int HEALTH_DATA_DISPLAY = 0x091C; // Devices in PERIPHERAL major class /** @@ -235,15 +237,15 @@ public final class BluetoothClass implements Parcelable { /** * @hide */ - public static final int PERIPHERAL_KEYBOARD = 0x0540; + public static final int PERIPHERAL_KEYBOARD = 0x0540; /** * @hide */ - public static final int PERIPHERAL_POINTING = 0x0580; + public static final int PERIPHERAL_POINTING = 0x0580; /** * @hide */ - public static final int PERIPHERAL_KEYBOARD_POINTING = 0x05C0; + public static final int PERIPHERAL_KEYBOARD_POINTING = 0x05C0; } /** @@ -291,6 +293,7 @@ public final class BluetoothClass implements Parcelable { * This is a simple heuristic that tries to guess if a device with the * given class bits might support specified profile. It is not accurate for all * devices. It tries to err on the side of false positives. + * * @param profile The profile to be checked * @return True if this device might support specified profile. * @hide @@ -322,7 +325,7 @@ public final class BluetoothClass implements Parcelable { switch (getDeviceClass()) { case Device.AUDIO_VIDEO_HIFI_AUDIO: case Device.AUDIO_VIDEO_SET_TOP_BOX: - case Device.AUDIO_VIDEO_VCR : + case Device.AUDIO_VIDEO_VCR: return true; default: return false; @@ -367,7 +370,7 @@ public final class BluetoothClass implements Parcelable { } } else if (profile == PROFILE_HID) { return (getDeviceClass() & Device.Major.PERIPHERAL) == Device.Major.PERIPHERAL; - } else if (profile == PROFILE_PANU || profile == PROFILE_NAP){ + } else if (profile == PROFILE_PANU || profile == PROFILE_NAP) { // No good way to distinguish between the two, based on class bits. if (hasService(Service.NETWORKING)) { return true; -- cgit v1.2.3 From 9e045d26d0128826b40520f523307d8d16473779 Mon Sep 17 00:00:00 2001 From: Jack He Date: Tue, 22 Aug 2017 21:21:23 -0700 Subject: Fix checkstyle errors (2/2) * Manual style corrections with IDE assistance * Variable name refactors are done through IDE * Corrected general style errors such as: - "final private var" -> "private final var" - "&&", "+", "||" should not be at the end of line - Non-static private variable should be like "mVar" - Private static variable should be like "sVar" - Code file should always end with newline - Inherited methods should be annotated with @Override and no @hide tags - Public methods should always have a JavaDoc entry - "int[] array" is preferred over "int array[]" - private methods should be accessed without "this." when there is no name collisions. - "boolean ? true : false" -> boolean - "boolean ? false : true" -> !boolean - "boolean == true" OR "boolean != false" -> boolean - "boolean != true" OR "boolean == false" -> !boolean Bug: 63596319 Test: make checkbuild, no functional changes Change-Id: Iabdc2be912a32dd63a53213d175cf1bfef268ccd --- framework/java/android/bluetooth/BluetoothClass.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index 2f6a79352b..57e4abb129 100755 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -81,6 +81,7 @@ public final class BluetoothClass implements Parcelable { return Integer.toHexString(mClass); } + @Override public int describeContents() { return 0; } @@ -96,6 +97,7 @@ public final class BluetoothClass implements Parcelable { } }; + @Override public void writeToParcel(Parcel out, int flags) { out.writeInt(mClass); } -- cgit v1.2.3 From 4729ea80cf268eb82091fe8f6c4a2071ca33606e Mon Sep 17 00:00:00 2001 From: Pulkit Bhuwalka Date: Wed, 16 Aug 2017 21:52:04 -0700 Subject: Modify Bluetooth Class of Device from Android stack Bug: 36015415 Test: Modified Class of Device using sample app and verified device icon change when discovering from a remote device. Change-Id: Ie25f10be5560f9c090ebe489d5f3bb00cbca81ef --- .../java/android/bluetooth/BluetoothClass.java | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index 57e4abb129..f22ea6e88e 100755 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -19,6 +19,10 @@ package android.bluetooth; import android.os.Parcel; import android.os.Parcelable; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Arrays; + /** * Represents a Bluetooth class, which describes general characteristics * and capabilities of a device. For example, a Bluetooth class will @@ -275,6 +279,48 @@ public final class BluetoothClass implements Parcelable { return (mClass & Device.BITMASK); } + /** + * Return the Bluetooth Class of Device (CoD) value including the + * {@link BluetoothClass.Service}, {@link BluetoothClass.Device.Major} and + * minor device fields. + * + *

This value is an integer representation of Bluetooth CoD as in + * Bluetooth specification. + * + * @see https://www.bluetooth.com/specifications/assigned-numbers/baseband + * + * @hide + */ + public int getClassOfDevice() { + return mClass; + } + + /** + * Return the Bluetooth Class of Device (CoD) value including the + * {@link BluetoothClass.Service}, {@link BluetoothClass.Device.Major} and + * minor device fields. + * + *

This value is a byte array representation of Bluetooth CoD as in + * Bluetooth specification. + * + *

Bluetooth COD information is 3 bytes, but stored as an int. Hence the + * MSB is useless and needs to be thrown away. The lower 3 bytes are + * converted into a byte array MSB to LSB. Hence, using BIG_ENDIAN. + * + * @see https://www.bluetooth.com/specifications/assigned-numbers/baseband + * + * @hide + */ + public byte[] getClassOfDeviceBytes() { + byte[] bytes = ByteBuffer.allocate(4) + .order(ByteOrder.BIG_ENDIAN) + .putInt(mClass) + .array(); + + // Discard the top byte + return Arrays.copyOfRange(bytes, 1, bytes.length); + } + /** @hide */ public static final int PROFILE_HEADSET = 0; /** @hide */ -- cgit v1.2.3 From 7d543894e0497651fc160728d659543483500f87 Mon Sep 17 00:00:00 2001 From: Mathew Inwood Date: Wed, 1 Aug 2018 15:07:20 +0100 Subject: Add @UnsupportedAppUsage annotations For packages: android.bluetooth.le android.bluetooth This is an automatically generated CL. See go/UnsupportedAppUsage for more details. Exempted-From-Owner-Approval: Mechanical changes to the codebase which have been approved by Android API council and announced on android-eng@ Bug: 110868826 Test: m Change-Id: Ifcf24c0617acd7facc0e03f30a95c3a6b09b205c Merged-In: I88a1311e27c5f9a5f9d1035db76034f86f650efc --- framework/java/android/bluetooth/BluetoothClass.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index f22ea6e88e..8557f389d9 100755 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -16,6 +16,7 @@ package android.bluetooth; +import android.annotation.UnsupportedAppUsage; import android.os.Parcel; import android.os.Parcelable; @@ -63,6 +64,7 @@ public final class BluetoothClass implements Parcelable { private final int mClass; /** @hide */ + @UnsupportedAppUsage public BluetoothClass(int classInt) { mClass = classInt; } @@ -322,8 +324,10 @@ public final class BluetoothClass implements Parcelable { } /** @hide */ + @UnsupportedAppUsage public static final int PROFILE_HEADSET = 0; /** @hide */ + @UnsupportedAppUsage public static final int PROFILE_A2DP = 1; /** @hide */ public static final int PROFILE_OPP = 2; @@ -346,6 +350,7 @@ public final class BluetoothClass implements Parcelable { * @return True if this device might support specified profile. * @hide */ + @UnsupportedAppUsage public boolean doesClassMatch(int profile) { if (profile == PROFILE_A2DP) { if (hasService(Service.RENDER)) { -- cgit v1.2.3 From 97f92616b0c91891e717a7d5fd053ea146b9878a Mon Sep 17 00:00:00 2001 From: Ralph Nathan Date: Mon, 23 Jul 2018 09:35:18 -0700 Subject: Mark BluetoothClass#getClassOfDevice as TestApi This method is being used the Android Things instrumentation test apk. Bug: 111654175 Test: tests pass Change-Id: Id3fcd2d89789868e50048542fd1dfe25d9986103 --- framework/java/android/bluetooth/BluetoothClass.java | 2 ++ 1 file changed, 2 insertions(+) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index 8557f389d9..3a78cbdd4d 100755 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -16,6 +16,7 @@ package android.bluetooth; +import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; import android.os.Parcel; import android.os.Parcelable; @@ -293,6 +294,7 @@ public final class BluetoothClass implements Parcelable { * * @hide */ + @TestApi public int getClassOfDevice() { return mClass; } -- cgit v1.2.3 From 7344059322fee5d4a13af2f53f276880aed246ac Mon Sep 17 00:00:00 2001 From: Mathew Inwood Date: Thu, 20 Dec 2018 13:53:36 +0000 Subject: Limit access to suspected false positives. Members modified herein are suspected to be false positives: i.e. things that were added to the greylist in P, but subsequent data analysis suggests that they are not, in fact, used after all. Add a maxTargetSdk=P to these APIs. This is lower-risk that simply removing these things from the greylist, as none of out data sources are perfect nor complete. For APIs that are not supported yet by annotations, move them to hiddenapi-greylist-max-p.txt instead which has the same effect. Exempted-From-Owner-Approval: Automatic changes to the codebase affecting only @UnsupportedAppUsage annotations, themselves added without requiring owners approval earlier. Bug: 115609023 Test: m Change-Id: I020a9c09672ebcae64c5357abc4993e07e744687 --- framework/java/android/bluetooth/BluetoothClass.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index 3a78cbdd4d..1edbacbae4 100755 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -18,6 +18,7 @@ package android.bluetooth; import android.annotation.TestApi; import android.annotation.UnsupportedAppUsage; +import android.os.Build; import android.os.Parcel; import android.os.Parcelable; @@ -65,7 +66,7 @@ public final class BluetoothClass implements Parcelable { private final int mClass; /** @hide */ - @UnsupportedAppUsage + @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) public BluetoothClass(int classInt) { mClass = classInt; } -- cgit v1.2.3 From 13613a3f176ab3e10367685367443dddeee77db5 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Thu, 28 Feb 2019 12:06:45 -0700 Subject: All Parcelable CREATOR fields are @NonNull. If they were null, then the Parcelable would fail to work. Bug: 126726802 Test: manual Change-Id: I7929ffa2f20e5de1c8e68e8263cca99496e9d014 Exempt-From-Owner-Approval: Trivial API annotations --- framework/java/android/bluetooth/BluetoothClass.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index 1edbacbae4..260e2fb1b8 100755 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -94,7 +94,7 @@ public final class BluetoothClass implements Parcelable { return 0; } - public static final Parcelable.Creator CREATOR = + public static final @android.annotation.NonNull Parcelable.Creator CREATOR = new Parcelable.Creator() { public BluetoothClass createFromParcel(Parcel in) { return new BluetoothClass(in.readInt()); -- cgit v1.2.3 From cb33332a4259dc9e5cc3833cd3d38c1caa165c7b Mon Sep 17 00:00:00 2001 From: Artur Satayev Date: Tue, 10 Dec 2019 17:47:52 +0000 Subject: Use new UnsupportedAppUsage annotation. Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I6ab53570aca580fbee1fcc927871caa09780f58f --- framework/java/android/bluetooth/BluetoothClass.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index 260e2fb1b8..905b0ceec4 100755 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -17,7 +17,7 @@ package android.bluetooth; import android.annotation.TestApi; -import android.annotation.UnsupportedAppUsage; +import android.compat.annotation.UnsupportedAppUsage; import android.os.Build; import android.os.Parcel; import android.os.Parcelable; -- cgit v1.2.3 From d8fe38cc98bb4f49cd0c4ab9d7855f98ee1209f3 Mon Sep 17 00:00:00 2001 From: Artur Satayev Date: Tue, 10 Dec 2019 17:47:52 +0000 Subject: Use new UnsupportedAppUsage annotation. Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library. Bug: 145132366 Test: m && diff unsupportedappusage_index.csv Change-Id: I6ab53570aca580fbee1fcc927871caa09780f58f Merged-In: I6ab53570aca580fbee1fcc927871caa09780f58f --- framework/java/android/bluetooth/BluetoothClass.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index 260e2fb1b8..905b0ceec4 100755 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -17,7 +17,7 @@ package android.bluetooth; import android.annotation.TestApi; -import android.annotation.UnsupportedAppUsage; +import android.compat.annotation.UnsupportedAppUsage; import android.os.Build; import android.os.Parcel; import android.os.Parcelable; -- cgit v1.2.3 From 2883f7ab9e740b5da3c872b9fe675691ddfc322d Mon Sep 17 00:00:00 2001 From: Roman Kalukiewicz Date: Wed, 14 Oct 2020 15:59:06 -0700 Subject: Add @Nullable annotation to the parameter of Object.equals() methods. Those annotations could be inferred by some tools (like Kotlin), but the https://checkerframework.org/ doesn't check inherited annotations complaining about all equals() invocations that get nullable argument. The change was generated by running find . -name \*.java | xargs sed -i 's/public boolean equals(Object /public boolean equals(@Nullable Object /' in the frameworks/base directory and by automatically adding and formatting required imports if needed. No manual edits. Bug: 170883422 Test: Annotation change only. Should have not impact. Exempt-From-Owner-Approval: Mechanical change not specific to any component. Change-Id: I5eedb571c9d78862115dfdc5dae1cf2a35343580 --- framework/java/android/bluetooth/BluetoothClass.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index 905b0ceec4..603a7ff29e 100755 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -16,6 +16,7 @@ package android.bluetooth; +import android.annotation.Nullable; import android.annotation.TestApi; import android.compat.annotation.UnsupportedAppUsage; import android.os.Build; @@ -72,7 +73,7 @@ public final class BluetoothClass implements Parcelable { } @Override - public boolean equals(Object o) { + public boolean equals(@Nullable Object o) { if (o instanceof BluetoothClass) { return mClass == ((BluetoothClass) o).mClass; } -- cgit v1.2.3 From a5e5c2b032748d60d5964ef9275978bd451ab654 Mon Sep 17 00:00:00 2001 From: Myles Watson Date: Wed, 2 Dec 2020 20:48:08 -0800 Subject: BluetoothClass: Use mask to get MajorDeviceClass Bug: 174650196 Test: compiles Change-Id: I6042a02fa329c5291aa7b9719907485e748582bf --- framework/java/android/bluetooth/BluetoothClass.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index 905b0ceec4..1e92fc0568 100755 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -425,13 +425,13 @@ public final class BluetoothClass implements Parcelable { return false; } } else if (profile == PROFILE_HID) { - return (getDeviceClass() & Device.Major.PERIPHERAL) == Device.Major.PERIPHERAL; + return getMajorDeviceClass() == Device.Major.PERIPHERAL; } else if (profile == PROFILE_PANU || profile == PROFILE_NAP) { // No good way to distinguish between the two, based on class bits. if (hasService(Service.NETWORKING)) { return true; } - return (getDeviceClass() & Device.Major.NETWORKING) == Device.Major.NETWORKING; + return getMajorDeviceClass() == Device.Major.NETWORKING; } else { return false; } -- cgit v1.2.3 From 19001515735eef64d46bf9ff7a10404dfc7c379a Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski Date: Wed, 5 Jan 2022 23:04:04 +0100 Subject: Bluetooth: add LE Audio COD constant definition Tag: #feature Test: compilation Bug: 150670922 Change-Id: Ic68cd1e9ce4f10d7c2388eeeabe67acad5e555ea --- framework/java/android/bluetooth/BluetoothClass.java | 1 + 1 file changed, 1 insertion(+) (limited to 'framework/java/android/bluetooth/BluetoothClass.java') diff --git a/framework/java/android/bluetooth/BluetoothClass.java b/framework/java/android/bluetooth/BluetoothClass.java index 7fe18a0704..8535b4fd28 100755 --- a/framework/java/android/bluetooth/BluetoothClass.java +++ b/framework/java/android/bluetooth/BluetoothClass.java @@ -119,6 +119,7 @@ public final class BluetoothClass implements Parcelable { private static final int BITMASK = 0xFFE000; public static final int LIMITED_DISCOVERABILITY = 0x002000; + public static final int LE_AUDIO = 0x004000; public static final int POSITIONING = 0x010000; public static final int NETWORKING = 0x020000; public static final int RENDER = 0x040000; -- cgit v1.2.3