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

Commit 1bd23707 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Improve javadocs in MediaController and VolumeProvider" into...

Merge "Merge "Improve javadocs in MediaController and VolumeProvider" into udc-dev am: b6d728a9 am: b24fef8d"
parents aff058d6 784b00e0
Loading
Loading
Loading
Loading
+21 −20
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@ package android.media;


import android.annotation.IntDef;
import android.annotation.IntDef;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.media.MediaRouter2.RoutingController;
import android.media.session.MediaSession;
import android.media.session.MediaSession;


import java.lang.annotation.Retention;
import java.lang.annotation.Retention;
@@ -66,32 +67,28 @@ public abstract class VolumeProvider {
    private Callback mCallback;
    private Callback mCallback;


    /**
    /**
     * Create a new volume provider for handling volume events. You must specify
     * Creates a new volume provider for handling volume events.
     * the type of volume control, the maximum volume that can be used, and the
     * current volume on the output.
     *
     *
     * @param volumeControl The method for controlling volume that is used by
     * @param volumeControl See {@link #getVolumeControl()}.
     *            this provider.
     * @param maxVolume The maximum allowed volume.
     * @param maxVolume The maximum allowed volume.
     * @param currentVolume The current volume on the output.
     * @param currentVolume The current volume on the output.
     */
     */

    public VolumeProvider(@ControlType int volumeControl, int maxVolume, int currentVolume) {
    public VolumeProvider(@ControlType int volumeControl, int maxVolume, int currentVolume) {
        this(volumeControl, maxVolume, currentVolume, null);
        this(volumeControl, maxVolume, currentVolume, null);
    }
    }


    /**
    /**
     * Create a new volume provider for handling volume events. You must specify
     * Creates a new volume provider for handling volume events.
     * the type of volume control, the maximum volume that can be used, and the
     * current volume on the output.
     *
     *
     * @param volumeControl The method for controlling volume that is used by
     * @param volumeControl See {@link #getVolumeControl()}.
     *            this provider.
     * @param maxVolume The maximum allowed volume.
     * @param maxVolume The maximum allowed volume.
     * @param currentVolume The current volume on the output.
     * @param currentVolume The current volume on the output.
     * @param volumeControlId The volume control ID of this provider.
     * @param volumeControlId See {@link #getVolumeControlId()}.
     */
     */
    public VolumeProvider(@ControlType int volumeControl, int maxVolume, int currentVolume,
    public VolumeProvider(
            @ControlType int volumeControl,
            int maxVolume,
            int currentVolume,
            @Nullable String volumeControlId) {
            @Nullable String volumeControlId) {
        mControlType = volumeControl;
        mControlType = volumeControl;
        mMaxVolume = maxVolume;
        mMaxVolume = maxVolume;
@@ -100,7 +97,10 @@ public abstract class VolumeProvider {
    }
    }


    /**
    /**
     * Get the volume control type that this volume provider uses.
     * Gets the volume control type that this volume provider uses.
     *
     * <p>One of {@link #VOLUME_CONTROL_FIXED}, {@link #VOLUME_CONTROL_ABSOLUTE}, or {@link
     * #VOLUME_CONTROL_RELATIVE}.
     *
     *
     * @return The volume control type for this volume provider
     * @return The volume control type for this volume provider
     */
     */
@@ -110,7 +110,7 @@ public abstract class VolumeProvider {
    }
    }


    /**
    /**
     * Get the maximum volume this provider allows.
     * Gets the maximum volume this provider allows.
     *
     *
     * @return The max allowed volume.
     * @return The max allowed volume.
     */
     */
@@ -129,8 +129,8 @@ public abstract class VolumeProvider {
    }
    }


    /**
    /**
     * Notify the system that the current volume has been changed. This must be
     * Notifies the system that the current volume has been changed. This must be called every time
     * called every time the volume changes to ensure it is displayed properly.
     * the volume changes to ensure it is displayed properly.
     *
     *
     * @param currentVolume The current volume on the output.
     * @param currentVolume The current volume on the output.
     */
     */
