From 0ba58cc6341d59cb4b9033037ca1d1cd4e22fa75 Mon Sep 17 00:00:00 2001 From: bachinger Date: Wed, 23 Nov 2022 13:39:26 +0000 Subject: [PATCH] Call future listener on the same handler that created the controller The direct executor is not the proper way to determine on what thread to run the `Future.Listener` and the `MediaControllerCreationListener` because the listener may call the controller passed as argument which must happen on the same thread that built the controller. This change makes sure this is the case. PiperOrigin-RevId: 490478587 (cherry picked from commit 68908be18d0a46478be05ad406a5027c15c38723) --- .../java/androidx/media3/session/MediaControllerTestRule.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerTestRule.java b/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerTestRule.java index d7cb969585..e2864b8a49 100644 --- a/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerTestRule.java +++ b/libraries/test_session_current/src/androidTest/java/androidx/media3/session/MediaControllerTestRule.java @@ -29,7 +29,6 @@ import androidx.media3.common.util.Log; import androidx.media3.test.session.common.HandlerThreadTestRule; import androidx.test.core.app.ApplicationProvider; import com.google.common.util.concurrent.ListenableFuture; -import com.google.common.util.concurrent.MoreExecutors; import java.util.Map; import java.util.concurrent.ExecutionException; import org.junit.rules.ExternalResource; @@ -206,7 +205,7 @@ public final class MediaControllerTestRule extends ExternalResource { controllerCreationListener.onCreated(mediaController); } }, - MoreExecutors.directExecutor()); + handlerThreadTestRule.getHandler()::post); } return future.get(timeoutMs, MILLISECONDS); }