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 Diff line number Diff line
@@ -316,7 +316,7 @@
        </service>
        <service
            android:process="@string/process"
            android:name = ".avrcp.AvrcpControllerService"
            android:name = ".avrcpcontroller.AvrcpControllerService"
            android:enabled="@bool/profile_supported_avrcp_controller">
            <intent-filter>
                <action android:name="android.bluetooth.IBluetoothAvrcpController" />
+398 −34

File changed.

Preview size limit exceeded, changes collapsed.

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

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

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

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

import android.bluetooth.BluetoothA2dpSink;
import android.bluetooth.BluetoothAvrcpController;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothAudioConfig;
import android.bluetooth.BluetoothDevice;
@@ -49,7 +48,7 @@ import android.util.Log;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.AdapterService;
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.State;
import com.android.internal.util.StateMachine;
@@ -694,16 +693,21 @@ final class A2dpSinkStateMachine extends StateMachine {
        return false;
    }

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

        // check priority and accept or reject the connection. if priority is undefined
        // it is likely that our SDP has not completed and peer is initiating the
        // connection. Allow this connection, provided the device is bonded
        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) {
@@ -802,6 +806,7 @@ final class A2dpSinkStateMachine extends StateMachine {
            this.type = type;
        }
    }

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

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

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

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