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

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

Merge "Adjust the signature of AudioDeviceVolumeManager methods" into main

parents 5d45314c b8c2bce5
Loading
Loading
Loading
Loading
+32 −23
Original line number Diff line number Diff line
@@ -86,10 +86,10 @@ public class AudioDeviceVolumeManager {
    /**
     * @hide
     * Interface to receive volume changes on a device that behaves in absolute volume mode.
     * @see #setDeviceAbsoluteMultiVolumeBehavior(AudioDeviceAttributes, List, Executor,
     *         OnAudioDeviceVolumeChangeListener)
     * @see #setDeviceAbsoluteVolumeBehavior(AudioDeviceAttributes, VolumeInfo, Executor,
     *         OnAudioDeviceVolumeChangeListener)
     * @see #setDeviceAbsoluteMultiVolumeBehavior(AudioDeviceAttributes, List, boolean, Executor,
     *          OnAudioDeviceVolumeChangedListener)
     * @see #setDeviceAbsoluteVolumeBehavior(AudioDeviceAttributes, VolumeInfo, boolean, Executor,
     *          OnAudioDeviceVolumeChangedListener)
     */
    public interface OnAudioDeviceVolumeChangedListener {
        /**
@@ -203,6 +203,9 @@ public class AudioDeviceVolumeManager {
     * 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
     * from volume changes. If true, adjustments from {@link AudioManager#adjustStreamVolume}
     * will be sent via {@link OnAudioDeviceVolumeChangedListener#onAudioDeviceVolumeAdjusted}.
     * @param executor the Executor used for receiving volume updates through the listener
     * @param vclistener the callback for volume updates
     */
@@ -211,13 +214,13 @@ public class AudioDeviceVolumeManager {
    public void setDeviceAbsoluteVolumeBehavior(
            @NonNull AudioDeviceAttributes device,
            @NonNull VolumeInfo volume,
            boolean handlesVolumeAdjustment,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull OnAudioDeviceVolumeChangedListener vclistener,
            boolean handlesVolumeAdjustment) {
            @NonNull OnAudioDeviceVolumeChangedListener vclistener) {
        final ArrayList<VolumeInfo> volumes = new ArrayList<>(1);
        volumes.add(volume);
        setDeviceAbsoluteMultiVolumeBehavior(device, volumes, executor, vclistener,
                handlesVolumeAdjustment);
        setDeviceAbsoluteMultiVolumeBehavior(device, volumes, handlesVolumeAdjustment, executor,
                vclistener);
    }

    /**
@@ -226,20 +229,20 @@ public class AudioDeviceVolumeManager {
     * registers a listener for receiving volume updates to apply on that device
     * @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
     * @param vclistener the callback for volume updates
     * @param handlesVolumeAdjustment whether the controller handles volume adjustments separately
     * from volume changes. If true, adjustments from {@link AudioManager#adjustStreamVolume}
     * will be sent via {@link OnAudioDeviceVolumeChangedListener#onAudioDeviceVolumeAdjusted}.
     * @param executor the Executor used for receiving volume updates through the listener
     * @param vclistener the callback for volume updates
     */
    @RequiresPermission(anyOf = { android.Manifest.permission.MODIFY_AUDIO_ROUTING,
            android.Manifest.permission.BLUETOOTH_PRIVILEGED })
    public void setDeviceAbsoluteMultiVolumeBehavior(
            @NonNull AudioDeviceAttributes device,
            @NonNull List<VolumeInfo> volumes,
            boolean handlesVolumeAdjustment,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull OnAudioDeviceVolumeChangedListener vclistener,
            boolean handlesVolumeAdjustment) {
            @NonNull OnAudioDeviceVolumeChangedListener vclistener) {
        baseSetDeviceAbsoluteMultiVolumeBehavior(device, volumes, executor, vclistener,
                handlesVolumeAdjustment, AudioManager.DEVICE_VOLUME_BEHAVIOR_ABSOLUTE);
    }
@@ -249,11 +252,14 @@ public class AudioDeviceVolumeManager {
     * Configures a device to use absolute volume model, and registers a listener for receiving
     * volume updates to apply on that device.
     *
     * Should be used instead of {@link #setDeviceAbsoluteVolumeBehavior} when there is no reliable
     * way to set the device's volume to a percentage.
     * <p>Should be used instead of {@link #setDeviceAbsoluteVolumeBehavior} when there is no
     * reliable way to set the device's volume to a percentage.
     *
     * @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
     * from volume changes. If true, adjustments from {@link AudioManager#adjustStreamVolume}
     * will be sent via {@link OnAudioDeviceVolumeChangedListener#onAudioDeviceVolumeAdjusted}.
     * @param executor the Executor used for receiving volume updates through the listener
     * @param vclistener the callback for volume updates
     */
@@ -262,13 +268,13 @@ public class AudioDeviceVolumeManager {
    public void setDeviceAbsoluteVolumeAdjustOnlyBehavior(
            @NonNull AudioDeviceAttributes device,
            @NonNull VolumeInfo volume,
            boolean handlesVolumeAdjustment,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull OnAudioDeviceVolumeChangedListener vclistener,
            boolean handlesVolumeAdjustment) {
            @NonNull OnAudioDeviceVolumeChangedListener vclistener) {
        final ArrayList<VolumeInfo> volumes = new ArrayList<>(1);
        volumes.add(volume);
        setDeviceAbsoluteMultiVolumeAdjustOnlyBehavior(device, volumes, executor, vclistener,
                handlesVolumeAdjustment);
        setDeviceAbsoluteMultiVolumeAdjustOnlyBehavior(device, volumes, handlesVolumeAdjustment,
                executor, vclistener);
    }

    /**
@@ -276,11 +282,14 @@ public class AudioDeviceVolumeManager {
     * 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.
     *
     * Should be used instead of {@link #setDeviceAbsoluteMultiVolumeBehavior} when there is
     * <p>Should be used instead of {@link #setDeviceAbsoluteMultiVolumeBehavior} when there is
     * no reliable way to set the device's volume to a percentage.
     *
     * @param device the audio device set to absolute multi-volume mode
     * @param volumes the list of volumes the given device responds to
     * @param handlesVolumeAdjustment whether the controller handles volume adjustments separately
     * from volume changes. If true, adjustments from {@link AudioManager#adjustStreamVolume}
     * will be sent via {@link OnAudioDeviceVolumeChangedListener#onAudioDeviceVolumeAdjusted}.
     * @param executor the Executor used for receiving volume updates through the listener
     * @param vclistener the callback for volume updates
     */
@@ -289,16 +298,16 @@ public class AudioDeviceVolumeManager {
    public void setDeviceAbsoluteMultiVolumeAdjustOnlyBehavior(
            @NonNull AudioDeviceAttributes device,
            @NonNull List<VolumeInfo> volumes,
            boolean handlesVolumeAdjustment,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull OnAudioDeviceVolumeChangedListener vclistener,
            boolean handlesVolumeAdjustment) {
            @NonNull OnAudioDeviceVolumeChangedListener vclistener) {
        baseSetDeviceAbsoluteMultiVolumeBehavior(device, volumes, executor, vclistener,
                handlesVolumeAdjustment, AudioManager.DEVICE_VOLUME_BEHAVIOR_ABSOLUTE_ADJUST_ONLY);
    }

    /**
     * Base method for configuring a device to use absolute volume behavior, or one of its variants.
     * See {@link AudioManager#AbsoluteDeviceVolumeBehavior} for a list of allowed behaviors.
     * See {@link AudioManager.AbsoluteDeviceVolumeBehavior} for a list of allowed behaviors.
     *
     * @param behavior the variant of absolute device volume behavior to adopt
     */
+4 −4
Original line number Diff line number Diff line
@@ -58,9 +58,9 @@ public interface AudioDeviceVolumeManagerWrapper {
    void setDeviceAbsoluteVolumeBehavior(
            @NonNull AudioDeviceAttributes device,
            @NonNull VolumeInfo volume,
            boolean handlesVolumeAdjustment,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull AudioDeviceVolumeManager.OnAudioDeviceVolumeChangedListener vclistener,
            boolean handlesVolumeAdjustment);
            @NonNull AudioDeviceVolumeManager.OnAudioDeviceVolumeChangedListener vclistener);

    /**
     * Wrapper for {@link AudioDeviceVolumeManager#setDeviceAbsoluteVolumeAdjustOnlyBehavior(
@@ -69,7 +69,7 @@ public interface AudioDeviceVolumeManagerWrapper {
    void setDeviceAbsoluteVolumeAdjustOnlyBehavior(
            @NonNull AudioDeviceAttributes device,
            @NonNull VolumeInfo volume,
            boolean handlesVolumeAdjustment,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull AudioDeviceVolumeManager.OnAudioDeviceVolumeChangedListener vclistener,
            boolean handlesVolumeAdjustment);
            @NonNull AudioDeviceVolumeManager.OnAudioDeviceVolumeChangedListener vclistener);
}
+7 −7
Original line number Diff line number Diff line
@@ -61,21 +61,21 @@ public class DefaultAudioDeviceVolumeManagerWrapper
    public void setDeviceAbsoluteVolumeBehavior(
            @NonNull AudioDeviceAttributes device,
            @NonNull VolumeInfo volume,
            boolean handlesVolumeAdjustment,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull AudioDeviceVolumeManager.OnAudioDeviceVolumeChangedListener vclistener,
            boolean handlesVolumeAdjustment) {
        mAudioDeviceVolumeManager.setDeviceAbsoluteVolumeBehavior(device, volume, executor,
                vclistener, handlesVolumeAdjustment);
            @NonNull AudioDeviceVolumeManager.OnAudioDeviceVolumeChangedListener vclistener) {
        mAudioDeviceVolumeManager.setDeviceAbsoluteVolumeBehavior(device, volume,
                handlesVolumeAdjustment, executor, vclistener);
    }

    @Override
    public void setDeviceAbsoluteVolumeAdjustOnlyBehavior(
            @NonNull AudioDeviceAttributes device,
            @NonNull VolumeInfo volume,
            boolean handlesVolumeAdjustment,
            @NonNull @CallbackExecutor Executor executor,
            @NonNull AudioDeviceVolumeManager.OnAudioDeviceVolumeChangedListener vclistener,
            boolean handlesVolumeAdjustment) {
            @NonNull AudioDeviceVolumeManager.OnAudioDeviceVolumeChangedListener vclistener) {
        mAudioDeviceVolumeManager.setDeviceAbsoluteVolumeAdjustOnlyBehavior(device, volume,
                executor, vclistener, handlesVolumeAdjustment);
                handlesVolumeAdjustment, executor, vclistener);
    }
}
+4 −4
Original line number Diff line number Diff line
@@ -4798,15 +4798,15 @@ public class HdmiControlService extends SystemService {
            Slog.d(TAG, "Enabling absolute volume behavior");
            for (AudioDeviceAttributes device : getAvbCapableAudioOutputDevices()) {
                getAudioDeviceVolumeManager().setDeviceAbsoluteVolumeBehavior(
                        device, volumeInfo, mServiceThreadExecutor,
                        mAbsoluteVolumeChangedListener, true);
                        device, volumeInfo, true, mServiceThreadExecutor,
                        mAbsoluteVolumeChangedListener);
            }
        } else if (tv() != null) {
            Slog.d(TAG, "Enabling adjust-only absolute volume behavior");
            for (AudioDeviceAttributes device : getAvbCapableAudioOutputDevices()) {
                getAudioDeviceVolumeManager().setDeviceAbsoluteVolumeAdjustOnlyBehavior(
                        device, volumeInfo, mServiceThreadExecutor,
                        mAbsoluteVolumeChangedListener, true);
                        device, volumeInfo, true, mServiceThreadExecutor,
                        mAbsoluteVolumeChangedListener);
            }
        }

+1 −1
Original line number Diff line number Diff line
@@ -432,7 +432,7 @@ public abstract class BaseAbsoluteVolumeBehaviorTest {
                        .setMaxVolumeIndex(AudioStatus.MAX_VOLUME)
                        .setMinVolumeIndex(AudioStatus.MIN_VOLUME)
                        .build()),
                any(), any(), anyBoolean());
                anyBoolean(), any(), any());
    }

    @Test
Loading