Merge "Revert^2 "Change PlaybackState#isActiveState to isActive"" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
05df0a936c
@@ -25202,6 +25202,7 @@ package android.media.session {
|
|||||||
method public float getPlaybackSpeed();
|
method public float getPlaybackSpeed();
|
||||||
method public long getPosition();
|
method public long getPosition();
|
||||||
method public int getState();
|
method public int getState();
|
||||||
|
method public boolean isActive();
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
method public void writeToParcel(android.os.Parcel, int);
|
||||||
field public static final long ACTION_FAST_FORWARD = 64L; // 0x40L
|
field public static final long ACTION_FAST_FORWARD = 64L; // 0x40L
|
||||||
field public static final long ACTION_PAUSE = 2L; // 0x2L
|
field public static final long ACTION_PAUSE = 2L; // 0x2L
|
||||||
|
|||||||
@@ -161,10 +161,6 @@ package android.media.session {
|
|||||||
method public void onVolumeChanged(@NonNull android.media.session.MediaSession.Token, int);
|
method public void onVolumeChanged(@NonNull android.media.session.MediaSession.Token, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class PlaybackState implements android.os.Parcelable {
|
|
||||||
method public boolean isActiveState();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
package android.net {
|
package android.net {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
|
|||||||
|
|
||||||
import android.annotation.DrawableRes;
|
import android.annotation.DrawableRes;
|
||||||
import android.annotation.StringRes;
|
import android.annotation.StringRes;
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.RemoteAction;
|
import android.app.RemoteAction;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
@@ -210,13 +211,16 @@ public class PipMediaController {
|
|||||||
/**
|
/**
|
||||||
* Gets the set of media actions currently available.
|
* Gets the set of media actions currently available.
|
||||||
*/
|
*/
|
||||||
|
// This is due to using PlaybackState#isActive, which is added in API 31.
|
||||||
|
// It can be removed when min_sdk of the app is set to 31 or greater.
|
||||||
|
@SuppressLint("NewApi")
|
||||||
private List<RemoteAction> getMediaActions() {
|
private List<RemoteAction> getMediaActions() {
|
||||||
if (mMediaController == null || mMediaController.getPlaybackState() == null) {
|
if (mMediaController == null || mMediaController.getPlaybackState() == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<RemoteAction> mediaActions = new ArrayList<>();
|
ArrayList<RemoteAction> mediaActions = new ArrayList<>();
|
||||||
boolean isPlaying = mMediaController.getPlaybackState().isActiveState();
|
boolean isPlaying = mMediaController.getPlaybackState().isActive();
|
||||||
long actions = mMediaController.getPlaybackState().getActions();
|
long actions = mMediaController.getPlaybackState().getActions();
|
||||||
|
|
||||||
// Prev action
|
// Prev action
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import android.annotation.DrawableRes;
|
|||||||
import android.annotation.IntDef;
|
import android.annotation.IntDef;
|
||||||
import android.annotation.LongDef;
|
import android.annotation.LongDef;
|
||||||
import android.annotation.Nullable;
|
import android.annotation.Nullable;
|
||||||
import android.annotation.SystemApi;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
@@ -493,15 +492,26 @@ public final class PlaybackState implements Parcelable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether this is considered as an active playback state.
|
* Returns whether this is considered as an active playback state.
|
||||||
* @hide
|
* <p>
|
||||||
|
* The playback state is considered as an active if the state is one of the following:
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link #STATE_BUFFERING}</li>
|
||||||
|
* <li>{@link #STATE_CONNECTING}</li>
|
||||||
|
* <li>{@link #STATE_FAST_FORWARDING}</li>
|
||||||
|
* <li>{@link #STATE_PLAYING}</li>
|
||||||
|
* <li>{@link #STATE_REWINDING}</li>
|
||||||
|
* <li>{@link #STATE_SKIPPING_TO_NEXT}</li>
|
||||||
|
* <li>{@link #STATE_SKIPPING_TO_PREVIOUS}</li>
|
||||||
|
* <li>{@link #STATE_SKIPPING_TO_QUEUE_ITEM}</li>
|
||||||
|
* </ul>
|
||||||
*/
|
*/
|
||||||
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
public boolean isActive() {
|
||||||
public boolean isActiveState() {
|
|
||||||
switch (mState) {
|
switch (mState) {
|
||||||
case PlaybackState.STATE_FAST_FORWARDING:
|
case PlaybackState.STATE_FAST_FORWARDING:
|
||||||
case PlaybackState.STATE_REWINDING:
|
case PlaybackState.STATE_REWINDING:
|
||||||
case PlaybackState.STATE_SKIPPING_TO_PREVIOUS:
|
case PlaybackState.STATE_SKIPPING_TO_PREVIOUS:
|
||||||
case PlaybackState.STATE_SKIPPING_TO_NEXT:
|
case PlaybackState.STATE_SKIPPING_TO_NEXT:
|
||||||
|
case PlaybackState.STATE_SKIPPING_TO_QUEUE_ITEM:
|
||||||
case PlaybackState.STATE_BUFFERING:
|
case PlaybackState.STATE_BUFFERING:
|
||||||
case PlaybackState.STATE_CONNECTING:
|
case PlaybackState.STATE_CONNECTING:
|
||||||
case PlaybackState.STATE_PLAYING:
|
case PlaybackState.STATE_PLAYING:
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR
|
|||||||
if (mPlaybackState == null) {
|
if (mPlaybackState == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return mPlaybackState.isActiveState() == expected;
|
return mPlaybackState.isActive() == expected;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user