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

Commit c024cec3 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "AVRCP 1.6 CT implementation"

parents 890334b2 2df89213
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -316,7 +316,7 @@
        </service>
        </service>
        <service
        <service
            android:process="@string/process"
            android:process="@string/process"
            android:name = ".avrcp.AvrcpControllerService"
            android:name = ".avrcpcontroller.AvrcpControllerService"
            android:enabled="@bool/profile_supported_avrcp_controller">
            android:enabled="@bool/profile_supported_avrcp_controller">
            <intent-filter>
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothAvrcpController" />
                <action android:name="android.bluetooth.IBluetoothAvrcpController" />
+398 −34

File changed.

Preview size limit exceeded, changes collapsed.

+7 −6
Original line number Original line Diff line number Diff line
@@ -17,13 +17,14 @@
package com.android.bluetooth.a2dpsink;
package com.android.bluetooth.a2dpsink;


import android.bluetooth.BluetoothAudioConfig;
import android.bluetooth.BluetoothAudioConfig;
import android.bluetooth.BluetoothAvrcpController;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.IBluetoothA2dpSink;
import android.bluetooth.IBluetoothA2dpSink;
import android.content.Intent;
import android.content.Intent;
import android.provider.Settings;
import android.provider.Settings;
import android.util.Log;
import android.util.Log;

import com.android.bluetooth.avrcpcontroller.AvrcpControllerService;
import com.android.bluetooth.a2dpsink.mbs.A2dpMediaBrowserService;
import com.android.bluetooth.a2dpsink.mbs.A2dpMediaBrowserService;