@@ -142,10 +142,11 @@ public abstract class VolumeProvider {
    }
    }


    /**
    /**
     * Gets the volume control ID. It can be used to identify which volume provider is
     * Gets the {@link RoutingController#getId() routing controller id} of the {@link
     * used by the session.
     * RoutingController} associated with this volume provider, or null if unset.
     *
     *
     * @return the volume control ID or {@code null} if it isn't set.
     * <p>This id allows mapping this volume provider to a routing controller, which provides
     * information about the media route and allows controlling its volume.
     */
     */
    @Nullable
    @Nullable
    public final String getVolumeControlId() {
    public final String getVolumeControlId() {
+19 −40
Original line number Original line Diff line number Diff line
@@ -29,7 +29,6 @@ import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.AudioManager;
import android.media.MediaMetadata;
import android.media.MediaMetadata;
import android.media.Rating;
import android.media.Rating;
import android.media.RoutingSessionInfo;
import android.media.VolumeProvider;
import android.media.VolumeProvider;
import android.media.VolumeProvider.ControlType;
import android.media.VolumeProvider.ControlType;
import android.media.session.MediaSession.QueueItem;
import android.media.session.MediaSession.QueueItem;
@@ -993,26 +992,23 @@ public final class MediaController {
        /**
        /**
         * Creates a new playback info.
         * Creates a new playback info.
         *
         *
         * @param playbackType The playback type. Should be {@link #PLAYBACK_TYPE_LOCAL} or
         * @param playbackType The playback type. Should be {@link #PLAYBACK_TYPE_LOCAL} or {@link
         *                     {@link #PLAYBACK_TYPE_REMOTE}
         *     #PLAYBACK_TYPE_REMOTE}
         * @param volumeControl The volume control. Should be one of:
         * @param volumeControl See {@link #getVolumeControl()}.
         *                      {@link VolumeProvider#VOLUME_CONTROL_ABSOLUTE},
         *                      {@link VolumeProvider#VOLUME_CONTROL_RELATIVE}, and
         *                      {@link VolumeProvider#VOLUME_CONTROL_FIXED}.
         * @param maxVolume The max volume. Should be equal or greater than zero.
         * @param maxVolume The max volume. Should be equal or greater than zero.
         * @param currentVolume The current volume. Should be in the interval [0, maxVolume].
         * @param currentVolume The current volume. Should be in the interval [0, maxVolume].
         * @param audioAttrs The audio attributes for this playback. Should not be null.
         * @param audioAttrs The audio attributes for this playback. Should not be null.
         * @param volumeControlId The {@link RoutingSessionInfo#getId() routing session id} of the
         * @param volumeControlId See {@link #getVolumeControlId()}.
         *     {@link RoutingSessionInfo} associated with this controller, or null if not
         *     applicable. This id allows mapping this controller to a routing session which, when
         *     applicable, provides information about the remote device, and support for volume
         *     adjustment.
         * @hide
         * @hide
         */
         */
        @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
        @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
        public PlaybackInfo(@PlaybackType int playbackType, @ControlType int volumeControl,
        public PlaybackInfo(
                @IntRange(from = 0) int maxVolume, @IntRange(from = 0) int currentVolume,
                @PlaybackType int playbackType,
                @NonNull AudioAttributes audioAttrs, @Nullable String volumeControlId) {
                @ControlType int volumeControl,
                @IntRange(from = 0) int maxVolume,
                @IntRange(from = 0) int currentVolume,
                @NonNull AudioAttributes audioAttrs,
                @Nullable String volumeControlId) {
            mPlaybackType = playbackType;
            mPlaybackType = playbackType;
            mVolumeControl = volumeControl;
            mVolumeControl = volumeControl;
            mMaxVolume = maxVolume;
            mMaxVolume = maxVolume;
@@ -1044,14 +1040,8 @@ public final class MediaController {
        }
        }


        /**
        /**
         * Get the type of volume control that can be used. One of:
         * Get the volume control type associated to the session, as indicated by {@link
         * <ul>
         * VolumeProvider#getVolumeControl()}.
         * <li>{@link VolumeProvider#VOLUME_CONTROL_ABSOLUTE}</li>
         * <li>{@link VolumeProvider#VOLUME_CONTROL_RELATIVE}</li>
         * <li>{@link VolumeProvider#VOLUME_CONTROL_FIXED}</li>
         * </ul>
         *
         * @return The type of volume control that may be used with this session.
         */
         */
        public int getVolumeControl() {
        public int getVolumeControl() {
            return mVolumeControl;
            return mVolumeControl;
@@ -1076,10 +1066,9 @@ public final class MediaController {
        }
        }


        /**
        /**
         * Get the audio attributes for this session. The attributes will affect
         * Get the audio attributes for this session. The attributes will affect volume handling for
         * volume handling for the session. When the volume type is
         * the session. When the playback type is {@link PlaybackInfo#PLAYBACK_TYPE_REMOTE} these
         * {@link PlaybackInfo#PLAYBACK_TYPE_REMOTE} these may be ignored by the
         * may be ignored by the remote volume handler.
         * remote volume handler.
         *
         *
         * @return The attributes for this session.
         * @return The attributes for this session.
         */
         */
@@ -1088,19 +1077,9 @@ public final class MediaController {
        }
        }


        /**
        /**
         * Gets the volume control ID for this session. It can be used to identify which
         * Get the routing controller ID for this session, as indicated by {@link
         * volume provider is used by the session.
         * VolumeProvider#getVolumeControlId()}. Returns null if unset, or if {@link
         * <p>
         * #getPlaybackType()} is {@link #PLAYBACK_TYPE_LOCAL}.
         * When the session starts to use {@link #PLAYBACK_TYPE_REMOTE remote volume handling},
         * a volume provider should be set and it may set the volume control ID of the provider
         * if the session wants to inform which volume provider is used.
         * It can be {@code null} if the session didn't set the volume control ID or it uses
         * {@link #PLAYBACK_TYPE_LOCAL local playback}.
         * </p>
         *
         * @return the volume control ID for this session or {@code null} if it uses local playback
         * or not set.
         * @see VolumeProvider#getVolumeControlId()
         */
         */
        @Nullable
        @Nullable
        public String getVolumeControlId() {
        public String getVolumeControlId() {