summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiddhesh Sahane <quic_ssahane@quicinc.com>2023-02-16 11:44:13 -0800
committerSiddhesh Sahane <quic_ssahane@quicinc.com>2023-02-28 09:29:40 -0800
commit7861df83464ce866e92132cf666acdd1adeaf2ee (patch)
tree6d57a4f5f0ecc52ae09603a87bbbebee63bdd08b
parent82a834356832cd6977ec8954fa5d8542fcc8dede (diff)
base: base: delay LE Audio device unavailability
-Like A2DP, add delay for LE Audio unavailability in order to account broadcast noisy intent delay. -This added delay will avoid any leakage of data over speaker when CNSSSSR triggers during ongoing music on BLE headset. -Disconnect DEVICE_IN_BLE_HEADSET also as a part of disconnectLeAudioUnicast(). Change-Id: Ic37c0d428a33e95969097c15119bdbfb14bf4746 CRs-Fixed: 3379602
-rw-r--r--services/art-profile3
-rw-r--r--services/core/java/com/android/server/audio/AudioDeviceBroker.java17
-rw-r--r--services/core/java/com/android/server/audio/AudioDeviceInventory.java41
3 files changed, 51 insertions, 10 deletions
diff --git a/services/art-profile b/services/art-profile
index 948661d12c5b..8c49766bd991 100644
--- a/services/art-profile
+++ b/services/art-profile
@@ -12663,6 +12663,7 @@ HSPLcom/android/server/audio/AudioDeviceBroker;->topCommunicationRouteClient()Lc
PLcom/android/server/audio/AudioDeviceBroker;->unregisterCommunicationDeviceDispatcher(Landroid/media/ICommunicationDeviceDispatcher;)V
HSPLcom/android/server/audio/AudioDeviceBroker;->updateActiveCommunicationDevice()V
HSPLcom/android/server/audio/AudioDeviceBroker;->waitForBrokerHandlerCreation()V
+PLcom/android/server/audio/AudioDeviceBroker;->setLeAudioTimeout(Ljava/lang/String;II)V
PLcom/android/server/audio/AudioDeviceInventory$$ExternalSyntheticLambda0;-><init>(Lcom/android/server/audio/AudioDeviceInventory;)V
PLcom/android/server/audio/AudioDeviceInventory$$ExternalSyntheticLambda0;->test(Ljava/lang/Object;)Z
PLcom/android/server/audio/AudioDeviceInventory$$ExternalSyntheticLambda10;-><init>(Landroid/util/ArraySet;)V
@@ -12760,6 +12761,8 @@ PLcom/android/server/audio/AudioDeviceInventory;->setPreferredDevicesForStrategy
HSPLcom/android/server/audio/AudioDeviceInventory;->setWiredDeviceConnectionState(Landroid/media/AudioDeviceAttributes;ILjava/lang/String;)I
HSPLcom/android/server/audio/AudioDeviceInventory;->startWatchingRoutes(Landroid/media/IAudioRoutesObserver;)Landroid/media/AudioRoutesInfo;
HSPLcom/android/server/audio/AudioDeviceInventory;->updateAudioRoutes(II)V
+PLcom/android/server/audio/AudioDeviceInventory;->makeLeAudioUnavailableLater(Ljava/lang/String;II)V
+PLcom/android/server/audio/AudioDeviceInventory;->onMakeLeAudioUnavailableNow(Ljava/lang/String;I)V
HSPLcom/android/server/audio/AudioEventLogger$Event;-><clinit>()V
HSPLcom/android/server/audio/AudioEventLogger$Event;-><init>()V
HSPLcom/android/server/audio/AudioEventLogger$Event;->printLog(ILjava/lang/String;)Lcom/android/server/audio/AudioEventLogger$Event;
diff --git a/services/core/java/com/android/server/audio/AudioDeviceBroker.java b/services/core/java/com/android/server/audio/AudioDeviceBroker.java
index c7f0336941a9..506754ae4e08 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceBroker.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceBroker.java
@@ -12,6 +12,11 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ *
*/
package com.android.server.audio;
@@ -1160,6 +1165,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
sendILMsg(MSG_IL_BTA2DP_TIMEOUT, SENDMSG_QUEUE, a2dpCodec, address, delayMs);
}
+ /*package*/ void setLeAudioTimeout(String address, int device, int delayMs) {
+ sendILMsg(MSG_IL_BTLEA_TIMEOUT, SENDMSG_QUEUE, device, address, delayMs);
+ }
+
/*package*/ void setAvrcpAbsoluteVolumeSupported(boolean supported) {
synchronized (mDeviceStateLock) {
mBtHelper.setAvrcpAbsoluteVolumeSupported(supported);
@@ -1543,6 +1552,11 @@ import java.util.concurrent.atomic.AtomicBoolean;
final int capturePreset = msg.arg1;
mDeviceInventory.onSaveClearPreferredDevicesForCapturePreset(capturePreset);
} break;
+ case MSG_IL_BTLEA_TIMEOUT:
+ synchronized (mDeviceStateLock) {
+ mDeviceInventory.onMakeLeAudioUnavailableNow((String) msg.obj, msg.arg1);
+ }
+ break;
default:
Log.wtf(TAG, "Invalid message " + msg.what);
}
@@ -1618,6 +1632,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
// process set volume for Le Audio, obj is BleVolumeInfo
private static final int MSG_II_SET_LE_AUDIO_OUT_VOLUME = 46;
private static final int MSG_L_A2DP_DEVICE_CONFIG_CHANGE_SHO = 47;
+ private static final int MSG_IL_BTLEA_TIMEOUT = 48;
private static boolean isMessageHandledUnderWakelock(int msgId) {
switch(msgId) {
@@ -1631,6 +1646,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
case MSG_L_HEARING_AID_DEVICE_CONNECTION_CHANGE_EXT:
case MSG_CHECK_MUTE_MUSIC:
case MSG_L_A2DP_ACTIVE_DEVICE_CHANGE_EXT:
+ case MSG_IL_BTLEA_TIMEOUT:
return true;
default:
return false;
@@ -1716,6 +1732,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
case MSG_L_SET_BT_ACTIVE_DEVICE:
case MSG_L_SET_WIRED_DEVICE_CONNECTION_STATE:
case MSG_IL_BTA2DP_TIMEOUT:
+ case MSG_IL_BTLEA_TIMEOUT:
case MSG_L_A2DP_DEVICE_CONFIG_CHANGE:
case MSG_L_A2DP_DEVICE_CONFIG_CHANGE_SHO:
if (sLastDeviceConnectMsgTime >= time) {
diff --git a/services/core/java/com/android/server/audio/AudioDeviceInventory.java b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
index 55366437aa8f..4dcd5e5254e7 100644
--- a/services/core/java/com/android/server/audio/AudioDeviceInventory.java
+++ b/services/core/java/com/android/server/audio/AudioDeviceInventory.java
@@ -12,6 +12,11 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
+ *
+ * Changes from Qualcomm Innovation Center are provided under the following license:
+ * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
+ * SPDX-License-Identifier: BSD-3-Clause-Clear
+ *
*/
package com.android.server.audio;
@@ -513,6 +518,12 @@ public class AudioDeviceInventory {
}
}
+ /*package*/ void onMakeLeAudioUnavailableNow(String address, int device) {
+ synchronized (mDevicesLock) {
+ makeLeAudioDeviceUnavailable(address, device);
+ }
+ }
+
/*package*/ void onReportNewRoutes() {
int n = mRoutesObservers.beginBroadcast();
if (n > 0) {
@@ -893,15 +904,11 @@ public class AudioDeviceInventory {
}
/*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) {
final ArraySet<String> toRemove = new ArraySet<>();
- // Disconnect ALL DEVICE_OUT_BLE_HEADSET or DEVICE_OUT_BLE_BROADCAST devices
+ /* Disconnect ALL DEVICE_OUT_BLE_HEADSET,
+ * DEVICE_IN_BLE_HEADSET or DEVICE_OUT_BLE_BROADCAST devices
+ */
mConnectedDevices.values().forEach(deviceInfo -> {
if (deviceInfo.mDeviceType == device) {
toRemove.add(deviceInfo.mDeviceAddress);
@@ -910,17 +917,22 @@ public class AudioDeviceInventory {
new MediaMetrics.Item(mMetricsId + "disconnectLeAudio")
.record();
if (toRemove.size() > 0) {
- final int delay = checkSendBecomingNoisyIntentInt(device, 0,
+ final int delay;
+ if (device != AudioSystem.DEVICE_IN_BLE_HEADSET) {
+ delay = checkSendBecomingNoisyIntentInt(device, 0,
AudioSystem.DEVICE_NONE);
+ } else {
+ delay = 0;
+ }
toRemove.stream().forEach(deviceAddress ->
- makeLeAudioDeviceUnavailable(deviceAddress, device)
- );
+ makeLeAudioUnavailableLater(deviceAddress, delay, device));
}
}
}
/*package*/ void disconnectLeAudioUnicast() {
disconnectLeAudio(AudioSystem.DEVICE_OUT_BLE_HEADSET);
+ disconnectLeAudio(AudioSystem.DEVICE_IN_BLE_HEADSET);
}
/*package*/ void disconnectLeAudioBroadcast() {
@@ -1179,6 +1191,15 @@ public class AudioDeviceInventory {
mDeviceBroker.setA2dpTimeout(address, a2dpCodec, delayMs);
}
+ @GuardedBy("mDevicesLock")
+ private void makeLeAudioUnavailableLater(String address, int delayMs, int device) {
+ final String deviceKey =
+ DeviceInfo.makeDeviceListKey(device, address);
+ // the device will be made unavailable later, so consider it disconnected right away
+ mConnectedDevices.remove(deviceKey);
+ // send the delayed message to make the device unavailable later
+ mDeviceBroker.setLeAudioTimeout(address, device, delayMs);
+ }
@GuardedBy("mDevicesLock")
private void makeA2dpSrcAvailable(String address, int a2dpCodec) {