Make ctor of MediaController.PlaybackInfo @SystemApi
Bug: 167522787
Test: make update-api -j; make -j;
Change-Id: I406097a10204ccc8e75d194fae8ec84f3a8154ac
diff --git a/api/module-lib-current.txt b/api/module-lib-current.txt
index 17545a4..b9eafc4 100644
--- a/api/module-lib-current.txt
+++ b/api/module-lib-current.txt
@@ -42,6 +42,10 @@
package android.media.session {
+ public static final class MediaController.PlaybackInfo implements android.os.Parcelable {
+ ctor public MediaController.PlaybackInfo(int, int, @IntRange(from=0) int, @IntRange(from=0) int, @NonNull android.media.AudioAttributes, @Nullable String);
+ }
+
public final class MediaSession {
field public static final int FLAG_EXCLUSIVE_GLOBAL_PRIORITY = 65536; // 0x10000
}
diff --git a/media/java/android/media/session/MediaController.java b/media/java/android/media/session/MediaController.java
index aa57233..24dacc4 100644
--- a/media/java/android/media/session/MediaController.java
+++ b/media/java/android/media/session/MediaController.java
@@ -16,8 +16,11 @@
package android.media.session;
+import android.annotation.IntDef;
+import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
+import android.annotation.SystemApi;
import android.app.PendingIntent;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
@@ -27,6 +30,7 @@
import android.media.MediaMetadata;
import android.media.Rating;
import android.media.VolumeProvider;
+import android.media.VolumeProvider.ControlType;
import android.media.session.MediaSession.QueueItem;
import android.net.Uri;
import android.os.Bundle;
@@ -41,6 +45,8 @@
import android.util.Log;
import android.view.KeyEvent;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
@@ -950,6 +956,14 @@
* this session.
*/
public static final class PlaybackInfo implements Parcelable {
+
+ /**
+ * @hide
+ */
+ @IntDef({PLAYBACK_TYPE_LOCAL, PLAYBACK_TYPE_REMOTE})
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface PlaybackType {}
+
/**
* The session uses local playback.
*/
@@ -959,7 +973,7 @@
*/
public static final int PLAYBACK_TYPE_REMOTE = 2;
- private final int mVolumeType;
+ private final int mPlaybackType;
private final int mVolumeControl;
private final int mMaxVolume;
private final int mCurrentVolume;
@@ -967,27 +981,35 @@
private final String mVolumeControlId;
/**
+ * Creates a new playback info.
+ *
+ * @param playbackType The playback type. Should be {@link #PLAYBACK_TYPE_LOCAL} or
+ * {@link #PLAYBACK_TYPE_REMOTE}
+ * @param volumeControl The volume control. Should be one of:
+ * {@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 currentVolume The current volume. Should be in the interval [0, maxVolume].
+ * @param audioAttrs The audio attributes for this playback. Should not be null.
+ * @param volumeControlId The volume control ID. This is used for matching
+ * {@link RoutingSessionInfo} and {@link MediaSession}.
* @hide
*/
- public PlaybackInfo(int type, int control, int max, int current, AudioAttributes attrs) {
- this(type, control, max, current, attrs, null);
- }
-
- /**
- * @hide
- */
- public PlaybackInfo(int type, int control, int max, int current, AudioAttributes attrs,
- String volumeControlId) {
- mVolumeType = type;
- mVolumeControl = control;
- mMaxVolume = max;
- mCurrentVolume = current;
- mAudioAttrs = attrs;
+ @SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
+ public PlaybackInfo(@PlaybackType int playbackType, @ControlType int volumeControl,
+ @IntRange(from = 0) int maxVolume, @IntRange(from = 0) int currentVolume,
+ @NonNull AudioAttributes audioAttrs, @Nullable String volumeControlId) {
+ mPlaybackType = playbackType;
+ mVolumeControl = volumeControl;
+ mMaxVolume = maxVolume;
+ mCurrentVolume = currentVolume;
+ mAudioAttrs = audioAttrs;
mVolumeControlId = volumeControlId;
}
PlaybackInfo(Parcel in) {
- mVolumeType = in.readInt();
+ mPlaybackType = in.readInt();
mVolumeControl = in.readInt();
mMaxVolume = in.readInt();
mCurrentVolume = in.readInt();
@@ -1005,7 +1027,7 @@
* @return The type of playback this session is using.
*/
public int getPlaybackType() {
- return mVolumeType;
+ return mPlaybackType;
}
/**
@@ -1016,8 +1038,7 @@
* <li>{@link VolumeProvider#VOLUME_CONTROL_FIXED}</li>
* </ul>
*
- * @return The type of volume control that may be used with this
- * session.
+ * @return The type of volume control that may be used with this session.
*/
public int getVolumeControl() {
return mVolumeControl;
@@ -1075,7 +1096,7 @@
@Override
public String toString() {
- return "volumeType=" + mVolumeType + ", volumeControl=" + mVolumeControl
+ return "playbackType=" + mPlaybackType + ", volumeControlType=" + mVolumeControl
+ ", maxVolume=" + mMaxVolume + ", currentVolume=" + mCurrentVolume
+ ", audioAttrs=" + mAudioAttrs + ", volumeControlId=" + mVolumeControlId;
}
@@ -1087,7 +1108,7 @@
@Override
public void writeToParcel(Parcel dest, int flags) {
- dest.writeInt(mVolumeType);
+ dest.writeInt(mPlaybackType);
dest.writeInt(mVolumeControl);
dest.writeInt(mMaxVolume);
dest.writeInt(mCurrentVolume);
diff --git a/non-updatable-api/module-lib-current.txt b/non-updatable-api/module-lib-current.txt
index 8892a29..565a128 100644
--- a/non-updatable-api/module-lib-current.txt
+++ b/non-updatable-api/module-lib-current.txt
@@ -42,6 +42,10 @@
package android.media.session {
+ public static final class MediaController.PlaybackInfo implements android.os.Parcelable {
+ ctor public MediaController.PlaybackInfo(int, int, @IntRange(from=0) int, @IntRange(from=0) int, @NonNull android.media.AudioAttributes, @Nullable String);
+ }
+
public final class MediaSession {
field public static final int FLAG_EXCLUSIVE_GLOBAL_PRIORITY = 65536; // 0x10000
}