b/2320107 NPE when receiving a Undock event without a device

Change-Id: Ic3c964f2d58462a1b7c82f2de2dd997679f90ba7
diff --git a/src/com/android/settings/bluetooth/BluetoothEventRedirector.java b/src/com/android/settings/bluetooth/BluetoothEventRedirector.java
index f283a67..c1a2116 100644
--- a/src/com/android/settings/bluetooth/BluetoothEventRedirector.java
+++ b/src/com/android/settings/bluetooth/BluetoothEventRedirector.java
@@ -131,7 +131,7 @@
                 int anythingButUnDocked = Intent.EXTRA_DOCK_STATE_UNDOCKED + 1;
                 int state = intent.getIntExtra(Intent.EXTRA_DOCK_STATE, anythingButUnDocked);
                 if (state == Intent.EXTRA_DOCK_STATE_UNDOCKED) {
-                    if (device.getBondState() == BluetoothDevice.BOND_NONE) {
+                    if (device != null && device.getBondState() == BluetoothDevice.BOND_NONE) {
                         mManager.getCachedDeviceManager().onDeviceDisappeared(device);
                     }
                 }