Skip to content

Commit

Permalink
Call future listener on the same handler that created the controller
Browse files Browse the repository at this point in the history
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
  • Loading branch information
marcbaechinger authored and icbaker committed Nov 24, 2022
1 parent a32b82f commit 68908be
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
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;
Expand Down Expand Up @@ -206,7 +205,7 @@ private MediaController createControllerOnHandler(
controllerCreationListener.onCreated(mediaController);
}
},
MoreExecutors.directExecutor());
handlerThreadTestRule.getHandler()::post);
}
return future.get(timeoutMs, MILLISECONDS);
}
Expand Down

0 comments on commit 68908be

Please sign in to comment.