Fields Summary |
---|
public static final android.os.ParcelUuid | AudioSink |
public static final android.os.ParcelUuid | AudioSource |
public static final android.os.ParcelUuid | AdvAudioDist |
public static final android.os.ParcelUuid | HSP |
public static final android.os.ParcelUuid | HSP_AG |
public static final android.os.ParcelUuid | Handsfree |
public static final android.os.ParcelUuid | Handsfree_AG |
public static final android.os.ParcelUuid | AvrcpController |
public static final android.os.ParcelUuid | AvrcpTarget |
public static final android.os.ParcelUuid | ObexObjectPush |
public static final android.os.ParcelUuid | Hid |
public static final android.os.ParcelUuid | Hogp |
public static final android.os.ParcelUuid | PANU |
public static final android.os.ParcelUuid | NAP |
public static final android.os.ParcelUuid | BNEP |
public static final android.os.ParcelUuid | PBAP_PCE |
public static final android.os.ParcelUuid | PBAP_PSE |
public static final android.os.ParcelUuid | MAP |
public static final android.os.ParcelUuid | MNS |
public static final android.os.ParcelUuid | MAS |
public static final android.os.ParcelUuid | BASE_UUID |
public static final int | UUID_BYTES_16_BITLength of bytes for 16 bit UUID |
public static final int | UUID_BYTES_32_BITLength of bytes for 32 bit UUID |
public static final int | UUID_BYTES_128_BITLength of bytes for 128 bit UUID |
public static final android.os.ParcelUuid[] | RESERVED_UUIDS |
Methods Summary |
---|
public static boolean | containsAllUuids(android.os.ParcelUuid[] uuidA, android.os.ParcelUuid[] uuidB)Returns true if all the ParcelUuids in ParcelUuidB are present in
ParcelUuidA
if (uuidA == null && uuidB == null) return true;
if (uuidA == null) {
return uuidB.length == 0 ? true : false;
}
if (uuidB == null) return true;
HashSet<ParcelUuid> uuidSet = new HashSet<ParcelUuid> (Arrays.asList(uuidA));
for (ParcelUuid uuid: uuidB) {
if (!uuidSet.contains(uuid)) return false;
}
return true;
|
public static boolean | containsAnyUuid(android.os.ParcelUuid[] uuidA, android.os.ParcelUuid[] uuidB)Returns true if there any common ParcelUuids in uuidA and uuidB.
if (uuidA == null && uuidB == null) return true;
if (uuidA == null) {
return uuidB.length == 0 ? true : false;
}
if (uuidB == null) {
return uuidA.length == 0 ? true : false;
}
HashSet<ParcelUuid> uuidSet = new HashSet<ParcelUuid> (Arrays.asList(uuidA));
for (ParcelUuid uuid: uuidB) {
if (uuidSet.contains(uuid)) return true;
}
return false;
|
public static int | getServiceIdentifierFromParcelUuid(android.os.ParcelUuid parcelUuid)Extract the Service Identifier or the actual uuid from the Parcel Uuid.
For example, if 0000110B-0000-1000-8000-00805F9B34FB is the parcel Uuid,
this function will return 110B
UUID uuid = parcelUuid.getUuid();
long value = (uuid.getMostSignificantBits() & 0x0000FFFF00000000L) >>> 32;
return (int)value;
|
public static boolean | is16BitUuid(android.os.ParcelUuid parcelUuid)Check whether the given parcelUuid can be converted to 16 bit bluetooth uuid.
UUID uuid = parcelUuid.getUuid();
if (uuid.getLeastSignificantBits() != BASE_UUID.getUuid().getLeastSignificantBits()) {
return false;
}
return ((uuid.getMostSignificantBits() & 0xFFFF0000FFFFFFFFL) == 0x1000L);
|
public static boolean | is32BitUuid(android.os.ParcelUuid parcelUuid)Check whether the given parcelUuid can be converted to 32 bit bluetooth uuid.
UUID uuid = parcelUuid.getUuid();
if (uuid.getLeastSignificantBits() != BASE_UUID.getUuid().getLeastSignificantBits()) {
return false;
}
if (is16BitUuid(parcelUuid)) {
return false;
}
return ((uuid.getMostSignificantBits() & 0xFFFFFFFFL) == 0x1000L);
|
public static boolean | isAdvAudioDist(android.os.ParcelUuid uuid)
return uuid.equals(AdvAudioDist);
|
public static boolean | isAudioSink(android.os.ParcelUuid uuid)
return uuid.equals(AudioSink);
|
public static boolean | isAudioSource(android.os.ParcelUuid uuid)
return uuid.equals(AudioSource);
|
public static boolean | isAvrcpController(android.os.ParcelUuid uuid)
return uuid.equals(AvrcpController);
|
public static boolean | isAvrcpTarget(android.os.ParcelUuid uuid)
return uuid.equals(AvrcpTarget);
|
public static boolean | isBnep(android.os.ParcelUuid uuid)
return uuid.equals(BNEP);
|
public static boolean | isHandsfree(android.os.ParcelUuid uuid)
return uuid.equals(Handsfree);
|
public static boolean | isHeadset(android.os.ParcelUuid uuid)
return uuid.equals(HSP);
|
public static boolean | isInputDevice(android.os.ParcelUuid uuid)
return uuid.equals(Hid);
|
public static boolean | isMap(android.os.ParcelUuid uuid)
return uuid.equals(MAP);
|
public static boolean | isMas(android.os.ParcelUuid uuid)
return uuid.equals(MAS);
|
public static boolean | isMns(android.os.ParcelUuid uuid)
return uuid.equals(MNS);
|
public static boolean | isNap(android.os.ParcelUuid uuid)
return uuid.equals(NAP);
|
public static boolean | isPanu(android.os.ParcelUuid uuid)
return uuid.equals(PANU);
|
public static boolean | isUuidPresent(android.os.ParcelUuid[] uuidArray, android.os.ParcelUuid uuid)Returns true if ParcelUuid is present in uuidArray
if ((uuidArray == null || uuidArray.length == 0) && uuid == null)
return true;
if (uuidArray == null)
return false;
for (ParcelUuid element: uuidArray) {
if (element.equals(uuid)) return true;
}
return false;
|
public static android.os.ParcelUuid | parseUuidFrom(byte[] uuidBytes)Parse UUID from bytes. The {@code uuidBytes} can represent a 16-bit, 32-bit or 128-bit UUID,
but the returned UUID is always in 128-bit format.
Note UUID is little endian in Bluetooth.
if (uuidBytes == null) {
throw new IllegalArgumentException("uuidBytes cannot be null");
}
int length = uuidBytes.length;
if (length != UUID_BYTES_16_BIT && length != UUID_BYTES_32_BIT &&
length != UUID_BYTES_128_BIT) {
throw new IllegalArgumentException("uuidBytes length invalid - " + length);
}
// Construct a 128 bit UUID.
if (length == UUID_BYTES_128_BIT) {
ByteBuffer buf = ByteBuffer.wrap(uuidBytes).order(ByteOrder.LITTLE_ENDIAN);
long msb = buf.getLong(8);
long lsb = buf.getLong(0);
return new ParcelUuid(new UUID(msb, lsb));
}
// For 16 bit and 32 bit UUID we need to convert them to 128 bit value.
// 128_bit_value = uuid * 2^96 + BASE_UUID
long shortUuid;
if (length == UUID_BYTES_16_BIT) {
shortUuid = uuidBytes[0] & 0xFF;
shortUuid += (uuidBytes[1] & 0xFF) << 8;
} else {
shortUuid = uuidBytes[0] & 0xFF ;
shortUuid += (uuidBytes[1] & 0xFF) << 8;
shortUuid += (uuidBytes[2] & 0xFF) << 16;
shortUuid += (uuidBytes[3] & 0xFF) << 24;
}
long msb = BASE_UUID.getUuid().getMostSignificantBits() + (shortUuid << 32);
long lsb = BASE_UUID.getUuid().getLeastSignificantBits();
return new ParcelUuid(new UUID(msb, lsb));
|