From b55bf39e2443fabefe4b56b44d466b8c03168445 Mon Sep 17 00:00:00 2001 From: Angela Wang Date: Tue, 15 Nov 2022 06:43:00 +0000 Subject: [PATCH] Updates hearing aid related log for BLE hearing aids (1/2) Retrives BLE hearing aid device type from HapClientProfile#getHearingAidType() and audio location from LeAudioProfile#getAudioLocation(). Sets these HearingAidInfo to CachedBluetoothDevice when both profiles are connected. Bug: 253192350 Test: m statsd_testdrive & statsd_testdrive 513 Change-Id: Ib50b2612903decf554f594335a56465fe4c47cfa --- .../LocalBluetoothProfileManager.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java index efee34ca10dd7..a3c2e70c7da40 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothProfileManager.java @@ -361,10 +361,28 @@ public class LocalBluetoothProfileManager { cachedDevice.setHearingAidInfo(infoBuilder.build()); } } - HearingAidStatsLogUtils.logHearingAidInfo(cachedDevice); } + final boolean isHapClientProfile = getHapClientProfile() != null + && mProfile instanceof HapClientProfile; + final boolean isLeAudioProfile = getLeAudioProfile() != null + && mProfile instanceof LeAudioProfile; + final boolean isHapClientOrLeAudioProfile = isHapClientProfile || isLeAudioProfile; + if (isHapClientOrLeAudioProfile && newState == BluetoothProfile.STATE_CONNECTED) { + + // Checks if both profiles are connected to the device. Hearing aid info need + // to be retrieved from these profiles separately. + if (cachedDevice.isConnectedLeAudioHearingAidDevice()) { + final BluetoothDevice device = cachedDevice.getDevice(); + final HearingAidInfo.Builder infoBuilder = new HearingAidInfo.Builder() + .setLeAudioLocation(getLeAudioProfile().getAudioLocation(device)) + .setHapDeviceType(getHapClientProfile().getHearingAidType(device)); + cachedDevice.setHearingAidInfo(infoBuilder.build()); + HearingAidStatsLogUtils.logHearingAidInfo(cachedDevice); + } + } + if (getCsipSetCoordinatorProfile() != null && mProfile instanceof CsipSetCoordinatorProfile && newState == BluetoothProfile.STATE_CONNECTED) {