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

Commit cb570c2a authored by Joseph Pirozzo's avatar Joseph Pirozzo Committed by Android (Google) Code Review
Browse files

Merge "AVRCP getConnectedDevices" into oc-mr1-dev

parents aeed100e 810b86ee
Loading
Loading
Loading
Loading
+29 −18
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.bluetooth.a2dpsink;

import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.media.AudioAttributes;
import android.media.AudioManager;
@@ -27,6 +28,8 @@ import android.util.Log;
import com.android.bluetooth.avrcpcontroller.AvrcpControllerService;
import com.android.bluetooth.R;

import java.util.List;

/**
 * Bluetooth A2DP SINK Streaming Handler.
 *
@@ -275,16 +278,20 @@ public class A2dpSinkStreamHandler extends Handler {
        if (DBG) {
            Log.d(TAG, "sendAvrcpPause");
        }
        if (avrcpService != null && avrcpService.getConnectedDevices().size() == 1) {
        if (avrcpService != null) {
            List<BluetoothDevice> connectedDevices = avrcpService.getConnectedDevices();
            if (!connectedDevices.isEmpty()) {
                BluetoothDevice targetDevice = connectedDevices.get(0);
                if (DBG) {
                    Log.d(TAG, "Pausing AVRCP.");
                }
            avrcpService.sendPassThroughCmd(avrcpService.getConnectedDevices().get(0),
                avrcpService.sendPassThroughCmd(targetDevice,
                        AvrcpControllerService.PASS_THRU_CMD_ID_PAUSE,
                        AvrcpControllerService.KEY_STATE_PRESSED);
            avrcpService.sendPassThroughCmd(avrcpService.getConnectedDevices().get(0),
                avrcpService.sendPassThroughCmd(targetDevice,
                        AvrcpControllerService.PASS_THRU_CMD_ID_PAUSE,
                        AvrcpControllerService.KEY_STATE_RELEASED);
            }
        } else {
            Log.e(TAG, "Passthrough not sent, connection un-available.");
        }
@@ -297,16 +304,20 @@ public class A2dpSinkStreamHandler extends Handler {
        if (DBG) {
            Log.d(TAG, "sendAvrcpPlay");
        }
        if (avrcpService != null && avrcpService.getConnectedDevices().size() == 1) {
        if (avrcpService != null) {
            List<BluetoothDevice> connectedDevices = avrcpService.getConnectedDevices();
            if (!connectedDevices.isEmpty()) {
                BluetoothDevice targetDevice = connectedDevices.get(0);
                if (DBG) {
                    Log.d(TAG, "Playing AVRCP.");
                }
            avrcpService.sendPassThroughCmd(avrcpService.getConnectedDevices().get(0),
                avrcpService.sendPassThroughCmd(targetDevice,
                        AvrcpControllerService.PASS_THRU_CMD_ID_PLAY,
                        AvrcpControllerService.KEY_STATE_PRESSED);
            avrcpService.sendPassThroughCmd(avrcpService.getConnectedDevices().get(0),
                avrcpService.sendPassThroughCmd(targetDevice,
                        AvrcpControllerService.PASS_THRU_CMD_ID_PLAY,
                        AvrcpControllerService.KEY_STATE_RELEASED);
            }
        } else {
            Log.e(TAG, "Passthrough not sent, connection un-available.");
        }