package src.com.hoho.android.usbserial.examples;

import android.content.Context;
import android.location.Location;
import android.location.LocationManager;
import android.location.LocationProvider;

/**
 * Created by michaelarthur on 2/09/15.
 */
public class MockLocationProvider {
    String providerName;
    Context ctx;

    public MockLocationProvider(String name, Context ctx) {
        this.providerName = name;
        this.ctx = ctx;

        LocationManager lm = (LocationManager) ctx.getSystemService(
                Context.LOCATION_SERVICE);
        lm.addTestProvider(providerName,
                "requiresNetwork" == "",
                "requiresSatellite" == "",
                "requiresCell" == "",
                "hasMonetaryCost" == "",
                "supportsAltitude" == "supportsAltitude",
                "supportsSpeed" == "supportsSpeed",
                "supportsBearing" == "supportsBearing",

                android.location.Criteria.POWER_LOW,
                android.location.Criteria.ACCURACY_FINE);

        lm.setTestProviderEnabled(providerName, true);

        lm.setTestProviderStatus
                (
                        providerName,
                        LocationProvider.AVAILABLE,
                        null,
                        System.currentTimeMillis()
                );
    }

    public void pushLocation(Location mockLocation) {
        LocationManager lm = (LocationManager) ctx.getSystemService(
                Context.LOCATION_SERVICE);

        mockLocation.setTime(System.currentTimeMillis());
        lm.setTestProviderLocation(providerName, mockLocation);
    }

    public void shutdown() {
        LocationManager lm = (LocationManager) ctx.getSystemService(
                Context.LOCATION_SERVICE);
        lm.removeTestProvider(providerName);
    }
}

@@ -1088,16 +1088,189 @@
 , true);
+%0A    %7D%0A%0A    public void pushLocation(Location mockLocation) %7B%0A        LocationManager lm = (LocationManager) ctx.getSystemService(%0A                Context.LOCATION_SERVICE);
 %0A%0A      
@@ -1338,28 +1338,44 @@
         
-providerName
+LocationManager.GPS_PROVIDER
 ,%0A      
@@ -1524,240 +1524,8 @@
  );%0A
-    %7D%0A%0A    public void pushLocation(Location mockLocation) %7B%0A        LocationManager lm = (LocationManager) ctx.getSystemService(%0A                Context.LOCATION_SERVICE);%0A%0A        mockLocation.setTime(System.currentTimeMillis());%0A
     

add extra bits for telling location provider we have a fix