From 607f9abfb96d7d421caf91c665cf801849b20bd6 Mon Sep 17 00:00:00 2001 From: Herbert von Broeuschmeul Date: Thu, 5 May 2011 21:39:43 +0200 Subject: correct the way we send command to SIRF GPS Sometimes, if we weren't able to obtain the connection with the GPS, we weren't also able to discard the writing task and to shutdown thread associated thread pool. --- .../bluetooth/provider/BlueetoothGpsManager.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java index a199099..4deba63 100644 --- a/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java +++ b/src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java @@ -160,9 +160,11 @@ public class BlueetoothGpsManager { try { do { Thread.sleep(100); - } while (! ready); - out.write(buffer); - out.flush(); + } while ((enabled) && (! ready)); + if ((enabled) && (ready)){ + out.write(buffer); + out.flush(); + } } catch (IOException e) { Log.e(LOG_TAG, "Exception during write", e); } catch (InterruptedException e) { @@ -177,11 +179,11 @@ public class BlueetoothGpsManager { try { do { Thread.sleep(100); - } while (! ready); - out2.print(buffer); - out2.flush(); - // } catch (IOException e) { - // Log.e("BT test", "Exception during write", e); + } while ((enabled) && (! ready)); + if ((enabled) && (ready)){ + out2.print(buffer); + out2.flush(); + } } catch (InterruptedException e) { Log.e(LOG_TAG, "Exception during write", e); } @@ -675,7 +677,7 @@ public class BlueetoothGpsManager { notificationPool.execute( new Runnable() { @Override public void run() { - while ((!enabled) || (!connected) || (connectedGps == null) || (!connectedGps.isReady())){ + while ((enabled) && ((!connected) || (connectedGps == null) || (!connectedGps.isReady()))){ Log.v(LOG_TAG, "writing thread is not ready"); SystemClock.sleep(500); } @@ -701,7 +703,7 @@ public class BlueetoothGpsManager { notificationPool.execute( new Runnable() { @Override public void run() { - while ((!enabled) || (!connected) || (connectedGps == null) || (!connectedGps.isReady())){ + while ((enabled) && ((!connected) || (connectedGps == null) || (!connectedGps.isReady()))){ Log.v(LOG_TAG, "writing thread is not ready"); SystemClock.sleep(500); } -- cgit v1.1