altosdroid: fix double call of stopAltosBluetooth()
authorMike Beattie <mike@ethernal.org>
Tue, 28 Aug 2012 09:54:05 +0000 (21:54 +1200)
committerMike Beattie <mike@ethernal.org>
Tue, 28 Aug 2012 09:54:05 +0000 (21:54 +1200)
Signed-off-by: Mike Beattie <mike@ethernal.org>
altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java

index ccb04de03860e8905adace8fa6ee7b587d6bc3a3..10c2e26fdd26f87d5111cda99c0d2e986468b33b 100644 (file)
@@ -110,8 +110,11 @@ public class TelemetryService extends Service {
                                s.startAltosBluetooth();
                                break;
                        case MSG_DISCONNECTED:
-                               if (D) Log.d(TAG, "Disconnected from " + s.device.getName());
-                               s.stopAltosBluetooth();
+                               // Only do the following if we haven't been shutdown elsewhere..
+                               if (s.device != null) {
+                                       if (D) Log.d(TAG, "Disconnected from " + s.device.getName());
+                                       s.stopAltosBluetooth();
+                               }
                                break;
                        case MSG_TELEMETRY:
                                s.sendMessageToClients(Message.obtain(null, AltosDroid.MSG_TELEMETRY, msg.obj));