Bluetooth Application Crash while try to pairing with laptop - IKDVXPSE-345

the handleRegistration will never run after we shutdown the handler thread first,
with this change, we can make sure the mObserver will never be null
when call handleRegistration.
bug:11148404

Change-Id: I93b351915b49cf59a7d2026b7d83a68a7e76dd38
diff --git a/src/com/android/bluetooth/map/BluetoothMnsObexClient.java b/src/com/android/bluetooth/map/BluetoothMnsObexClient.java
index fa2567b..f419bdd 100644
--- a/src/com/android/bluetooth/map/BluetoothMnsObexClient.java
+++ b/src/com/android/bluetooth/map/BluetoothMnsObexClient.java
@@ -113,6 +113,18 @@
     }
 
     public void disconnect() {
+        /* should shutdown handler thread first to make sure
+         * handleRegistration won't be called when disconnet
+         */
+        if (mHandler != null) {
+            // Shut down the thread
+            mHandler.removeCallbacksAndMessages(null);
+            Looper looper = mHandler.getLooper();
+            if (looper != null) {
+                looper.quit();
+            }
+            mHandler = null;
+        }
         try {
             if (mClientSession != null) {
                 mClientSession.disconnect(null);
@@ -150,15 +162,6 @@
             mObserver.deinit();
             mObserver = null;
         }
-        if (mHandler != null) {
-            // Shut down the thread
-            mHandler.removeCallbacksAndMessages(null);
-            Looper looper = mHandler.getLooper();
-            if (looper != null) {
-                looper.quit();
-            }
-            mHandler = null;
-        }
     }
 
     private HeaderSet hsConnect = null;