le_audio: Extend handling of Broadcaster as active device
Patch extends handling Broadcaster as active Bluetooth device. Broadcast device. Bug: 150670922 Tag: #feature Sponsor: jpawlowski@ Change-Id: Ic41c619411f1784bf586aa48ad0fa4a39a37ecb7
This commit is contained in:
committed by
Łukasz Rymanowski
parent
59afd5ccf7
commit
7c1bf84c37
@@ -370,6 +370,7 @@ public class AudioDeviceInventory {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BluetoothProfile.LE_AUDIO:
|
case BluetoothProfile.LE_AUDIO:
|
||||||
|
case BluetoothProfile.LE_AUDIO_BROADCAST:
|
||||||
if (switchToUnavailable) {
|
if (switchToUnavailable) {
|
||||||
makeLeAudioDeviceUnavailable(address, btInfo.mAudioSystemDevice);
|
makeLeAudioDeviceUnavailable(address, btInfo.mAudioSystemDevice);
|
||||||
} else if (switchToAvailable) {
|
} else if (switchToAvailable) {
|
||||||
@@ -847,7 +848,10 @@ public class AudioDeviceInventory {
|
|||||||
disconnectHearingAid();
|
disconnectHearingAid();
|
||||||
break;
|
break;
|
||||||
case BluetoothProfile.LE_AUDIO:
|
case BluetoothProfile.LE_AUDIO:
|
||||||
disconnectLeAudio();
|
disconnectLeAudioUnicast();
|
||||||
|
break;
|
||||||
|
case BluetoothProfile.LE_AUDIO_BROADCAST:
|
||||||
|
disconnectLeAudioBroadcast();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Not a valid profile to disconnect
|
// Not a valid profile to disconnect
|
||||||
@@ -857,28 +861,39 @@ public class AudioDeviceInventory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*package*/ void disconnectLeAudio() {
|
/*package*/ void disconnectLeAudio(int device) {
|
||||||
|
if (device != AudioSystem.DEVICE_OUT_BLE_HEADSET ||
|
||||||
|
device != AudioSystem.DEVICE_OUT_BLE_BROADCAST) {
|
||||||
|
Log.e(TAG, "disconnectLeAudio: Can't disconnect not LE Audio device " + device);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
synchronized (mDevicesLock) {
|
synchronized (mDevicesLock) {
|
||||||
final ArraySet<String> toRemove = new ArraySet<>();
|
final ArraySet<String> toRemove = new ArraySet<>();
|
||||||
// Disconnect ALL DEVICE_OUT_BLE_HEADSET devices
|
// Disconnect ALL DEVICE_OUT_BLE_HEADSET or DEVICE_OUT_BLE_BROADCAST devices
|
||||||
mConnectedDevices.values().forEach(deviceInfo -> {
|
mConnectedDevices.values().forEach(deviceInfo -> {
|
||||||
if (deviceInfo.mDeviceType == AudioSystem.DEVICE_OUT_BLE_HEADSET) {
|
if (deviceInfo.mDeviceType == device) {
|
||||||
toRemove.add(deviceInfo.mDeviceAddress);
|
toRemove.add(deviceInfo.mDeviceAddress);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
new MediaMetrics.Item(mMetricsId + "disconnectLeAudio")
|
new MediaMetrics.Item(mMetricsId + "disconnectLeAudio")
|
||||||
.record();
|
.record();
|
||||||
if (toRemove.size() > 0) {
|
if (toRemove.size() > 0) {
|
||||||
final int delay = checkSendBecomingNoisyIntentInt(
|
|
||||||
AudioSystem.DEVICE_OUT_BLE_HEADSET, 0, AudioSystem.DEVICE_NONE);
|
|
||||||
toRemove.stream().forEach(deviceAddress ->
|
toRemove.stream().forEach(deviceAddress ->
|
||||||
makeLeAudioDeviceUnavailable(deviceAddress,
|
makeLeAudioDeviceUnavailable(deviceAddress, device)
|
||||||
AudioSystem.DEVICE_OUT_BLE_HEADSET)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*package*/ void disconnectLeAudioUnicast() {
|
||||||
|
disconnectLeAudio(AudioSystem.DEVICE_OUT_BLE_HEADSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*package*/ void disconnectLeAudioBroadcast() {
|
||||||
|
disconnectLeAudio(AudioSystem.DEVICE_OUT_BLE_BROADCAST);
|
||||||
|
}
|
||||||
|
|
||||||
// must be called before removing the device from mConnectedDevices
|
// must be called before removing the device from mConnectedDevices
|
||||||
// musicDevice argument is used when not AudioSystem.DEVICE_NONE instead of querying
|
// musicDevice argument is used when not AudioSystem.DEVICE_NONE instead of querying
|
||||||
// from AudioSystem
|
// from AudioSystem
|
||||||
@@ -908,7 +923,9 @@ public class AudioDeviceInventory {
|
|||||||
int delay;
|
int delay;
|
||||||
synchronized (mDevicesLock) {
|
synchronized (mDevicesLock) {
|
||||||
if (!info.mSupprNoisy
|
if (!info.mSupprNoisy
|
||||||
&& ((info.mProfile == BluetoothProfile.LE_AUDIO && info.mIsLeOutput)
|
&& (((info.mProfile == BluetoothProfile.LE_AUDIO
|
||||||
|
|| info.mProfile == BluetoothProfile.LE_AUDIO_BROADCAST)
|
||||||
|
&& info.mIsLeOutput)
|
||||||
|| info.mProfile == BluetoothProfile.HEARING_AID
|
|| info.mProfile == BluetoothProfile.HEARING_AID
|
||||||
|| info.mProfile == BluetoothProfile.A2DP)) {
|
|| info.mProfile == BluetoothProfile.A2DP)) {
|
||||||
@AudioService.ConnectionState int asState =
|
@AudioService.ConnectionState int asState =
|
||||||
@@ -1162,8 +1179,7 @@ public class AudioDeviceInventory {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int leAudioVolIndex = mDeviceBroker.getVssVolumeForDevice(streamType,
|
final int leAudioVolIndex = mDeviceBroker.getVssVolumeForDevice(streamType, device);
|
||||||
AudioSystem.DEVICE_OUT_BLE_HEADSET);
|
|
||||||
final int maxIndex = mDeviceBroker.getMaxVssVolumeForStream(streamType);
|
final int maxIndex = mDeviceBroker.getMaxVssVolumeForStream(streamType);
|
||||||
mDeviceBroker.postSetLeAudioVolumeIndex(leAudioVolIndex, maxIndex, streamType);
|
mDeviceBroker.postSetLeAudioVolumeIndex(leAudioVolIndex, maxIndex, streamType);
|
||||||
mDeviceBroker.postApplyVolumeOnDevice(streamType, device, "makeLeAudioDeviceAvailable");
|
mDeviceBroker.postApplyVolumeOnDevice(streamType, device, "makeLeAudioDeviceAvailable");
|
||||||
@@ -1215,6 +1231,7 @@ public class AudioDeviceInventory {
|
|||||||
BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_LINE);
|
BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_LINE);
|
||||||
BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_HEARING_AID);
|
BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_HEARING_AID);
|
||||||
BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_BLE_HEADSET);
|
BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_BLE_HEADSET);
|
||||||
|
BECOMING_NOISY_INTENT_DEVICES_SET.add(AudioSystem.DEVICE_OUT_BLE_BROADCAST);
|
||||||
BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_A2DP_SET);
|
BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_A2DP_SET);
|
||||||
BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_USB_SET);
|
BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_USB_SET);
|
||||||
BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_BLE_SET);
|
BECOMING_NOISY_INTENT_DEVICES_SET.addAll(AudioSystem.DEVICE_OUT_ALL_BLE_SET);
|
||||||
|
|||||||
@@ -3228,7 +3228,8 @@ public class AudioService extends IAudioService.Stub
|
|||||||
dispatchAbsoluteVolumeChanged(streamType, info, newIndex);
|
dispatchAbsoluteVolumeChanged(streamType, info, newIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device == AudioSystem.DEVICE_OUT_BLE_HEADSET
|
if ((device == AudioSystem.DEVICE_OUT_BLE_HEADSET
|
||||||
|
|| device == AudioSystem.DEVICE_OUT_BLE_BROADCAST)
|
||||||
&& streamType == getBluetoothContextualVolumeStream()
|
&& streamType == getBluetoothContextualVolumeStream()
|
||||||
&& (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) {
|
&& (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) {
|
||||||
if (DEBUG_VOL) {
|
if (DEBUG_VOL) {
|
||||||
@@ -3891,7 +3892,8 @@ public class AudioService extends IAudioService.Stub
|
|||||||
dispatchAbsoluteVolumeChanged(streamType, info, index);
|
dispatchAbsoluteVolumeChanged(streamType, info, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device == AudioSystem.DEVICE_OUT_BLE_HEADSET
|
if ((device == AudioSystem.DEVICE_OUT_BLE_HEADSET
|
||||||
|
|| device == AudioSystem.DEVICE_OUT_BLE_BROADCAST)
|
||||||
&& streamType == getBluetoothContextualVolumeStream()
|
&& streamType == getBluetoothContextualVolumeStream()
|
||||||
&& (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) {
|
&& (flags & AudioManager.FLAG_BLUETOOTH_ABS_VOLUME) == 0) {
|
||||||
if (DEBUG_VOL) {
|
if (DEBUG_VOL) {
|
||||||
@@ -6832,6 +6834,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
BluetoothProfile.A2DP,
|
BluetoothProfile.A2DP,
|
||||||
BluetoothProfile.A2DP_SINK,
|
BluetoothProfile.A2DP_SINK,
|
||||||
BluetoothProfile.LE_AUDIO,
|
BluetoothProfile.LE_AUDIO,
|
||||||
|
BluetoothProfile.LE_AUDIO_BROADCAST,
|
||||||
})
|
})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
public @interface BtProfile {}
|
public @interface BtProfile {}
|
||||||
@@ -6853,6 +6856,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
final int profile = info.getProfile();
|
final int profile = info.getProfile();
|
||||||
if (profile != BluetoothProfile.A2DP && profile != BluetoothProfile.A2DP_SINK
|
if (profile != BluetoothProfile.A2DP && profile != BluetoothProfile.A2DP_SINK
|
||||||
&& profile != BluetoothProfile.LE_AUDIO
|
&& profile != BluetoothProfile.LE_AUDIO
|
||||||
|
&& profile != BluetoothProfile.LE_AUDIO_BROADCAST
|
||||||
&& profile != BluetoothProfile.HEARING_AID) {
|
&& profile != BluetoothProfile.HEARING_AID) {
|
||||||
throw new IllegalArgumentException("Illegal BluetoothProfile profile for device "
|
throw new IllegalArgumentException("Illegal BluetoothProfile profile for device "
|
||||||
+ previousDevice + " -> " + newDevice + ". Got: " + profile);
|
+ previousDevice + " -> " + newDevice + ". Got: " + profile);
|
||||||
|
|||||||
Reference in New Issue
Block a user