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

Commit 4024d1c1 authored by Rohit Singh's avatar Rohit Singh Committed by Linux Build Service Account
Browse files

Bluetooth: Changes to support AVRCP 1.5

Provide support for AVRCP1.5 so that remote controller
is able to browse the list of available media players
on DUT and select the media player from the available
list of players, from remote.

Change-Id: Ia1a340d1efaa16091e684f6ff7c738ce0accaee3
(cherry picked from commit 22af77236fccc546c6bec3956b0027fc1642ba1c)
(cherry picked from commit c9bc05d824197921a44d862026b3bc352d0f6a27)
(cherry picked from commit 3fad1502e08b9ccc7ecfd3f35be4b38190d9aa81)
parent 79a3b461
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -201,6 +201,28 @@ public class AudioManager {
    public static final String EXTRA_MASTER_VOLUME_MUTED =
        "android.media.EXTRA_MASTER_VOLUME_MUTED";


    /**
     * @hide Broadcast intent when RemoteControlClient list is updated.
     */
    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
    public static final String RCC_CHANGED_ACTION = "org.codeaurora.bluetooth.RCC_CHANGED_ACTION";

    /**
     * @hide Used for sharing the calling package name
     */
    public static final String EXTRA_CALLING_PACKAGE_NAME = "org.codeaurora.bluetooth.EXTRA_CALLING_PACKAGE_NAME";

    /**
     * @hide Used for sharing the focus changed value
     */
    public static final String EXTRA_FOCUS_CHANGED_VALUE = "org.codeaurora.bluetooth.EXTRA_FOCUS_CHANGED_VALUE";

    /**
     * @hide Used for sharing the availability changed value
     */
    public static final String EXTRA_AVAILABLITY_CHANGED_VALUE = "org.codeaurora.bluetooth.EXTRA_AVAILABLITY_CHANGED_VALUE";

    /** The audio stream for phone calls */
    public static final int STREAM_VOICE_CALL = AudioSystem.STREAM_VOICE_CALL;
    /** The audio stream for system sounds */
+1 −1
Original line number Diff line number Diff line
@@ -1139,7 +1139,7 @@ public class AudioService extends IAudioService.Stub {
        return delta;
    }

    private void sendBroadcastToAll(Intent intent) {
    protected void sendBroadcastToAll(Intent intent) {
        final long ident = Binder.clearCallingIdentity();
        try {
            mContext.sendBroadcastAsUser(intent, UserHandle.ALL);
+53 −1
Original line number Diff line number Diff line
@@ -1635,10 +1635,37 @@ public class MediaFocusControl implements OnFinished {
        }
    }


    //==========================================================================================
    // Remote control display / client
    //==========================================================================================
    /**
     * Update the remote control displays with the new "focused" client generation
     */
    private void updateDisplaysOnRCCUpdate_syncRcsCurrc(
                        RemoteControlStackEntry rcse, boolean isFocussed, boolean isAvailable) {
        synchronized(mRCStack) {
            try {
                Intent intent = new Intent(AudioManager.RCC_CHANGED_ACTION);
                intent.putExtra(AudioManager.EXTRA_CALLING_PACKAGE_NAME, rcse.mCallingPackageName);
                intent.putExtra(AudioManager.EXTRA_FOCUS_CHANGED_VALUE, isFocussed);
                intent.putExtra(AudioManager.EXTRA_AVAILABLITY_CHANGED_VALUE, isAvailable);
                mAudioService.sendBroadcastToAll(intent);
                Log.v(TAG, "updating focussed RCC change to RCD: CallingPackageName:"
                        + rcse.mCallingPackageName + " isFocussed:" + isFocussed + " isAvailable:"
                        + isAvailable);
            } catch (Exception e) {
                Log.e(TAG, "Error while updating focussed RCC change",e);
            }
        }
    }


    /**
     * Called when processing MSG_RCDISPLAY_UPDATE event
     */
    private void onRcDisplayUpdate(RemoteControlStackEntry rcse, int flags /* USED ?*/) {
        if (DEBUG_RC) Log.d(TAG, "onRcDisplayUpdate:");
        synchronized(mRCStack) {
            synchronized(mCurrentRcLock) {
                if ((mCurrentRcClient != null) && (mCurrentRcClient.equals(rcse.mRcClient))) {
@@ -1650,7 +1677,8 @@ public class MediaFocusControl implements OnFinished {
                    setNewRcClient_syncRcsCurrc(mCurrentRcClientGen,
                            rcse.mMediaIntent /*newMediaIntent*/,
                            false /*clearing*/);

                    updateDisplaysOnRCCUpdate_syncRcsCurrc(rcse, true, true);
                    if (DEBUG_RC) Log.v(TAG, "update RCC focus change in onRcDisplayUpdate");
                    // tell the current client that it needs to send info
                    try {
                        //TODO change name to informationRequestForAllDisplays()
@@ -1950,6 +1978,8 @@ public class MediaFocusControl implements OnFinished {
                            // 1/ give the new client the displays (if any)
                            if (mRcDisplays.size() > 0) {
                                plugRemoteControlDisplaysIntoClient_syncRcStack(rcse.mRcClient);
                                updateDisplaysOnRCCUpdate_syncRcsCurrc(rcse, false, true);
                                if (DEBUG_RC) Log.v(TAG, "update on RCC availability");
                            }
                            // 2/ monitor the new client's death
                            IBinder b = rcse.mRcClient.asBinder();
@@ -1999,6 +2029,9 @@ public class MediaFocusControl implements OnFinished {
                            // we found the IRemoteControlClient to unregister
                            // stop monitoring its death
                            rcse.unlinkToRcClientDeath();
                            // update RCD on the unavailability of new RCC
                            updateDisplaysOnRCCUpdate_syncRcsCurrc(rcse, false, false);
                            if (DEBUG_RC) Log.v(TAG, "update on RCC availability from unregister");
                            // reset the client-related fields
                            rcse.mRcClient = null;
                            rcse.mCallingPackageName = null;
@@ -2180,11 +2213,30 @@ public class MediaFocusControl implements OnFinished {
                    if(rcse.mRcClient != null) {
                        try {
                            rcse.mRcClient.plugRemoteControlDisplay(rcd, w, h);
                            // Notify newly launched RCD regarding availability of Launched RCCs
                            if (DEBUG_RC) Log.v(TAG, "update RCD on RCC availability");
                            if (DEBUG_RC) Log.v(TAG, "packageName:" + rcse.mCallingPackageName);
                            updateDisplaysOnRCCUpdate_syncRcsCurrc(rcse, false, true);
                        } catch (RemoteException e) {
                            Log.e(TAG, "Error connecting RCD to client: ", e);
                        }
                    }
                }
                try {
                    // As top of RCC stack entry represents the focussed RCC, intimate RCD regarding the same
                    RemoteControlStackEntry rcse = mRCStack.peek();
                    if (rcse != null && rcse.mCallingPackageName != null) {
                        // Notify newly launched RCD regarding Focussed RCC
                        if (DEBUG_RC) Log.v(TAG, "update RCD on RCC focus change");
                        if (DEBUG_RC) Log.v(TAG, "packageName:" + rcse.mCallingPackageName);
                        updateDisplaysOnRCCUpdate_syncRcsCurrc(rcse, true, true);
                    } else {
                        if (DEBUG_RC) Log.v(TAG, "top of RCC stack not found");
                    }
                } catch (Exception e) {
                    Log.e(TAG, "Error updating focussed RCC to RCD ", e);
                }


                // we have a new display, of which all the clients are now aware: have it be
                // initialized wih the current gen ID and the current client info, do not