Fix NPE in bluetooth Permission Activity

This fixes a NPE by ensuring that cached device  list has
a cached device associated with a given BDA before accessing
the cached device
Bug:5964529

Change-Id: Ib2c3596e6e008c78f9f1137134e421ca710e1217
diff --git a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
old mode 100644
new mode 100755
index 4fd6cee..16476fa
--- a/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
+++ b/src/com/android/settings/bluetooth/BluetoothPermissionActivity.java
@@ -251,6 +251,13 @@
         CachedBluetoothDeviceManager cachedDeviceManager =
             bluetoothManager.getCachedDeviceManager();
         CachedBluetoothDevice cachedDevice = cachedDeviceManager.findDevice(mDevice);
-        cachedDevice.setPhonebookPermissionChoice(permissionChoice);
+        if (cachedDevice != null ) {
+            cachedDevice.setPhonebookPermissionChoice(permissionChoice);
+        } else {
+            cachedDevice = cachedDeviceManager.addDevice(bluetoothManager.getBluetoothAdapter(),
+                                                         bluetoothManager.getProfileManager(),
+                                                         mDevice);
+            cachedDevice.setPhonebookPermissionChoice(permissionChoice);
+        }
     }
 }