Bump java library versions
[fw/altos] / altosdroid / src / org / altusmetrum / AltosDroid / TelemetryService.java
index 4b26d263509b18ff1cb3bc6dff49bf258ab74a07..6519a1144ccc42791561c0c58e98f883498a0592 100644 (file)
@@ -40,7 +40,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,6 +129,7 @@ public class TelemetryService extends Service implements AltosIdleMonitorListene
                        case MSG_DISCONNECT:
                                AltosDebug.debug("Disconnect command received");
                                s.address = null;
+                               AltosDroidPreferences.set_active_device(null);
                                s.disconnect(true);
                                break;
                        case MSG_DELETE_SERIAL:
@@ -263,7 +264,7 @@ public class TelemetryService extends Service implements AltosIdleMonitorListene
                telem.update_state(state);
                telemetry_state.states.put(telem.serial, state);
                if (state != null) {
-                       AltosPreferences.set_state(telem.serial, state, null);
+                       AltosPreferences.set_state(state);
                }
                send_to_clients();
        }
@@ -613,24 +614,21 @@ public class TelemetryService extends Service implements AltosIdleMonitorListene
                telemetry_state.latest_serial = AltosPreferences.latest_state();
 
                for (int serial : serials) {
-                       AltosSavedState saved_state = AltosPreferences.state(serial);
+                       AltosState saved_state = AltosPreferences.state(serial);
                        if (saved_state != null) {
-                               if (serial == 0) {
-                                       serial = saved_state.state.serial;
-                                       AltosPreferences.set_state(serial, saved_state.state, saved_state.listener_state);
-                                       AltosPreferences.remove_state(0);
-                               }
                                if (telemetry_state.latest_serial == 0)
                                        telemetry_state.latest_serial = serial;
 
-                               AltosDebug.debug("recovered old state serial %d flight %d\n",
+                               AltosDebug.debug("recovered old state serial %d flight %d",
                                                 serial,
-                                                saved_state.state.flight);
-                               if (saved_state.state.gps != null)
-                                       AltosDebug.debug("\tposition %f,%f\n",
-                                                        saved_state.state.gps.lat,
-                                                        saved_state.state.gps.lon);
-                               telemetry_state.states.put(serial, saved_state.state);
+                                                saved_state.flight);
+                               if (saved_state.gps != null)
+                                       AltosDebug.debug("\tposition %f,%f",
+                                                        saved_state.gps.lat,
+                                                        saved_state.gps.lon);
+                               telemetry_state.states.put(serial, saved_state);
+                       } else {
+                               AltosDebug.debug("Failed to recover state for %d", serial);
                        }
                }
        }
@@ -703,4 +701,8 @@ public class TelemetryService extends Service implements AltosIdleMonitorListene
 
        public void failed() {
        }
+
+       public void error(String reason) {
+               stop_idle_monitor();
+       }
 }