use of android.bluetooth.BluetoothClass in project android_frameworks_base by crdroidandroid.
the class CachedBluetoothDevice method updateProfiles.
private boolean updateProfiles() {
ParcelUuid[] uuids = mDevice.getUuids();
if (uuids == null)
return false;
ParcelUuid[] localUuids = mLocalAdapter.getUuids();
if (localUuids == null)
return false;
/**
* Now we know if the device supports PBAP, update permissions...
*/
processPhonebookAccess();
mProfileManager.updateProfiles(uuids, localUuids, mProfiles, mRemovedProfiles, mLocalNapRoleConnected, mDevice);
if (DEBUG) {
Log.e(TAG, "updating profiles for " + mDevice.getAliasName());
BluetoothClass bluetoothClass = mDevice.getBluetoothClass();
if (bluetoothClass != null)
Log.v(TAG, "Class: " + bluetoothClass.toString());
Log.v(TAG, "UUID:");
for (ParcelUuid uuid : uuids) {
Log.v(TAG, " " + uuid);
}
}
return true;
}
use of android.bluetooth.BluetoothClass in project android_frameworks_base by AOSPA.
the class CachedBluetoothDevice method updateProfiles.
private boolean updateProfiles() {
ParcelUuid[] uuids = mDevice.getUuids();
if (uuids == null)
return false;
ParcelUuid[] localUuids = mLocalAdapter.getUuids();
if (localUuids == null)
return false;
/**
* Now we know if the device supports PBAP, update permissions...
*/
processPhonebookAccess();
mProfileManager.updateProfiles(uuids, localUuids, mProfiles, mRemovedProfiles, mLocalNapRoleConnected, mDevice);
if (DEBUG) {
Log.e(TAG, "updating profiles for " + mDevice.getAliasName());
BluetoothClass bluetoothClass = mDevice.getBluetoothClass();
if (bluetoothClass != null)
Log.v(TAG, "Class: " + bluetoothClass.toString());
Log.v(TAG, "UUID:");
for (ParcelUuid uuid : uuids) {
Log.v(TAG, " " + uuid);
}
}
return true;
}
use of android.bluetooth.BluetoothClass in project platform_frameworks_base by android.
the class AudioService method setBtScoDeviceConnectionState.
void setBtScoDeviceConnectionState(BluetoothDevice btDevice, int state) {
if (btDevice == null) {
return;
}
String address = btDevice.getAddress();
BluetoothClass btClass = btDevice.getBluetoothClass();
int outDevice = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO;
int inDevice = AudioSystem.DEVICE_IN_BLUETOOTH_SCO_HEADSET;
if (btClass != null) {
switch(btClass.getDeviceClass()) {
case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET:
case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE:
outDevice = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_HEADSET;
break;
case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO:
outDevice = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_CARKIT;
break;
}
}
if (!BluetoothAdapter.checkBluetoothAddress(address)) {
address = "";
}
boolean connected = (state == BluetoothProfile.STATE_CONNECTED);
String btDeviceName = btDevice.getName();
boolean success = handleDeviceConnection(connected, outDevice, address, btDeviceName) && handleDeviceConnection(connected, inDevice, address, btDeviceName);
if (!success) {
return;
}
/* When one BT headset is disconnected while another BT headset
* is connected, don't mess with the headset device.
*/
if ((state == BluetoothProfile.STATE_DISCONNECTED || state == BluetoothProfile.STATE_DISCONNECTING) && mBluetoothHeadset != null && mBluetoothHeadset.getAudioState(btDevice) == BluetoothHeadset.STATE_AUDIO_CONNECTED) {
Log.w(TAG, "SCO connected through another device, returning");
return;
}
synchronized (mScoClients) {
if (connected) {
mBluetoothHeadsetDevice = btDevice;
} else {
mBluetoothHeadsetDevice = null;
resetBluetoothSco();
}
}
}
use of android.bluetooth.BluetoothClass in project android_frameworks_base by DirtyUnicorns.
the class AudioService method setBtScoDeviceConnectionState.
void setBtScoDeviceConnectionState(BluetoothDevice btDevice, int state) {
if (btDevice == null) {
return;
}
String address = btDevice.getAddress();
BluetoothClass btClass = btDevice.getBluetoothClass();
int outDevice = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO;
int inDevice = AudioSystem.DEVICE_IN_BLUETOOTH_SCO_HEADSET;
if (btClass != null) {
switch(btClass.getDeviceClass()) {
case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET:
case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE:
outDevice = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_HEADSET;
break;
case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO:
outDevice = AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_CARKIT;
break;
}
}
if (!BluetoothAdapter.checkBluetoothAddress(address)) {
address = "";
}
boolean connected = (state == BluetoothProfile.STATE_CONNECTED);
String btDeviceName = btDevice.getName();
boolean success = handleDeviceConnection(connected, outDevice, address, btDeviceName) && handleDeviceConnection(connected, inDevice, address, btDeviceName);
if (success) {
synchronized (mScoClients) {
if (connected) {
mBluetoothHeadsetDevice = btDevice;
switch(mLaunchPlayer) {
case 0:
case 1:
//do nothing
break;
case 2:
case 4:
//launch the player if bt headset is not a carkit
if (outDevice != AudioSystem.DEVICE_OUT_BLUETOOTH_SCO_CARKIT) {
startMusicPlayer();
}
break;
case 3:
case 5:
//launch the player for all bt headsets
startMusicPlayer();
break;
}
} else {
mBluetoothHeadsetDevice = null;
resetBluetoothSco();
}
}
}
}
use of android.bluetooth.BluetoothClass in project XobotOS by xamarin.
the class BluetoothEventLoop method onDevicePropertyChanged.
/**
* Called by native code on a PropertyChanged signal from
* org.bluez.Device.
*
* @param deviceObjectPath the object path for the changed device
* @param propValues a string array containing the key and one or more
* values.
*/
private void onDevicePropertyChanged(String deviceObjectPath, String[] propValues) {
String name = propValues[0];
String address = mBluetoothService.getAddressFromObjectPath(deviceObjectPath);
if (address == null) {
Log.e(TAG, "onDevicePropertyChanged: Address of the remote device in null");
return;
}
log("Device property changed: " + address + " property: " + name + " value: " + propValues[1]);
BluetoothDevice device = mAdapter.getRemoteDevice(address);
if (name.equals("Name")) {
mBluetoothService.setRemoteDeviceProperty(address, name, propValues[1]);
Intent intent = new Intent(BluetoothDevice.ACTION_NAME_CHANGED);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
intent.putExtra(BluetoothDevice.EXTRA_NAME, propValues[1]);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
mContext.sendBroadcast(intent, BLUETOOTH_PERM);
} else if (name.equals("Alias")) {
mBluetoothService.setRemoteDeviceProperty(address, name, propValues[1]);
} else if (name.equals("Class")) {
mBluetoothService.setRemoteDeviceProperty(address, name, propValues[1]);
Intent intent = new Intent(BluetoothDevice.ACTION_CLASS_CHANGED);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
intent.putExtra(BluetoothDevice.EXTRA_CLASS, new BluetoothClass(Integer.valueOf(propValues[1])));
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
mContext.sendBroadcast(intent, BLUETOOTH_PERM);
} else if (name.equals("Connected")) {
mBluetoothService.setRemoteDeviceProperty(address, name, propValues[1]);
Intent intent = null;
if (propValues[1].equals("true")) {
intent = new Intent(BluetoothDevice.ACTION_ACL_CONNECTED);
// for bluetooth docks.
if (mBluetoothService.isBluetoothDock(address)) {
mBluetoothService.setLinkTimeout(address, 8000);
}
} else {
intent = new Intent(BluetoothDevice.ACTION_ACL_DISCONNECTED);
}
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
mContext.sendBroadcast(intent, BLUETOOTH_PERM);
} else if (name.equals("UUIDs")) {
String uuid = null;
int len = Integer.valueOf(propValues[1]);
if (len > 0) {
StringBuilder str = new StringBuilder();
for (int i = 2; i < propValues.length; i++) {
str.append(propValues[i]);
str.append(",");
}
uuid = str.toString();
}
mBluetoothService.setRemoteDeviceProperty(address, name, uuid);
// UUIDs have changed, query remote service channel and update cache.
mBluetoothService.updateDeviceServiceChannelCache(address);
mBluetoothService.sendUuidIntent(address);
} else if (name.equals("Paired")) {
if (propValues[1].equals("true")) {
// successful return value in onCreatePairedDeviceResult
if (null == mBluetoothService.getPendingOutgoingBonding()) {
mBluetoothService.setBondState(address, BluetoothDevice.BOND_BONDED);
}
} else {
mBluetoothService.setBondState(address, BluetoothDevice.BOND_NONE);
mBluetoothService.setRemoteDeviceProperty(address, "Trusted", "false");
}
} else if (name.equals("Trusted")) {
if (DBG)
log("set trust state succeeded, value is: " + propValues[1]);
mBluetoothService.setRemoteDeviceProperty(address, name, propValues[1]);
}
}
Aggregations