android.os.ParcelUuid#getUuid ( )源码实例Demo

下面列出了android.os.ParcelUuid#getUuid ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: RxAndroidBle   文件: ScanFilter.java
private static boolean matchesServiceUuids(ParcelUuid uuid, ParcelUuid parcelUuidMask,
                                           List<ParcelUuid> uuids) {
    if (uuid == null) {
        return true;
    }
    if (uuids == null) {
        return false;
    }

    for (ParcelUuid parcelUuid : uuids) {
        UUID uuidMask = parcelUuidMask == null ? null : parcelUuidMask.getUuid();
        if (matchesServiceUuid(uuid.getUuid(), uuidMask, parcelUuid.getUuid())) {
            return true;
        }
    }
    return false;
}
 
源代码2 项目: AndroidBleManager   文件: ScanFilterCompat.java
private boolean matchesServiceUuids(ParcelUuid uuid, ParcelUuid parcelUuidMask,
                                    List<ParcelUuid> uuids) {
    if (uuid == null) {
        return true;
    }
    if (uuids == null) {
        return false;
    }

    for (ParcelUuid parcelUuid : uuids) {
        UUID uuidMask = parcelUuidMask == null ? null : parcelUuidMask.getUuid();
        if (matchesServiceUuid(uuid.getUuid(), uuidMask, parcelUuid.getUuid())) {
            return true;
        }
    }
    return false;
}
 
/**
 * Check if the uuid pattern is contained in a list of parcel uuids.
 */
private static boolean matchesServiceUuids(@Nullable final ParcelUuid uuid,
										   @Nullable final ParcelUuid parcelUuidMask,
										   @Nullable final List<ParcelUuid> uuids) {
	if (uuid == null) {
		return true;
	}
	if (uuids == null) {
		return false;
	}

	for (final ParcelUuid parcelUuid : uuids) {
		final UUID uuidMask = parcelUuidMask == null ? null : parcelUuidMask.getUuid();
		if (matchesServiceUuid(uuid.getUuid(), uuidMask, parcelUuid.getUuid())) {
			return true;
		}
	}
	return false;
}
 
