Merge "Fix the finding logic of MediaButtonSession" into oc-dev
This commit is contained in:
@@ -319,6 +319,15 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
|
|||||||
return mIsActive && !mDestroyed;
|
return mIsActive && !mDestroyed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the playback state.
|
||||||
|
*
|
||||||
|
* @return The current playback state.
|
||||||
|
*/
|
||||||
|
public PlaybackState getPlaybackState() {
|
||||||
|
return mPlaybackState;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the session is currently performing playback.
|
* Check if the session is currently performing playback.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ class MediaSessionStack {
|
|||||||
mCachedVolumeDefault = null;
|
mCachedVolumeDefault = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// In most cases, playback state isn't needed for finding media buttion session,
|
// In most cases, playback state isn't needed for finding media button session,
|
||||||
// but we only use it as a hint if an app has multiple local media sessions.
|
// but we only use it as a hint if an app has multiple local media sessions.
|
||||||
// In that case, we pick the media session whose PlaybackState matches
|
// In that case, we pick the media session whose PlaybackState matches
|
||||||
// the audio playback configuration.
|
// the audio playback configuration.
|
||||||
@@ -204,8 +204,9 @@ class MediaSessionStack {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Find the media button session with the given {@param uid}.
|
* 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
|
* If the app has multiple media sessions, the media session whose playback state is not null
|
||||||
* becomes the media button session.
|
* and matches the audio playback state becomes the media button session. Otherwise the top
|
||||||
|
* priority session becomes the media button session.
|
||||||
*
|
*
|
||||||
* @return The media button session. Returns {@code null} if the app doesn't have a media
|
* @return The media button session. Returns {@code null} if the app doesn't have a media
|
||||||
* session.
|
* session.
|
||||||
@@ -214,7 +215,7 @@ class MediaSessionStack {
|
|||||||
MediaSessionRecord mediaButtonSession = null;
|
MediaSessionRecord mediaButtonSession = null;
|
||||||
for (MediaSessionRecord session : mSessions) {
|
for (MediaSessionRecord session : mSessions) {
|
||||||
if (uid == session.getUid()) {
|
if (uid == session.getUid()) {
|
||||||
if (session.isPlaybackActive() ==
|
if (session.getPlaybackState() != null && session.isPlaybackActive() ==
|
||||||
mAudioPlaybackMonitor.isPlaybackActive(session.getUid())) {
|
mAudioPlaybackMonitor.isPlaybackActive(session.getUid())) {
|
||||||
// If there's a media session whose PlaybackState matches
|
// If there's a media session whose PlaybackState matches
|
||||||
// the audio playback state, return it immediately.
|
// the audio playback state, return it immediately.
|
||||||
|
|||||||
Reference in New Issue
Block a user