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

Commit 0e84d9c8 authored by Ajay Panicker's avatar Ajay Panicker Committed by Jack He
Browse files

AVRCP: Ignore addressed player changed to telecom

* During a phone call, com.android.server.telecom is chosen by the media
  framework as the addressed player. It listens to media button presses
  to control various call functions.
* Bluetooth uses Hands Free Profile (HFP) instead of media buttons to
  control phone calls. Therefore, Bluetooth does not need to interact
  with telecom's HeadsetMediaButton during a call.
* Moreover, switching addressed player during SCO codec negotiation
  confuses some car kits, making HFP not functional.
* This CL ignores addressed player change to telecom.

Bug: 64043110
Test: Make a phone call while playing music, AVRCP and HFP regression
Change-Id: If01b84275f8aab23d793e321f71b6b46e8e926aa
parent d1c7ec94
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1641,6 +1641,10 @@ public final class Avrcp {
            updateCurrentController(0, mCurrBrowsePlayerID);
            return;
        }
        if (packageName.equals("com.android.server.telecom")) {
            Log.d(TAG, "Ignore addressed media session change to telecom");
            return;
        }
        // No change.
        if (getPackageName(mCurrAddrPlayerID).equals(packageName)) return;
        if (DEBUG) Log.v(TAG, "Changing addressed media session to " + packageName);
@@ -1667,6 +1671,10 @@ public final class Avrcp {
    private void setActiveMediaSession(MediaSession.Token token) {
        android.media.session.MediaController activeController =
                new android.media.session.MediaController(mContext, token);
        if (activeController.getPackageName().equals("com.android.server.telecom")) {
            Log.d(TAG, "Ignore active media session change to telecom");
            return;
        }
        if (DEBUG) Log.v(TAG, "Set active media session " + activeController.getPackageName());
        addMediaPlayerController(activeController);
        setAddressedMediaSessionPackage(activeController.getPackageName());
@@ -1805,6 +1813,10 @@ public final class Avrcp {
        int updateId = -1;
        boolean updated = false;
        boolean currentRemoved = false;
        if (info.getPackageName().equals("com.android.server.telecom")) {
            Log.d(TAG, "Skip adding telecom to the media player info list");
            return updated;
        }
        synchronized (mMediaPlayerInfoList) {
            for (Map.Entry<Integer, MediaPlayerInfo> entry : mMediaPlayerInfoList.entrySet()) {
                MediaPlayerInfo current = entry.getValue();