private Location copyOf(Location location) { if (location == null) return null; Location copy = new Location(location); copy.setAccuracy(location.getAccuracy()); copy.setAltitude(location.getAltitude()); copy.setBearing(location.getBearing()); copy.setExtras(location.getExtras()); copy.setLatitude(location.getLatitude()); copy.setLongitude(location.getLongitude()); copy.setProvider(location.getProvider()); copy.setSpeed(location.getSpeed()); copy.setTime(location.getTime()); return copy; }
Location location int a = location.getExtras().getInt("satellites") ; if (a > 4) { } else { singal loss }
@Override public void onLocationChanged (Location location){ Bundle extras = location.getExtras(); boolean isMockLocation = extras != null && extras.getBoolean(FusedLocationProviderApi.KEY_MOCK_LOCATION, false); }
private int getSignalLevel(Location location) { return Math.abs(location.getExtras().getInt(LocationRetriever.EXTRA_SIGNAL_LEVEL) - MIN_SIGNAL_LEVEL); }
private boolean isVerified(Location location) { return location.getExtras().getLong(LocationRetriever.EXTRA_VERIFIED_TIME) > System.currentTimeMillis() - ONE_DAY; }
@Override public double getWeight(Location location) { double weight = calculateWeight(location, finalMinSignal, finalMaxSignal); Log.d(TAG, String.format("Using with weight=%f mac=%s sig=%d acc=%f lat=%f lon=%f", weight, location.getExtras().getString(LocationRetriever.EXTRA_MAC_ADDRESS), location.getExtras().getInt(LocationRetriever.EXTRA_SIGNAL_LEVEL), location.getAccuracy(), location.getLatitude(), location.getLongitude())); return weight; } }, extras);
public void put(Location location) { if (location == null) return; ContentValues values = new ContentValues(); values.put(FIELD_MAC, location.getExtras().getString(LocationRetriever .EXTRA_MAC_ADDRESS)); values.put(FIELD_LATITUDE, location.getLatitude()); values.put(FIELD_LONGITUDE, location.getLongitude()); if (location.hasAltitude()) { values.put(FIELD_ALTITUDE, location.getAltitude()); } if (location.hasAccuracy()) { values.put(FIELD_ACCURACY, location.getAccuracy()); } values.put(FIELD_TIME, location.getTime()); values.put(FIELD_VERIFIED, location.getExtras().getLong(LocationRetriever .EXTRA_VERIFIED_TIME)); db.insertWithOnConflict(TABLE_NAME, null, values, SQLiteDatabase.CONFLICT_REPLACE); }
/** * Formats the number of satellites from the #Location into a * string. In case #LocationManager.NETWORK_PROVIDER is used, it * returns the faked value "1", because some software refuses to * work with a "0" or an empty value. */ public String formatSatellites(Location location) { if (location.getProvider().equals(LocationManager.GPS_PROVIDER)) { Bundle bundle = location.getExtras(); return bundle != null ? "" + bundle.getInt("satellites") : ""; } else if (location.getProvider().equals(LocationManager.NETWORK_PROVIDER)) // fake this variable return "1"; else return ""; }
private void verify(Set<Location> cls) { WifiLocationDatabase.Editor editor = database.edit(); for (Location location : cls) { location.getExtras().putLong(LocationRetriever.EXTRA_VERIFIED_TIME, System.currentTimeMillis()); editor.put(location); } editor.end(); }
private Location combine(Set<Location> locations) { float minSignal = Integer.MAX_VALUE, maxSignal = Integer.MIN_VALUE; long verified = -1; for (Location location : locations) { minSignal = Math.min(minSignal, getSignalLevel(location)); maxSignal = Math.max(maxSignal, getSignalLevel(location)); if (location.getExtras().containsKey(LocationRetriever.EXTRA_VERIFIED_TIME)) { verified = Math.max(verified, location.getExtras().getLong(LocationRetriever.EXTRA_VERIFIED_TIME)); } } final float finalMaxSignal = maxSignal; final float finalMinSignal = minSignal; Bundle extras = new Bundle(); extras.putInt("COMBINED_OF", locations.size()); if (verified != -1) { extras.putLong(LocationRetriever.EXTRA_VERIFIED_TIME, verified); } return LocationHelper.weightedAverage(provider, locations, new LocationHelper.LocationBalance() { @Override public double getWeight(Location location) { double weight = calculateWeight(location, finalMinSignal, finalMaxSignal); Log.d(TAG, String.format("Using with weight=%f mac=%s sig=%d acc=%f lat=%f lon=%f", weight, location.getExtras().getString(LocationRetriever.EXTRA_MAC_ADDRESS), location.getExtras().getInt(LocationRetriever.EXTRA_SIGNAL_LEVEL), location.getAccuracy(), location.getLatitude(), location.getLongitude())); return weight; } }, extras); }
reqdCount = Math.min(l.getExtras().getLong(RfEmitter.LOC_MIN_COUNT,9999L),reqdCount);
float asu = loc.getExtras().getInt(RfEmitter.LOC_ASU); double weight = asu/ loc.getAccuracy();
location.getExtras().putInt(LocationRetriever.EXTRA_SIGNAL_LEVEL, wifi.getRssi()); if (location.hasAccuracy() && location.getAccuracy() != -1) { locations.add(location);
for (Location location : response) { editor.put(location); toRetrieve.remove(location.getExtras().getString(LocationRetriever .EXTRA_MAC_ADDRESS));
private Location copyOf(Location location) { if (location == null) return null; Location copy = new Location(location); copy.setAccuracy(location.getAccuracy()); copy.setAltitude(location.getAltitude()); copy.setBearing(location.getBearing()); copy.setExtras(location.getExtras()); copy.setLatitude(location.getLatitude()); copy.setLongitude(location.getLongitude()); copy.setProvider(location.getProvider()); copy.setSpeed(location.getSpeed()); copy.setTime(location.getTime()); return copy; }
private Location copyOf(Location location) { if (location == null) return null; Location copy = new Location(location); copy.setAccuracy(location.getAccuracy()); copy.setAltitude(location.getAltitude()); copy.setBearing(location.getBearing()); copy.setExtras(location.getExtras()); copy.setLatitude(location.getLatitude()); copy.setLongitude(location.getLongitude()); copy.setProvider(location.getProvider()); copy.setSpeed(location.getSpeed()); copy.setTime(location.getTime()); return copy; }
private Location copyOf(Location location) { if (location == null) return null; Location copy = new Location(location); copy.setAccuracy(location.getAccuracy()); copy.setAltitude(location.getAltitude()); copy.setBearing(location.getBearing()); copy.setExtras(location.getExtras()); copy.setLatitude(location.getLatitude()); copy.setLongitude(location.getLongitude()); copy.setProvider(location.getProvider()); copy.setSpeed(location.getSpeed()); copy.setTime(location.getTime()); return copy; }
private Location copyOf(Location location) { if (location == null) return null; Location copy = new Location(location); copy.setAccuracy(location.getAccuracy()); copy.setAltitude(location.getAltitude()); copy.setBearing(location.getBearing()); copy.setExtras(location.getExtras()); copy.setLatitude(location.getLatitude()); copy.setLongitude(location.getLongitude()); copy.setProvider(location.getProvider()); copy.setSpeed(location.getSpeed()); copy.setTime(location.getTime()); return copy; }