From ec15471c10a53ac9abd6915771326c979aa1b3b4 Mon Sep 17 00:00:00 2001 From: Caitlin Shkuratov Date: Tue, 15 Nov 2022 22:34:06 +0000 Subject: [PATCH] [Bluetooth] Add more logs around active devices. Bug: 257845933 Test: Verified logcat contained "CachedBluetoothDevice: onActiveDeviceChanged:" logs when a device changes active states Test: Verified BluetoothController dump contains active statuses Change-Id: I788f4de1d4c2906df269c1f5b4fbee5431de9f08 --- .../settingslib/bluetooth/CachedBluetoothDevice.java | 6 ++++++ .../statusbar/policy/BluetoothControllerImpl.java | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java index 950ee21ae7b56..9583a59148fce 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java @@ -668,6 +668,12 @@ public class CachedBluetoothDevice implements Comparable * @param bluetoothProfile the Bluetooth profile */ public void onActiveDeviceChanged(boolean isActive, int bluetoothProfile) { + if (BluetoothUtils.D) { + Log.d(TAG, "onActiveDeviceChanged: " + + "profile " + BluetoothProfile.getProfileName(bluetoothProfile) + + ", device " + mDevice.getAnonymizedAddress() + + ", isActive " + isActive); + } boolean changed = false; switch (bluetoothProfile) { case BluetoothProfile.A2DP: diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java index aae0f93a0e19a..576d7806aecc6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java @@ -145,7 +145,13 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa } private String getDeviceString(CachedBluetoothDevice device) { - return device.getName() + " " + device.getBondState() + " " + device.isConnected(); + return device.getName() + + " bondState=" + device.getBondState() + + " connected=" + device.isConnected() + + " active[A2DP]=" + device.isActiveDevice(BluetoothProfile.A2DP) + + " active[HEADSET]=" + device.isActiveDevice(BluetoothProfile.HEADSET) + + " active[HEARING_AID]=" + device.isActiveDevice(BluetoothProfile.HEARING_AID) + + " active[LE_AUDIO]=" + device.isActiveDevice(BluetoothProfile.LE_AUDIO); } @Override