From 097df1246e0f5e3f03bf0495ddd776cfe1943395 Mon Sep 17 00:00:00 2001 From: Herbert von Broeuschmeul Date: Thu, 12 May 2011 18:00:27 +0200 Subject: update (and improve ? ) disable and socket closing process. --- .../android/gps/bluetooth/provider/BlueetoothGpsManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java index bfdb0cf..a199099 100644 --- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java +++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java @@ -338,7 +338,7 @@ public class BlueetoothGpsManager { if (connectedGps != null){ connectedGps.close(); } - if (gpsSocket != null){ + if ((gpsSocket != null) && ((connectedGps == null) || (connectedGps.socket != gpsSocket))){ Log.d(LOG_TAG, "trying to close old socket"); gpsSocket.close(); } @@ -488,10 +488,11 @@ public class BlueetoothGpsManager { e.printStackTrace(); } if (!connectionAndReadingPool.isTerminated()){ + connectionAndReadingPool.shutdownNow(); if (connectedGps != null){ connectedGps.close(); } - if (gpsSocket != null){ + if ((gpsSocket != null) && ((connectedGps == null) || (connectedGps.socket != gpsSocket))){ try { Log.d(LOG_TAG, "closing Bluetooth GPS socket"); gpsSocket.close(); @@ -499,7 +500,6 @@ public class BlueetoothGpsManager { Log.e(LOG_TAG, "error while closing socket", closeException); } } - connectionAndReadingPool.shutdownNow(); } } }; -- cgit v1.1