altosdroid: Track device location in app, not telemetry service
[fw/altos] / altosdroid / src / org / altusmetrum / AltosDroid / TelemetryService.java
index 4a056d9550812f27c885cbfce3d1e059361bb344..1834d55b2eb1fa4bb3280803b5fbc1a283b06f21 100644 (file)
@@ -38,14 +38,11 @@ import android.os.Messenger;
 import android.os.RemoteException;
 import android.os.Looper;
 import android.widget.Toast;
-import android.location.Location;
-import android.location.LocationManager;
-import android.location.LocationListener;
 import android.location.Criteria;
 
-import org.altusmetrum.altoslib_8.*;
+import org.altusmetrum.altoslib_10.*;
 
-public class TelemetryService extends Service implements LocationListener {
+public class TelemetryService extends Service {
 
        static final int MSG_REGISTER_CLIENT   = 1;
        static final int MSG_UNREGISTER_CLIENT = 2;
@@ -248,7 +245,7 @@ public class TelemetryService extends Service implements LocationListener {
 
                /* On connect, send the current state to the new client
                 */
-               send_to_client(client, message());
+               send_to_client(client);
 
                /* If we've got an address from a previous session, then
                 * go ahead and try to reconnect to the device
@@ -275,7 +272,8 @@ public class TelemetryService extends Service implements LocationListener {
                 }
        }
 
-       private void send_to_client(Messenger client, Message m) {
+       private void send_to_client(Messenger client) {
+               Message m = message();
                try {
                        client.send(m);
                } catch (RemoteException e) {
@@ -285,9 +283,8 @@ public class TelemetryService extends Service implements LocationListener {
        }
 
        private void send_to_clients() {
-               Message m = message();
                for (Messenger client : clients)
-                       send_to_client(client, m);
+                       send_to_client(client);
        }
 
        private void disconnect(boolean notify) {
@@ -484,11 +481,6 @@ public class TelemetryService extends Service implements LocationListener {
                                telemetry_state.states.put(serial, saved_state.state);
                        }
                }
-
-               // Listen for GPS and Network position updates
-               LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
-
-               locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, this);
        }
 
        @Override
@@ -535,9 +527,6 @@ public class TelemetryService extends Service implements LocationListener {
        @Override
        public void onDestroy() {
 
-               // Stop listening for location updates
-               ((LocationManager) getSystemService(Context.LOCATION_SERVICE)).removeUpdates(this);
-
                // Stop the bluetooth Comms threads
                disconnect(true);
 
@@ -552,21 +541,4 @@ public class TelemetryService extends Service implements LocationListener {
        public IBinder onBind(Intent intent) {
                return messenger.getBinder();
        }
-
-
-       public void onLocationChanged(Location location) {
-               telemetry_state.location = location;
-               AltosDebug.debug("location changed");
-               send_to_clients();
-       }
-
-       public void onStatusChanged(String provider, int status, Bundle extras) {
-       }
-
-       public void onProviderEnabled(String provider) {
-       }
-
-       public void onProviderDisabled(String provider) {
-       }
-
 }