源代码4 项目: android_9.0.0_r45   文件: BluetoothUuid.java
/**
 * Check whether the given parcelUuid can be converted to 16 bit bluetooth uuid.
 *
 * @param parcelUuid
 * @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);
}
 
源代码5 项目: android_9.0.0_r45   文件: BluetoothUuid.java
/**
 * 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);
}
 
源代码6 项目: BLExplorer   文件: BluetoothUuid.java
/**
 * 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);
}
 
源代码7 项目: Android-nRF-Mesh-Library   文件: Group.java
private UUID readVirtualLabelFromParcelable(Parcel in, final int address) {
    if (MeshAddress.isValidVirtualAddress(address)) {
        final ParcelUuid parcelUuid = in.readParcelable(ParcelUuid.class.getClassLoader());
        if (parcelUuid != null) {
            return parcelUuid.getUuid();
        }
    }
    return null;
}
 
源代码8 项目: physical-web   文件: BluetoothUuid.java
/**
 * Check whether the given parcelUuid can be converted to 16 bit bluetooth uuid.
 *
 * @param parcelUuid
 * @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;
}
 
源代码9 项目: Android-nRF-Mesh-Library   文件: AccessMessage.java
protected AccessMessage(final Parcel source) {
    super(source);
    final ParcelUuid parcelUuid = source.readParcelable(ParcelUuid.class.getClassLoader());
    if (parcelUuid != null) {
        label = parcelUuid.getUuid();
    }
    lowerTransportAccessPdu = readSparseArrayToParcelable(source);
    accessPdu = source.createByteArray();
    transportPdu = source.createByteArray();
}
 
源代码10 项目: EFRConnect-android   文件: BluetoothUuid.java
/**
 * Check whether the given parcelUuid can be converted to 16 bit bluetooth uuid.
 *
 * @param parcelUuid
 * @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);
}
 
源代码11 项目: BLE   文件: UuidFilterScanCallback.java
@Override
public BluetoothLeDevice onFilter(BluetoothLeDevice bluetoothLeDevice) {
    BluetoothLeDevice tempDevice = null;
    if (bluetoothLeDevice != null && bluetoothLeDevice.getDevice() != null
            && bluetoothLeDevice.getDevice().getUuids() != null
            && bluetoothLeDevice.getDevice().getUuids().length > 0) {
        for (ParcelUuid parcelUuid : bluetoothLeDevice.getDevice().getUuids()) {
            if (uuid != null && uuid == parcelUuid.getUuid()) {
                tempDevice = bluetoothLeDevice;
            }
        }
    }
    return tempDevice;
}
 
源代码12 项目: AndroidBleManager   文件: BluetoothUuidCompat.java
/**
 * Check whether the given parcelUuid can be converted to 16 bit bluetooth uuid.
 *
 * @param parcelUuid
 * @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);
}
 
源代码13 项目: AndroidBleManager   文件: BluetoothUuidCompat.java
/**
 * 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);
}
 
源代码14 项目: BLExplorer   文件: BluetoothUuid.java
/**
 * Check whether the given parcelUuid can be converted to 16 bit bluetooth uuid.
 *
 * @param parcelUuid
 * @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);
}
 
源代码15 项目: blessed-android   文件: BluetoothCentralTest.java
@Test
public void scanForPeripheralsWithServicesTest() throws Exception {
    application.grantPermissions(Manifest.permission.ACCESS_COARSE_LOCATION);
    UUID BLP_SERVICE_UUID = UUID.fromString("00001810-0000-1000-8000-00805f9b34fb");
    central.scanForPeripheralsWithServices(new UUID[]{BLP_SERVICE_UUID});

    // Make sure startScan is called
    ArgumentCaptor<List> scanFiltersCaptor = ArgumentCaptor.forClass(List.class);
    ArgumentCaptor<ScanSettings> scanSettingsCaptor = ArgumentCaptor.forClass(ScanSettings.class);
    ArgumentCaptor<ScanCallback> scanCallbackCaptor = ArgumentCaptor.forClass(ScanCallback.class);
    verify(scanner).startScan(scanFiltersCaptor.capture(), scanSettingsCaptor.capture(), scanCallbackCaptor.capture());

    // Verify there is only 1 filter set
    List<ScanFilter> filters = scanFiltersCaptor.getValue();
    assertEquals(1, filters.size());

    // Verify the filter contains the UUID we added
    ScanFilter uuidFilter = filters.get(0);
    ParcelUuid parcelUuid = uuidFilter.getServiceUuid();
    UUID uuid = parcelUuid.getUuid();
    assertEquals(BLP_SERVICE_UUID.toString(), uuid.toString());

    // Grab the scan callback that is used
    Field field = BluetoothCentral.class.getDeclaredField("scanByServiceUUIDCallback");
    field.setAccessible(true);
    ScanCallback scanCallback = (ScanCallback) field.get(central);

    // Fake scan result
    ScanResult scanResult = mock(ScanResult.class);
    BluetoothDevice device = mock(BluetoothDevice.class);
    when(device.getAddress()).thenReturn("00:00:00:00");
    when(scanResult.getDevice()).thenReturn(device);
    scanCallback.onScanResult(CALLBACK_TYPE_ALL_MATCHES, scanResult);

    // See if we get it back
    ArgumentCaptor<BluetoothPeripheral> bluetoothPeripheralCaptor = ArgumentCaptor.forClass(BluetoothPeripheral.class);
    ArgumentCaptor<ScanResult> scanResultCaptor = ArgumentCaptor.forClass(ScanResult.class);
    verify(callback).onDiscoveredPeripheral(bluetoothPeripheralCaptor.capture(), scanResultCaptor.capture());

    assertEquals(scanResultCaptor.getValue(), scanResult);
    assertEquals(bluetoothPeripheralCaptor.getValue().getAddress(), "00:00:00:00");
}
 
源代码16 项目: android_9.0.0_r45   文件: BluetoothUuid.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
 *
 * @param parcelUuid
 * @return the service identifier.
 */
public static int getServiceIdentifierFromParcelUuid(ParcelUuid parcelUuid) {
    UUID uuid = parcelUuid.getUuid();
    long value = (uuid.getMostSignificantBits() & 0xFFFFFFFF00000000L) >>> 32;
    return (int) value;
}
 
源代码17 项目: EFRConnect-android   文件: BluetoothUuid.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
 *
 * @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;
}
 
源代码18 项目: physical-web   文件: BluetoothUuid.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
 *
 * @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;
}
 
源代码19 项目: AndroidBleManager   文件: BluetoothUuidCompat.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
 *
 * @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;
}
 
源代码20 项目: BLExplorer   文件: BluetoothUuid.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
 *
 * @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;
}