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 68908be18d)
This commit is contained in:
bachinger 2022-11-23 13:39:26 +00:00 committed by christosts
parent a98efd8b97
commit 0ba58cc634

View file

@ -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);
}