public Location toSysLocation() { Location location = new Location(LocationManager.GPS_PROVIDER); location.setAccuracy(8f); Bundle extraBundle = new Bundle(); location.setBearing(bearing); Reflect.on(location).call("setIsFromMockProvider", false); location.setLatitude(latitude); location.setLongitude(longitude); location.setSpeed(speed); location.setTime(System.currentTimeMillis()); location.setExtras(extraBundle); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { location.setElapsedRealtimeNanos(277000000); } int svCount = VirtualGPSSatalines.get().getSvCount(); extraBundle.putInt("satellites", svCount); extraBundle.putInt("satellitesvalue", svCount); return location; } }
@Override public void run() { while (true) { currentLocation.setTime(System.currentTimeMillis()); currentLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); mLocationManager.setTestProviderLocation(mockLocationProvider, currentLocation); try { Thread.sleep(100); } catch (InterruptedException e) { e.printStackTrace(); } } } }).start();
@SuppressLint("NewApi") public Location createLocation(double lat, double lng, float accuracy) { // Create a new Location Location newLocation = new Location(PROVIDER); newLocation.setLatitude(lat); newLocation.setLongitude(lng); newLocation.setAccuracy(accuracy); newLocation.setTime(System.currentTimeMillis()); int sdk = android.os.Build.VERSION.SDK_INT; if(sdk >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { newLocation.setElapsedRealtimeNanos( SystemClock.elapsedRealtimeNanos()); } return newLocation; }
Location loc = new Location(LocationManager.GPS_PROVIDER); loc.setLatitude(37.422); loc.setLongitude(-122.084); loc.setAltitude(0); loc.setTime(System.currentTimeMillis()); loc.setAccuracy(10); if (android.os.Build.VERSION.SDK_INT >= 17) loc.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
public Location createLocation(double lat, double lng, float accuracy) { // Create a new Location Location newLocation = new Location(LocationManager.GPS_PROVIDER); newLocation.setLatitude(lat); newLocation.setLongitude(lng); newLocation.setProvider(LocationManager.GPS_PROVIDER); newLocation.setAccuracy(1); newLocation.setTime(new Date().getTime()); newLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); return newLocation; }
public class GPSPollingServiceTest extends AndroidTestCase { private LocationManager locationManager; public void testGPS() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { LocationManager locationManager = (LocationManager) this.getContext().getSystemService(Context.LOCATION_SERVICE); List providers = locationManager.getAllProviders(); if(!providers.contains(TEST_MOCK_GPS_LOCATION)) { locationManager.addTestProvider(TEST_MOCK_GPS_LOCATION, false, false, false, false, false, false, false, Criteria.POWER_LOW, Criteria.ACCURACY_FINE); locationManager.setTestProviderEnabled(TEST_MOCK_GPS_LOCATION, true); // Set up your test Location location = new Location(TEST_MOCK_GPS_LOCATION); location.setLatitude(34.1233400); location.setLongitude(15.6777880); location.setAccuracy(7); location.setTime(8); location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); locationManager.setTestProviderLocation(TEST_MOCK_GPS_LOCATION, location); Method locationJellyBeanFixMethod = Location.class.getMethod("makeComplete"); if (locationJellyBeanFixMethod != null) { locationJellyBeanFixMethod.invoke(location); } } else { // Check if your listener reacted the right way locationManager.removeTestProvider(TEST_MOCK_GPS_LOCATION); } }
Location location = new Location(LocationManager.GPS_PROVIDER); location.setLatitude(48.446743); location.setLongitude(52.44672); location.setAccuracy(4.0f); location.setElapsedRealtimeNanos(elapsedTimeNanos); location.setTime(currentTime); LocationServices.FusedLocationApi.setMockLocation(mGoogleApiClient, location);
@Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Location location = new Location(LocationManager.GPS_PROVIDER); XSharedPreferences xsp =new XSharedPreferences("com.markypq.gpshook","markypq"); double latitude = Double.valueOf(xsp.getString("lan"," 117.536246"))+ (double) new Random().nextInt(1000) / 1000000 ; double longtitude = Double.valueOf(xsp.getString("lon","36.681752"))+ (double) new Random().nextInt(1000) / 1000000 ; location.setLatitude(latitude); location.setLongitude(longtitude); location.setAccuracy(Float.valueOf(xsp.getString("acc","1050"))); location.setTime(System.currentTimeMillis()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); } XposedBridge.log("getLastKnownLocation"); param.setResult(location); } });
public static Location a(double d, double d2) { Location location = new Location("gps"); location.setLatitude(d); location.setLongitude(d2); location.setAccuracy(100.0f); location.setTime(System.currentTimeMillis()); if (VERSION.SDK_INT >= 17) { location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); } return location; }
@Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Location location = new Location(LocationManager.GPS_PROVIDER); XSharedPreferences xsp =new XSharedPreferences("com.markypq.gpshook","markypq"); double latitude = Double.valueOf(xsp.getString("lan"," 117.536246"))+ (double) new Random().nextInt(1000) / 1000000 ; double longtitude = Double.valueOf(xsp.getString("lon","36.681752"))+ (double) new Random().nextInt(1000) / 1000000 ; location.setLatitude(latitude); location.setLongitude(longtitude); location.setAccuracy(Float.valueOf(xsp.getString("acc","1050"))); location.setTime(System.currentTimeMillis()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); } XposedBridge.log("getLastLocation"); param.setResult(location); } });
mMockLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
public static Location makeLocation(double latitude, double longitude) { Location location = new Location("gps"); location.setLatitude(latitude); location.setLongitude(longitude); location.setAccuracy(100.0F); location.setTime(System.currentTimeMillis()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); } return location; }
location.setElapsedRealtimeNanos(mElapsedRealtimeNanos);
void pushLocation(double lat, double lon,double alt,float accuracy) { LocationManager lm = (LocationManager) ctx.getSystemService( Context.LOCATION_SERVICE); Location mockLocation = new Location(providerName); mockLocation.setLatitude(lat); mockLocation.setLongitude(lon); mockLocation.setAltitude(alt); mockLocation.setTime(System.currentTimeMillis()); mockLocation.setAccuracy(accuracy); if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { mockLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); } lm.setTestProviderLocation(providerName, mockLocation); }
location.setElapsedRealtimeNanos(mLastObservation.getElapsedRealtimeNanos());
private void setMock(double latitude, double longitude, float accuracy) { locMgr.addTestProvider (LocationManager.GPS_PROVIDER, "requiresNetwork" == "", "requiresSatellite" == "", "requiresCell" == "", "hasMonetaryCost" == "", "supportsAltitude" == "", "supportsSpeed" == "", "supportsBearing" == "", android.location.Criteria.POWER_LOW, android.location.Criteria.ACCURACY_FINE); Location newLocation = new Location(LocationManager.GPS_PROVIDER); newLocation.setLatitude(latitude); newLocation.setLongitude(longitude); newLocation.setAccuracy(accuracy); newLocation.setAltitude(0); newLocation.setAccuracy(500); newLocation.setTime(System.currentTimeMillis()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { newLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); } locMgr.setTestProviderEnabled(LocationManager.GPS_PROVIDER, true); locMgr.setTestProviderStatus(LocationManager.GPS_PROVIDER, LocationProvider.AVAILABLE, null,System.currentTimeMillis()); locMgr.setTestProviderLocation(LocationManager.GPS_PROVIDER, newLocation);}
@Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Location l = new Location(LocationManager.GPS_PROVIDER); l.setLatitude(latitude); l.setLongitude(longtitude); l.setAccuracy(100f); l.setTime(System.currentTimeMillis()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { l.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); } param.setResult(l); } });
@Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Location l = new Location(LocationManager.GPS_PROVIDER); l.setLatitude(latitude); l.setLongitude(longtitude); l.setAccuracy(100f); l.setTime(System.currentTimeMillis()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { l.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); } param.setResult(l); } });
public Location toSysLocation() { Location location = new Location(LocationManager.GPS_PROVIDER); location.setAccuracy(8f); Bundle extraBundle = new Bundle(); location.setBearing(bearing); Reflect.on(location).call("setIsFromMockProvider", false); location.setLatitude(latitude); location.setLongitude(longitude); location.setSpeed(speed); location.setTime(System.currentTimeMillis()); location.setExtras(extraBundle); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { location.setElapsedRealtimeNanos(277000000); } int svCount = VirtualGPSSatalines.get().getSvCount(); extraBundle.putInt("satellites", svCount); extraBundle.putInt("satellitesvalue", svCount); return location; } }
public Location toSysLocation() { Location location = new Location(LocationManager.GPS_PROVIDER); location.setAccuracy(8f); Bundle extraBundle = new Bundle(); location.setBearing(bearing); Reflect.on(location).call("setIsFromMockProvider", false); location.setLatitude(latitude); location.setLongitude(longitude); location.setSpeed(speed); location.setTime(System.currentTimeMillis()); location.setExtras(extraBundle); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { location.setElapsedRealtimeNanos(277000000); } int svCount = VirtualGPSSatalines.get().getSvCount(); extraBundle.putInt("satellites", svCount); extraBundle.putInt("satellitesvalue", svCount); return location; } }