Commit cc6c6aa6 by bachinger Committed by microkatz

Call callback future listeners on app handler

Calling maybeUpdateLegacyErrorState potentially creates a new legacy playback
state which involves calling player methods. This change makes sure that the call
sites of `maybeUpdateLegacyErrorState` are called on the app thread as enforced by
the library.

PiperOrigin-RevId: 476406282
(cherry picked from commit 74124f48)
parent e1b947ec
...@@ -18,6 +18,7 @@ package androidx.media3.session; ...@@ -18,6 +18,7 @@ package androidx.media3.session;
import static androidx.media3.common.util.Assertions.checkNotNull; import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.common.util.Assertions.checkState; import static androidx.media3.common.util.Assertions.checkState;
import static androidx.media3.common.util.Assertions.checkStateNotNull; import static androidx.media3.common.util.Assertions.checkStateNotNull;
import static androidx.media3.common.util.Util.postOrRun;
import static androidx.media3.session.LibraryResult.RESULT_ERROR_SESSION_AUTHENTICATION_EXPIRED; import static androidx.media3.session.LibraryResult.RESULT_ERROR_SESSION_AUTHENTICATION_EXPIRED;
import static androidx.media3.session.LibraryResult.RESULT_SUCCESS; import static androidx.media3.session.LibraryResult.RESULT_SUCCESS;
import static androidx.media3.session.MediaConstants.ERROR_CODE_AUTHENTICATION_EXPIRED_COMPAT; import static androidx.media3.session.MediaConstants.ERROR_CODE_AUTHENTICATION_EXPIRED_COMPAT;
...@@ -129,7 +130,7 @@ import java.util.concurrent.Future; ...@@ -129,7 +130,7 @@ import java.util.concurrent.Future;
maybeUpdateLegacyErrorState(result); maybeUpdateLegacyErrorState(result);
} }
}, },
MoreExecutors.directExecutor()); (Runnable r) -> postOrRun(getApplicationHandler(), r));
return future; return future;
} }
...@@ -149,7 +150,7 @@ import java.util.concurrent.Future; ...@@ -149,7 +150,7 @@ import java.util.concurrent.Future;
verifyResultItems(result, pageSize); verifyResultItems(result, pageSize);
} }
}, },
MoreExecutors.directExecutor()); (Runnable r) -> postOrRun(getApplicationHandler(), r));
return future; return future;
} }
...@@ -164,7 +165,7 @@ import java.util.concurrent.Future; ...@@ -164,7 +165,7 @@ import java.util.concurrent.Future;
maybeUpdateLegacyErrorState(result); maybeUpdateLegacyErrorState(result);
} }
}, },
MoreExecutors.directExecutor()); (Runnable r) -> postOrRun(getApplicationHandler(), r));
return future; return future;
} }
...@@ -226,7 +227,7 @@ import java.util.concurrent.Future; ...@@ -226,7 +227,7 @@ import java.util.concurrent.Future;
maybeUpdateLegacyErrorState(result); maybeUpdateLegacyErrorState(result);
} }
}, },
MoreExecutors.directExecutor()); (Runnable r) -> postOrRun(getApplicationHandler(), r));
return future; return future;
} }
...@@ -246,7 +247,7 @@ import java.util.concurrent.Future; ...@@ -246,7 +247,7 @@ import java.util.concurrent.Future;
verifyResultItems(result, pageSize); verifyResultItems(result, pageSize);
} }
}, },
MoreExecutors.directExecutor()); (Runnable r) -> postOrRun(getApplicationHandler(), r));
return future; return future;
} }
......
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