OSDN Git Service

am f8a473c3: am c5c8dad0: Use new apply() instead of commit().
[android-x86/packages-apps-Settings.git] / src / com / android / settings / bluetooth / BluetoothEventRedirector.java
index cc3db6e..54fde9d 100644 (file)
@@ -24,6 +24,8 @@ import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothClass;
 import android.bluetooth.BluetoothDevice;
 import android.bluetooth.BluetoothHeadset;
+import android.bluetooth.BluetoothInputDevice;
+import android.bluetooth.BluetoothPan;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
@@ -119,6 +121,31 @@ public class BluetoothEventRedirector {
                 mManager.getCachedDeviceManager().onProfileStateChanged(device,
                         Profile.A2DP, newState);
 
+            } else if (action.equals(BluetoothInputDevice.ACTION_INPUT_DEVICE_STATE_CHANGED)) {
+                final int newState = intent.getIntExtra(
+                        BluetoothInputDevice.EXTRA_INPUT_DEVICE_STATE, 0);
+                final int oldState = intent.getIntExtra(
+                        BluetoothInputDevice.EXTRA_PREVIOUS_INPUT_DEVICE_STATE, 0);
+                if (newState == BluetoothInputDevice.STATE_DISCONNECTED &&
+                        oldState == BluetoothInputDevice.STATE_CONNECTING) {
+                    Log.i(TAG, "Failed to connect BT HID");
+                }
+
+                mManager.getCachedDeviceManager().onProfileStateChanged(device,
+                        Profile.HID, newState);
+
+            } else if (action.equals(BluetoothPan.ACTION_PAN_STATE_CHANGED)) {
+                final int newState = intent.getIntExtra(
+                        BluetoothPan.EXTRA_PAN_STATE, 0);
+                final int oldState = intent.getIntExtra(
+                        BluetoothPan.EXTRA_PREVIOUS_PAN_STATE, 0);
+                if (newState == BluetoothPan.STATE_DISCONNECTED &&
+                        oldState == BluetoothPan.STATE_CONNECTING) {
+                    Log.i(TAG, "Failed to connect BT PAN");
+                }
+                mManager.getCachedDeviceManager().onProfileStateChanged(device,
+                        Profile.PAN, newState);
+
             } else if (action.equals(BluetoothDevice.ACTION_CLASS_CHANGED)) {
                 mManager.getCachedDeviceManager().onBtClassChanged(device);
 
@@ -166,6 +193,7 @@ public class BluetoothEventRedirector {
         // Fine-grained state broadcasts
         filter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
         filter.addAction(BluetoothHeadset.ACTION_STATE_CHANGED);
+        filter.addAction(BluetoothPan.ACTION_PAN_STATE_CHANGED);
         filter.addAction(BluetoothDevice.ACTION_CLASS_CHANGED);
         filter.addAction(BluetoothDevice.ACTION_UUID);