From 72098b9e8c2fed88578cab0ec708c7c4cab62cf5 Mon Sep 17 00:00:00 2001 From: Safe Path Date: Thu, 19 Mar 2020 14:45:09 -0400 Subject: [PATCH 1/2] remove motiontracker requirement; adjust location params; backfill stationary points --- app/services/LocationService.js | 40 ++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/app/services/LocationService.js b/app/services/LocationService.js index 720a62f8b0..256f7dd074 100644 --- a/app/services/LocationService.js +++ b/app/services/LocationService.js @@ -7,7 +7,9 @@ import { Alert } from 'react-native'; var instanceCount = 0; var lastPointCount = 0; - +var locationInterval = 60000 * 5; // Time (in milliseconds) between location information polls. E.g. 60000*5 = 5 minutes +// DEBUG: Reduce Time intervall for faster debugging +// var locationInterval = 5000; function saveLocation(location) { // Persist this location data in our local storage of time/lat/lon values @@ -35,6 +37,15 @@ function saveLocation(location) { } } + // Backfill the stationary points, if available + if (curated.length >= 1) { + var lastLocationArray = curated[curated.length - 1]; + var lastTS = lastLocationArray["time"]; + for (; lastTS < unixtimeUTC - locationInterval; lastTS += locationInterval) { + curated.push(JSON.parse(JSON.stringify(lastLocationArray))); + } + } + // Save the location using the current lat-lon and the // calculated UTC time (maybe a few milliseconds off from // when the GPS data was collected, but that's unimportant @@ -63,30 +74,23 @@ export default class LocationServices { BackgroundGeolocation.configure({ desiredAccuracy: BackgroundGeolocation.HIGH_ACCURACY, - stationaryRadius: 50, - distanceFilter: 50, + stationaryRadius: 5, + distanceFilter: 5, notificationTitle: 'Private Kit Enabled', notificationText: 'Private Kit is securely storing your GPS coordinates once every five minutes on this device.', debug: false, // when true, it beeps every time a loc is read - startOnBoot: false, + startOnBoot: true, stopOnTerminate: false, - locationProvider: BackgroundGeolocation.ACTIVITY_PROVIDER, - - // DEBUG: Use these to get a faster output - /*interval: 2000, - fastestInterval: 2000, // Time (in milliseconds) between location information polls. E.g. 60000*5 = 5 minutes - activitiesInterval: 2000,*/ + locationProvider: BackgroundGeolocation.DISTANCE_FILTER_PROVIDER, - interval: 20000, - fastestInterval: 60000 * 5, // Time (in milliseconds) between location information polls. E.g. 60000*5 = 5 minutes - activitiesInterval: 20000, + interval: locationInterval, + fastestInterval: locationInterval, + activitiesInterval: locationInterval, + activityType: "AutomotiveNavigation", + pauseLocationUpdates: false, + saveBatteryOnBackground: true, stopOnStillActivity: false, - postTemplate: { - lat: '@latitude', - lon: '@longitude', - foo: 'bar' // you can also add your own properties - } }); BackgroundGeolocation.on('location', (location) => { From fcf4aa0963722fdc06a5b49cdd0259abc80194b4 Mon Sep 17 00:00:00 2001 From: David Biga Date: Thu, 19 Mar 2020 18:42:44 -0500 Subject: [PATCH 2/2] Remove Additional Stop Location Recording --- app/views/LocationTracking.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/app/views/LocationTracking.js b/app/views/LocationTracking.js index 888b107192..e6b47df118 100644 --- a/app/views/LocationTracking.js +++ b/app/views/LocationTracking.js @@ -115,16 +115,10 @@ class LocationTracking extends Component { ) } - - {this.state.isLogging ? + + {this.state.isLogging ? It is currently logging your location privately every five minutes. Your location information will NOT leave your phone. : NOTE: After clicking this button you may be prompted to grant Private Kit access to your location. } - - - -