Merge "PBAP C: Run the abort operation in a seperate thread"
diff --git a/src/org/codeaurora/bluetooth/pbapclient/BluetoothPbapObexSession.java b/src/org/codeaurora/bluetooth/pbapclient/BluetoothPbapObexSession.java
index c29f0f9..8292dae 100644
--- a/src/org/codeaurora/bluetooth/pbapclient/BluetoothPbapObexSession.java
+++ b/src/org/codeaurora/bluetooth/pbapclient/BluetoothPbapObexSession.java
@@ -100,14 +100,17 @@
              * since abort may block until complete GET is processed inside OBEX
              * session, let's run it in separate thread so it won't block UI
              */
-            Log.d(TAG, "aborting the ongoing request");
-            (new Thread() {
-                @Override
-                public void run() {
+            Thread t = new Thread(new Runnable() {
+            public void run () {
+                if (mObexClientThread != null && mObexClientThread.mRequest != null) {
+                    Log.d(TAG, "Spawning a new thread for aborting");
                     mObexClientThread.mRequest.abort();
                 }
-            }).run();
-        }
+            }
+            });
+            t.start();
+            Log.d(TAG, "Exiting from the abort thread");
+       }
     }
 
     public boolean schedule(BluetoothPbapRequest request) {