Merge "MediaSessionService: Nullify the media button sesison when it's removed" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
3d5f41bb03
@@ -121,9 +121,12 @@ class MediaSessionStack {
|
||||
public void removeSession(MediaSessionRecord record) {
|
||||
mSessions.remove(record);
|
||||
if (mMediaButtonSession == record) {
|
||||
// When the media button session is gone, try to find the alternative media session
|
||||
// in the media button session app.
|
||||
onMediaSessionChangeInMediaButtonSessionApp();
|
||||
// When the media button session is removed, nullify the media button session and do not
|
||||
// search for the alternative media session within the app. It's because the alternative
|
||||
// media session might be a dummy which isn't able to handle the media key events.
|
||||
mOnMediaButtonSessionChangedListener.onMediaButtonSessionChanged(
|
||||
mMediaButtonSession, null);
|
||||
mMediaButtonSession = null;
|
||||
}
|
||||
clearCache(record.getUserId());
|
||||
}
|
||||
@@ -157,7 +160,13 @@ class MediaSessionStack {
|
||||
// In that case, we pick the media session whose PlaybackState matches
|
||||
// the audio playback configuration.
|
||||
if (mMediaButtonSession != null && mMediaButtonSession.getUid() == record.getUid()) {
|
||||
onMediaSessionChangeInMediaButtonSessionApp();
|
||||
MediaSessionRecord newMediaButtonSession =
|
||||
findMediaButtonSession(mMediaButtonSession.getUid());
|
||||
if (newMediaButtonSession != mMediaButtonSession) {
|
||||
mOnMediaButtonSessionChangedListener.onMediaButtonSessionChanged(
|
||||
mMediaButtonSession, newMediaButtonSession);
|
||||
mMediaButtonSession = newMediaButtonSession;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,22 +208,6 @@ class MediaSessionStack {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the change in a media session in the media button session app.
|
||||
* <p>If the app has multiple media sessions, change in a media sesion in the app may change
|
||||
* the media button session.
|
||||
* @see #findMediaButtonSession
|
||||
*/
|
||||
private void onMediaSessionChangeInMediaButtonSessionApp() {
|
||||
MediaSessionRecord newMediaButtonSession =
|
||||
findMediaButtonSession(mMediaButtonSession.getUid());
|
||||
if (newMediaButtonSession != mMediaButtonSession) {
|
||||
mOnMediaButtonSessionChangedListener.onMediaButtonSessionChanged(mMediaButtonSession,
|
||||
newMediaButtonSession);
|
||||
mMediaButtonSession = newMediaButtonSession;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the media button session with the given {@param uid}.
|
||||
* If the app has multiple media sessions, the media session matches the audio playback state
|
||||
|
||||
Reference in New Issue
Block a user