Example usage for android.os ParcelUuid getUuid

List of usage examples for android.os ParcelUuid getUuid

Introduction

In this page you can find the example usage for android.os ParcelUuid getUuid.

Prototype

public UUID getUuid() 

Source Link

Document

Get the UUID represented by the ParcelUuid.

Usage

From source file:Main.java

/**
 * 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//  w  w  w.  j av a  2  s . com
 * @param parcelUuid
 * @return the service identifier.
 */
public static int getServiceIdentifierFromParcelUuid(ParcelUuid parcelUuid) {
    UUID uuid = parcelUuid.getUuid();
    long value = (uuid.getMostSignificantBits() & 0x0000FFFF00000000L) >>> 32;
    return (int) value;
}

From source file:Main.java

/**
 * Check whether the given parcelUuid can be converted to 16 bit bluetooth uuid.
 *
 * @param parcelUuid//from  w  w w  .j a v  a2 s . c  o m
 * @return true if the parcelUuid can be converted to 16 bit uuid, false otherwise.
 */
public static boolean is16BitUuid(ParcelUuid parcelUuid) {
    UUID uuid = parcelUuid.getUuid();
    if (uuid.getLeastSignificantBits() != BASE_UUID.getUuid().getLeastSignificantBits()) {
        return false;
    }
    return ((uuid.getMostSignificantBits() & 0xFFFF0000FFFFFFFFL) == 0x1000L);
}

From source file:Main.java

/**
 * Check whether the given parcelUuid can be converted to 32 bit bluetooth uuid.
 *
 * @param parcelUuid/*from w  w  w . jav a  2 s.c  om*/
 * @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);
}

From source file:com.improvelectronics.sync.android.SyncStreamingService.java

private void updatePairedDevices() {
    Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
    if (pairedDevices == null || pairedDevices.size() == 0)
        return;//ww  w .ja va2 s .  co  m

    if (DEBUG)
        Log.d(TAG, "searching for paired Syncs");

    mPairedDevices.clear();
    for (BluetoothDevice device : pairedDevices) {
        if (device.getName() != null && device.getName().equals("Sync")) {
            if (DEBUG)
                Log.d(TAG, "found a Boogie Board Sync");
            mPairedDevices.add(device);
        }
    }

    // Connect to the first device that was found in the list of paired devices.
    if (mPairedDevices.size() > 0 && mState != STATE_CONNECTED) {
        BluetoothDevice device = mPairedDevices.get(0);

        // Device must first be checked to see if it has the most up to date firmware.
        // This check is done by ensuring the device has all the correct UUIDs.
        // If it doesn't have the CONNECT_UUID then the firmware is not the latest.
        boolean foundUuid = false;
        for (ParcelUuid uuid : device.getUuids()) {
            if (uuid.getUuid().equals(CONNECT_UUID))
                foundUuid = true;
        }
        if (!foundUuid) {
            showUpdateFirmwareNotification();
        }
    }
}