From f0c9f0b62f35a98c7d49b064372a02871bf84bfd Mon Sep 17 00:00:00 2001 From: timhypeng Date: Mon, 8 Nov 2021 13:12:41 +0000 Subject: [PATCH] Switch the audio path from the settings during the call, and the music will be transferred to the DUT at the end of the call -Do not call removeActiveDevice(ACTIVE_DEVICE_ALL) -removeActiveDevice() by phone call status Bug: 204286292 Test: manual test Change-Id: I4e6b26a70fd57173a3cd49f67b831d49c27223f1 --- .../settingslib/bluetooth/HearingAidProfile.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java index a1fba4a018e2d..dc109cac37b27 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidProfile.java @@ -16,7 +16,8 @@ package com.android.settingslib.bluetooth; -import static android.bluetooth.BluetoothAdapter.ACTIVE_DEVICE_ALL; +import static android.bluetooth.BluetoothAdapter.ACTIVE_DEVICE_AUDIO; +import static android.bluetooth.BluetoothAdapter.ACTIVE_DEVICE_PHONE_CALL; import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_ALLOWED; import static android.bluetooth.BluetoothProfile.CONNECTION_POLICY_FORBIDDEN; @@ -29,6 +30,7 @@ import android.content.Context; import android.util.Log; import com.android.settingslib.R; +import com.android.settingslib.Utils; import java.util.ArrayList; import java.util.List; @@ -162,9 +164,12 @@ public class HearingAidProfile implements LocalBluetoothProfile { if (mBluetoothAdapter == null) { return false; } + int profiles = Utils.isAudioModeOngoingCall(mContext) + ? ACTIVE_DEVICE_PHONE_CALL + : ACTIVE_DEVICE_AUDIO; return device == null - ? mBluetoothAdapter.removeActiveDevice(ACTIVE_DEVICE_ALL) - : mBluetoothAdapter.setActiveDevice(device, ACTIVE_DEVICE_ALL); + ? mBluetoothAdapter.removeActiveDevice(profiles) + : mBluetoothAdapter.setActiveDevice(device, profiles); } public List getActiveDevices() {