|
|
|
@ -64,7 +64,6 @@ import android.os.ResultReceiver;
|
|
|
|
|
import android.support.annotation.GuardedBy;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.util.ArrayMap;
|
|
|
|
|
import android.util.ArraySet;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
import java.lang.ref.WeakReference;
|
|
|
|
@ -108,6 +107,8 @@ public class MediaSession2Impl implements MediaSession2Provider {
|
|
|
|
|
@GuardedBy("mLock")
|
|
|
|
|
private MediaPlayerBase mPlayer;
|
|
|
|
|
@GuardedBy("mLock")
|
|
|
|
|
private MediaPlaylistController mMplc;
|
|
|
|
|
@GuardedBy("mLock")
|
|
|
|
|
private VolumeProvider2 mVolumeProvider;
|
|
|
|
|
@GuardedBy("mLock")
|
|
|
|
|
private PlaybackInfo mPlaybackInfo;
|
|
|
|
@ -116,17 +117,18 @@ public class MediaSession2Impl implements MediaSession2Provider {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Can be only called by the {@link Builder#build()}.
|
|
|
|
|
*
|
|
|
|
|
* @param context
|
|
|
|
|
* @param player
|
|
|
|
|
* @param id
|
|
|
|
|
* @param mplc
|
|
|
|
|
* @param volumeProvider
|
|
|
|
|
* @param sessionActivity
|
|
|
|
|
* @param callbackExecutor
|
|
|
|
|
* @param callback
|
|
|
|
|
*/
|
|
|
|
|
public MediaSession2Impl(Context context, MediaPlayerBase player, String id,
|
|
|
|
|
VolumeProvider2 volumeProvider, PendingIntent sessionActivity,
|
|
|
|
|
MediaPlaylistController mplc, VolumeProvider2 volumeProvider,
|
|
|
|
|
PendingIntent sessionActivity,
|
|
|
|
|
Executor callbackExecutor, SessionCallback callback) {
|
|
|
|
|
// TODO(jaewan): Keep other params.
|
|
|
|
|
mInstance = createInstance();
|
|
|
|
@ -140,6 +142,7 @@ public class MediaSession2Impl implements MediaSession2Provider {
|
|
|
|
|
mSessionActivity = sessionActivity;
|
|
|
|
|
mSessionStub = new MediaSession2Stub(this);
|
|
|
|
|
mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
|
|
|
|
mMplc = mplc;
|
|
|
|
|
|
|
|
|
|
// Infer type from the id and package name.
|
|
|
|
|
String libraryService = getServiceName(context, MediaLibraryService2.SERVICE_INTERFACE, id);
|
|
|
|
@ -203,13 +206,13 @@ public class MediaSession2Impl implements MediaSession2Provider {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updatePlayer_impl(MediaPlayerBase player, MediaPlaylistController mpcl,
|
|
|
|
|
public void updatePlayer_impl(MediaPlayerBase player, MediaPlaylistController mplc,
|
|
|
|
|
VolumeProvider2 volumeProvider) throws IllegalArgumentException {
|
|
|
|
|
ensureCallingThread();
|
|
|
|
|
if (player == null) {
|
|
|
|
|
throw new IllegalArgumentException("player shouldn't be null");
|
|
|
|
|
}
|
|
|
|
|
// TODO(jaewan): Handle mpcl
|
|
|
|
|
mMplc = mplc;
|
|
|
|
|
setPlayer(player, volumeProvider);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1287,6 +1290,7 @@ public class MediaSession2Impl implements MediaSession2Provider {
|
|
|
|
|
String mId;
|
|
|
|
|
Executor mCallbackExecutor;
|
|
|
|
|
C mCallback;
|
|
|
|
|
MediaPlaylistController mMplc;
|
|
|
|
|
VolumeProvider2 mVolumeProvider;
|
|
|
|
|
PendingIntent mSessionActivity;
|
|
|
|
|
|
|
|
|
@ -1307,17 +1311,25 @@ public class MediaSession2Impl implements MediaSession2Provider {
|
|
|
|
|
mId = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setPlayer_impl(MediaPlayerBase player, MediaPlaylistController mplc,
|
|
|
|
|
VolumeProvider2 volumeProvider) {
|
|
|
|
|
// TODO: Use MediaPlaylistController
|
|
|
|
|
public void setPlayer_impl(MediaPlayerBase player) {
|
|
|
|
|
if (player == null) {
|
|
|
|
|
throw new IllegalArgumentException("player shouldn't be null");
|
|
|
|
|
}
|
|
|
|
|
mPlayer = player;
|
|
|
|
|
mVolumeProvider = volumeProvider;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setPlaylistController_impl(MediaPlaylistController mplc) {
|
|
|
|
|
if (mplc == null) {
|
|
|
|
|
throw new IllegalArgumentException("mplc shouldn't be null");
|
|
|
|
|
}
|
|
|
|
|
mMplc = mplc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setVolumeProvider_impl(VolumeProvider2 volumeProvider) {
|
|
|
|
|
if (volumeProvider == null) {
|
|
|
|
|
throw new IllegalArgumentException("volumeProvider shouldn't be null");
|
|
|
|
|
}
|
|
|
|
|
mVolumeProvider = volumeProvider;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1360,8 +1372,8 @@ public class MediaSession2Impl implements MediaSession2Provider {
|
|
|
|
|
mCallback = new SessionCallback(mContext) {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new MediaSession2Impl(mContext, mPlayer, mId, mVolumeProvider,
|
|
|
|
|
mSessionActivity, mCallbackExecutor, mCallback).getInstance();
|
|
|
|
|
return new MediaSession2Impl(mContext, mPlayer, mId, mMplc,
|
|
|
|
|
mVolumeProvider, mSessionActivity, mCallbackExecutor, mCallback).getInstance();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|