类android.os.ParcelUuid源码实例Demo

下面列出了怎么用android.os.ParcelUuid的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: android_9.0.0_r45   文件: ScanFilter.java
/**
 * Set partial filter on service data. For any bit in the mask, set it to 1 if it needs to
 * match the one in service data, otherwise set it to 0 to ignore that bit.
 * <p>
 * The {@code serviceDataMask} must have the same length of the {@code serviceData}.
 *
 * @throws IllegalArgumentException If {@code serviceDataUuid} is null or {@code
 * serviceDataMask} is {@code null} while {@code serviceData} is not or {@code
 * serviceDataMask} and {@code serviceData} has different length.
 */
public Builder setServiceData(ParcelUuid serviceDataUuid,
        byte[] serviceData, byte[] serviceDataMask) {
    if (serviceDataUuid == null) {
        throw new IllegalArgumentException("serviceDataUuid is null");
    }
    if (mServiceDataMask != null) {
        if (mServiceData == null) {
            throw new IllegalArgumentException(
                    "serviceData is null while serviceDataMask is not null");
        }
        // Since the mServiceDataMask is a bit mask for mServiceData, the lengths of the two
        // byte array need to be the same.
        if (mServiceData.length != mServiceDataMask.length) {
            throw new IllegalArgumentException(
                    "size mismatch for service data and service data mask");
        }
    }
    mServiceDataUuid = serviceDataUuid;
    mServiceData = serviceData;
    mServiceDataMask = serviceDataMask;
    return this;
}
 
源代码2 项目: physical-web   文件: BluetoothUuid.java
/**
 * Returns true if there any common ParcelUuids in uuidA and uuidB.
 *
 * @param uuidA - List of ParcelUuids
 * @param uuidB - List of ParcelUuids
 */
public static boolean containsAnyUuid(ParcelUuid[] uuidA, ParcelUuid[] 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;
}
 
/**
 * Starts reconnecting to the device
 */
private void startScan() {
    if (mIsScanning)
        return;

    mIsScanning = true;
    // Scanning settings
    final ScanSettings settings = new ScanSettings.Builder()
            .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
            // Refresh the devices list every second
            .setReportDelay(0)
            // Hardware filtering has some issues on selected devices
            .setUseHardwareFilteringIfSupported(false)
            // Samsung S6 and S6 Edge report equal value of RSSI for all devices. In this app we ignore the RSSI.
            /*.setUseHardwareBatchingIfSupported(false)*/
            .build();

    // Let's use the filter to scan only for Mesh devices
    final List<ScanFilter> filters = new ArrayList<>();
    filters.add(new ScanFilter.Builder().setServiceUuid(new ParcelUuid((MESH_PROXY_UUID))).build());

    final BluetoothLeScannerCompat scanner = BluetoothLeScannerCompat.getScanner();
    scanner.startScan(filters, settings, scanCallback);
    Log.v(TAG, "Scan started");
    mHandler.postDelayed(mScannerTimeout, 20000);
}
 
源代码4 项目: RxAndroidBle   文件: ScanRecordImplCompat.java
public ScanRecordImplCompat(
        @Nullable List<ParcelUuid> serviceUuids,
        SparseArray<byte[]> manufacturerData,
        Map<ParcelUuid, byte[]> serviceData,
        int advertiseFlags,
        int txPowerLevel,
        String localName,
        byte[] bytes
) {
    this.serviceUuids = serviceUuids;
    this.manufacturerSpecificData = manufacturerData;
    this.serviceData = serviceData;
    this.deviceName = localName;
    this.advertiseFlags = advertiseFlags;
    this.txPowerLevel = txPowerLevel;
    this.bytes = bytes;
}
 
源代码5 项目: android_9.0.0_r45   文件: ScanFilter.java
/**
 * Check if the uuid pattern is contained in a list of parcel uuids.
 *
 * @hide
 */
public 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;
}
 
