Commit f4989f5d by olly Committed by Ian Baker

Forward callback invocations to MediaLibrarySessionImpl

This is required for correct subscription notifications, as per the
referenced bug. It also just seems better to plumb things this way
in general, rather than re-implementing the functionality in the stub.

PiperOrigin-RevId: 413963824
parent 41a2f9a6
...@@ -97,12 +97,7 @@ import java.util.concurrent.atomic.AtomicReference; ...@@ -97,12 +97,7 @@ import java.util.concurrent.atomic.AtomicReference;
postOrRun( postOrRun(
librarySessionImpl.getApplicationHandler(), librarySessionImpl.getApplicationHandler(),
() -> { () -> {
futureReference.set( futureReference.set(librarySessionImpl.onGetLibraryRootOnHandler(controller, params));
checkNotNull(
librarySessionImpl
.getCallback()
.onGetLibraryRoot(librarySessionImpl.getInstance(), controller, params),
"onGetLibraryRoot must return non-null future"));
haveFuture.open(); haveFuture.open();
}); });
@Nullable LibraryResult<MediaItem> result = null; @Nullable LibraryResult<MediaItem> result = null;
...@@ -143,10 +138,7 @@ import java.util.concurrent.atomic.AtomicReference; ...@@ -143,10 +138,7 @@ import java.util.concurrent.atomic.AtomicReference;
@Nullable @Nullable
LibraryParams params = LibraryParams params =
MediaUtils.convertToLibraryParams(librarySessionImpl.getContext(), option); MediaUtils.convertToLibraryParams(librarySessionImpl.getContext(), option);
ignoreFuture( ignoreFuture(librarySessionImpl.onSubscribeOnHandler(controller, id, params));
librarySessionImpl
.getCallback()
.onSubscribe(librarySessionImpl.getInstance(), controller, id, params));
}); });
} }
...@@ -168,10 +160,7 @@ import java.util.concurrent.atomic.AtomicReference; ...@@ -168,10 +160,7 @@ import java.util.concurrent.atomic.AtomicReference;
controller, SessionCommand.COMMAND_CODE_LIBRARY_UNSUBSCRIBE)) { controller, SessionCommand.COMMAND_CODE_LIBRARY_UNSUBSCRIBE)) {
return; return;
} }
ignoreFuture( ignoreFuture(librarySessionImpl.onUnsubscribeOnHandler(controller, id));
librarySessionImpl
.getCallback()
.onUnsubscribe(librarySessionImpl.getInstance(), controller, id));
}); });
} }
...@@ -216,17 +205,8 @@ import java.util.concurrent.atomic.AtomicReference; ...@@ -216,17 +205,8 @@ import java.util.concurrent.atomic.AtomicReference;
LibraryParams params = LibraryParams params =
MediaUtils.convertToLibraryParams(librarySessionImpl.getContext(), options); MediaUtils.convertToLibraryParams(librarySessionImpl.getContext(), options);
ListenableFuture<LibraryResult<ImmutableList<MediaItem>>> future = ListenableFuture<LibraryResult<ImmutableList<MediaItem>>> future =
checkNotNull( librarySessionImpl.onGetChildrenOnHandler(
librarySessionImpl controller, parentId, page, pageSize, params);
.getCallback()
.onGetChildren(
librarySessionImpl.getInstance(),
controller,
parentId,
page,
pageSize,
params),
"onGetChildren must return non-null future");
sendLibraryResultWithMediaItemsWhenReady(result, future); sendLibraryResultWithMediaItemsWhenReady(result, future);
return; return;
} }
...@@ -239,17 +219,12 @@ import java.util.concurrent.atomic.AtomicReference; ...@@ -239,17 +219,12 @@ import java.util.concurrent.atomic.AtomicReference;
} }
// A MediaBrowserCompat called loadChildren with no pagination option. // A MediaBrowserCompat called loadChildren with no pagination option.
ListenableFuture<LibraryResult<ImmutableList<MediaItem>>> future = ListenableFuture<LibraryResult<ImmutableList<MediaItem>>> future =
checkNotNull( librarySessionImpl.onGetChildrenOnHandler(
librarySessionImpl controller,
.getCallback() parentId,
.onGetChildren( /* page= */ 0,
librarySessionImpl.getInstance(), /* pageSize= */ Integer.MAX_VALUE,
controller, /* extras= */ null);
parentId,
/* page= */ 0,
/* pageSize= */ Integer.MAX_VALUE,
/* extras= */ null),
"onGetChildren must return non-null future");
sendLibraryResultWithMediaItemsWhenReady(result, future); sendLibraryResultWithMediaItemsWhenReady(result, future);
}); });
} }
...@@ -277,11 +252,7 @@ import java.util.concurrent.atomic.AtomicReference; ...@@ -277,11 +252,7 @@ import java.util.concurrent.atomic.AtomicReference;
return; return;
} }
ListenableFuture<LibraryResult<MediaItem>> future = ListenableFuture<LibraryResult<MediaItem>> future =
checkNotNull( librarySessionImpl.onGetItemOnHandler(controller, itemId);
librarySessionImpl
.getCallback()
.onGetItem(librarySessionImpl.getInstance(), controller, itemId),
"onGetItem must return non-null future");
sendLibraryResultWithMediaItemWhenReady(result, future); sendLibraryResultWithMediaItemWhenReady(result, future);
}); });
} }
...@@ -316,10 +287,7 @@ import java.util.concurrent.atomic.AtomicReference; ...@@ -316,10 +287,7 @@ import java.util.concurrent.atomic.AtomicReference;
@Nullable @Nullable
LibraryParams params = LibraryParams params =
MediaUtils.convertToLibraryParams(librarySessionImpl.getContext(), extras); MediaUtils.convertToLibraryParams(librarySessionImpl.getContext(), extras);
ignoreFuture( ignoreFuture(librarySessionImpl.onSearchOnHandler(controller, query, params));
librarySessionImpl
.getCallback()
.onSearch(librarySessionImpl.getInstance(), controller, query, params));
// Actual search result will be sent by notifySearchResultChanged(). // Actual search result will be sent by notifySearchResultChanged().
}); });
} }
...@@ -526,17 +494,8 @@ import java.util.concurrent.atomic.AtomicReference; ...@@ -526,17 +494,8 @@ import java.util.concurrent.atomic.AtomicReference;
MediaUtils.convertToLibraryParams( MediaUtils.convertToLibraryParams(
librarySessionImpl.getContext(), request.extras); librarySessionImpl.getContext(), request.extras);
ListenableFuture<LibraryResult<ImmutableList<MediaItem>>> future = ListenableFuture<LibraryResult<ImmutableList<MediaItem>>> future =
checkNotNull( librarySessionImpl.onGetSearchResultOnHandler(
librarySessionImpl request.controller, request.query, page, pageSize, libraryParams);
.getCallback()
.onGetSearchResult(
librarySessionImpl.getInstance(),
request.controller,
request.query,
page,
pageSize,
libraryParams),
"onGetSearchResult must return non-null future");
sendLibraryResultWithMediaItemsWhenReady(request.result, future); sendLibraryResultWithMediaItemsWhenReady(request.result, future);
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment