From 745e28cb0b52eaf93da752af2b70062f5ff3ca89 Mon Sep 17 00:00:00 2001 From: Jaewan Kim Date: Wed, 10 May 2017 20:14:35 +0900 Subject: [PATCH] Don't ignore remote media sessions when sending media key events According to our new media button handling logic, we don't prioritize media session for the remote playback. (i.e. Casting) It's because users will expect change in headset/earphone where the media buttons are attached. However, when a Bluetooth device is connected, media sessions in an app built with the support library older than 25.4 is considered as remote playback by MediaRouter.setMediaSessionCompat(MediaSessionCompat). So we shouldn't exclude remote media sessions when sending media key. This change will still keep our policy because app with the actual remote playback wouldn't report AudioPlaybackConfiguration, and it will be ignored anyway. Bug: 38191402 Test: Run CTS (MediaSessionTest, and MediaSessionManagerTest) and manual tests as follows 1. Confirmed that apps built with older support library can receive receive the media key events when a Bluetooth headset/earphone is connected). 2. Confirmed that apps with remote playback (i.e. cast) doesn't receive media key events neither by Bluetooth nor wired headset. Change-Id: I8e2e0babc43460aa497b5edc5e4fb98f986783cf --- .../java/com/android/server/media/MediaSessionStack.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/media/MediaSessionStack.java b/services/core/java/com/android/server/media/MediaSessionStack.java index 0e69bca9dfd11..cd0da795ce153 100644 --- a/services/core/java/com/android/server/media/MediaSessionStack.java +++ b/services/core/java/com/android/server/media/MediaSessionStack.java @@ -219,11 +219,7 @@ class MediaSessionStack { private MediaSessionRecord findMediaButtonSession(int uid) { MediaSessionRecord mediaButtonSession = null; for (MediaSessionRecord session : mSessions) { - // Since the media buttons come with the headset/speaker, users will expect changes in - // the headset/speaker when they press media buttons. So only consider local playback - // for the media button session. - if (uid == session.getUid() - && session.getPlaybackType() == PlaybackInfo.PLAYBACK_TYPE_LOCAL) { + if (uid == session.getUid()) { if (session.isPlaybackActive() == mAudioPlaybackMonitor.isPlaybackActive(session.getUid())) { // If there's a media session whose PlaybackState matches