源代码6 项目: bitgatt   文件: MockScanResultProvider.java
MockScanResultProvider(int numberOfMockResults, int minRssi, int maxRssi){
    rnd = new Random(System.currentTimeMillis());
    scanResults = new ArrayList<>(numberOfMockResults);
    serviceDataMap = new HashMap<>();
    byte[] randomData = new byte[16];
    rnd.nextBytes(randomData);
    serviceDataMap.put(new ParcelUuid(UUID.fromString("adabfb00-6e7d-4601-bda2-bffaa68956ba")), randomData);
    for(int i=0; i < numberOfMockResults; i++) {
        ScanResult result = Mockito.mock(ScanResult.class);
        BluetoothDevice device = Mockito.mock(BluetoothDevice.class);
        ScanRecord record = Mockito.mock(ScanRecord.class);
        Mockito.when(device.getAddress()).thenReturn(randomMACAddress());
        Mockito.when(device.getName()).thenReturn("foobar-" + String.valueOf(i));
        Mockito.when(result.getDevice()).thenReturn(device);
        Mockito.when(result.getRssi()).thenReturn(-1 * (rnd.nextInt(Math.abs(minRssi) + 1 - Math.abs(maxRssi)) + Math.abs(maxRssi)));
        Assert.assertTrue("Rssi is less than zero", result.getRssi() < 0);
        Mockito.when(record.getDeviceName()).thenReturn("foobar-" + String.valueOf(i));
        Mockito.when(record.getServiceData()).thenReturn(serviceDataMap);
        scanResults.add(result);
    }
}
 
源代码7 项目: android-ponewheel   文件: BluetoothUtilImpl.java
void scanLeDevice(final boolean enable) {
    Timber.d("scanLeDevice enable = " + enable);
    if (enable) {
        mScanning = true;
        List<ScanFilter> filters_v2 = new ArrayList<>();
        ScanFilter scanFilter = new ScanFilter.Builder()
                .setServiceUuid(ParcelUuid.fromString(OWDevice.OnewheelServiceUUID))
                .build();
        filters_v2.add(scanFilter);
        //c03f7c8d-5e96-4a75-b4b6-333d36230365
        mBluetoothLeScanner.startScan(filters_v2, settings, mScanCallback);
    } else {
        mScanning = false;
        mBluetoothLeScanner.stopScan(mScanCallback);
        // added 10/23 to try cleanup
        mBluetoothLeScanner.flushPendingScanResults(mScanCallback);
    }
    mainActivity.invalidateOptionsMenu();
}
 
private BluetoothGattCharacteristic(Parcel in) {
    mUuid = ((ParcelUuid) in.readParcelable(null)).getUuid();
    mInstance = in.readInt();
    mProperties = in.readInt();
    mPermissions = in.readInt();
    mKeySize = in.readInt();
    mWriteType = in.readInt();

    mDescriptors = new ArrayList<BluetoothGattDescriptor>();

    ArrayList<BluetoothGattDescriptor> descs =
            in.createTypedArrayList(BluetoothGattDescriptor.CREATOR);
    if (descs != null) {
        for (BluetoothGattDescriptor desc : descs) {
            desc.setCharacteristic(this);
            mDescriptors.add(desc);
        }
    }
}
 
源代码9 项目: android_9.0.0_r45   文件: BluetoothAdapter.java
/**
 * Get the UUIDs supported by the local Bluetooth adapter.
 *
 * <p>Requires {@link android.Manifest.permission#BLUETOOTH}
 *
 * @return the UUIDs supported by the local Bluetooth Adapter.
 * @hide
 */
public ParcelUuid[] getUuids() {
    if (getState() != STATE_ON) {
        return null;
    }
    try {
        mServiceLock.readLock().lock();
        if (mService != null) {
            return mService.getUuids();
        }
    } catch (RemoteException e) {
        Log.e(TAG, "", e);
    } finally {
        mServiceLock.readLock().unlock();
    }
    return null;
}
 
源代码10 项目: EFRConnect-android   文件: BluetoothUuid.java
/**
 * Returns true if all the ParcelUuids in ParcelUuidB are present in ParcelUuidA
 *
 * @param uuidA - Array of ParcelUuidsA
 * @param uuidB - Array of ParcelUuidsB
 */
public static boolean containsAllUuids(ParcelUuid[] uuidA, ParcelUuid[] uuidB) {
    if (uuidA == null && uuidB == null) {
        return true;
    }
    if (uuidA == null) {
        return uuidB.length == 0;
    }
    if (uuidB == null) {
        return true;
    }
    HashSet<ParcelUuid> uuidSet = new HashSet<>(Arrays.asList(uuidA));
    for (ParcelUuid uuid : uuidB) {
        if (!uuidSet.contains(uuid)) {
            return false;
        }
    }
    return true;
}
 
