altosdroid: fix up 'send last' code.
authorMike Beattie <mike@ethernal.org>
Sun, 21 Apr 2013 02:44:07 +0000 (14:44 +1200)
committerMike Beattie <mike@ethernal.org>
Sun, 21 Apr 2013 02:44:07 +0000 (14:44 +1200)
Signed-off-by: Mike Beattie <mike@ethernal.org>
altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java

index f1304a95298f3d645e10eb13419e90ba9d993a07..bc3371f3cfee607dc16f495cc2565976bee0d93b 100644 (file)
@@ -133,16 +133,14 @@ public class TelemetryService extends Service {
                                        // Now we try to send the freshly connected UI any relavant information about what
                                        // we're talking to - Basically state and Config Data.
                                        msg.replyTo.send(Message.obtain(null, AltosDroid.MSG_STATE_CHANGE, s.state, -1, s.mConfigData));
+                                       // We also send any recent telemetry or location data that's cached
+                                       if (s.last_state      != null) msg.replyTo.send(Message.obtain(null, AltosDroid.MSG_TELEMETRY, s.last_state     ));
+                                       if (s.last_location   != null) msg.replyTo.send(Message.obtain(null, AltosDroid.MSG_LOCATION , s.last_location  ));
+                                       if (s.last_crc_errors != 0   ) msg.replyTo.send(Message.obtain(null, AltosDroid.MSG_CRC_ERROR, s.last_crc_errors));
                                } catch (RemoteException e) {
                                        s.mClients.remove(msg.replyTo);
                                }
                                if (D) Log.d(TAG, "Client bound to service");
-                               if (s.last_state != null)
-                                       s.sendTelemetry(s.last_state);
-                               if (s.last_location != null)
-                                       s.sendLocation(s.last_location);
-                               if (s.last_crc_errors != 0)
-                                       s.sendCrcErrors(s.last_crc_errors);
                                break;
                        case MSG_UNREGISTER_CLIENT:
                                s.mClients.remove(msg.replyTo);
@@ -198,16 +196,6 @@ public class TelemetryService extends Service {
                }
        }
 
-       public void sendTelemetry(AltosState state) {
-       }
-
-       public void sendLocation(Location location) {
-               mHandler.obtainMessage(MSG_LOCATION, location).sendToTarget();
-       }
-
-       public void sendCrcErrors(int crc_errors) {
-       }
-
        private void sendMessageToClients(Message m) {
                for (int i=mClients.size()-1; i>=0; i--) {
                        try {