Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 12bf321b authored by Eric Laurent's avatar Eric Laurent
Browse files

AudioDeviceInventory: improve log for device connection.

Indicate if a device is a source or sink device in the connection or
disconnection events logged in audio dumpsys. Some BT profiles like LE
Audio or HFP where not clearly indicating the nature of the device.

Test: make
Change-Id: I09e2bf19740750e43cfd249ac5f9225268e0fb3c
parent 8bc28f86
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ public final class AudioDeviceAttributes implements Parcelable {
     * @param name the name of the device, or an empty string for devices without one
     */
    public AudioDeviceAttributes(int nativeType, @NonNull String address, @NonNull String name) {
        mRole = (nativeType & AudioSystem.DEVICE_BIT_IN) != 0 ? ROLE_INPUT : ROLE_OUTPUT;
        mRole = AudioSystem.isInputDevice(nativeType) ? ROLE_INPUT : ROLE_OUTPUT;
        mType = AudioDeviceInfo.convertInternalDeviceToDeviceType(nativeType);
        mAddress = address;
        mName = name;
+2 −2
Original line number Diff line number Diff line
@@ -6133,7 +6133,7 @@ public class AudioManager {
     */
    public static boolean isOutputDevice(int device)
    {
        return (device & AudioSystem.DEVICE_BIT_IN) == 0;
        return !AudioSystem.isInputDevice(device);
    }

    /**
@@ -6142,7 +6142,7 @@ public class AudioManager {
     */
    public static boolean isInputDevice(int device)
    {
        return (device & AudioSystem.DEVICE_BIT_IN) == AudioSystem.DEVICE_BIT_IN;
        return AudioSystem.isInputDevice(device);
    }


+6 −1
Original line number Diff line number Diff line
@@ -1304,6 +1304,11 @@ public class AudioSystem
        DEVICE_IN_ALL_BLE_SET.add(DEVICE_IN_BLE_HEADSET);
    }

    /** @hide */
    public static boolean isInputDevice(int deviceType) {
        return (deviceType & DEVICE_BIT_IN) == DEVICE_BIT_IN;
    }

    /** @hide */
    public static boolean isBluetoothDevice(int deviceType) {
        return isBluetoothA2dpOutDevice(deviceType)
@@ -1602,7 +1607,7 @@ public class AudioSystem
     * @return a string describing the device type
     */
    public static @NonNull String getDeviceName(int device) {
        if ((device & DEVICE_BIT_IN) != 0) {
        if (isInputDevice(device)) {
            return getInputDeviceName(device);
        }
        return getOutputDeviceName(device);
+8 −3
Original line number Diff line number Diff line
@@ -1549,6 +1549,10 @@ public class AudioDeviceInventory {
                    } else {
                        addAudioDeviceInInventoryIfNeeded(device, address, "");
                    }
                    AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent(
                            "SCO " + (AudioSystem.isInputDevice(device) ? "source" : "sink")
                            + " device addr=" + address
                            + (connect ? " now available" : " made unavailable")).printLog(TAG));
                }
                mmi.set(MediaMetrics.Property.STATE, MediaMetrics.Value.CONNECTED).record();
            } else {
@@ -1810,7 +1814,7 @@ public class AudioDeviceInventory {
            // TODO: return;
        } else {
            AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent(
                    "A2DP device addr=" + Utils.anonymizeBluetoothAddress(address)
                    "A2DP source device addr=" + Utils.anonymizeBluetoothAddress(address)
                            + " now available").printLog(TAG));
        }

@@ -2264,7 +2268,8 @@ public class AudioDeviceInventory {
                // TODO: return;
            } else {
                AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent(
                        "LE Audio device addr=" + Utils.anonymizeBluetoothAddress(address)
                        "LE Audio " + (AudioSystem.isInputDevice(device) ? "source" : "sink")
                                + " device addr=" + Utils.anonymizeBluetoothAddress(address)
                                + " now available").printLog(TAG));
            }
            // Reset LEA suspend state each time a new sink is connected
@@ -2403,7 +2408,7 @@ public class AudioDeviceInventory {
        int delay = 0;
        Set<Integer> devices = new HashSet<>();
        for (DeviceInfo di : mConnectedDevices.values()) {
            if (((di.mDeviceType & AudioSystem.DEVICE_BIT_IN) == 0)
            if (!AudioSystem.isInputDevice(di.mDeviceType)
                    && BECOMING_NOISY_INTENT_DEVICES_SET.contains(di.mDeviceType)) {
                devices.add(di.mDeviceType);
                Log.i(TAG, "NOISY: adding 0x" + Integer.toHexString(di.mDeviceType));
+2 −0
Original line number Diff line number Diff line
@@ -120,6 +120,8 @@ public class AudioServiceEvents {
            return new StringBuilder("setWiredDeviceConnectionState(")
                    .append(" type:").append(
                            Integer.toHexString(mState.mAttributes.getInternalType()))
                    .append(" (").append(AudioSystem.isInputDevice(
                            mState.mAttributes.getInternalType()) ? "source" : "sink").append(") ")
                    .append(" state:").append(AudioSystem.deviceStateToString(mState.mState))
                    .append(" addr:").append(mState.mAttributes.getAddress())
                    .append(" name:").append(mState.mAttributes.getName())
Loading