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 74124f48ea838fcdb436726ba8337e82abc7552e)
This commit is contained in:
bachinger 2022-09-23 17:34:25 +00:00 committed by microkatz
parent e1b947ec92
commit cc6c6aa62b

View File

@ -18,6 +18,7 @@ package androidx.media3.session;
import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.common.util.Assertions.checkState;
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_SUCCESS;
import static androidx.media3.session.MediaConstants.ERROR_CODE_AUTHENTICATION_EXPIRED_COMPAT;
@ -129,7 +130,7 @@ import java.util.concurrent.Future;
maybeUpdateLegacyErrorState(result);
}
},
MoreExecutors.directExecutor());
(Runnable r) -> postOrRun(getApplicationHandler(), r));
return future;
}
@ -149,7 +150,7 @@ import java.util.concurrent.Future;
verifyResultItems(result, pageSize);
}
},
MoreExecutors.directExecutor());
(Runnable r) -> postOrRun(getApplicationHandler(), r));
return future;
}
@ -164,7 +165,7 @@ import java.util.concurrent.Future;
maybeUpdateLegacyErrorState(result);
}
},
MoreExecutors.directExecutor());
(Runnable r) -> postOrRun(getApplicationHandler(), r));
return future;
}
@ -226,7 +227,7 @@ import java.util.concurrent.Future;
maybeUpdateLegacyErrorState(result);
}
},
MoreExecutors.directExecutor());
(Runnable r) -> postOrRun(getApplicationHandler(), r));
return future;
}
@ -246,7 +247,7 @@ import java.util.concurrent.Future;
verifyResultItems(result, pageSize);
}
},
MoreExecutors.directExecutor());
(Runnable r) -> postOrRun(getApplicationHandler(), r));
return future;
}