Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
authorBdale Garbee <bdale@gag.com>
Mon, 7 Jun 2021 23:11:01 +0000 (17:11 -0600)
committerBdale Garbee <bdale@gag.com>
Mon, 7 Jun 2021 23:11:01 +0000 (17:11 -0600)
altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/AltosDroidPreferences.java
altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/AltosMapOnline.java
altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/AltosUsb.java
altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/DeviceListActivity.java
altosdroid/app/src/main/java/org/altusmetrum/AltosDroid/TelemetryService.java
altoslib/AltosConfigData.java
configure.ac
doc/telelaunch-configuration.inc

index f49f11004a30c419da4b311abe36d110064bfce5..4d9204d9ac79c71b210e3a53d54467d999a6aa0f 100644 (file)
@@ -72,6 +72,8 @@ public class AltosDroidPreferences extends AltosPreferences {
        }
 
        public static void set_active_device(DeviceAddress address) {
+               if (backend == null)
+                       return;
                synchronized(backend) {
                        active_device_address = address;
                        if (active_device_address != null) {
@@ -86,6 +88,9 @@ public class AltosDroidPreferences extends AltosPreferences {
        }
 
        public static DeviceAddress active_device() {
+               if (backend == null)
+                       return null;
+
                synchronized(backend) {
                        return active_device_address;
                }
@@ -94,6 +99,8 @@ public class AltosDroidPreferences extends AltosPreferences {
        static LinkedList<AltosDroidMapSourceListener> map_source_listeners;
 
        public static void set_map_source(int map_source) {
+               if (backend == null)
+                       return;
                synchronized(backend) {
                        AltosDroidPreferences.map_source = map_source;
                        backend.putInt(mapSourcePreference, map_source);
@@ -107,12 +114,17 @@ public class AltosDroidPreferences extends AltosPreferences {
        }
 
        public static int map_source() {
+               if (backend == null)
+                       return MAP_SOURCE_ONLINE;
                synchronized(backend) {
                        return map_source;
                }
        }
 
        public static void register_map_source_listener(AltosDroidMapSourceListener l) {
+               if (backend == null)
+                       return;
+
                synchronized(backend) {
                        if (map_source_listeners == null)
                                map_source_listeners = new LinkedList<AltosDroidMapSourceListener>();
@@ -121,18 +133,25 @@ public class AltosDroidPreferences extends AltosPreferences {
        }
 
        public static void unregister_map_source_listener(AltosDroidMapSourceListener l) {
+               if (backend == null)
+                       return;
                synchronized(backend) {
                        map_source_listeners.remove(l);
                }
        }
 
        public static int font_size() {
+               if (backend == null)
+                       return font_size_medium;
+
                synchronized (backend) {
                        return font_size;
                }
        }
 
        public static void set_font_size(int new_font_size) {
+               if (backend == null)
+                       return;
                synchronized (backend) {
                        if (font_size != new_font_size) {
                                font_size = new_font_size;
@@ -144,12 +163,18 @@ public class AltosDroidPreferences extends AltosPreferences {
 
 
        public static int tracker_sort() {
+               if (backend == null)
+                       return 0;
+
                synchronized(backend) {
                        return tracker_sort;
                }
        }
 
        public static void set_tracker_sort(int new_tracker_sort) {
+               if (backend == null)
+                       return;
+
                synchronized(backend) {
                        if (tracker_sort != new_tracker_sort) {
                                tracker_sort = new_tracker_sort;
index c35bbb4d308c32ae608583ac5fe813ad69a2e3ef..76cd990be7f5b474f38fbddea13f3c8653db1341 100644 (file)
@@ -174,10 +174,12 @@ public class AltosMapOnline implements AltosDroidMapInterface, GoogleMap.OnMarke
        }
 
        private RocketOnline[] sorted_rockets() {
-               RocketOnline[]  rocket_array = rockets.values().toArray(new RocketOnline[0]);
+               synchronized(rockets) {
+                       RocketOnline[]  rocket_array = rockets.values().toArray(new RocketOnline[0]);
 
-               Arrays.sort(rocket_array);
-               return rocket_array;
+                       Arrays.sort(rocket_array);
+                       return rocket_array;
+               }
        }
 
        public void onMapClick(LatLng lat_lng) {
@@ -260,22 +262,26 @@ public class AltosMapOnline implements AltosDroidMapInterface, GoogleMap.OnMarke
                if (mMap == null)
                        return;
 
-               if (rockets.containsKey(serial)) {
-                       rocket = rockets.get(serial);
-                       rocket.set_position(new AltosLatLon(state.gps.lat, state.gps.lon), state.received_time);
-               } else {
-                       rocket = new RocketOnline(context,
-                                                 serial,
-                                                 mMap, state.gps.lat, state.gps.lon,
-                                                 state.received_time);
-                       rockets.put(serial, rocket);
+               synchronized(rockets) {
+                       if (rockets.containsKey(serial)) {
+                               rocket = rockets.get(serial);
+                               rocket.set_position(new AltosLatLon(state.gps.lat, state.gps.lon), state.received_time);
+                       } else {
+                               rocket = new RocketOnline(context,
+                                                         serial,
+                                                         mMap, state.gps.lat, state.gps.lon,
+                                                         state.received_time);
+                               rockets.put(serial, rocket);
+                       }
                }
        }
 
        private void remove_rocket(int serial) {
-               RocketOnline rocket = rockets.get(serial);
-               rocket.remove();
-               rockets.remove(serial);
+               synchronized(rockets) {
+                       RocketOnline rocket = rockets.get(serial);
+                       rocket.remove();
+                       rockets.remove(serial);
+               }
        }
 
        public void set_visible(boolean visible) {
@@ -286,13 +292,15 @@ public class AltosMapOnline implements AltosDroidMapInterface, GoogleMap.OnMarke
        public void show(TelemetryState telem_state, AltosState state, AltosGreatCircle from_receiver, Location receiver) {
 
                if (telem_state != null) {
-                       for (int serial : rockets.keySet()) {
-                               if (!telem_state.containsKey(serial))
-                                       remove_rocket(serial);
-                       }
+                       synchronized(rockets) {
+                               for (int serial : rockets.keySet()) {
+                                       if (!telem_state.containsKey(serial))
+                                               remove_rocket(serial);
+                               }
 
-                       for (int serial : telem_state.keySet()) {
-                               set_rocket(serial, telem_state.get(serial));
+                               for (int serial : telem_state.keySet()) {
+                                       set_rocket(serial, telem_state.get(serial));
+                               }
                        }
                }
 
index 35514483f026af968a6a31c13bc55f734b4a250b..ad47707d90c9706d3bba397ca384cb66dfac7974 100644 (file)
@@ -210,12 +210,16 @@ public class AltosUsb extends AltosDroidLink {
        }
 
        int read(byte[] buffer, int len) {
+               if (connection == null)
+                       return 0;
                int ret = connection.bulkTransfer(in, buffer, len, -1);
                AltosDebug.debug("read(%d) = %d\n", len, ret);
                return ret;
        }
 
        int write(byte[] buffer, int len) {
+               if (connection == null)
+                       return 0;
                int ret = connection.bulkTransfer(out, buffer, len, -1);
                AltosDebug.debug("write(%d) = %d\n", len, ret);
                return ret;
index 1c3e1dbab21019bd9bfa82423e820a2129720c00..60fba9d367126bec3317e120fd05c0bee3a00381 100644 (file)
@@ -152,11 +152,16 @@ public class DeviceListActivity extends Activity {
        // The on-click listener for all devices in the ListViews
        private OnItemClickListener mDeviceClickListener = new OnItemClickListener() {
                public void onItemClick(AdapterView<?> av, View v, int arg2, long arg3) {
+                       // Get the device MAC address, which is the last 17 chars in the View
+                       String info = ((TextView) v).getText().toString();
+
+                       /* Ignore clicks on items that are too short */
+                       if (info.length() <= 17)
+                               return;
+
                        // Cancel discovery because it's costly and we're about to connect
                        mBtAdapter.cancelDiscovery();
 
-                       // Get the device MAC address, which is the last 17 chars in the View
-                       String info = ((TextView) v).getText().toString();
                        String address = info.substring(info.length() - 17);
 
                        int newline = info.indexOf('\n');
index 31616c825371d5e4f2f411343edf4c2464b622b0..2c2095df68186847225e4480993754123be524a2 100644 (file)
@@ -416,7 +416,7 @@ public class TelemetryService extends Service implements AltosIdleMonitorListene
        }
 
        private void start_altos_bluetooth(DeviceAddress address, boolean pause) {
-               if (bluetooth_adapter == null || !bluetooth_adapter.isEnabled())
+               if (bluetooth_adapter == null || !bluetooth_adapter.isEnabled() || address.address == null)
                        return;
 
                disconnect(false);
index 7b78f760cbf43646fd5923f2fbce0aa7a695a0f6..b6105f92fc3cb27265e087fb530d84da2f2f79e8 100644 (file)
@@ -223,6 +223,8 @@ public class AltosConfigData {
        }
 
        public boolean has_monitor_battery() {
+               if (product == null)
+                       return false;
                if (product.startsWith("TeleBT"))
                        return true;
                return false;
index ece8ac9386b957a33f18d50b5d5f2a74a143ac60..8b2e0656dc2465db518c75d645679a787359f334 100644 (file)
@@ -18,13 +18,13 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-AC_INIT([altos], 1.9.7)
-ANDROID_VERSION=27
+AC_INIT([altos], 1.9.6.5)
+ANDROID_VERSION=28
 AC_CONFIG_SRCDIR([src/kernel/ao.h])
 AM_INIT_AUTOMAKE([foreign dist-bzip2])
 AM_MAINTAINER_MODE
 
-RELEASE_DATE=2021-04-12
+RELEASE_DATE=2021-05-30
 AC_SUBST(RELEASE_DATE)
 
 DOC_DATE=`LC_ALL=C date -d $RELEASE_DATE +'%d %b %Y'`
index 0317613cae8340033759a4d5c9554bad10f52241..a24776331a09818cece9e6cdfb77b7e78a1a0ec0 100644 (file)
@@ -59,7 +59,7 @@
                memory.  For example, the default 435.750 MHz would be 
                configured using
 
-                       c F 435750
+                       c F 435750 +
                        c w
 
                Note that the 'f' parameter is a frequency calibration value