/**
 * Begin advertising over Bluetooth that this device is connectable
 * and supports the Current Time Service.
 */
private void startAdvertising() {
    BluetoothAdapter bluetoothAdapter = mBluetoothManager.getAdapter();
    mBluetoothLeAdvertiser = bluetoothAdapter.getBluetoothLeAdvertiser();
    if (mBluetoothLeAdvertiser == null) {
        Log.w(TAG, "Failed to create advertiser");
        return;
    }

    AdvertiseSettings settings = new AdvertiseSettings.Builder()
            .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED)
            .setConnectable(true)
            .setTimeout(0)
            .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)
            .build();

    AdvertiseData data = new AdvertiseData.Builder()
            .setIncludeDeviceName(true)
            .setIncludeTxPowerLevel(false)
            .addServiceUuid(new ParcelUuid(TimeProfile.TIME_SERVICE))
            .build();

    mBluetoothLeAdvertiser
            .startAdvertising(settings, data, mAdvertiseCallback);
}
 
源代码12 项目: bluetooth   文件: MainActivity.java
void discover() {
    mBluetoothLeScanner = BluetoothAdapter.getDefaultAdapter().getBluetoothLeScanner();

    ScanFilter filter = new ScanFilter.Builder()
        .setServiceUuid( new ParcelUuid(UUID.fromString( getString(R.string.ble_uuid ) ) ) )
        .build();
    List<ScanFilter> filters = new ArrayList<ScanFilter>();
    filters.add( filter );

    ScanSettings settings = new ScanSettings.Builder()
        .setScanMode( ScanSettings.SCAN_MODE_LOW_LATENCY )
        .build();
    mBluetoothLeScanner.startScan(filters, settings, mScanCallback);
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            mBluetoothLeScanner.stopScan(mScanCallback);
        }
    }, 10000);
}
 
源代码13 项目: android_9.0.0_r45   文件: BluetoothUuid.java
/**
 * Returns true if there any common ParcelUuids in uuidA and uuidB.
 *
 * @param uuidA - List of ParcelUuids
 * @param uuidB - List of ParcelUuids
 */
public static boolean containsAnyUuid(ParcelUuid[] uuidA, ParcelUuid[] uuidB) {
    if (uuidA == null && uuidB == null) return true;

    if (uuidA == null) {
        return uuidB.length == 0;
    }

    if (uuidB == null) {
        return uuidA.length == 0;
    }

    HashSet<ParcelUuid> uuidSet = new HashSet<ParcelUuid>(Arrays.asList(uuidA));
    for (ParcelUuid uuid : uuidB) {
        if (uuidSet.contains(uuid)) return true;
    }
    return false;
}
 
源代码14 项目: android_9.0.0_r45   文件: BluetoothUuid.java
/**
 * Returns true if all the ParcelUuids in ParcelUuidB are present in
 * ParcelUuidA
 *
 * @param uuidA - Array of ParcelUuidsA
 * @param uuidB - Array of ParcelUuidsB
 */
public static boolean containsAllUuids(ParcelUuid[] uuidA, ParcelUuid[] uuidB) {
    if (uuidA == null && uuidB == null) return true;

    if (uuidA == null) {
        return uuidB.length == 0;
    }

    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;
}
 
private ScanFilter(@Nullable final String name, @Nullable final String deviceAddress,
				   @Nullable final ParcelUuid uuid, @Nullable final ParcelUuid uuidMask,
				   @Nullable final ParcelUuid serviceDataUuid, @Nullable final byte[] serviceData,
				   @Nullable final byte[] serviceDataMask, final int manufacturerId,
				   @Nullable final byte[] manufacturerData,
				   @Nullable final byte[] manufacturerDataMask) {
	this.deviceName = name;
	this.serviceUuid = uuid;
	this.serviceUuidMask = uuidMask;
	this.deviceAddress = deviceAddress;
	this.serviceDataUuid = serviceDataUuid;
	this.serviceData = serviceData;
	this.serviceDataMask = serviceDataMask;
	this.manufacturerId = manufacturerId;
	this.manufacturerData = manufacturerData;
	this.manufacturerDataMask = manufacturerDataMask;
}
 
