Switch from GPLv2 to GPLv2+
[fw/altos] / altosdroid / src / org / altusmetrum / AltosDroid / TelemetryService.java
index a81e24b03d063a7724a030f0dbeb8d7dc49b226f..34c86ce5b56e31b5d7b5cc46409297811d2353f2 100644 (file)
@@ -3,7 +3,8 @@
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -40,7 +41,7 @@ import android.os.Looper;
 import android.widget.Toast;
 import android.location.Criteria;
 
-import org.altusmetrum.altoslib_10.*;
+import org.altusmetrum.altoslib_11.*;
 
 public class TelemetryService extends Service implements AltosIdleMonitorListener {
 
@@ -129,7 +130,8 @@ public class TelemetryService extends Service implements AltosIdleMonitorListene
                        case MSG_DISCONNECT:
                                AltosDebug.debug("Disconnect command received");
                                s.address = null;
-                               AltosDroidPreferences.set_active_device(null);
+                               if (!(Boolean) msg.obj)
+                                       AltosDroidPreferences.set_active_device(null);
                                s.disconnect(true);
                                break;
                        case MSG_DELETE_SERIAL:
@@ -613,6 +615,8 @@ public class TelemetryService extends Service implements AltosIdleMonitorListene
 
                telemetry_state.latest_serial = AltosPreferences.latest_state();
 
+               AltosDebug.debug("latest serial %d\n", telemetry_state.latest_serial);
+
                for (int serial : serials) {
                        AltosState saved_state = AltosPreferences.state(serial);
                        if (saved_state != null) {
@@ -629,6 +633,7 @@ public class TelemetryService extends Service implements AltosIdleMonitorListene
                                telemetry_state.states.put(serial, saved_state);
                        } else {
                                AltosDebug.debug("Failed to recover state for %d", serial);
+                               AltosPreferences.remove_state(serial);
                        }
                }
        }