Commit 0ba58cc6 by bachinger Committed by christosts

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 68908be1)
parent a98efd8b
...@@ -29,7 +29,6 @@ import androidx.media3.common.util.Log; ...@@ -29,7 +29,6 @@ import androidx.media3.common.util.Log;
import androidx.media3.test.session.common.HandlerThreadTestRule; import androidx.media3.test.session.common.HandlerThreadTestRule;
import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import org.junit.rules.ExternalResource; import org.junit.rules.ExternalResource;
...@@ -206,7 +205,7 @@ public final class MediaControllerTestRule extends ExternalResource { ...@@ -206,7 +205,7 @@ public final class MediaControllerTestRule extends ExternalResource {
controllerCreationListener.onCreated(mediaController); controllerCreationListener.onCreated(mediaController);
} }
}, },
MoreExecutors.directExecutor()); handlerThreadTestRule.getHandler()::post);
} }
return future.get(timeoutMs, MILLISECONDS); return future.get(timeoutMs, MILLISECONDS);
} }
......
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