summaryrefslogtreecommitdiff
path: root/src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java')
-rw-r--r--src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java b/src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java
index 09b8f76a3..d2521ac72 100644
--- a/src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java
+++ b/src/com/android/server/telecom/bluetooth/BluetoothStateReceiver.java
@@ -26,11 +26,14 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.media.AudioDeviceInfo;
import android.os.Bundle;
import android.telecom.Log;
import android.telecom.Logging.Session;
import com.android.internal.os.SomeArgs;
+import com.android.server.telecom.CallAudioCommunicationDeviceTracker;
+import com.android.server.telecom.flags.FeatureFlags;
import static com.android.server.telecom.bluetooth.BluetoothRouteManager.BT_AUDIO_IS_ON;
import static com.android.server.telecom.bluetooth.BluetoothRouteManager.BT_AUDIO_LOST;
@@ -56,6 +59,8 @@ public class BluetoothStateReceiver extends BroadcastReceiver {
private boolean mIsInCall = false;
private final BluetoothRouteManager mBluetoothRouteManager;
private final BluetoothDeviceManager mBluetoothDeviceManager;
+ private CallAudioCommunicationDeviceTracker mCommunicationDeviceTracker;
+ private FeatureFlags mFeatureFlags;
public void onReceive(Context context, Intent intent) {
Log.startSession("BSR.oR");
@@ -205,17 +210,27 @@ public class BluetoothStateReceiver extends BroadcastReceiver {
/* In Le Audio case, once device got Active, the Telecom needs to make sure it
* is set as communication device before we can say that BT_AUDIO_IS_ON
*/
+ boolean isLeAudioSetForCommunication =
+ mFeatureFlags.callAudioCommunicationDeviceRefactor()
+ ? mCommunicationDeviceTracker.setCommunicationDevice(
+ AudioDeviceInfo.TYPE_BLE_HEADSET, device)
+ : mBluetoothDeviceManager.setLeAudioCommunicationDevice();
if ((!usePreferredAudioProfile
|| preferredDuplexProfile == BluetoothProfile.LE_AUDIO)
- && !mBluetoothDeviceManager.setLeAudioCommunicationDevice()) {
+ && !isLeAudioSetForCommunication) {
Log.w(LOG_TAG,
"Device %s cannot be use as LE audio communication device.",
device);
return;
}
} else {
+ boolean isHearingAidSetForCommunication =
+ mFeatureFlags.callAudioCommunicationDeviceRefactor()
+ ? mCommunicationDeviceTracker.setCommunicationDevice(
+ AudioDeviceInfo.TYPE_HEARING_AID, null)
+ : mBluetoothDeviceManager.setHearingAidCommunicationDevice();
/* deviceType == BluetoothDeviceManager.DEVICE_TYPE_HEARING_AID */
- if (!mBluetoothDeviceManager.setHearingAidCommunicationDevice()) {
+ if (!isHearingAidSetForCommunication) {
Log.w(LOG_TAG,
"Device %s cannot be use as hearing aid communication device.",
device);
@@ -232,9 +247,13 @@ public class BluetoothStateReceiver extends BroadcastReceiver {
}
public BluetoothStateReceiver(BluetoothDeviceManager deviceManager,
- BluetoothRouteManager routeManager) {
+ BluetoothRouteManager routeManager,
+ CallAudioCommunicationDeviceTracker communicationDeviceTracker,
+ FeatureFlags featureFlags) {
mBluetoothDeviceManager = deviceManager;
mBluetoothRouteManager = routeManager;
+ mCommunicationDeviceTracker = communicationDeviceTracker;
+ mFeatureFlags = featureFlags;
}
public void setIsInCall(boolean isInCall) {