Register playbackstate callback after autoplay
Bug: 145331204
Test: Manual
Change-Id: I9a64d9ef4c6736077d4b2b4be66d01dadbd9c323
(cherry picked from commit 15b49aadbdfc4121252048db7a931341a0e5dab0)
diff --git a/service/src/com/android/car/CarMediaService.java b/service/src/com/android/car/CarMediaService.java
index ee6c643..9f57179 100644
--- a/service/src/com/android/car/CarMediaService.java
+++ b/service/src/com/android/car/CarMediaService.java
@@ -530,8 +530,6 @@
mActiveUserMediaController = null;
mPreviousMediaComponent = mPrimaryMediaComponent;
mPrimaryMediaComponent = componentName;
- updateActiveMediaController(mMediaSessionManager
- .getActiveSessionsForUser(null, ActivityManager.getCurrentUser()));
if (mPrimaryMediaComponent != null && !TextUtils.isEmpty(
mPrimaryMediaComponent.flattenToString())) {
@@ -546,8 +544,11 @@
startMediaConnectorService(shouldStartPlayback(mPlayOnMediaSourceChangedConfig),
new UserHandle(mCurrentUser));
// Reset current playback state for the new source, in the case that the app is in an error
- // state (e.g. not signed in). This state will be updated when the app begins playback.
+ // state (e.g. not signed in). This state will be updated from the app callback registered
+ // below, to make sure mCurrentPlaybackState reflects the current source only.
mCurrentPlaybackState = PlaybackState.STATE_NONE;
+ updateActiveMediaController(mMediaSessionManager
+ .getActiveSessionsForUser(null, ActivityManager.getCurrentUser()));
}
private void notifyListeners() {