use of android.bluetooth.BluetoothDevice in project android_frameworks_base by DirtyUnicorns.
the class ScanFilterTest method setUp.
@Override
protected void setUp() throws Exception {
byte[] scanRecord = new byte[] { // advertising flags
0x02, // advertising flags
0x01, // advertising flags
0x1a, // 16 bit service uuids
0x05, // 16 bit service uuids
0x02, // 16 bit service uuids
0x0b, // 16 bit service uuids
0x11, // 16 bit service uuids
0x0a, // 16 bit service uuids
0x11, // setName
0x04, // setName
0x09, // setName
0x50, // setName
0x65, // setName
0x64, // tx power level
0x02, // tx power level
0x0A, // tx power level
(byte) 0xec, // service data
0x05, // service data
0x16, // service data
0x0b, // service data
0x11, // service data
0x50, // service data
0x64, // manufacturer specific data
0x05, // manufacturer specific data
(byte) 0xff, // manufacturer specific data
(byte) 0xe0, // manufacturer specific data
0x00, // manufacturer specific data
0x02, // manufacturer specific data
0x15, // an unknown data type won't cause trouble
0x03, // an unknown data type won't cause trouble
0x50, // an unknown data type won't cause trouble
0x01, // an unknown data type won't cause trouble
0x02 };
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
BluetoothDevice device = adapter.getRemoteDevice(DEVICE_MAC);
mScanResult = new ScanResult(device, ScanRecord.parseFromBytes(scanRecord), -10, 1397545200000000L);
mFilterBuilder = new ScanFilter.Builder();
}
use of android.bluetooth.BluetoothDevice in project android_frameworks_base by DirtyUnicorns.
the class MidiService method openBluetoothDevice.
@Override
public void openBluetoothDevice(IBinder token, BluetoothDevice bluetoothDevice, IMidiDeviceOpenCallback callback) {
Client client = getClient(token);
if (client == null)
return;
// Bluetooth devices are created on demand
Device device;
synchronized (mDevicesByInfo) {
device = mBluetoothDevices.get(bluetoothDevice);
if (device == null) {
device = new Device(bluetoothDevice);
mBluetoothDevices.put(bluetoothDevice, device);
}
}
// clear calling identity so bindService does not fail
long identity = Binder.clearCallingIdentity();
try {
client.addDeviceConnection(device, callback);
} finally {
Binder.restoreCallingIdentity(identity);
}
}
use of android.bluetooth.BluetoothDevice in project android_frameworks_base by DirtyUnicorns.
the class PbapClientProfile method connect.
public boolean connect(BluetoothDevice device) {
if (V) {
Log.d(TAG, "PBAPClientProfile got connect request");
}
if (mService == null) {
return false;
}
List<BluetoothDevice> srcs = getConnectedDevices();
if (srcs != null) {
for (BluetoothDevice src : srcs) {
if (src.equals(device)) {
// Connect to same device, Ignore it
Log.d(TAG, "Ignoring Connect");
return true;
}
}
for (BluetoothDevice src : srcs) {
mService.disconnect(device);
}
}
Log.d(TAG, "PBAPClientProfile attempting to connect to " + device.getAddress());
return mService.connect(device);
}
use of android.bluetooth.BluetoothDevice in project android_frameworks_base by crdroidandroid.
the class MidiService method openBluetoothDevice.
@Override
public void openBluetoothDevice(IBinder token, BluetoothDevice bluetoothDevice, IMidiDeviceOpenCallback callback) {
Client client = getClient(token);
if (client == null)
return;
// Bluetooth devices are created on demand
Device device;
synchronized (mDevicesByInfo) {
device = mBluetoothDevices.get(bluetoothDevice);
if (device == null) {
device = new Device(bluetoothDevice);
mBluetoothDevices.put(bluetoothDevice, device);
}
}
// clear calling identity so bindService does not fail
long identity = Binder.clearCallingIdentity();
try {
client.addDeviceConnection(device, callback);
} finally {
Binder.restoreCallingIdentity(identity);
}
}
use of android.bluetooth.BluetoothDevice in project android_frameworks_base by crdroidandroid.
the class ScanResultTest method testScanResultParceling.
/**
* Test read and write parcel of ScanResult
*/
@SmallTest
public void testScanResultParceling() {
BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice("01:02:03:04:05:06");
byte[] scanRecord = new byte[] { 1, 2, 3 };
int rssi = -10;
long timestampMicros = 10000L;
ScanResult result = new ScanResult(device, ScanRecord.parseFromBytes(scanRecord), rssi, timestampMicros);
Parcel parcel = Parcel.obtain();
result.writeToParcel(parcel, 0);
// Need to reset parcel data position to the beginning.
parcel.setDataPosition(0);
ScanResult resultFromParcel = ScanResult.CREATOR.createFromParcel(parcel);
assertEquals(result, resultFromParcel);
}
Aggregations