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

Commit 1404bfc7 authored by Vlad Popa's avatar Vlad Popa Committed by Android (Google) Code Review
Browse files

Merge "Reset a2dp device behavior when it's unavailable" into main

parents a4b1818e 2272d371
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -416,6 +416,10 @@ public class AudioDeviceVolumeManager {
     * @hide
     * Configures a device to use absolute volume model, and registers a listener for receiving
     * volume updates to apply on that device
     *
     * <p>For A2DP devices only, this behavior is reset when they are disconnected / made
     * unavailable as this capability is communicated asynchronously at connection time.
     *
     * @param device the audio device set to absolute volume mode
     * @param volume the type of volume this device responds to
     * @param executor the Executor used for receiving volume updates through the listener
@@ -439,7 +443,8 @@ public class AudioDeviceVolumeManager {
    /**
     * @hide
     * Configures a device to use absolute volume model, and registers a listener for receiving
     * volume updates to apply on that device
     * volume updates to apply on that device.
     *
     * @param device the audio device set to absolute volume mode
     * @param volume the type of volume this device responds to
     * @param handlesVolumeAdjustment whether the controller handles volume adjustments separately
@@ -465,7 +470,11 @@ public class AudioDeviceVolumeManager {
    /**
     * @hide
     * Configures a device to use absolute volume model applied to different volume types, and
     * registers a listener for receiving volume updates to apply on that device
     * registers a listener for receiving volume updates to apply on that device.
     *
     * <p>For A2DP devices only, this behavior is reset when they are disconnected / made
     * unavailable as this capability is communicated asynchronously at connection time.
     *
     * @param device the audio device set to absolute multi-volume mode
     * @param volumes the list of volumes the given device responds to
     * @param executor the Executor used for receiving volume updates through the listener
+6 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
package com.android.server.audio;

import static android.media.audio.Flags.scoManagedByAudio;
import static android.media.audio.Flags.unifyAbsoluteVolumeManagement;
import static android.media.AudioSystem.DEVICE_IN_ALL_SCO_SET;
import static android.media.AudioSystem.DEVICE_IN_BLE_HEADSET;
import static android.media.AudioSystem.DEVICE_IN_BLUETOOTH_SCO_HEADSET;
@@ -1731,9 +1732,13 @@ public class AudioDeviceBroker {
        }
    }

    /*package*/ void clearAvrcpAbsoluteVolumeSupported() {
    /*package*/ void clearAvrcpAbsoluteVolumeSupported(AudioDeviceAttributes ada) {
        setAvrcpAbsoluteVolumeSupported(false);
        mAudioService.setAvrcpAbsoluteVolumeSupported(false);

        if (unifyAbsoluteVolumeManagement()) {
            mAudioService.unregisterAbsoluteVolumeDevice(ada);
        }
    }

    /*package*/ boolean getBluetoothA2dpEnabled() {
+1 −1
Original line number Diff line number Diff line
@@ -2397,9 +2397,9 @@ public class AudioDeviceInventory {
        }

        // device to remove was visible by APM, update APM
        mDeviceBroker.clearAvrcpAbsoluteVolumeSupported();
        AudioDeviceAttributes ada = new AudioDeviceAttributes(
                AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, address);
        mDeviceBroker.clearAvrcpAbsoluteVolumeSupported(ada);
        final int res = mAudioSystem.setDeviceConnectionState(ada,
                AudioSystem.DEVICE_STATE_UNAVAILABLE, codec, deviceSwitch);

+9 −5
Original line number Diff line number Diff line
@@ -8454,11 +8454,15 @@ public class AudioService extends IAudioService.Stub
                }
            }
        } else {
            AbsoluteVolumeDeviceInfo deviceInfo = removeFromAbsoluteVolumeDevices(device);
            unregisterAbsoluteVolumeDevice(device);
        }
    }
    /*package*/ void unregisterAbsoluteVolumeDevice(AudioDeviceAttributes ada) {
        AbsoluteVolumeDeviceInfo deviceInfo = removeFromAbsoluteVolumeDevices(ada);
        if (deviceInfo != null) {
            deviceInfo.unlinkToDeath();
                dispatchDeviceVolumeBehavior(device, DEVICE_VOLUME_BEHAVIOR_VARIABLE);
            }
            dispatchDeviceVolumeBehavior(ada, DEVICE_VOLUME_BEHAVIOR_VARIABLE);
        }
    }