Loading android/app/res/values/config.xml +2 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,8 @@ <!-- For A2DP sink ducking volume feature. --> <integer name="a2dp_sink_duck_percent">25</integer> <!-- If true, device requests audio focus and start avrcp updates on source start or play --> <bool name="a2dp_sink_automatically_request_audio_focus">false</bool> <!-- For enabling the hfp client connection service --> <bool name="hfp_client_connection_service_enabled">false</bool> Loading android/app/src/com/android/bluetooth/a2dpsink/A2dpSinkStreamHandler.java +17 −16 Original line number Diff line number Diff line Loading @@ -112,11 +112,8 @@ public class A2dpSinkStreamHandler extends Handler { } switch (message.what) { case SRC_STR_START: // Always request audio focus if on TV. if (isTvDevice()) { if (mAudioFocus == AudioManager.AUDIOFOCUS_NONE) { requestAudioFocus(); } if (isTvDevice() || shouldRequestFocus()) { requestAudioFocusIfNone(); } // Audio stream has started, stop it if we don't have focus. if (mAudioFocus == AudioManager.AUDIOFOCUS_NONE) { Loading @@ -130,9 +127,7 @@ public class A2dpSinkStreamHandler extends Handler { case SNK_PLAY: // Local play command, gain focus and start avrcp updates. if (mAudioFocus == AudioManager.AUDIOFOCUS_NONE) { requestAudioFocus(); } requestAudioFocusIfNone(); break; case SNK_PAUSE: Loading @@ -143,11 +138,8 @@ public class A2dpSinkStreamHandler extends Handler { case SRC_PLAY: mStreamAvailable = true; // Remote play command. // If is an iot device gain focus and start avrcp updates. if (isIotDevice() || isTvDevice()) { if (mAudioFocus == AudioManager.AUDIOFOCUS_NONE) { requestAudioFocus(); } if (isIotDevice() || isTvDevice() || shouldRequestFocus()) { requestAudioFocusIfNone(); break; } // Otherwise, pause if we don't have focus Loading @@ -162,9 +154,7 @@ public class A2dpSinkStreamHandler extends Handler { break; case REQUEST_FOCUS: if (mAudioFocus == AudioManager.AUDIOFOCUS_NONE) { requestAudioFocus(); } requestAudioFocusIfNone(); break; case DISCONNECT: Loading Loading @@ -232,6 +222,12 @@ public class A2dpSinkStreamHandler extends Handler { /** * Utility functions. */ private void requestAudioFocusIfNone() { if (mAudioFocus == AudioManager.AUDIOFOCUS_NONE) { requestAudioFocus(); } } private synchronized int requestAudioFocus() { // Bluetooth A2DP may carry Music, Audio Books, Navigation, or other sounds so mark content // type unknown. Loading Loading @@ -356,4 +352,9 @@ public class A2dpSinkStreamHandler extends Handler { return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK); } private boolean shouldRequestFocus() { return mContext.getResources() .getBoolean(R.bool.a2dp_sink_automatically_request_audio_focus); } } Loading
android/app/res/values/config.xml +2 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,8 @@ <!-- For A2DP sink ducking volume feature. --> <integer name="a2dp_sink_duck_percent">25</integer> <!-- If true, device requests audio focus and start avrcp updates on source start or play --> <bool name="a2dp_sink_automatically_request_audio_focus">false</bool> <!-- For enabling the hfp client connection service --> <bool name="hfp_client_connection_service_enabled">false</bool> Loading
android/app/src/com/android/bluetooth/a2dpsink/A2dpSinkStreamHandler.java +17 −16 Original line number Diff line number Diff line Loading @@ -112,11 +112,8 @@ public class A2dpSinkStreamHandler extends Handler { } switch (message.what) { case SRC_STR_START: // Always request audio focus if on TV. if (isTvDevice()) { if (mAudioFocus == AudioManager.AUDIOFOCUS_NONE) { requestAudioFocus(); } if (isTvDevice() || shouldRequestFocus()) { requestAudioFocusIfNone(); } // Audio stream has started, stop it if we don't have focus. if (mAudioFocus == AudioManager.AUDIOFOCUS_NONE) { Loading @@ -130,9 +127,7 @@ public class A2dpSinkStreamHandler extends Handler { case SNK_PLAY: // Local play command, gain focus and start avrcp updates. if (mAudioFocus == AudioManager.AUDIOFOCUS_NONE) { requestAudioFocus(); } requestAudioFocusIfNone(); break; case SNK_PAUSE: Loading @@ -143,11 +138,8 @@ public class A2dpSinkStreamHandler extends Handler { case SRC_PLAY: mStreamAvailable = true; // Remote play command. // If is an iot device gain focus and start avrcp updates. if (isIotDevice() || isTvDevice()) { if (mAudioFocus == AudioManager.AUDIOFOCUS_NONE) { requestAudioFocus(); } if (isIotDevice() || isTvDevice() || shouldRequestFocus()) { requestAudioFocusIfNone(); break; } // Otherwise, pause if we don't have focus Loading @@ -162,9 +154,7 @@ public class A2dpSinkStreamHandler extends Handler { break; case REQUEST_FOCUS: if (mAudioFocus == AudioManager.AUDIOFOCUS_NONE) { requestAudioFocus(); } requestAudioFocusIfNone(); break; case DISCONNECT: Loading Loading @@ -232,6 +222,12 @@ public class A2dpSinkStreamHandler extends Handler { /** * Utility functions. */ private void requestAudioFocusIfNone() { if (mAudioFocus == AudioManager.AUDIOFOCUS_NONE) { requestAudioFocus(); } } private synchronized int requestAudioFocus() { // Bluetooth A2DP may carry Music, Audio Books, Navigation, or other sounds so mark content // type unknown. Loading Loading @@ -356,4 +352,9 @@ public class A2dpSinkStreamHandler extends Handler { return mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK); } private boolean shouldRequestFocus() { return mContext.getResources() .getBoolean(R.bool.a2dp_sink_automatically_request_audio_focus); } }