Merge "AudioService: Add makeLeAudioDeviceUnavailableLater" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0525657da9
@@ -1263,6 +1263,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
sendILMsg(MSG_IL_BTA2DP_TIMEOUT, SENDMSG_QUEUE, a2dpCodec, address, delayMs);
|
sendILMsg(MSG_IL_BTA2DP_TIMEOUT, SENDMSG_QUEUE, a2dpCodec, address, delayMs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*package*/ void setLeAudioTimeout(String address, int device, int delayMs) {
|
||||||
|
sendILMsg(MSG_IL_BTLEAUDIO_TIMEOUT, SENDMSG_QUEUE, device, address, delayMs);
|
||||||
|
}
|
||||||
|
|
||||||
/*package*/ void setAvrcpAbsoluteVolumeSupported(boolean supported) {
|
/*package*/ void setAvrcpAbsoluteVolumeSupported(boolean supported) {
|
||||||
synchronized (mDeviceStateLock) {
|
synchronized (mDeviceStateLock) {
|
||||||
mBtHelper.setAvrcpAbsoluteVolumeSupported(supported);
|
mBtHelper.setAvrcpAbsoluteVolumeSupported(supported);
|
||||||
@@ -1467,6 +1471,13 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
mDeviceInventory.onMakeA2dpDeviceUnavailableNow((String) msg.obj, msg.arg1);
|
mDeviceInventory.onMakeA2dpDeviceUnavailableNow((String) msg.obj, msg.arg1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case MSG_IL_BTLEAUDIO_TIMEOUT:
|
||||||
|
// msg.obj == address of LE Audio device
|
||||||
|
synchronized (mDeviceStateLock) {
|
||||||
|
mDeviceInventory.onMakeLeAudioDeviceUnavailableNow(
|
||||||
|
(String) msg.obj, msg.arg1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case MSG_L_A2DP_DEVICE_CONFIG_CHANGE:
|
case MSG_L_A2DP_DEVICE_CONFIG_CHANGE:
|
||||||
final BluetoothDevice btDevice = (BluetoothDevice) msg.obj;
|
final BluetoothDevice btDevice = (BluetoothDevice) msg.obj;
|
||||||
synchronized (mDeviceStateLock) {
|
synchronized (mDeviceStateLock) {
|
||||||
@@ -1703,12 +1714,14 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
|
|
||||||
private static final int MSG_IL_SAVE_NDEF_DEVICE_FOR_STRATEGY = 47;
|
private static final int MSG_IL_SAVE_NDEF_DEVICE_FOR_STRATEGY = 47;
|
||||||
private static final int MSG_IL_SAVE_REMOVE_NDEF_DEVICE_FOR_STRATEGY = 48;
|
private static final int MSG_IL_SAVE_REMOVE_NDEF_DEVICE_FOR_STRATEGY = 48;
|
||||||
|
private static final int MSG_IL_BTLEAUDIO_TIMEOUT = 49;
|
||||||
|
|
||||||
private static boolean isMessageHandledUnderWakelock(int msgId) {
|
private static boolean isMessageHandledUnderWakelock(int msgId) {
|
||||||
switch(msgId) {
|
switch(msgId) {
|
||||||
case MSG_L_SET_WIRED_DEVICE_CONNECTION_STATE:
|
case MSG_L_SET_WIRED_DEVICE_CONNECTION_STATE:
|
||||||
case MSG_L_SET_BT_ACTIVE_DEVICE:
|
case MSG_L_SET_BT_ACTIVE_DEVICE:
|
||||||
case MSG_IL_BTA2DP_TIMEOUT:
|
case MSG_IL_BTA2DP_TIMEOUT:
|
||||||
|
case MSG_IL_BTLEAUDIO_TIMEOUT:
|
||||||
case MSG_L_A2DP_DEVICE_CONFIG_CHANGE:
|
case MSG_L_A2DP_DEVICE_CONFIG_CHANGE:
|
||||||
case MSG_TOGGLE_HDMI:
|
case MSG_TOGGLE_HDMI:
|
||||||
case MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT:
|
case MSG_L_A2DP_DEVICE_CONNECTION_CHANGE_EXT:
|
||||||
@@ -1800,6 +1813,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
case MSG_L_SET_BT_ACTIVE_DEVICE:
|
case MSG_L_SET_BT_ACTIVE_DEVICE:
|
||||||
case MSG_L_SET_WIRED_DEVICE_CONNECTION_STATE:
|
case MSG_L_SET_WIRED_DEVICE_CONNECTION_STATE:
|
||||||
case MSG_IL_BTA2DP_TIMEOUT:
|
case MSG_IL_BTA2DP_TIMEOUT:
|
||||||
|
case MSG_IL_BTLEAUDIO_TIMEOUT:
|
||||||
case MSG_L_A2DP_DEVICE_CONFIG_CHANGE:
|
case MSG_L_A2DP_DEVICE_CONFIG_CHANGE:
|
||||||
if (sLastDeviceConnectMsgTime >= time) {
|
if (sLastDeviceConnectMsgTime >= time) {
|
||||||
// add a little delay to make sure messages are ordered as expected
|
// add a little delay to make sure messages are ordered as expected
|
||||||
|
|||||||
@@ -395,7 +395,7 @@ public class AudioDeviceInventory {
|
|||||||
case BluetoothProfile.LE_AUDIO:
|
case BluetoothProfile.LE_AUDIO:
|
||||||
case BluetoothProfile.LE_AUDIO_BROADCAST:
|
case BluetoothProfile.LE_AUDIO_BROADCAST:
|
||||||
if (switchToUnavailable) {
|
if (switchToUnavailable) {
|
||||||
makeLeAudioDeviceUnavailable(address, btInfo.mAudioSystemDevice);
|
makeLeAudioDeviceUnavailableNow(address, btInfo.mAudioSystemDevice);
|
||||||
} else if (switchToAvailable) {
|
} else if (switchToAvailable) {
|
||||||
makeLeAudioDeviceAvailable(address, BtHelper.getName(btInfo.mDevice),
|
makeLeAudioDeviceAvailable(address, BtHelper.getName(btInfo.mDevice),
|
||||||
streamType, btInfo.mVolume == -1 ? -1 : btInfo.mVolume * 10,
|
streamType, btInfo.mVolume == -1 ? -1 : btInfo.mVolume * 10,
|
||||||
@@ -507,6 +507,12 @@ public class AudioDeviceInventory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*package*/ void onMakeLeAudioDeviceUnavailableNow(String address, int device) {
|
||||||
|
synchronized (mDevicesLock) {
|
||||||
|
makeLeAudioDeviceUnavailableNow(address, device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*package*/ void onReportNewRoutes() {
|
/*package*/ void onReportNewRoutes() {
|
||||||
int n = mRoutesObservers.beginBroadcast();
|
int n = mRoutesObservers.beginBroadcast();
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
@@ -1027,10 +1033,11 @@ public class AudioDeviceInventory {
|
|||||||
new MediaMetrics.Item(mMetricsId + "disconnectLeAudio")
|
new MediaMetrics.Item(mMetricsId + "disconnectLeAudio")
|
||||||
.record();
|
.record();
|
||||||
if (toRemove.size() > 0) {
|
if (toRemove.size() > 0) {
|
||||||
final int delay = checkSendBecomingNoisyIntentInt(device, 0,
|
final int delay = checkSendBecomingNoisyIntentInt(device,
|
||||||
|
AudioService.CONNECTION_STATE_DISCONNECTED,
|
||||||
AudioSystem.DEVICE_NONE);
|
AudioSystem.DEVICE_NONE);
|
||||||
toRemove.stream().forEach(deviceAddress ->
|
toRemove.stream().forEach(deviceAddress ->
|
||||||
makeLeAudioDeviceUnavailable(deviceAddress, device)
|
makeLeAudioDeviceUnavailableLater(deviceAddress, device, delay)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1366,7 +1373,7 @@ public class AudioDeviceInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GuardedBy("mDevicesLock")
|
@GuardedBy("mDevicesLock")
|
||||||
private void makeLeAudioDeviceUnavailable(String address, int device) {
|
private void makeLeAudioDeviceUnavailableNow(String address, int device) {
|
||||||
if (device != AudioSystem.DEVICE_NONE) {
|
if (device != AudioSystem.DEVICE_NONE) {
|
||||||
final int res = AudioSystem.setDeviceConnectionState(new AudioDeviceAttributes(
|
final int res = AudioSystem.setDeviceConnectionState(new AudioDeviceAttributes(
|
||||||
device, address),
|
device, address),
|
||||||
@@ -1389,6 +1396,14 @@ public class AudioDeviceInventory {
|
|||||||
setCurrentAudioRouteNameIfPossible(null, false /*fromA2dp*/);
|
setCurrentAudioRouteNameIfPossible(null, false /*fromA2dp*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GuardedBy("mDevicesLock")
|
||||||
|
private void makeLeAudioDeviceUnavailableLater(String address, int device, int delayMs) {
|
||||||
|
// the device will be made unavailable later, so consider it disconnected right away
|
||||||
|
mConnectedDevices.remove(DeviceInfo.makeDeviceListKey(device, address));
|
||||||
|
// send the delayed message to make the device unavailable later
|
||||||
|
mDeviceBroker.setLeAudioTimeout(address, device, delayMs);
|
||||||
|
}
|
||||||
|
|
||||||
@GuardedBy("mDevicesLock")
|
@GuardedBy("mDevicesLock")
|
||||||
private void setCurrentAudioRouteNameIfPossible(String name, boolean fromA2dp) {
|
private void setCurrentAudioRouteNameIfPossible(String name, boolean fromA2dp) {
|
||||||
synchronized (mCurAudioRoutes) {
|
synchronized (mCurAudioRoutes) {
|
||||||
|
|||||||
Reference in New Issue
Block a user