源代码16 项目: AndroidBleManager   文件: BluetoothUuidCompat.java
/**
 * Returns true if ParcelUuid is present in uuidArray
 *
 * @param uuidArray - Array of ParcelUuids
 * @param uuid
 */
public static boolean isUuidPresent(ParcelUuid[] uuidArray, ParcelUuid uuid) {
    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;
}
 
源代码17 项目: xDrip   文件: ScanRecordImplCompatLocal.java
/**
 * Returns the service data byte array associated with the {@code serviceUuid}. Returns
 * {@code null} if the {@code serviceDataUuid} is not found.
 */
@Nullable
public byte[] getServiceData(ParcelUuid serviceDataUuid) {
    if (serviceDataUuid == null) {
        return null;
    }
    return serviceData.get(serviceDataUuid);
}
 
源代码18 项目: bluetooth   文件: AdvertiseFragment.java
/**
 * start advertise
 * setup the power levels, the UUID, and the data
 * which is used the callback then call start advertising.
 */
private void start_advertise() {

    //define the power settings  could use ADVERTISE_MODE_LOW_POWER, ADVERTISE_MODE_BALANCED too.
    AdvertiseSettings settings = new AdvertiseSettings.Builder()
        .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY)
        .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH)
        .setConnectable(false)
        .build();
    //get the UUID needed.
    ParcelUuid pUuid = new ParcelUuid(UUID.fromString(getString(R.string.blue_uuid)));
    //build
    AdvertiseData data = new AdvertiseData.Builder()
        .setIncludeDeviceName(false)  //should be true, but we are bigger then 31bytes in the name?
        .addServiceUuid(pUuid)
        //this is where the text is added.
        .addServiceData(pUuid, text.getText().toString().getBytes(Charset.forName("UTF-8")))
        .build();
    advertisingCallback = new AdvertiseCallback() {
        @Override
        public void onStartSuccess(AdvertiseSettings settingsInEffect) {
            logthis("Advertising has started");
            logthis("message is " + text.getText().toString());
            advertising = true;
            advertise.setText("Stop Advertising");
            super.onStartSuccess(settingsInEffect);
        }

        @Override
        public void onStartFailure(int errorCode) {
            logthis("Advertising onStartFailure: " + errorCode);
            advertising = false;
            advertise.setText("Start Advertising");
            super.onStartFailure(errorCode);
        }
    };

    advertiser.startAdvertising(settings, data, advertisingCallback);

}
 
源代码19 项目: 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();
}
 
@SuppressWarnings("unused")
public static boolean isUartAdvertised(@NonNull BlePeripheral blePeripheral) {
    List<ParcelUuid> serviceUuids = blePeripheral.getScanRecord().getServiceUuids();
    boolean found = false;

    if (serviceUuids != null) {
        int i = 0;
        while (i < serviceUuids.size() && !found) {
            found = serviceUuids.get(i).getUuid().equals(kUartServiceUUID);
            i++;
        }
    }
    return found;
}
 
源代码21 项目: bitgatt   文件: BondTransactionTests.java
@Before
public void before() {
    this.mockContext = InstrumentationRegistry.getInstrumentation().getContext();
    services = new ArrayList<>();
    services.add(new ParcelUuid(UUID.fromString("adabfb00-6e7d-4601-bda2-bffaa68956ba")));
    CountDownLatch cd = new CountDownLatch(1);
    NoOpGattCallback cb = new NoOpGattCallback() {

        @Override
        public void onGattClientStarted() {
            FitbitBluetoothDevice device = new FitbitBluetoothDevice(MOCK_ADDRESS, "Stupid");
            conn = new GattConnection(device, mockContext.getMainLooper());
            conn.setMockMode(true);
            conn.setState(GattState.CONNECTED);
            // idempotent, can't put the same connection into the map more than once
            FitbitGatt.getInstance().putConnectionIntoDevices(device, conn);
            cd.countDown();
        }


    };
    FitbitGatt.getInstance().registerGattEventListener(cb);

    FitbitGatt.getInstance().startGattClient(mockContext);
    FitbitGatt.getInstance().setScanServiceUuidFilters(services);
    FitbitGatt.getInstance().initializeScanner(mockContext);
    try {
        cd.await(1, TimeUnit.SECONDS);
    } catch (InterruptedException e) {
        fail("Timeout during test setup");
    }
}
 
