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

Commit c06d1b0b authored by Jakub Pawłowski's avatar Jakub Pawłowski Committed by Android (Google) Code Review
Browse files

Merge "AudioService: log LE Audio device made avaliable/unavaliable"

parents f5c2b924 c4233117
Loading
Loading
Loading
Loading
+26 −2
Original line number Diff line number Diff line
@@ -1331,9 +1331,21 @@ public class AudioDeviceInventory {
             */
            mDeviceBroker.setBluetoothA2dpOnInt(true, false /*fromA2dp*/, eventSource);

            AudioSystem.setDeviceConnectionState(new AudioDeviceAttributes(device, address, name),
            final int res = AudioSystem.setDeviceConnectionState(new AudioDeviceAttributes(
                    device, address, name),
                    AudioSystem.DEVICE_STATE_AVAILABLE,
                    AudioSystem.AUDIO_FORMAT_DEFAULT);
            if (res != AudioSystem.AUDIO_STATUS_OK) {
                AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent(
                        "APM failed to make available LE Audio device addr=" + address
                                + " error=" + res).printLog(TAG));
                // TODO: connection failed, stop here
                // TODO: return;
            } else {
                AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent(
                        "LE Audio device addr=" + address + " now available").printLog(TAG));
            }

            mConnectedDevices.put(DeviceInfo.makeDeviceListKey(device, address),
                    new DeviceInfo(device, name, address, AudioSystem.AUDIO_FORMAT_DEFAULT));
            mDeviceBroker.postAccessoryPlugMediaUnmute(device);
@@ -1356,9 +1368,21 @@ public class AudioDeviceInventory {
    @GuardedBy("mDevicesLock")
    private void makeLeAudioDeviceUnavailable(String address, int device) {
        if (device != AudioSystem.DEVICE_NONE) {
            AudioSystem.setDeviceConnectionState(new AudioDeviceAttributes(device, address),
            final int res = AudioSystem.setDeviceConnectionState(new AudioDeviceAttributes(
                    device, address),
                    AudioSystem.DEVICE_STATE_UNAVAILABLE,
                    AudioSystem.AUDIO_FORMAT_DEFAULT);

            if (res != AudioSystem.AUDIO_STATUS_OK) {
                AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent(
                        "APM failed to make unavailable LE Audio device addr=" + address
                                + " error=" + res).printLog(TAG));
                // TODO:  failed to disconnect, stop here
                // TODO: return;
            } else {
                AudioService.sDeviceLogger.enqueue(new EventLogger.StringEvent(
                        "LE Audio device addr=" + address + " made unavailable").printLog(TAG));
            }
            mConnectedDevices.remove(DeviceInfo.makeDeviceListKey(device, address));
        }