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

Commit 77786d57 authored by Joseph Pirozzo's avatar Joseph Pirozzo Committed by android-build-merger
Browse files

Merge changes Icb9b0e85,I5f5c85d6,I58997b3b,Ia764ea54

am: 780cbe32

Change-Id: I43df69e5dd2975c104deca538cc6ce429cf524d7
parents 3e844589 780cbe32
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -413,7 +413,8 @@ public class A2dpSinkService extends ProfileService {
        if (state == StackEvent.AUDIO_STATE_STARTED) {
            mA2dpSinkStreamHandler.obtainMessage(
                    A2dpSinkStreamHandler.SRC_STR_START).sendToTarget();
        } else if (state == StackEvent.AUDIO_STATE_STOPPED) {
        } else if (state == StackEvent.AUDIO_STATE_STOPPED
                || state == StackEvent.AUDIO_STATE_REMOTE_SUSPEND) {
            mA2dpSinkStreamHandler.obtainMessage(
                    A2dpSinkStreamHandler.SRC_STR_STOP).sendToTarget();
        }
+8 −2
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.bluetooth.a2dpsink;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadsetClientCall;
import android.content.Context;
import android.content.pm.PackageManager;
import android.media.AudioAttributes;
@@ -26,6 +27,7 @@ import android.media.AudioManager.OnAudioFocusChangeListener;
import android.media.MediaPlayer;
import android.os.Handler;
import android.os.Message;
import android.support.v4.media.session.PlaybackStateCompat;
import android.util.Log;

import com.android.bluetooth.R;
@@ -225,7 +227,8 @@ public class A2dpSinkStreamHandler extends Handler {
                break;

            case DELAYED_PAUSE:
                if (mStreamAvailable && !inCallFromStreamingDevice()) {
                if (BluetoothMediaBrowserService.getPlaybackState()
                            == PlaybackStateCompat.STATE_PLAYING && !inCallFromStreamingDevice()) {
                    sendAvrcpPause();
                    mSentPause = true;
                    mStreamAvailable = false;
@@ -359,7 +362,10 @@ public class A2dpSinkStreamHandler extends Handler {
        }
        HeadsetClientService headsetClientService = HeadsetClientService.getHeadsetClientService();
        if (targetDevice != null && headsetClientService != null) {
            return headsetClientService.getCurrentCalls(targetDevice).size() > 0;
            List<BluetoothHeadsetClientCall> currentCalls =
                    headsetClientService.getCurrentCalls(targetDevice);
            if (currentCalls == null) return false;
            return currentCalls.size() > 0;
        }
        return false;
    }
+7 −3
Original line number Diff line number Diff line
@@ -361,11 +361,14 @@ class AvrcpControllerStateMachine extends StateMachine {
                    BluetoothMediaBrowserService.notifyChanged(mAddressedPlayer.getPlaybackState());
                    if (mAddressedPlayer.getPlaybackState().getState()
                            == PlaybackStateCompat.STATE_PLAYING
                            && A2dpSinkService.getFocusState() == AudioManager.AUDIOFOCUS_NONE
                            && !shouldRequestFocus()) {
                            && A2dpSinkService.getFocusState() == AudioManager.AUDIOFOCUS_NONE) {
                        if (shouldRequestFocus()) {
                            mSessionCallbacks.onPrepare();
                        } else {
                        sendMessage(MSG_AVRCP_PASSTHRU,
                                AvrcpControllerService.PASS_THRU_CMD_ID_PAUSE);
                        }
                    }
                    return true;

                case MESSAGE_PROCESS_PLAY_POS_CHANGED:
@@ -882,6 +885,7 @@ class AvrcpControllerStateMachine extends StateMachine {

    private boolean shouldRequestFocus() {
        return mService.getResources()
                .getBoolean(R.bool.a2dp_sink_automatically_request_audio_focus);
                .getBoolean(R.bool.a2dp_sink_automatically_request_audio_focus)
                || !mAudioManager.isMusicActive();
    }
}
+14 −0
Original line number Diff line number Diff line
@@ -184,6 +184,20 @@ public class BluetoothMediaBrowserService extends MediaBrowserServiceCompat {
        }
    }

    /**
     * Get playback state
     */
    public static synchronized int getPlaybackState() {
        if (sBluetoothMediaBrowserService != null) {
            PlaybackStateCompat currentPlaybackState =
                    sBluetoothMediaBrowserService.mSession.getController().getPlaybackState();
            if (currentPlaybackState != null) {
                return currentPlaybackState.getState();
            }
        }
        return PlaybackStateCompat.STATE_ERROR;
    }

    /**
     * Get object for controlling playback
     */
+8 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ public class BrowseTree {
    }

    BrowseNode getTrackFromNowPlayingList(int trackNumber) {
        return mNowPlayingNode.mChildren.get(trackNumber);
        return mNowPlayingNode.getChild(trackNumber);
    }

    // Each node of the tree is represented by Folder ID, Folder Name and the children.
@@ -218,6 +218,13 @@ public class BrowseTree {
            return mChildren;
        }

        synchronized BrowseNode getChild(int index) {
            if (index < 0 || index >= mChildren.size()) {
                return null;
            }
            return mChildren.get(index);
        }

        synchronized BrowseNode getParent() {
            return mParent;
        }
Loading