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

Commit c98b6775 authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "AudioDeviceInventory: improve log for device connection." into main

parents 3bf1227a 12bf321b
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
@@ -6134,7 +6134,7 @@ public class AudioManager {
     */
    public static boolean isOutputDevice(int device)
    {
        return (device & AudioSystem.DEVICE_BIT_IN) == 0;
        return !AudioSystem.isInputDevice(device);
    }

    /**
@@ -6143,7 +6143,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
@@ -1664,6 +1664,10 @@ public class AudioDeviceInventory {
                        addAudioDeviceInInventoryIfNeeded(device, address, "",
                                BtHelper.getBtDeviceCategory(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 {
@@ -1925,7 +1929,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));
        }

@@ -2382,7 +2386,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
@@ -2522,7 +2527,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