Remove interfaces that don't seem to serve a purpose
PiperOrigin-RevId: 413966081
This commit is contained in:
parent
f4989f5de1
commit
b9f0592702
@ -48,9 +48,9 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
private final ArrayMap<ControllerInfo, ConnectedControllerRecord<T>> controllerRecords =
|
||||
new ArrayMap<>();
|
||||
|
||||
private final MediaSession.MediaSessionImpl sessionImpl;
|
||||
private final MediaSessionImpl sessionImpl;
|
||||
|
||||
public ConnectedControllersManager(MediaSession.MediaSessionImpl session) {
|
||||
public ConnectedControllersManager(MediaSessionImpl session) {
|
||||
// Initialize default values.
|
||||
lock = new Object();
|
||||
|
||||
|
@ -464,7 +464,7 @@ public abstract class MediaLibraryService extends MediaSessionService {
|
||||
SessionCallback callback,
|
||||
MediaItemFiller mediaItemFiller,
|
||||
Bundle tokenExtras) {
|
||||
return new MediaLibrarySessionImplBase(
|
||||
return new MediaLibrarySessionImpl(
|
||||
this, context, id, player, sessionActivity, callback, mediaItemFiller, tokenExtras);
|
||||
}
|
||||
|
||||
@ -533,55 +533,6 @@ public abstract class MediaLibraryService extends MediaSessionService {
|
||||
.notifySearchResultChanged(
|
||||
checkNotNull(browser), checkNotEmpty(query), itemCount, params);
|
||||
}
|
||||
|
||||
interface MediaLibrarySessionImpl extends MediaSessionImpl {
|
||||
|
||||
// LibrarySession methods
|
||||
void notifyChildrenChanged(String parentId, int itemCount, @Nullable LibraryParams params);
|
||||
|
||||
void notifyChildrenChanged(
|
||||
ControllerInfo browser, String parentId, int itemCount, @Nullable LibraryParams params);
|
||||
|
||||
void notifySearchResultChanged(
|
||||
ControllerInfo browser, String query, int itemCount, @Nullable LibraryParams params);
|
||||
|
||||
// LibrarySession callback implementations called on the application thread
|
||||
ListenableFuture<LibraryResult<MediaItem>> onGetLibraryRootOnHandler(
|
||||
ControllerInfo browser, @Nullable LibraryParams params);
|
||||
|
||||
ListenableFuture<LibraryResult<MediaItem>> onGetItemOnHandler(
|
||||
ControllerInfo browser, String mediaId);
|
||||
|
||||
ListenableFuture<LibraryResult<ImmutableList<MediaItem>>> onGetChildrenOnHandler(
|
||||
ControllerInfo browser,
|
||||
String parentId,
|
||||
int page,
|
||||
int pageSize,
|
||||
@Nullable LibraryParams params);
|
||||
|
||||
ListenableFuture<LibraryResult<Void>> onSubscribeOnHandler(
|
||||
ControllerInfo browser, String parentId, @Nullable LibraryParams params);
|
||||
|
||||
ListenableFuture<LibraryResult<Void>> onUnsubscribeOnHandler(
|
||||
ControllerInfo browser, String parentId);
|
||||
|
||||
ListenableFuture<LibraryResult<Void>> onSearchOnHandler(
|
||||
ControllerInfo browser, String query, @Nullable LibraryParams params);
|
||||
|
||||
ListenableFuture<LibraryResult<ImmutableList<MediaItem>>> onGetSearchResultOnHandler(
|
||||
ControllerInfo browser,
|
||||
String query,
|
||||
int page,
|
||||
int pageSize,
|
||||
@Nullable LibraryParams params);
|
||||
|
||||
// Internally used methods - only changing return type
|
||||
@Override
|
||||
MediaLibrarySession getInstance();
|
||||
|
||||
@Override
|
||||
MediaLibrarySessionCallback getCallback();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -735,7 +686,7 @@ public abstract class MediaLibraryService extends MediaSessionService {
|
||||
|
||||
@Override
|
||||
/* package */ MediaSessionServiceImpl createImpl() {
|
||||
return new MediaLibraryServiceImplBase();
|
||||
return new MediaLibraryServiceImpl();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -20,7 +20,7 @@ import android.os.IBinder;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/** Implementation of {@link MediaLibraryService}. */
|
||||
/* package */ class MediaLibraryServiceImplBase extends MediaSessionServiceImplBase {
|
||||
/* package */ class MediaLibraryServiceImpl extends MediaSessionServiceImpl {
|
||||
|
||||
@Override
|
||||
@Nullable
|
@ -39,7 +39,6 @@ import androidx.media3.common.util.ConditionVariable;
|
||||
import androidx.media3.common.util.Log;
|
||||
import androidx.media3.common.util.Util;
|
||||
import androidx.media3.session.MediaLibraryService.LibraryParams;
|
||||
import androidx.media3.session.MediaLibraryService.MediaLibrarySession.MediaLibrarySessionImpl;
|
||||
import androidx.media3.session.MediaSession.ControllerCb;
|
||||
import androidx.media3.session.MediaSession.ControllerInfo;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
@ -45,13 +45,12 @@ import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/* package */ class MediaLibrarySessionImplBase extends MediaSessionImplBase
|
||||
implements MediaLibrarySession.MediaLibrarySessionImpl {
|
||||
/* package */ class MediaLibrarySessionImpl extends MediaSessionImpl {
|
||||
|
||||
@GuardedBy("lock")
|
||||
private final ArrayMap<ControllerCb, Set<String>> subscriptions = new ArrayMap<>();
|
||||
|
||||
public MediaLibrarySessionImplBase(
|
||||
public MediaLibrarySessionImpl(
|
||||
MediaSession instance,
|
||||
Context context,
|
||||
String id,
|
||||
@ -63,30 +62,6 @@ import java.util.concurrent.Future;
|
||||
super(instance, context, id, player, sessionActivity, callback, mediaItemFiller, tokenExtras);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaSessionServiceLegacyStub createLegacyBrowserService(
|
||||
MediaSessionCompat.Token compatToken) {
|
||||
MediaLibraryServiceLegacyStub stub = new MediaLibraryServiceLegacyStub(this);
|
||||
stub.initialize(compatToken);
|
||||
return stub;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaLibrarySession getInstance() {
|
||||
return (MediaLibrarySession) super.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaLibrarySession.MediaLibrarySessionCallback getCallback() {
|
||||
return (MediaLibrarySession.MediaLibrarySessionCallback) super.getCallback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected MediaLibraryServiceLegacyStub getLegacyBrowserService() {
|
||||
return (MediaLibraryServiceLegacyStub) super.getLegacyBrowserService();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ControllerInfo> getConnectedControllers() {
|
||||
List<ControllerInfo> list = super.getConnectedControllers();
|
||||
@ -107,66 +82,34 @@ import java.util.concurrent.Future;
|
||||
&& legacyStub.getConnectedControllersManager().isConnected(controller);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyChildrenChanged(
|
||||
String parentId, int itemCount, @Nullable LibraryParams params) {
|
||||
dispatchRemoteControllerTaskWithoutReturn(
|
||||
new RemoteControllerTask() {
|
||||
@Override
|
||||
public void run(ControllerCb callback, int seq) throws RemoteException {
|
||||
if (isSubscribed(callback, parentId)) {
|
||||
callback.onChildrenChanged(seq, parentId, itemCount, params);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyChildrenChanged(
|
||||
ControllerInfo browser, String parentId, int itemCount, @Nullable LibraryParams params) {
|
||||
dispatchRemoteControllerTaskWithoutReturn(
|
||||
browser,
|
||||
new RemoteControllerTask() {
|
||||
@Override
|
||||
public void run(ControllerCb callback, int seq) throws RemoteException {
|
||||
if (!isSubscribed(callback, parentId)) {
|
||||
return;
|
||||
}
|
||||
(callback, seq) -> {
|
||||
if (isSubscribed(callback, parentId)) {
|
||||
callback.onChildrenChanged(seq, parentId, itemCount, params);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifySearchResultChanged(
|
||||
ControllerInfo browser, String query, int itemCount, @Nullable LibraryParams params) {
|
||||
public void notifyChildrenChanged(
|
||||
ControllerInfo browser, String parentId, int itemCount, @Nullable LibraryParams params) {
|
||||
dispatchRemoteControllerTaskWithoutReturn(
|
||||
browser,
|
||||
new RemoteControllerTask() {
|
||||
@Override
|
||||
public void run(ControllerCb callback, int seq) throws RemoteException {
|
||||
callback.onSearchResultChanged(seq, query, itemCount, params);
|
||||
(callback, seq) -> {
|
||||
if (!isSubscribed(callback, parentId)) {
|
||||
return;
|
||||
}
|
||||
callback.onChildrenChanged(seq, parentId, itemCount, params);
|
||||
});
|
||||
}
|
||||
|
||||
private static void verifyResultItems(
|
||||
LibraryResult<ImmutableList<MediaItem>> result, int pageSize) {
|
||||
if (result.resultCode == RESULT_SUCCESS) {
|
||||
List<MediaItem> items = checkNotNull(result.value);
|
||||
if (items.size() > pageSize) {
|
||||
throw new AssertionError(
|
||||
"The number of items must be less than or equal to the pageSize"
|
||||
+ ", size="
|
||||
+ items.size()
|
||||
+ ", pageSize="
|
||||
+ pageSize);
|
||||
}
|
||||
}
|
||||
public void notifySearchResultChanged(
|
||||
ControllerInfo browser, String query, int itemCount, @Nullable LibraryParams params) {
|
||||
dispatchRemoteControllerTaskWithoutReturn(
|
||||
browser, (callback, seq) -> callback.onSearchResultChanged(seq, query, itemCount, params));
|
||||
}
|
||||
|
||||
/** Called by {@link MediaSessionStub#getLibraryRoot(IMediaController, int, Bundle)}. */
|
||||
@Override
|
||||
public ListenableFuture<LibraryResult<MediaItem>> onGetLibraryRootOnHandler(
|
||||
ControllerInfo browser, @Nullable LibraryParams params) {
|
||||
// onGetLibraryRoot is defined to return a non-null result but it's implemented by applications,
|
||||
@ -176,12 +119,6 @@ import java.util.concurrent.Future;
|
||||
"onGetLibraryRoot must return non-null future");
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by {@link MediaSessionStub#getItem(IMediaController, int, String)}.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ListenableFuture<LibraryResult<MediaItem>> onGetItemOnHandler(
|
||||
ControllerInfo browser, String mediaId) {
|
||||
// onGetItem is defined to return a non-null result but it's implemented by applications,
|
||||
@ -191,7 +128,6 @@ import java.util.concurrent.Future;
|
||||
"onGetItem must return non-null future");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFuture<LibraryResult<ImmutableList<MediaItem>>> onGetChildrenOnHandler(
|
||||
ControllerInfo browser,
|
||||
String parentId,
|
||||
@ -215,7 +151,6 @@ import java.util.concurrent.Future;
|
||||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFuture<LibraryResult<Void>> onSubscribeOnHandler(
|
||||
ControllerInfo browser, String parentId, @Nullable LibraryParams params) {
|
||||
ControllerCb controller = checkStateNotNull(browser.getControllerCb());
|
||||
@ -253,7 +188,6 @@ import java.util.concurrent.Future;
|
||||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFuture<LibraryResult<Void>> onUnsubscribeOnHandler(
|
||||
ControllerInfo browser, String parentId) {
|
||||
// onUnsubscribe is defined to return a non-null result but it's implemented by applications,
|
||||
@ -274,7 +208,6 @@ import java.util.concurrent.Future;
|
||||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFuture<LibraryResult<Void>> onSearchOnHandler(
|
||||
ControllerInfo browser, String query, @Nullable LibraryParams params) {
|
||||
// onSearch is defined to return a non-null result but it's implemented by applications,
|
||||
@ -284,7 +217,6 @@ import java.util.concurrent.Future;
|
||||
"onSearch must return non-null future");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFuture<LibraryResult<ImmutableList<MediaItem>>> onGetSearchResultOnHandler(
|
||||
ControllerInfo browser,
|
||||
String query,
|
||||
@ -309,6 +241,30 @@ import java.util.concurrent.Future;
|
||||
return future;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MediaLibrarySession getInstance() {
|
||||
return (MediaLibrarySession) super.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MediaLibrarySession.MediaLibrarySessionCallback getCallback() {
|
||||
return (MediaLibrarySession.MediaLibrarySessionCallback) super.getCallback();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
protected MediaLibraryServiceLegacyStub getLegacyBrowserService() {
|
||||
return (MediaLibraryServiceLegacyStub) super.getLegacyBrowserService();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MediaSessionServiceLegacyStub createLegacyBrowserService(
|
||||
MediaSessionCompat.Token compatToken) {
|
||||
MediaLibraryServiceLegacyStub stub = new MediaLibraryServiceLegacyStub(this);
|
||||
stub.initialize(compatToken);
|
||||
return stub;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchRemoteControllerTaskWithoutReturn(RemoteControllerTask task) {
|
||||
super.dispatchRemoteControllerTaskWithoutReturn(task);
|
||||
@ -341,4 +297,19 @@ import java.util.concurrent.Future;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void verifyResultItems(
|
||||
LibraryResult<ImmutableList<MediaItem>> result, int pageSize) {
|
||||
if (result.resultCode == RESULT_SUCCESS) {
|
||||
List<MediaItem> items = checkNotNull(result.value);
|
||||
if (items.size() > pageSize) {
|
||||
throw new AssertionError(
|
||||
"The number of items must be less than or equal to the pageSize"
|
||||
+ ", size="
|
||||
+ items.size()
|
||||
+ ", pageSize="
|
||||
+ pageSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -26,7 +26,6 @@ import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.RemoteException;
|
||||
@ -496,7 +495,7 @@ public class MediaSession {
|
||||
SessionCallback callback,
|
||||
MediaItemFiller mediaItemFiller,
|
||||
Bundle tokenExtras) {
|
||||
return new MediaSessionImplBase(
|
||||
return new MediaSessionImpl(
|
||||
this, context, id, player, sessionActivity, callback, mediaItemFiller, tokenExtras);
|
||||
}
|
||||
|
||||
@ -1210,73 +1209,6 @@ public class MediaSession {
|
||||
default void onRenderedFirstFrame(int seq) throws RemoteException {}
|
||||
}
|
||||
|
||||
/* package */ interface MediaSessionImpl {
|
||||
|
||||
void setPlayer(Player player);
|
||||
|
||||
PlayerWrapper getPlayerWrapper();
|
||||
|
||||
String getId();
|
||||
|
||||
Uri getUri();
|
||||
|
||||
SessionToken getToken();
|
||||
|
||||
List<ControllerInfo> getConnectedControllers();
|
||||
|
||||
boolean isConnected(ControllerInfo controller);
|
||||
|
||||
void release();
|
||||
|
||||
ListenableFuture<SessionResult> setCustomLayout(
|
||||
ControllerInfo controller, List<CommandButton> layout);
|
||||
|
||||
void setAvailableCommands(
|
||||
ControllerInfo controller, SessionCommands sessionCommands, Player.Commands playerCommands);
|
||||
|
||||
void broadcastCustomCommand(SessionCommand command, Bundle args);
|
||||
|
||||
ListenableFuture<SessionResult> sendCustomCommand(
|
||||
ControllerInfo controller, SessionCommand command, Bundle args);
|
||||
|
||||
// Internally used methods
|
||||
MediaSession getInstance();
|
||||
|
||||
MediaSessionCompat getSessionCompat();
|
||||
|
||||
void setLegacyControllerConnectionTimeoutMs(long timeoutMs);
|
||||
|
||||
Context getContext();
|
||||
|
||||
Handler getApplicationHandler();
|
||||
|
||||
SessionCallback getCallback();
|
||||
|
||||
MediaItemFiller getMediaItemFiller();
|
||||
|
||||
boolean isReleased();
|
||||
|
||||
@Nullable
|
||||
PendingIntent getSessionActivity();
|
||||
|
||||
IBinder getLegacyBrowserServiceBinder();
|
||||
|
||||
void setSessionPositionUpdateDelayMsOnHandler(long updateDelayMs);
|
||||
|
||||
void connectFromService(
|
||||
IMediaController caller,
|
||||
int controllerVersion,
|
||||
String packageName,
|
||||
int pid,
|
||||
int uid,
|
||||
Bundle connectionHints);
|
||||
|
||||
void setForegroundServiceEventCallback(
|
||||
ForegroundServiceEventCallback foregroundServiceEventCallback);
|
||||
|
||||
void clearForegroundServiceEventCallback();
|
||||
}
|
||||
|
||||
/**
|
||||
* A base class for {@link MediaSession.Builder} and {@link
|
||||
* MediaLibraryService.MediaLibrarySession.Builder}. Any changes to this class should be also
|
||||
|
@ -75,7 +75,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
/* package */ class MediaSessionImplBase implements MediaSession.MediaSessionImpl {
|
||||
/* package */ class MediaSessionImpl {
|
||||
|
||||
// Create a static lock for synchronize methods below.
|
||||
// We'd better not use MediaSessionImplBase.class for synchronized(), which indirectly exposes
|
||||
@ -138,7 +138,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Nullable private MediaSession.ForegroundServiceEventCallback foregroundServiceEventCallback;
|
||||
|
||||
public MediaSessionImplBase(
|
||||
public MediaSessionImpl(
|
||||
MediaSession instance,
|
||||
Context context,
|
||||
String id,
|
||||
@ -152,7 +152,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@SuppressWarnings("nullness:assignment")
|
||||
@Initialized
|
||||
MediaSessionImplBase thisRef = this;
|
||||
MediaSessionImpl thisRef = this;
|
||||
|
||||
sessionStub = new MediaSessionStub(thisRef);
|
||||
this.sessionActivity = sessionActivity;
|
||||
@ -177,7 +177,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
// See {@link PendingIntent} and {@link Intent#filterEquals} for details.
|
||||
sessionUri =
|
||||
new Uri.Builder()
|
||||
.scheme(MediaSessionImplBase.class.getName())
|
||||
.scheme(MediaSessionImpl.class.getName())
|
||||
.appendPath(id)
|
||||
.appendPath(String.valueOf(SystemClock.elapsedRealtime()))
|
||||
.build();
|
||||
@ -227,10 +227,9 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
intent.setComponent(mbrComponent);
|
||||
if (Util.SDK_INT >= 26) {
|
||||
mediaButtonIntent =
|
||||
PendingIntent.getForegroundService(this.context, 0, intent, pendingIntentFlagMutable);
|
||||
PendingIntent.getForegroundService(context, 0, intent, pendingIntentFlagMutable);
|
||||
} else {
|
||||
mediaButtonIntent =
|
||||
PendingIntent.getService(this.context, 0, intent, pendingIntentFlagMutable);
|
||||
mediaButtonIntent = PendingIntent.getService(context, 0, intent, pendingIntentFlagMutable);
|
||||
}
|
||||
broadcastReceiver = null;
|
||||
}
|
||||
@ -251,7 +250,6 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
thisRef::notifyPeriodicSessionPositionInfoChangesOnHandler, sessionPositionUpdateDelayMs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayer(Player player) {
|
||||
if (player == playerWrapper.getWrappedPlayer()) {
|
||||
return;
|
||||
@ -283,7 +281,6 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
onPlayerInfoChangedHandler.sendPlayerInfoChangedMessage(/* excludeTimeline= */ false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
synchronized (lock) {
|
||||
if (closed) {
|
||||
@ -317,27 +314,22 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
dispatchRemoteControllerTaskWithoutReturn(ControllerCb::onDisconnected);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerWrapper getPlayerWrapper() {
|
||||
return playerWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri getUri() {
|
||||
return sessionUri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionToken getToken() {
|
||||
return sessionToken;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ControllerInfo> getConnectedControllers() {
|
||||
List<ControllerInfo> controllers = new ArrayList<>();
|
||||
controllers.addAll(sessionStub.getConnectedControllersManager().getConnectedControllers());
|
||||
@ -346,13 +338,11 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
return controllers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected(ControllerInfo controller) {
|
||||
return sessionStub.getConnectedControllersManager().isConnected(controller)
|
||||
|| sessionLegacyStub.getConnectedControllersManager().isConnected(controller);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFuture<SessionResult> setCustomLayout(
|
||||
ControllerInfo controller, List<CommandButton> layout) {
|
||||
return dispatchRemoteControllerTask(
|
||||
@ -365,7 +355,6 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAvailableCommands(
|
||||
ControllerInfo controller, SessionCommands sessionCommands, Player.Commands playerCommands) {
|
||||
if (sessionStub.getConnectedControllersManager().isConnected(controller)) {
|
||||
@ -388,7 +377,6 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcastCustomCommand(SessionCommand command, Bundle args) {
|
||||
dispatchRemoteControllerTaskWithoutReturn(
|
||||
(controller, seq) -> controller.sendCustomCommand(seq, command, args));
|
||||
@ -444,69 +432,12 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListenableFuture<SessionResult> sendCustomCommand(
|
||||
ControllerInfo controller, SessionCommand command, Bundle args) {
|
||||
return dispatchRemoteControllerTask(
|
||||
controller, (cb, seq) -> cb.sendCustomCommand(seq, command, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaSession getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Handler getApplicationHandler() {
|
||||
return applicationHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionCallback getCallback() {
|
||||
return callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaItemFiller getMediaItemFiller() {
|
||||
return mediaItemFiller;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaSessionCompat getSessionCompat() {
|
||||
return sessionLegacyStub.getSessionCompat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLegacyControllerConnectionTimeoutMs(long timeoutMs) {
|
||||
sessionLegacyStub.setLegacyControllerDisconnectTimeoutMs(timeoutMs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReleased() {
|
||||
synchronized (lock) {
|
||||
return closed;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public PendingIntent getSessionActivity() {
|
||||
return sessionActivity;
|
||||
}
|
||||
|
||||
public MediaSessionServiceLegacyStub createLegacyBrowserService(
|
||||
MediaSessionCompat.Token compatToken) {
|
||||
MediaSessionServiceLegacyStub stub = new MediaSessionServiceLegacyStub(this);
|
||||
stub.initialize(compatToken);
|
||||
return stub;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectFromService(
|
||||
IMediaController caller,
|
||||
int controllerVersion,
|
||||
@ -518,12 +449,50 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
caller, controllerVersion, packageName, pid, uid, checkStateNotNull(connectionHints));
|
||||
}
|
||||
|
||||
public MediaSessionCompat getSessionCompat() {
|
||||
return sessionLegacyStub.getSessionCompat();
|
||||
}
|
||||
|
||||
public void setLegacyControllerConnectionTimeoutMs(long timeoutMs) {
|
||||
sessionLegacyStub.setLegacyControllerDisconnectTimeoutMs(timeoutMs);
|
||||
}
|
||||
|
||||
protected MediaSession getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
protected Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
protected Handler getApplicationHandler() {
|
||||
return applicationHandler;
|
||||
}
|
||||
|
||||
protected SessionCallback getCallback() {
|
||||
return callback;
|
||||
}
|
||||
|
||||
protected MediaItemFiller getMediaItemFiller() {
|
||||
return mediaItemFiller;
|
||||
}
|
||||
|
||||
protected boolean isReleased() {
|
||||
synchronized (lock) {
|
||||
return closed;
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected PendingIntent getSessionActivity() {
|
||||
return sessionActivity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the service binder from the MediaBrowserServiceCompat. Should be only called by the thread
|
||||
* with a Looper.
|
||||
*/
|
||||
@Override
|
||||
public IBinder getLegacyBrowserServiceBinder() {
|
||||
protected IBinder getLegacyBrowserServiceBinder() {
|
||||
MediaSessionServiceLegacyStub legacyStub;
|
||||
synchronized (lock) {
|
||||
if (browserServiceLegacyStub == null) {
|
||||
@ -536,8 +505,14 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
return legacyStub.onBind(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSessionPositionUpdateDelayMsOnHandler(long updateDelayMs) {
|
||||
protected MediaSessionServiceLegacyStub createLegacyBrowserService(
|
||||
MediaSessionCompat.Token compatToken) {
|
||||
MediaSessionServiceLegacyStub stub = new MediaSessionServiceLegacyStub(this);
|
||||
stub.initialize(compatToken);
|
||||
return stub;
|
||||
}
|
||||
|
||||
protected void setSessionPositionUpdateDelayMsOnHandler(long updateDelayMs) {
|
||||
verifyApplicationThread();
|
||||
sessionPositionUpdateDelayMs = updateDelayMs;
|
||||
|
||||
@ -546,14 +521,12 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
this::notifyPeriodicSessionPositionInfoChangesOnHandler, updateDelayMs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setForegroundServiceEventCallback(
|
||||
protected void setForegroundServiceEventCallback(
|
||||
MediaSession.ForegroundServiceEventCallback foregroundServiceEventCallback) {
|
||||
this.foregroundServiceEventCallback = foregroundServiceEventCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearForegroundServiceEventCallback() {
|
||||
protected void clearForegroundServiceEventCallback() {
|
||||
foregroundServiceEventCallback = null;
|
||||
}
|
||||
|
||||
@ -700,17 +673,17 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
private static class PlayerListener implements Player.Listener {
|
||||
|
||||
private final WeakReference<MediaSessionImplBase> session;
|
||||
private final WeakReference<MediaSessionImpl> session;
|
||||
private final WeakReference<PlayerWrapper> player;
|
||||
|
||||
public PlayerListener(MediaSessionImplBase session, PlayerWrapper player) {
|
||||
public PlayerListener(MediaSessionImpl session, PlayerWrapper player) {
|
||||
this.session = new WeakReference<>(session);
|
||||
this.player = new WeakReference<>(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerError(PlaybackException error) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -728,7 +701,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
@Override
|
||||
public void onMediaItemTransition(
|
||||
@Nullable MediaItem mediaItem, @Player.MediaItemTransitionReason int reason) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -748,7 +721,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
@Override
|
||||
public void onPlayWhenReadyChanged(
|
||||
boolean playWhenReady, @Player.PlayWhenReadyChangeReason int reason) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -767,7 +740,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onPlaybackSuppressionReasonChanged(@Player.PlaybackSuppressionReason int reason) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -788,7 +761,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onPlaybackStateChanged(@Player.State int playbackState) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -808,7 +781,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onIsPlayingChanged(boolean isPlaying) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -825,7 +798,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onIsLoadingChanged(boolean isLoading) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -843,7 +816,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
@Override
|
||||
public void onPositionDiscontinuity(
|
||||
PositionInfo oldPosition, PositionInfo newPosition, @DiscontinuityReason int reason) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -863,7 +836,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -880,7 +853,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onSeekBackIncrementChanged(long seekBackIncrementMs) {
|
||||
MediaSessionImplBase session = getSession();
|
||||
MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -897,7 +870,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onSeekForwardIncrementChanged(long seekForwardIncrementMs) {
|
||||
MediaSessionImplBase session = getSession();
|
||||
MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -914,7 +887,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onTimelineChanged(Timeline timeline, @Player.TimelineChangeReason int reason) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -931,7 +904,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onPlaylistMetadataChanged(MediaMetadata playlistMetadata) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -944,7 +917,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onRepeatModeChanged(@RepeatMode int repeatMode) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -961,7 +934,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -978,7 +951,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onAudioAttributesChanged(AudioAttributes attributes) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -995,7 +968,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onVideoSizeChanged(VideoSize size) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -1008,7 +981,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onVolumeChanged(@FloatRange(from = 0, to = 1) float volume) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -1021,7 +994,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onCues(List<Cue> cues) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -1036,7 +1009,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onDeviceInfoChanged(DeviceInfo deviceInfo) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -1053,7 +1026,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onDeviceVolumeChanged(int volume, boolean muted) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -1070,7 +1043,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onAvailableCommandsChanged(Player.Commands availableCommands) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -1091,7 +1064,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onTrackSelectionParametersChanged(TrackSelectionParameters parameters) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -1108,7 +1081,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onMediaMetadataChanged(MediaMetadata mediaMetadata) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -1125,7 +1098,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onRenderedFirstFrame() {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -1135,7 +1108,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onMaxSeekToPreviousPositionChanged(long maxSeekToPreviousPositionMs) {
|
||||
@Nullable MediaSessionImplBase session = getSession();
|
||||
@Nullable MediaSessionImpl session = getSession();
|
||||
if (session == null) {
|
||||
return;
|
||||
}
|
||||
@ -1150,7 +1123,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private MediaSessionImplBase getSession() {
|
||||
private MediaSessionImpl getSession() {
|
||||
return this.session.get();
|
||||
}
|
||||
}
|
||||
@ -1164,7 +1137,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
return;
|
||||
}
|
||||
Uri sessionUri = intent.getData();
|
||||
if (!Util.areEqual(sessionUri, MediaSessionImplBase.this.sessionUri)) {
|
||||
if (!Util.areEqual(sessionUri, MediaSessionImpl.this.sessionUri)) {
|
||||
return;
|
||||
}
|
||||
KeyEvent keyEvent = (KeyEvent) intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
|
@ -100,7 +100,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
private final ConnectedControllersManager<RemoteUserInfo> connectedControllersManager;
|
||||
|
||||
private final MediaSession.MediaSessionImpl sessionImpl;
|
||||
private final MediaSessionImpl sessionImpl;
|
||||
private final MediaSessionManager sessionManager;
|
||||
private final ControllerCb controllerLegacyCbForBroadcast;
|
||||
private final ConnectionTimeoutHandler connectionTimeoutHandler;
|
||||
@ -111,7 +111,7 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
private volatile long connectionTimeoutMs;
|
||||
|
||||
public MediaSessionLegacyStub(
|
||||
MediaSession.MediaSessionImpl session,
|
||||
MediaSessionImpl session,
|
||||
ComponentName mbrComponent,
|
||||
PendingIntent mediaButtonIntent,
|
||||
Handler handler) {
|
||||
|
@ -122,7 +122,7 @@ public abstract class MediaSessionService extends Service {
|
||||
}
|
||||
|
||||
/* package */ MediaSessionServiceImpl createImpl() {
|
||||
return new MediaSessionServiceImplBase();
|
||||
return new androidx.media3.session.MediaSessionServiceImpl();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -298,25 +298,4 @@ public abstract class MediaSessionService extends Service {
|
||||
this.notification = checkNotNull(notification);
|
||||
}
|
||||
}
|
||||
|
||||
interface MediaSessionServiceImpl {
|
||||
|
||||
void onCreate(MediaSessionService service);
|
||||
|
||||
int onStartCommand(@Nullable Intent intent, int flags, int startId);
|
||||
|
||||
@Nullable
|
||||
IBinder onBind(@Nullable Intent intent);
|
||||
|
||||
void onDestroy();
|
||||
|
||||
void addSession(MediaSession session);
|
||||
|
||||
void removeSession(MediaSession session);
|
||||
|
||||
@Nullable
|
||||
MediaNotification onUpdateNotification(MediaSession session);
|
||||
|
||||
List<MediaSession> getSessions();
|
||||
}
|
||||
}
|
||||
|
@ -38,16 +38,15 @@ import androidx.media.MediaSessionManager.RemoteUserInfo;
|
||||
import androidx.media3.common.util.Log;
|
||||
import androidx.media3.session.MediaSession.ControllerInfo;
|
||||
import androidx.media3.session.MediaSessionService.MediaNotification;
|
||||
import androidx.media3.session.MediaSessionService.MediaSessionServiceImpl;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/** Implementation of {@link MediaSessionService}. */
|
||||
/* package */ class MediaSessionServiceImplBase implements MediaSessionServiceImpl {
|
||||
/* package */ class MediaSessionServiceImpl {
|
||||
|
||||
private static final String TAG = "MSSImplBase";
|
||||
private static final String TAG = "MSSImpl";
|
||||
|
||||
private final Object lock;
|
||||
|
||||
@ -66,12 +65,11 @@ import java.util.Map;
|
||||
@Nullable
|
||||
private MediaNotificationHandler notificationHandler;
|
||||
|
||||
public MediaSessionServiceImplBase() {
|
||||
public MediaSessionServiceImpl() {
|
||||
lock = new Object();
|
||||
sessions = new ArrayMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(MediaSessionService service) {
|
||||
synchronized (lock) {
|
||||
instance = service;
|
||||
@ -80,7 +78,6 @@ import java.util.Map;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public IBinder onBind(@Nullable Intent intent) {
|
||||
if (intent == null) {
|
||||
@ -116,7 +113,6 @@ import java.util.Map;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
synchronized (lock) {
|
||||
instance = null;
|
||||
@ -127,7 +123,6 @@ import java.util.Map;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSession(MediaSession session) {
|
||||
@Nullable MediaSession old;
|
||||
synchronized (lock) {
|
||||
@ -157,7 +152,6 @@ import java.util.Map;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeSession(MediaSession session) {
|
||||
synchronized (lock) {
|
||||
sessions.remove(session.getId());
|
||||
@ -166,7 +160,6 @@ import java.util.Map;
|
||||
session.getImpl().getApplicationHandler(), session::clearForegroundServiceEventCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(@Nullable Intent intent, int flags, int startId) {
|
||||
if (intent == null) {
|
||||
return START_STICKY;
|
||||
@ -190,7 +183,6 @@ import java.util.Map;
|
||||
return START_STICKY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaNotification onUpdateNotification(MediaSession session) {
|
||||
MediaNotificationHandler handler;
|
||||
synchronized (lock) {
|
||||
@ -199,7 +191,6 @@ import java.util.Map;
|
||||
return handler.onUpdateNotification(session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MediaSession> getSessions() {
|
||||
synchronized (lock) {
|
||||
return new ArrayList<>(sessions.values());
|
||||
@ -221,13 +212,13 @@ import java.util.Map;
|
||||
|
||||
private static final class MediaSessionServiceStub extends IMediaSessionService.Stub {
|
||||
|
||||
private final WeakReference<MediaSessionServiceImplBase> serviceImpl;
|
||||
private final WeakReference<MediaSessionServiceImpl> serviceImpl;
|
||||
|
||||
private final Handler handler;
|
||||
|
||||
private final MediaSessionManager mediaSessionManager;
|
||||
|
||||
public MediaSessionServiceStub(MediaSessionServiceImplBase serviceImpl) {
|
||||
public MediaSessionServiceStub(MediaSessionServiceImpl serviceImpl) {
|
||||
this.serviceImpl = new WeakReference<>(serviceImpl);
|
||||
Context context = checkStateNotNull(serviceImpl.getInstance());
|
||||
handler = new Handler(context.getMainLooper());
|
||||
@ -262,7 +253,7 @@ import java.util.Map;
|
||||
boolean shouldNotifyDisconnected = true;
|
||||
try {
|
||||
@Nullable
|
||||
MediaSessionServiceImplBase serviceImpl =
|
||||
MediaSessionServiceImpl serviceImpl =
|
||||
MediaSessionServiceStub.this.serviceImpl.get();
|
||||
if (serviceImpl == null) {
|
||||
return;
|
@ -40,11 +40,11 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
private static final String TAG = "MSSLegacyStub";
|
||||
|
||||
private final MediaSessionManager manager;
|
||||
private final MediaSession.MediaSessionImpl sessionImpl;
|
||||
private final MediaSessionImpl sessionImpl;
|
||||
private final ConnectedControllersManager<RemoteUserInfo> connectedControllersManager;
|
||||
|
||||
/** Creates a new instance. Caller must call {@link #initialize} to the instance. */
|
||||
public MediaSessionServiceLegacyStub(MediaSession.MediaSessionImpl sessionImpl) {
|
||||
public MediaSessionServiceLegacyStub(MediaSessionImpl sessionImpl) {
|
||||
super();
|
||||
manager = MediaSessionManager.getSessionManager(sessionImpl.getContext());
|
||||
this.sessionImpl = sessionImpl;
|
||||
|
@ -74,10 +74,8 @@ import androidx.media3.common.util.Log;
|
||||
import androidx.media3.common.util.Util;
|
||||
import androidx.media3.session.MediaLibraryService.LibraryParams;
|
||||
import androidx.media3.session.MediaLibraryService.MediaLibrarySession;
|
||||
import androidx.media3.session.MediaLibraryService.MediaLibrarySession.MediaLibrarySessionImpl;
|
||||
import androidx.media3.session.MediaSession.ControllerCb;
|
||||
import androidx.media3.session.MediaSession.ControllerInfo;
|
||||
import androidx.media3.session.MediaSession.MediaSessionImpl;
|
||||
import androidx.media3.session.SessionCommand.CommandCode;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
@ -99,11 +97,11 @@ import java.util.concurrent.ExecutionException;
|
||||
private static final String TAG = "MediaSessionStub";
|
||||
|
||||
private final Object lock;
|
||||
private final WeakReference<MediaSession.MediaSessionImpl> sessionImpl;
|
||||
private final WeakReference<MediaSessionImpl> sessionImpl;
|
||||
private final MediaSessionManager sessionManager;
|
||||
private final ConnectedControllersManager<IBinder> connectedControllersManager;
|
||||
|
||||
public MediaSessionStub(MediaSession.MediaSessionImpl sessionImpl) {
|
||||
public MediaSessionStub(MediaSessionImpl sessionImpl) {
|
||||
// Initialize default values.
|
||||
lock = new Object();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user