OSDN Git Service

Only apply foreground flag for audio state connected
authorZach Johnson <zachoverflow@google.com>
Sun, 18 Oct 2015 06:18:23 +0000 (23:18 -0700)
committerZach Johnson <zachoverflow@google.com>
Sun, 18 Oct 2015 06:18:23 +0000 (23:18 -0700)
The other states aren't really that important, and
this reduces the chance of ANR.

Change-Id: Ie019b81a9fbfb9238cf8b6cce1308d0d7358cbf8

src/com/android/bluetooth/hfpclient/HeadsetClientStateMachine.java

index 21d38e2..bc18339 100644 (file)
@@ -2242,11 +2242,11 @@ final class HeadsetClientStateMachine extends StateMachine {
 
     private void broadcastAudioState(BluetoothDevice device, int newState, int prevState) {
         Intent intent = new Intent(BluetoothHeadsetClient.ACTION_AUDIO_STATE_CHANGED);
-        intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
         intent.putExtra(BluetoothProfile.EXTRA_PREVIOUS_STATE, prevState);
         intent.putExtra(BluetoothProfile.EXTRA_STATE, newState);
 
         if (newState == BluetoothHeadsetClient.STATE_AUDIO_CONNECTED) {
+            intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
             intent.putExtra(BluetoothHeadsetClient.EXTRA_AUDIO_WBS, mAudioWbs);
         }