Search in sources :

Example 96 with ParcelUuid

use of android.os.ParcelUuid in project android_frameworks_base by AOSPA.

the class BluetoothGattService method writeToParcel.

@Override
public void writeToParcel(Parcel out, int flags) {
    out.writeParcelable(new ParcelUuid(mUuid), 0);
    out.writeInt(mInstanceId);
    out.writeInt(mServiceType);
    out.writeTypedList(mCharacteristics);
    ArrayList<BluetoothGattIncludedService> includedServices = new ArrayList<BluetoothGattIncludedService>(mIncludedServices.size());
    for (BluetoothGattService s : mIncludedServices) {
        includedServices.add(new BluetoothGattIncludedService(s.getUuid(), s.getInstanceId(), s.getType()));
    }
    out.writeTypedList(includedServices);
}
Also used : ParcelUuid(android.os.ParcelUuid) ArrayList(java.util.ArrayList)

Example 97 with ParcelUuid

use of android.os.ParcelUuid in project android_frameworks_base by AOSPA.

the class BluetoothUuid method parseUuidFrom.

/**
     * 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.
     *
     * @param uuidBytes Byte representation of uuid.
     * @return {@link ParcelUuid} parsed from bytes.
     * @throws IllegalArgumentException If the {@code uuidBytes} cannot be parsed.
     */
public static ParcelUuid parseUuidFrom(byte[] uuidBytes) {
    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));
}
Also used : ParcelUuid(android.os.ParcelUuid) UUID(java.util.UUID) ByteBuffer(java.nio.ByteBuffer)

Example 98 with ParcelUuid

use of android.os.ParcelUuid in project android_frameworks_base by AOSPA.

the class BluetoothGattDescriptor method writeToParcel.

public void writeToParcel(Parcel out, int flags) {
    out.writeParcelable(new ParcelUuid(mUuid), 0);
    out.writeInt(mInstance);
    out.writeInt(mPermissions);
}
Also used : ParcelUuid(android.os.ParcelUuid)

Example 99 with ParcelUuid

use of android.os.ParcelUuid in project android_frameworks_base by AOSPA.

the class BluetoothGattIncludedService method writeToParcel.

public void writeToParcel(Parcel out, int flags) {
    out.writeParcelable(new ParcelUuid(mUuid), 0);
    out.writeInt(mInstanceId);
    out.writeInt(mServiceType);
}
Also used : ParcelUuid(android.os.ParcelUuid)

Example 100 with ParcelUuid

use of android.os.ParcelUuid in project android_frameworks_base by AOSPA.

the class AdvertiseDataTest method testServiceUuid.

@SmallTest
public void testServiceUuid() {
    Parcel parcel = Parcel.obtain();
    ParcelUuid uuid = ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB");
    ParcelUuid uuid2 = ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB");
    AdvertiseData data = mAdvertiseDataBuilder.setIncludeDeviceName(true).addServiceUuid(uuid).addServiceUuid(uuid2).build();
    data.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);
    AdvertiseData dataFromParcel = AdvertiseData.CREATOR.createFromParcel(parcel);
    assertEquals(data, dataFromParcel);
}
Also used : ParcelUuid(android.os.ParcelUuid) Parcel(android.os.Parcel) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

ParcelUuid (android.os.ParcelUuid)147 SmallTest (android.test.suitebuilder.annotation.SmallTest)43 RemoteException (android.os.RemoteException)29 UUID (java.util.UUID)24 ArrayList (java.util.ArrayList)23 GenericSoundModel (android.hardware.soundtrigger.SoundTrigger.GenericSoundModel)20 Parcel (android.os.Parcel)20 ScanFilter (android.bluetooth.le.ScanFilter)19 RecognitionConfig (android.hardware.soundtrigger.SoundTrigger.RecognitionConfig)12 LargeTest (android.test.suitebuilder.annotation.LargeTest)12 ScanRecord (android.bluetooth.le.ScanRecord)10 BluetoothDevice (android.bluetooth.BluetoothDevice)9 Socket (java.net.Socket)9 DataOutputStream (java.io.DataOutputStream)8 ByteBuffer (java.nio.ByteBuffer)8 SparseArray (android.util.SparseArray)6 RequiresPermission (android.annotation.RequiresPermission)5 BluetoothClass (android.bluetooth.BluetoothClass)5 BluetoothLeScanner (android.bluetooth.le.BluetoothLeScanner)5 ScanCallback (android.bluetooth.le.ScanCallback)5