/**
 * Start scanning for Bluetooth devices.
 *
 * @param filterUuid UUID to filter scan results with
 */
public void startScan(final UUID filterUuid) {
    mFilterUuid = filterUuid;

    if (mScannerStateLiveData.isScanning()) {
        return;
    }

    if (mFilterUuid.equals(BleMeshManager.MESH_PROXY_UUID)) {
        final MeshNetwork network = mMeshManagerApi.getMeshNetwork();
        if (network != null) {
            if (!network.getNetKeys().isEmpty()) {
                mNetworkId = mMeshManagerApi.generateNetworkId(network.getNetKeys().get(0).getKey());
            }
        }
    }

    mScannerStateLiveData.scanningStarted();
    //Scanning settings
    final ScanSettings settings = new ScanSettings.Builder()
            .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
            // Refresh the devices list every second
            .setReportDelay(0)
            // Hardware filtering has some issues on selected devices
            .setUseHardwareFilteringIfSupported(false)
            // Samsung S6 and S6 Edge report equal value of RSSI for all devices. In this app we ignore the RSSI.
            /*.setUseHardwareBatchingIfSupported(false)*/
            .build();

    //Let's use the filter to scan only for unprovisioned mesh nodes.
    final List<ScanFilter> filters = new ArrayList<>();
    filters.add(new ScanFilter.Builder().setServiceUuid(new ParcelUuid((filterUuid))).build());

    final BluetoothLeScannerCompat scanner = BluetoothLeScannerCompat.getScanner();
    scanner.startScan(filters, settings, mScanCallbacks);
}
 
源代码23 项目: bitgatt   文件: FitbitGattTest.java
@Test
public void setScanServiceUuidFilters() {
    List<ParcelUuid> filters = new ArrayList<>();

    fitbitGatt.setPeripheralScanner(scannerMock);
    fitbitGatt.setScanServiceUuidFilters(filters);

    verify(scannerMock).setServiceUuidFilters(filters);
    verifyNoMoreInteractions(scannerMock);
}
 
源代码24 项目: AndroidBleManager   文件: ScanFilterCompat.java
/**
 * Set filter on partial service uuid. The {@code uuidMask} is the bit mask for the
 * {@code serviceUuid}. Set any bit in the mask to 1 to indicate a match is needed for the
 * bit in {@code serviceUuid}, and 0 to ignore that bit.
 *
 * @throws IllegalArgumentException If {@code serviceUuid} is {@code null} but
 *                                  {@code uuidMask} is not {@code null}.
 */
public Builder setServiceUuid(ParcelUuid serviceUuid, ParcelUuid uuidMask) {
    if (mUuidMask != null && mServiceUuid == null) {
        throw new IllegalArgumentException("uuid is null while uuidMask is not null!");
    }
    mServiceUuid = serviceUuid;
    mUuidMask = uuidMask;
    return this;
}
 
源代码25 项目: xDrip-plus   文件: ScanRecordImplCompatLocal.java
/**
 * Returns the service data byte array associated with the {@code serviceUuid}. Returns
 * {@code null} if the {@code serviceDataUuid} is not found.
 */
@Nullable
public byte[] getServiceData(ParcelUuid serviceDataUuid) {
    if (serviceDataUuid == null) {
        return null;
    }
    return serviceData.get(serviceDataUuid);
}
 
源代码26 项目: 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);
}
 
源代码27 项目: 365browser   文件: WebContentsImpl.java
@Override
public WebContents createFromParcel(Parcel source) {
    Bundle bundle = source.readBundle();

    // Check the version.
    if (bundle.getLong(PARCEL_VERSION_KEY, -1) != 0) return null;

    // Check that we're in the same process.
    ParcelUuid parcelUuid = bundle.getParcelable(PARCEL_PROCESS_GUARD_KEY);
    if (sParcelableUUID.compareTo(parcelUuid.getUuid()) != 0) return null;

    // Attempt to retrieve the WebContents object from the native pointer.
    return nativeFromNativePtr(bundle.getLong(PARCEL_WEBCONTENTS_KEY));
}
 
