mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Post initial media button preferences update
Controller and browsers are typically obtained with Futures.addCallback(future, getMainExecutor()), which triggers the onSuccess callback with a message post. We currently send the initial media button preferences inline, causing the callback in MediaController.Listener.onMediaButtonPreferencesChanged to arrive before the FutureCallback.onSuccess callback. In the test controller app, which causes crashed when connecting to existing sessions for example. We can make this more robust by also posting the initial update of the media button preferences. PiperOrigin-RevId: 726923498
This commit is contained in:
parent
28bfb27fb5
commit
d5df227b3a
@ -1647,16 +1647,20 @@ import org.checkerframework.checker.initialization.qual.UnderInitialization;
|
|||||||
if (!oldControllerInfo.mediaButtonPreferences.equals(
|
if (!oldControllerInfo.mediaButtonPreferences.equals(
|
||||||
newControllerInfo.mediaButtonPreferences)) {
|
newControllerInfo.mediaButtonPreferences)) {
|
||||||
getInstance()
|
getInstance()
|
||||||
.notifyControllerListener(
|
.applicationHandler
|
||||||
listener -> {
|
.post(
|
||||||
ignoreFuture(
|
() ->
|
||||||
listener.onSetCustomLayout(
|
getInstance()
|
||||||
getInstance(), newControllerInfo.mediaButtonPreferences));
|
.notifyControllerListener(
|
||||||
listener.onCustomLayoutChanged(
|
listener -> {
|
||||||
getInstance(), newControllerInfo.mediaButtonPreferences);
|
ignoreFuture(
|
||||||
listener.onMediaButtonPreferencesChanged(
|
listener.onSetCustomLayout(
|
||||||
getInstance(), newControllerInfo.mediaButtonPreferences);
|
getInstance(), newControllerInfo.mediaButtonPreferences));
|
||||||
});
|
listener.onCustomLayoutChanged(
|
||||||
|
getInstance(), newControllerInfo.mediaButtonPreferences);
|
||||||
|
listener.onMediaButtonPreferencesChanged(
|
||||||
|
getInstance(), newControllerInfo.mediaButtonPreferences);
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user