Fix crash when headset disconnects before we try to connect.

When we don't have the UUIDs we wait. However, during this time
the headset can disconnect. Based on reports from external users.
Bug: 2677383

Change-Id: I11e3fd4a4de57798710cb509a70d65a4a4b740e1
diff --git a/src/com/android/phone/BluetoothHeadsetService.java b/src/com/android/phone/BluetoothHeadsetService.java
index de1dd67..8162a52 100644
--- a/src/com/android/phone/BluetoothHeadsetService.java
+++ b/src/com/android/phone/BluetoothHeadsetService.java
@@ -491,7 +491,8 @@
         }
     }
 
-    private void getSdpRecordsAndConnect() {
+    private synchronized void getSdpRecordsAndConnect() {
+        if (mRemoteDevice == null) return;
         ParcelUuid[] uuids = mRemoteDevice.getUuids();
         if (uuids != null) {
             if (BluetoothUuid.isUuidPresent(uuids, BluetoothUuid.Handsfree)) {