源代码28 项目: android-beacon-library   文件: ScanFilterUtils.java
public List<ScanFilter> createScanFiltersForBeaconParsers(List<BeaconParser> beaconParsers) {
    List<ScanFilter> scanFilters = new ArrayList<ScanFilter>();
    // for each beacon parser, make a filter expression that includes all its desired
    // hardware manufacturers
    for (BeaconParser beaconParser: beaconParsers) {
        List<ScanFilterData> sfds = createScanFilterDataForBeaconParser(beaconParser);
        for (ScanFilterData sfd: sfds) {
            ScanFilter.Builder builder = new ScanFilter.Builder();
            if (sfd.serviceUuid != null) {
                // Use a 16 bit service UUID in a 128 bit form
                String serviceUuidString = String.format("0000%04X-0000-1000-8000-00805f9b34fb", sfd.serviceUuid);
                String serviceUuidMaskString = "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF";
                ParcelUuid parcelUuid = ParcelUuid.fromString(serviceUuidString);
                ParcelUuid parcelUuidMask = ParcelUuid.fromString(serviceUuidMaskString);
                if (LogManager.isVerboseLoggingEnabled()) {
                    LogManager.d(TAG, "making scan filter for service: "+serviceUuidString+" "+parcelUuid);
                    LogManager.d(TAG, "making scan filter with service mask: "+serviceUuidMaskString+" "+parcelUuidMask);
                }
                builder.setServiceUuid(parcelUuid, parcelUuidMask);
            }
            else {
                builder.setServiceUuid(null);
                builder.setManufacturerData((int) sfd.manufacturer, sfd.filter, sfd.mask);
            }
            ScanFilter scanFilter = builder.build();
            if (LogManager.isVerboseLoggingEnabled()) {
                LogManager.d(TAG, "Set up a scan filter: "+scanFilter);
            }
            scanFilters.add(scanFilter);
        }
    }
    return scanFilters;
}
 
源代码29 项目: DeviceConnect-Android   文件: AbstractHOGPServer.java
/**
 * アドバタイジングを開始します.
 */
private void startAdvertising() {
    if (DEBUG) {
        Log.d(TAG, "startAdvertising");
    }

    mHandler.post(new Runnable() {
        @Override
        public void run() {
            // set up advertising setting
            final AdvertiseSettings advertiseSettings = new AdvertiseSettings.Builder()
                    .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH)
                    .setConnectable(true)
                    .setTimeout(0)
                    .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY)
                    .build();

            // set up advertising data
            final AdvertiseData advertiseData = new AdvertiseData.Builder()
                    .setIncludeTxPowerLevel(false)
                    .setIncludeDeviceName(true)
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_DEVICE_INFORMATION.toString()))
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_BLE_HID.toString()))
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_BATTERY.toString()))
                    .build();

            // set up scan result
            final AdvertiseData scanResult = new AdvertiseData.Builder()
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_DEVICE_INFORMATION.toString()))
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_BLE_HID.toString()))
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_BATTERY.toString()))
                    .build();

            mBluetoothLeAdvertiser.startAdvertising(advertiseSettings, advertiseData, scanResult, mAdvertiseCallback);
        }
    });
}
 
源代码30 项目: RxAndroidBle   文件: ScanFilter.java
ScanFilter(String name, String deviceAddress, ParcelUuid uuid,
           ParcelUuid uuidMask, ParcelUuid serviceDataUuid,
           byte[] serviceData, byte[] serviceDataMask,
           int manufacturerId, byte[] manufacturerData, byte[] manufacturerDataMask) {
    mDeviceName = name;
    mServiceUuid = uuid;
    mServiceUuidMask = uuidMask;
    mDeviceAddress = deviceAddress;
    mServiceDataUuid = serviceDataUuid;
    mServiceData = serviceData;
    mServiceDataMask = serviceDataMask;
    mManufacturerId = manufacturerId;
    mManufacturerData = manufacturerData;
    mManufacturerDataMask = manufacturerDataMask;
}
 
 类所在包
 同包方法