use of android.bluetooth.BluetoothClass in project platform_frameworks_base by android.
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 XobotOS by xamarin.
the class BluetoothEventLoop method addDevice.
private void addDevice(String address, String[] properties) {
BluetoothDeviceProperties deviceProperties = mBluetoothService.getDeviceProperties();
deviceProperties.addProperties(address, properties);
String rssi = deviceProperties.getProperty(address, "RSSI");
String classValue = deviceProperties.getProperty(address, "Class");
String name = deviceProperties.getProperty(address, "Name");
short rssiValue;
// If we accept the pairing, we will automatically show it at the top of the list.
if (rssi != null) {
rssiValue = (short) Integer.valueOf(rssi).intValue();
} else {
rssiValue = Short.MIN_VALUE;
}
if (classValue != null) {
Intent intent = new Intent(BluetoothDevice.ACTION_FOUND);
intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address));
intent.putExtra(BluetoothDevice.EXTRA_CLASS, new BluetoothClass(Integer.valueOf(classValue)));
intent.putExtra(BluetoothDevice.EXTRA_RSSI, rssiValue);
intent.putExtra(BluetoothDevice.EXTRA_NAME, name);
mContext.sendBroadcast(intent, BLUETOOTH_PERM);
} else {
log("ClassValue: " + classValue + " for remote device: " + address + " is null");
}
}
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 android_frameworks_base by AOSPA.
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);
/* When one BT headset is disconnected while there is SCO with another BT
* headset, ignore the BT headset disconncting/disconnected intents.
*/
if ((state == BluetoothProfile.STATE_DISCONNECTED || state == BluetoothProfile.STATE_DISCONNECTING) && mBluetoothHeadset != null && mBluetoothHeadset.getAudioState(btDevice) == BluetoothHeadset.STATE_AUDIO_CONNECTED) {
Log.w(TAG, "SCO is there with another device, returning");
return;
}
if (success) {
synchronized (mScoClients) {
if (connected) {
mBluetoothHeadsetDevice = btDevice;
} else {
mBluetoothHeadsetDevice = null;
resetBluetoothSco();
}
}
}
}
use of android.bluetooth.BluetoothClass in project android_frameworks_base by ResurrectionRemix.
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);
/* When one BT headset is disconnected while there is SCO with another BT
* headset, ignore the BT headset disconncting/disconnected intents.
*/
if ((state == BluetoothProfile.STATE_DISCONNECTED || state == BluetoothProfile.STATE_DISCONNECTING) && mBluetoothHeadset != null && mBluetoothHeadset.getAudioState(btDevice) == BluetoothHeadset.STATE_AUDIO_CONNECTED) {
Log.w(TAG, "SCO is there with another device, returning");
return;
}
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) {
launchMusicPlayer();
}
break;
case 3:
case 5:
//launch the player for all bt headsets
launchMusicPlayer();
break;
}
} else {
mBluetoothHeadsetDevice = null;
resetBluetoothSco();
}
}
}
}
Aggregations