summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorWei Wang <weiwa@google.com>2014-05-07 14:54:43 -0700
committerWei Wang <weiwa@google.com>2014-05-19 19:37:05 -0700
commit51800847d9a9965a5d00a7960abb50983651d4a2 (patch)
treea2ab92c6b13bb1f15ba009d0dc7ee2778d72015a /core
parent2f4a82af91faf76aa7dd59b22c1354f06410b634 (diff)
downloadframeworks_base-51800847d9a9965a5d00a7960abb50983651d4a2.zip
frameworks_base-51800847d9a9965a5d00a7960abb50983651d4a2.tar.gz
frameworks_base-51800847d9a9965a5d00a7960abb50983651d4a2.tar.bz2
Add a method to check whether a UUID is 32bit.
Change-Id: I92e8bab560b2083e9f4855d28b3f54f2120ef628
Diffstat (limited to 'core')
-rw-r--r--core/java/android/bluetooth/BluetoothUuid.java20
-rw-r--r--core/tests/bluetoothtests/src/android/bluetooth/BluetoothUuidTest.java16
2 files changed, 35 insertions, 1 deletions
diff --git a/core/java/android/bluetooth/BluetoothUuid.java b/core/java/android/bluetooth/BluetoothUuid.java
index ab53fb0..1e22eb3 100644
--- a/core/java/android/bluetooth/BluetoothUuid.java
+++ b/core/java/android/bluetooth/BluetoothUuid.java
@@ -273,11 +273,29 @@ public final class BluetoothUuid {
* @param parcelUuid
* @return true if the parcelUuid can be converted to 16 bit uuid, false otherwise.
*/
- public static boolean isShortUuid(ParcelUuid parcelUuid) {
+ public static boolean is16BitUuid(ParcelUuid parcelUuid) {
UUID uuid = parcelUuid.getUuid();
if (uuid.getLeastSignificantBits() != BASE_UUID.getUuid().getLeastSignificantBits()) {
return false;
}
return ((uuid.getMostSignificantBits() & 0xFFFF0000FFFFFFFFL) == 0x1000L);
}
+
+
+ /**
+ * Check whether the given parcelUuid can be converted to 32 bit bluetooth uuid.
+ *
+ * @param parcelUuid
+ * @return true if the parcelUuid can be converted to 32 bit uuid, false otherwise.
+ */
+ public static boolean is32BitUuid(ParcelUuid parcelUuid) {
+ UUID uuid = parcelUuid.getUuid();
+ if (uuid.getLeastSignificantBits() != BASE_UUID.getUuid().getLeastSignificantBits()) {
+ return false;
+ }
+ if (is16BitUuid(parcelUuid)) {
+ return false;
+ }
+ return ((uuid.getMostSignificantBits() & 0xFFFFFFFFL) == 0x1000L);
+ }
}
diff --git a/core/tests/bluetoothtests/src/android/bluetooth/BluetoothUuidTest.java b/core/tests/bluetoothtests/src/android/bluetooth/BluetoothUuidTest.java
index 0f3ea0e..536d7226 100644
--- a/core/tests/bluetoothtests/src/android/bluetooth/BluetoothUuidTest.java
+++ b/core/tests/bluetoothtests/src/android/bluetooth/BluetoothUuidTest.java
@@ -47,4 +47,20 @@ public class BluetoothUuidTest extends TestCase {
assertEquals(ParcelUuid.fromString("FF0F0E0D-0C0B-0A09-0807-0060504030201"),
BluetoothUuid.parseUuidFrom(uuid128));
}
+
+ @SmallTest
+ public void testUuidType() {
+ assertTrue(BluetoothUuid.is16BitUuid(
+ ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB")));
+ assertFalse(BluetoothUuid.is32BitUuid(
+ ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB")));
+
+ assertFalse(BluetoothUuid.is16BitUuid(
+ ParcelUuid.fromString("FE33110B-0000-1000-8000-00805F9B34FB")));
+ assertTrue(BluetoothUuid.is32BitUuid(
+ ParcelUuid.fromString("FE33110B-0000-1000-8000-00805F9B34FB")));
+ assertFalse(BluetoothUuid.is32BitUuid(
+ ParcelUuid.fromString("FE33110B-1000-1000-8000-00805F9B34FB")));
+
+ }
}