aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2011-05-05 21:39:43 +0200
committerHerbert von Broeuschmeul <Herbert.Broeuschmeul@gmail.com>2011-05-12 18:10:43 +0200
commit607f9abfb96d7d421caf91c665cf801849b20bd6 (patch)
tree0807060041b10ea7fe29333ecf5317fb636383a2
parentd7f90eb9b2dbf0e3b9bae8cbea6ea0a1f658352c (diff)
downloadBlueGPS-607f9abfb96d7d421caf91c665cf801849b20bd6.zip
BlueGPS-607f9abfb96d7d421caf91c665cf801849b20bd6.tar.gz
BlueGPS-607f9abfb96d7d421caf91c665cf801849b20bd6.tar.bz2
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.
-rw-r--r--src/org/broeuschmeul/android/gps/bluetooth/provider/BlueetoothGpsManager.java22
1 files changed, 12 insertions, 10 deletions
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);
}