aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java6
1 files 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();
}
}
};