import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.btservice.ProfileService;
@@ -192,12 +193,12 @@ public class A2dpSinkService extends ProfileService {
     */
     */
    public void informAvrcpPassThroughCmd(BluetoothDevice device, int keyCode, int keyState) {
    public void informAvrcpPassThroughCmd(BluetoothDevice device, int keyCode, int keyState) {
        if (mStateMachine != null) {
        if (mStateMachine != null) {
            if (keyCode == BluetoothAvrcpController.PASS_THRU_CMD_ID_PLAY &&
            if (keyCode == AvrcpControllerService.PASS_THRU_CMD_ID_PLAY &&
                keyState == BluetoothAvrcpController.KEY_STATE_RELEASED) {
                keyState == AvrcpControllerService.KEY_STATE_RELEASED) {
                mStateMachine.sendMessage(A2dpSinkStateMachine.EVENT_AVRCP_CT_PLAY);
                mStateMachine.sendMessage(A2dpSinkStateMachine.EVENT_AVRCP_CT_PLAY);
            } else if ((keyCode == BluetoothAvrcpController.PASS_THRU_CMD_ID_PAUSE ||
            } else if ((keyCode == AvrcpControllerService.PASS_THRU_CMD_ID_PAUSE ||
                       keyCode == BluetoothAvrcpController.PASS_THRU_CMD_ID_STOP) &&
                       keyCode == AvrcpControllerService.PASS_THRU_CMD_ID_STOP) &&
                       keyState == BluetoothAvrcpController.KEY_STATE_RELEASED) {
                       keyState == AvrcpControllerService.KEY_STATE_RELEASED) {
                mStateMachine.sendMessage(A2dpSinkStateMachine.EVENT_AVRCP_CT_PAUSE);
                mStateMachine.sendMessage(A2dpSinkStateMachine.EVENT_AVRCP_CT_PAUSE);
            }
            }
        }
        }
+18 −13
Original line number Original line Diff line number Diff line
@@ -29,7 +29,6 @@
package com.android.bluetooth.a2dpsink;
package com.android.bluetooth.a2dpsink;


import android.bluetooth.BluetoothA2dpSink;
import android.bluetooth.BluetoothA2dpSink;
import android.bluetooth.BluetoothAvrcpController;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothAudioConfig;
import android.bluetooth.BluetoothAudioConfig;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothDevice;
@@ -49,7 +48,7 @@ import android.util.Log;
import com.android.bluetooth.Utils;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.avrcp.AvrcpControllerService;
import com.android.bluetooth.avrcpcontroller.AvrcpControllerService;
import com.android.internal.util.IState;
import com.android.internal.util.IState;
import com.android.internal.util.State;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
import com.android.internal.util.StateMachine;
@@ -694,16 +693,21 @@ final class A2dpSinkStateMachine extends StateMachine {
        return false;
        return false;
    }
    }


    // Utility Functions
    boolean okToConnect(BluetoothDevice device) {
    boolean okToConnect(BluetoothDevice device) {
        AdapterService adapterService = AdapterService.getAdapterService();
        AdapterService adapterService = AdapterService.getAdapterService();
        boolean ret = true;
        int priority = mService.getPriority(device);
        //check if this is an incoming connection in Quiet mode.

        if((adapterService == null) ||
        // check priority and accept or reject the connection. if priority is undefined
           ((adapterService.isQuietModeEnabled() == true) &&
        // it is likely that our SDP has not completed and peer is initiating the
           (mTargetDevice == null))){
        // connection. Allow this connection, provided the device is bonded
            ret = false;
        if((BluetoothProfile.PRIORITY_OFF < priority) ||
                ((BluetoothProfile.PRIORITY_UNDEFINED == priority) &&
                (device.getBondState() != BluetoothDevice.BOND_NONE))){
            return true;
        }
        }
        return ret;
        logw("okToConnect not OK to connect " + device);
        return false;
    }
    }


    synchronized List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
    synchronized List<BluetoothDevice> getDevicesMatchingConnectionStates(int[] states) {
@@ -802,6 +806,7 @@ final class A2dpSinkStateMachine extends StateMachine {
            this.type = type;
            this.type = type;
        }
        }
    }
    }

    /** Handles A2DP connection state change intent broadcasts. */
    /** Handles A2DP connection state change intent broadcasts. */
    private class IntentBroadcastHandler extends Handler {
    private class IntentBroadcastHandler extends Handler {


@@ -833,11 +838,11 @@ final class A2dpSinkStateMachine extends StateMachine {
            if ((avrcpCtrlService != null) && (mDevice != null) &&
            if ((avrcpCtrlService != null) && (mDevice != null) &&
                (avrcpCtrlService.getConnectedDevices().contains(mDevice))){
                (avrcpCtrlService.getConnectedDevices().contains(mDevice))){
                avrcpCtrlService.sendPassThroughCmd(mDevice,
                avrcpCtrlService.sendPassThroughCmd(mDevice,
                    BluetoothAvrcpController.PASS_THRU_CMD_ID_PLAY,
                    AvrcpControllerService.PASS_THRU_CMD_ID_PLAY,
                    BluetoothAvrcpController.KEY_STATE_PRESSED);
                    AvrcpControllerService.KEY_STATE_PRESSED);
                avrcpCtrlService.sendPassThroughCmd(mDevice,
                avrcpCtrlService.sendPassThroughCmd(mDevice,
                    BluetoothAvrcpController.PASS_THRU_CMD_ID_PLAY,
                    AvrcpControllerService.PASS_THRU_CMD_ID_PLAY,
                    BluetoothAvrcpController.KEY_STATE_RELEASED);
                    AvrcpControllerService.KEY_STATE_RELEASED);
                log(" SendPassThruPlay command sent - ");
                log(" SendPassThruPlay command sent - ");
                return true;
                return true;
            } else {
            } else {
+9 −10
Original line number Original line Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.bluetooth.a2dpsink;
package com.android.bluetooth.a2dpsink;


import android.bluetooth.BluetoothA2dpSink;
import android.bluetooth.BluetoothA2dpSink;
import android.bluetooth.BluetoothAvrcpController;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.Context;
import android.media.AudioManager;
import android.media.AudioManager;
@@ -25,7 +24,7 @@ import android.media.AudioManager.OnAudioFocusChangeListener;
import android.os.Message;
import android.os.Message;
import android.util.Log;
import android.util.Log;


import com.android.bluetooth.avrcp.AvrcpControllerService;
import com.android.bluetooth.avrcpcontroller.AvrcpControllerService;
import com.android.bluetooth.R;
import com.android.bluetooth.R;
import com.android.internal.util.IState;
import com.android.internal.util.IState;
import com.android.internal.util.State;
import com.android.internal.util.State;
@@ -209,12 +208,12 @@ final class A2dpSinkStreamingStateMachine extends StateMachine {
            }
            }
            avrcpService.sendPassThroughCmd(
            avrcpService.sendPassThroughCmd(
                avrcpService.getConnectedDevices().get(0),
                avrcpService.getConnectedDevices().get(0),
                BluetoothAvrcpController.PASS_THRU_CMD_ID_PAUSE,
                AvrcpControllerService.PASS_THRU_CMD_ID_PAUSE,
                BluetoothAvrcpController.KEY_STATE_PRESSED);
                AvrcpControllerService.KEY_STATE_PRESSED);
            avrcpService.sendPassThroughCmd(
            avrcpService.sendPassThroughCmd(
                avrcpService.getConnectedDevices().get(0),
                avrcpService.getConnectedDevices().get(0),
                BluetoothAvrcpController.PASS_THRU_CMD_ID_PAUSE,
                AvrcpControllerService.PASS_THRU_CMD_ID_PAUSE,
                BluetoothAvrcpController.KEY_STATE_RELEASED);
                AvrcpControllerService.KEY_STATE_RELEASED);
        } else {
        } else {
            Log.e(TAG, "Passthrough not sent, connection un-available.");
            Log.e(TAG, "Passthrough not sent, connection un-available.");
        }
        }
@@ -233,12 +232,12 @@ final class A2dpSinkStreamingStateMachine extends StateMachine {
            }
            }
            avrcpService.sendPassThroughCmd(
            avrcpService.sendPassThroughCmd(
                avrcpService.getConnectedDevices().get(0),
                avrcpService.getConnectedDevices().get(0),
                BluetoothAvrcpController.PASS_THRU_CMD_ID_PLAY,
                AvrcpControllerService.PASS_THRU_CMD_ID_PLAY,
                BluetoothAvrcpController.KEY_STATE_PRESSED);
                AvrcpControllerService.KEY_STATE_PRESSED);
            avrcpService.sendPassThroughCmd(
            avrcpService.sendPassThroughCmd(
                avrcpService.getConnectedDevices().get(0),
                avrcpService.getConnectedDevices().get(0),
                BluetoothAvrcpController.PASS_THRU_CMD_ID_PLAY,
                AvrcpControllerService.PASS_THRU_CMD_ID_PLAY,
                BluetoothAvrcpController.KEY_STATE_RELEASED);
                AvrcpControllerService.KEY_STATE_RELEASED);
        } else {
        } else {
            Log.e(TAG, "Passthrough not sent, connection un-available.");
            Log.e(TAG, "Passthrough not sent, connection un-available.");
        }
        }
Loading