Return null if media notification controller Future is not done
When the media notification controller is requested for a session with `getConnectedControllerForSession` and the `Future` is not null but not yet completed, the `Future` was returned either way. This was reported as creating a race condition between the notification being requested for update the very first time, and the media notification controller having completed connecting to the session. Returning null from `getConnectedControllerForSession` when the `Future` is available but not yet done fixes the problem. This is safe because for the case when a notification update is dropped, the media notification controller will trigger the update as soon as the connection completes. Issue: androidx/media#917 #minor-release PiperOrigin-RevId: 595699929
This commit is contained in:
parent
1cb6865884
commit
5c50b27e8f
@ -123,6 +123,9 @@
|
||||
* Fix a bug where setting a negative time for a disabled `setWhen` timer
|
||||
of the notification caused a crash on some devices
|
||||
([#903](https://github.com/androidx/media/issues/903)).
|
||||
* Fix `IllegalStateException` when the media notification controller
|
||||
hasn't completed connecting when the first notification update is
|
||||
requested ([#917](https://github.com/androidx/media/issues/917)).
|
||||
* UI:
|
||||
* Fix issue where forward and rewind buttons are not visible when used
|
||||
with Material Design in a BottomSheetDialogFragment
|
||||
|
@ -260,7 +260,7 @@ import java.util.concurrent.TimeoutException;
|
||||
@Nullable
|
||||
private MediaController getConnectedControllerForSession(MediaSession session) {
|
||||
ListenableFuture<MediaController> controller = controllerMap.get(session);
|
||||
if (controller == null) {
|
||||
if (controller == null || !controller.isDone()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user