Loading android/app/src/com/android/bluetooth/a2dpsink/A2dpSinkService.java +2 −1 Original line number Diff line number Diff line Loading @@ -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(); } Loading android/app/src/com/android/bluetooth/a2dpsink/A2dpSinkStreamHandler.java +8 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; } Loading android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachine.java +7 −3 Original line number Diff line number Diff line Loading @@ -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: Loading Loading @@ -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(); } } android/app/src/com/android/bluetooth/avrcpcontroller/BluetoothMediaBrowserService.java +14 −0 Original line number Diff line number Diff line Loading @@ -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 */ Loading android/app/src/com/android/bluetooth/avrcpcontroller/BrowseTree.java +8 −1 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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 Loading
android/app/src/com/android/bluetooth/a2dpsink/A2dpSinkService.java +2 −1 Original line number Diff line number Diff line Loading @@ -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(); } Loading
android/app/src/com/android/bluetooth/a2dpsink/A2dpSinkStreamHandler.java +8 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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; } Loading
android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachine.java +7 −3 Original line number Diff line number Diff line Loading @@ -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: Loading Loading @@ -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(); } }
android/app/src/com/android/bluetooth/avrcpcontroller/BluetoothMediaBrowserService.java +14 −0 Original line number Diff line number Diff line Loading @@ -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 */ Loading
android/app/src/com/android/bluetooth/avrcpcontroller/BrowseTree.java +8 −1 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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