summaryrefslogtreecommitdiff
path: root/altosdroid/src
diff options
context:
space:
mode:
authorMike Beattie <mike@ethernal.org>2012-08-28 21:55:40 +1200
committerMike Beattie <mike@ethernal.org>2012-08-28 21:55:40 +1200
commit502b24eb2c9c76e4e2bdcc79be0b71a869488b37 (patch)
treeab537baffd11975a1a0899b1802936daf6316533 /altosdroid/src
parentc7bef83fd553987f83c0bf7ff37ef941872564fe (diff)
altosdroid: fix a connection retry having a null pointer
Signed-off-by: Mike Beattie <mike@ethernal.org>
Diffstat (limited to 'altosdroid/src')
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java
index 10c2e26f..1fa62d87 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java
@@ -161,8 +161,14 @@ public class TelemetryService extends Service {
mAltosBluetooth = new AltosBluetooth(device, mHandler);
setState(STATE_CONNECTING);
} else {
+ // This is a bit of a hack - if it appears we're still connected, we treat this as a restart.
+ // So, to give a suitable delay to teardown/bringup, we just schedule a resend of a message
+ // to ourselves in a few seconds time that will ultimately call this method again.
+ // ... then we tear down the existing connection.
+ // We do it this way around so that we don't lose a reference to the device when this method
+ // is called on reception of MSG_CONNECT_FAILED in the handler above.
+ mHandler.sendMessageDelayed(Message.obtain(null, MSG_CONNECT, device), 3000);
stopAltosBluetooth();
- mHandler.sendMessageDelayed(Message.obtain(null, MSG_CONNECT, device), 1000);
}
}