Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 745e28cb authored by Jaewan Kim's avatar Jaewan Kim
Browse files

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
parent cc416b6c
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -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