Merge "Change MediaSession#isActiveState to PlaybackState#isActiveState"
This commit is contained in:
committed by
Android (Google) Code Review
commit
27faccff33
@@ -103,6 +103,10 @@ package android.media.session {
|
||||
field public static final int RESULT_MEDIA_KEY_NOT_HANDLED = 0; // 0x0
|
||||
}
|
||||
|
||||
public final class PlaybackState implements android.os.Parcelable {
|
||||
method public boolean isActiveState();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.net {
|
||||
|
||||
@@ -28,7 +28,6 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.graphics.drawable.Icon;
|
||||
import android.media.session.MediaController;
|
||||
import android.media.session.MediaSession;
|
||||
import android.media.session.MediaSessionManager;
|
||||
import android.media.session.PlaybackState;
|
||||
import android.os.UserHandle;
|
||||
@@ -153,8 +152,7 @@ public class PipMediaController {
|
||||
}
|
||||
|
||||
ArrayList<RemoteAction> mediaActions = new ArrayList<>();
|
||||
int state = mMediaController.getPlaybackState().getState();
|
||||
boolean isPlaying = MediaSession.isActiveState(state);
|
||||
boolean isPlaying = mMediaController.getPlaybackState().isActiveState();
|
||||
long actions = mMediaController.getPlaybackState().getActions();
|
||||
|
||||
// Prev action
|
||||
|
||||
@@ -608,25 +608,6 @@ public final class MediaSession {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this is considered an active playback state.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static boolean isActiveState(int state) {
|
||||
switch (state) {
|
||||
case PlaybackState.STATE_FAST_FORWARDING:
|
||||
case PlaybackState.STATE_REWINDING:
|
||||
case PlaybackState.STATE_SKIPPING_TO_PREVIOUS:
|
||||
case PlaybackState.STATE_SKIPPING_TO_NEXT:
|
||||
case PlaybackState.STATE_BUFFERING:
|
||||
case PlaybackState.STATE_CONNECTING:
|
||||
case PlaybackState.STATE_PLAYING:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the given bundle includes non-framework Parcelables.
|
||||
*/
|
||||
|
||||
@@ -19,6 +19,7 @@ import android.annotation.DrawableRes;
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.LongDef;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SystemApi;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
@@ -480,6 +481,25 @@ public final class PlaybackState implements Parcelable {
|
||||
return mExtras;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this is considered as an active playback state.
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
||||
public boolean isActiveState() {
|
||||
switch (mState) {
|
||||
case PlaybackState.STATE_FAST_FORWARDING:
|
||||
case PlaybackState.STATE_REWINDING:
|
||||
case PlaybackState.STATE_SKIPPING_TO_PREVIOUS:
|
||||
case PlaybackState.STATE_SKIPPING_TO_NEXT:
|
||||
case PlaybackState.STATE_BUFFERING:
|
||||
case PlaybackState.STATE_CONNECTING:
|
||||
case PlaybackState.STATE_PLAYING:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static final @android.annotation.NonNull Parcelable.Creator<PlaybackState> CREATOR =
|
||||
new Parcelable.Creator<PlaybackState>() {
|
||||
@Override
|
||||
|
||||
@@ -93,6 +93,10 @@ package android.media.session {
|
||||
field public static final int RESULT_MEDIA_KEY_NOT_HANDLED = 0; // 0x0
|
||||
}
|
||||
|
||||
public final class PlaybackState implements android.os.Parcelable {
|
||||
method public boolean isActiveState();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.os {
|
||||
|
||||
@@ -382,7 +382,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient, MediaSessionR
|
||||
if (mPlaybackState == null) {
|
||||
return false;
|
||||
}
|
||||
return MediaSession.isActiveState(mPlaybackState.getState()) == expected;
|
||||
return mPlaybackState.isActiveState() == expected;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user