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:
tonihei 2025-02-14 07:37:52 -08:00 committed by Copybara-Service
parent 28bfb27fb5
commit d5df227b3a

View File

@ -1646,6 +1646,10 @@ import org.checkerframework.checker.initialization.qual.UnderInitialization;
getInstance().notifyAccepted();
if (!oldControllerInfo.mediaButtonPreferences.equals(
newControllerInfo.mediaButtonPreferences)) {
getInstance()
.applicationHandler
.post(
() ->
getInstance()
.notifyControllerListener(
listener -> {
@ -1656,7 +1660,7 @@ import org.checkerframework.checker.initialization.qual.UnderInitialization;
getInstance(), newControllerInfo.mediaButtonPreferences);
listener.onMediaButtonPreferencesChanged(
getInstance(), newControllerInfo.mediaButtonPreferences);
});
}));
}
return;
}