mDeviceBroker.setDeviceVolume(
streamState, AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP);
}
- makeA2dpDeviceAvailable(address, btDevice.getName(),
+ makeA2dpDeviceAvailable(address, BtHelper.getName(btDevice),
"onSetA2dpSinkConnectionState", a2dpCodec);
}
}
if (isConnected && state != BluetoothProfile.STATE_CONNECTED) {
makeHearingAidDeviceUnavailable(address);
} else if (!isConnected && state == BluetoothProfile.STATE_CONNECTED) {
- makeHearingAidDeviceAvailable(address, btDevice.getName(),
+ makeHearingAidDeviceAvailable(address, BtHelper.getName(btDevice),
"onSetHearingAidConnectionState");
}
}
}
}
if (AudioSystem.handleDeviceConfigChange(AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, address,
- btDevice.getName(), a2dpCodec) != AudioSystem.AUDIO_STATUS_OK) {
+ BtHelper.getName(btDevice), a2dpCodec) != AudioSystem.AUDIO_STATUS_OK) {
int musicDevice = mDeviceBroker.getDeviceForStream(AudioSystem.STREAM_MUSIC);
// force A2DP device disconnection in case of error so that AudioService state is
// consistent with audio policy manager state
}
// A2DP device exists, handle active device change
final String existingDevicekey = mConnectedDevices.keyAt(i);
- final String deviceName = device.getName();
mConnectedDevices.remove(existingDevicekey);
mConnectedDevices.put(deviceKey, new DeviceInfo(
- AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, deviceName,
+ AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, BtHelper.getName(device),
address, a2dpCodec));
mDeviceBroker.postA2dpActiveDeviceChange(
new BtHelper.BluetoothA2dpDeviceInfo(
}
}
+ /*package*/ @NonNull static String getName(@NonNull BluetoothDevice device) {
+ final String deviceName = device.getName();
+ if (deviceName == null) {
+ return "";
+ }
+ return deviceName;
+ }
+
//----------------------------------------------------------------------
// Interface for AudioDeviceBroker
if (!BluetoothAdapter.checkBluetoothAddress(address)) {
address = "";
}
- String btDeviceName = btDevice.getName();
+ String btDeviceName = getName(btDevice);
boolean result = false;
if (isActive) {
result |= mDeviceBroker.handleDeviceConnection(