transistorsoft / cordova-background-geolocation-lt

The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
http://www.transistorsoft.com/shop/products/cordova-background-geolocation
Other
655 stars 277 forks source link

Location mocking is detected #1370

Closed tushaagit closed 2 weeks ago

tushaagit commented 1 year ago

Your Environment

{ reset: true, debug: false, logLevel: bgGeo.LOG_LEVEL_VERBOSE, desiredAccuracy: bgGeo.DESIRED_ACCURACY_HIGH, distanceFilter: app.config.distanceFilterInMeters, desiredOdometerAccuracy: 250, disableElasticity: true, stationaryRadius: 25, foregroundService: true, enableHeadless: true, notification: { priority: bgGeo.NOTIFICATION_PRIORITY_MIN }, locationAuthorizationRequest: 'Always', backgroundPermissionRationale: { title: "Allow {applicationName} to access to this device's location in the background?", message: "In order to track your activity in the background, please enable {backgroundPermissionOptionLabel} location permission", positiveAction: "Change to {backgroundPermissionOptionLabel}", negativeAction: "Cancel" }, persistMode: bgGeo.PERSIST_MODE_LOCATION, autoSync: true, stopOnTerminate: false, startOnBoot: false, } On getting user login details, new config added:

bgGeo.setConfig({ url: window.app.config.serviceServicePath + 'RecordUserGeoLocation', params: { "EmployeeID": empID, "UserID": userID, "UserName": userName, "Remarks": "Transistorsoft Recording", "AttendanceID": localStorage.getItem("AttendanceID"), } }


## Expected Behavior

distance calculated through Odometer in geolocation object, should be similar to actual travelled distance
When checked the log, below issue found:

Detected invalid location (teleport) with apparent speed of 381.81464 meters/s (distance from last location: 12613.246 meters, dt: 33035.0)
  ⚠️  However, location mocking is detected.  Normally, this location would be ignored as an anomaly.

## Actual Behavior
sometimes odometer distance gets added up by 12 kms approx. for every few minutes, so the values reaches few 1000 kms even though no actual movement is there OR have just few meters of movement .

## Steps to Reproduce
<!--- reproduce this issue; include code to reproduce, if relevant -->
1. once user starts moving, his coordinates are captured with correct distance for most of the travel,
2. at some point it automatically sums up the odometer distance by nearly 12kms,
3. and this summing up continues for whole day
4.

## Context

We are trying to record exact/approx kms travelled by user, but it fails for some users

## Debug logs
<!-- include iOS / Android logs
- ios XCode logs,
- use #getLog #emailLog methods (@see docs)
- Android: $ adb logcat
-->
<details>
    <summary>Logs</summary>

Attached detail log file, still adding the log section for reference where first mock location was found:

║ TrackingService: LocationResult
╠═════════════════════════════════════════════
╟─ 📍  Location[fused 10.080022,76.348352 hAcc=1400 et=+9d20h33m7s589ms alt=-88.5 vAcc=6 sAcc=??? bAcc=??? {Bundle[{}]}]
╟─ Age: 143ms, time: 1666009775387

10-17 17:59:35.531 DEBUG [TSLocationManager onLocationResult] 
╔═════════════════════════════════════════════
║ Process LocationResult
╠═════════════════════════════════════════════

10-17 17:59:35.532 DEBUG [TSLocationManager locationIsInvalid] Distance from last location: 12613.246, apparent speed: 381.81464
10-17 17:59:35.533 WARN [TSLocationManager locationIsInvalid] 
  ⚠️  Detected invalid location (teleport) with apparent speed of 381.81464 meters/s (distance from last location: 12613.246 meters, dt: 33035.0)
  ⚠️  However, location mocking is detected.  Normally, this location would be ignored as an anomaly.
10-17 17:59:35.533 DEBUG [TSLocationManager calculateMedianAccuracy] Median accuracy: 20.0
10-17 17:59:35.534 DEBUG [AbstractService finish] ⚙️︎  finish TrackingService [eventCount: 0, sticky: true]
10-17 17:59:35.544 INFO [b persist] 
  ✅  INSERT: d899574a-6de4-4b1a-a925-4eadc2be9d55
10-17 17:59:35.793 DEBUG [AbstractService start] 
  🎾  TrackingService [eventCount: 1]
10-17 17:59:35.794 DEBUG [TrackingService handleLocationResult] 

```<!-- Syntax highlighting:  DO NOT REMOVE -->
PASTE_YOUR_LOGS_HERE

christocracy commented 1 year ago

You'll have a hard time testing odometer with Mocked location.

tushaagit commented 1 year ago

Sir, This issue is not happening regularly, but get few random cases, so our km calculation logic gets disturbed, any solution for this? Can we apply any filter to avoid recording such mock locations and avoid summing up of odometer value?

christocracy commented 1 year ago

This issue is not happening regularly, but get few random cases

This issue is happening because the user of that device is using a Mock location app. Of course the odometer value is going to go crazy when a mock location is detected. What do you expect the plugin to do in that case?

tushaagit commented 1 year ago

Sir, Its hard to guess whether he is having such app, or if you know any trick, please let us know, Also if you check the full attached log the users track and km is accurate till the evening 5:30 ist, mocking location at the day end is not of any use for that user, so i doubt why he would do so when last few minutes of his work is pending, also the users reporting person tracks that user regularly.

christocracy commented 1 year ago

Sir, Its hard to guess whether he is having such app, or if you know any trick

It’s not hard to guess. Android tells me exactly when the location is being mocked. See the api docs Location.mock

tushaagit commented 1 year ago

yes, thanks, i had gone through that paramater, but how to restrict the location object from incrementing the odometer distance, its just an identification that mock location found, but internally the odometer is already updated

christocracy commented 1 year ago

but internally the odometer is already updated

So that developers can test the odometer with mock locations.

tushaagit commented 1 year ago

i meant to say, there is a setting to restrict locations from updating if location accuracy > desiredAccuracy in BGeoconfig , same way is there any setting or function we can write in jquery/javascript to restrict odometer update if location mock:true

christocracy commented 1 year ago

is there any setting to restrict odometer update if location mock:true

No.

github-actions[bot] commented 1 month ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 2 weeks ago

This issue was closed because it has been inactive for 14 days since being marked as stale.