From 3bdd3cf037d41b0917d88f1f71a7f6d777c80f01 Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Fri, 13 May 2022 12:17:45 -0700 Subject: [PATCH] AudioServer: dump BluetoothClass.Device Identify the connected BT device info for spatialization. Test: adb shell dumpsys audio Bug: 232558126 Change-Id: I84d6be1d6671aee0de9f235af4d8363b6286e974 --- .../com/android/server/audio/BtHelper.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/services/core/java/com/android/server/audio/BtHelper.java b/services/core/java/com/android/server/audio/BtHelper.java index 0aa9a2bc4990b..0e38232757777 100644 --- a/services/core/java/com/android/server/audio/BtHelper.java +++ b/services/core/java/com/android/server/audio/BtHelper.java @@ -35,6 +35,7 @@ import android.media.BluetoothProfileConnectionInfo; import android.os.Binder; import android.os.UserHandle; import android.provider.Settings; +import android.text.TextUtils; import android.util.Log; import com.android.internal.annotations.GuardedBy; @@ -911,10 +912,65 @@ public class BtHelper { } } + /** + * Returns the string equivalent for the btDeviceClass class. + */ + public static String btDeviceClassToString(int btDeviceClass) { + switch (btDeviceClass) { + case BluetoothClass.Device.AUDIO_VIDEO_UNCATEGORIZED: + return "AUDIO_VIDEO_UNCATEGORIZED"; + case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET: + return "AUDIO_VIDEO_WEARABLE_HEADSET"; + case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE: + return "AUDIO_VIDEO_HANDSFREE"; + case 0x040C: + return "AUDIO_VIDEO_RESERVED_0x040C"; // uncommon + case BluetoothClass.Device.AUDIO_VIDEO_MICROPHONE: + return "AUDIO_VIDEO_MICROPHONE"; + case BluetoothClass.Device.AUDIO_VIDEO_LOUDSPEAKER: + return "AUDIO_VIDEO_LOUDSPEAKER"; + case BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES: + return "AUDIO_VIDEO_HEADPHONES"; + case BluetoothClass.Device.AUDIO_VIDEO_PORTABLE_AUDIO: + return "AUDIO_VIDEO_PORTABLE_AUDIO"; + case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO: + return "AUDIO_VIDEO_CAR_AUDIO"; + case BluetoothClass.Device.AUDIO_VIDEO_SET_TOP_BOX: + return "AUDIO_VIDEO_SET_TOP_BOX"; + case BluetoothClass.Device.AUDIO_VIDEO_HIFI_AUDIO: + return "AUDIO_VIDEO_HIFI_AUDIO"; + case BluetoothClass.Device.AUDIO_VIDEO_VCR: + return "AUDIO_VIDEO_VCR"; + case BluetoothClass.Device.AUDIO_VIDEO_VIDEO_CAMERA: + return "AUDIO_VIDEO_VIDEO_CAMERA"; + case BluetoothClass.Device.AUDIO_VIDEO_CAMCORDER: + return "AUDIO_VIDEO_CAMCORDER"; + case BluetoothClass.Device.AUDIO_VIDEO_VIDEO_MONITOR: + return "AUDIO_VIDEO_VIDEO_MONITOR"; + case BluetoothClass.Device.AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER: + return "AUDIO_VIDEO_VIDEO_DISPLAY_AND_LOUDSPEAKER"; + case BluetoothClass.Device.AUDIO_VIDEO_VIDEO_CONFERENCING: + return "AUDIO_VIDEO_VIDEO_CONFERENCING"; + case 0x0444: + return "AUDIO_VIDEO_RESERVED_0x0444"; // uncommon + case BluetoothClass.Device.AUDIO_VIDEO_VIDEO_GAMING_TOY: + return "AUDIO_VIDEO_VIDEO_GAMING_TOY"; + default: // other device classes printed as a hex string. + return TextUtils.formatSimple("0x%04x", btDeviceClass); + } + } + //------------------------------------------------------------ /*package*/ void dump(PrintWriter pw, String prefix) { pw.println("\n" + prefix + "mBluetoothHeadset: " + mBluetoothHeadset); pw.println(prefix + "mBluetoothHeadsetDevice: " + mBluetoothHeadsetDevice); + if (mBluetoothHeadsetDevice != null) { + final BluetoothClass bluetoothClass = mBluetoothHeadsetDevice.getBluetoothClass(); + if (bluetoothClass != null) { + pw.println(prefix + "mBluetoothHeadsetDevice.DeviceClass: " + + btDeviceClassToString(bluetoothClass.getDeviceClass())); + } + } pw.println(prefix + "mScoAudioState: " + scoAudioStateToString(mScoAudioState)); pw.println(prefix + "mScoAudioMode: " + scoAudioModeToString(mScoAudioMode)); pw.println("\n" + prefix + "mHearingAid: " + mHearingAid);