diff options
Diffstat (limited to 'com/android/settingslib/bluetooth/BluetoothEventManager.java')
-rw-r--r-- | com/android/settingslib/bluetooth/BluetoothEventManager.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/com/android/settingslib/bluetooth/BluetoothEventManager.java b/com/android/settingslib/bluetooth/BluetoothEventManager.java index b74b2cd0..06fe4de4 100644 --- a/com/android/settingslib/bluetooth/BluetoothEventManager.java +++ b/com/android/settingslib/bluetooth/BluetoothEventManager.java @@ -27,6 +27,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.telephony.TelephonyManager; import android.util.Log; import com.android.settingslib.R; @@ -119,6 +120,12 @@ public class BluetoothEventManager { addHandler(BluetoothHearingAid.ACTION_ACTIVE_DEVICE_CHANGED, new ActiveDeviceChangedHandler()); + // Headset state changed broadcasts + addHandler(BluetoothHeadset.ACTION_AUDIO_STATE_CHANGED, + new AudioModeChangedHandler()); + addHandler(TelephonyManager.ACTION_PHONE_STATE_CHANGED, + new AudioModeChangedHandler()); + mContext.registerReceiver(mBroadcastReceiver, mAdapterIntentFilter, null, mReceiverHandler); mContext.registerReceiver(mProfileBroadcastReceiver, mProfileIntentFilter, null, mReceiverHandler); } @@ -456,4 +463,25 @@ public class BluetoothEventManager { } } } + + private class AudioModeChangedHandler implements Handler { + + @Override + public void onReceive(Context context, Intent intent, BluetoothDevice device) { + final String action = intent.getAction(); + if (action == null) { + Log.w(TAG, "AudioModeChangedHandler() action is null"); + return; + } + dispatchAudioModeChanged(); + } + } + + private void dispatchAudioModeChanged() { + synchronized (mCallbacks) { + for (BluetoothCallback callback : mCallbacks) { + callback.onAudioModeChanged(); + } + } + } } |