e-mission / e-mission-data-collection

Repository for our own data collection
BSD 3-Clause "New" or "Revised" License
4 stars 19 forks source link

Stop tracking unwanted trips in fleet mode on iOS #234

Closed catarial closed 2 months ago

catarial commented 2 months ago

Unwanted trips where there is no BLE beacon are happening on iPhone when using a fleet server. This is caused by not checking for fleet mode when receiving a VISIT_ENDED transition.

This can be tested by using an opcode for a fleet server then forcing a transition into VISIT_ENDED. In the unpatched code this triggers a trip start.

Log showing trip start:

In TripDiaryStateMachine, received transition T_VISIT_ENDED in state STATE_WAITING_FOR_TRIP_START
DEBUG: In TripDiaryStateMachine, received transition T_VISIT_ENDED in state STATE_WAITING_FOR_TRIP_START
data has 96 bytes, str has size 96
data has 69 bytes, str has size 69
started fine location tracking with accuracy = -1 and distanceFilter = 1
DEBUG: started fine location tracking with accuracy = -1 and distanceFilter = 1
In TripDiaryStateMachine, received transition T_TRIP_STARTED in state STATE_WAITING_FOR_TRIP_START
DEBUG: In TripDiaryStateMachine, received transition T_TRIP_STARTED in state STATE_WAITING_FOR_TRIP_START
data has 98 bytes, str has size 98
data has 69 bytes, str has size 69
Moved from STATE_WAITING_FOR_TRIP_START to STATE_ONGOING_TRIP

This was fixed by simply ignoring a VISIT_ENDED transition for fleet mode.

Log after patch, trip doesn't start:

DEBUG: In TripDiaryStateMachine, received transition T_VISIT_ENDED in state STATE_WAITING_FOR_TRIP_START
data has 97 bytes, str has size 97
data has 68 bytes, str has size 68
Got transition T_VISIT_ENDED in state STATE_WAITING_FOR_TRIP_START with fleet mode, ignoring, no beacon found
Ignoring silent push notification
THREAD WARNING: ['DataCollection'] took '10,231.5830' ms. Plugin should use a background thread.
DEBUG:parseState: state = STATE_WAITING_FOR_TRIP_START; 
      platformId = ios
DEBUG: parseState: state = STATE_WAITING_FOR_TRIP_START; 
      platformId = iOS
catarial commented 2 months ago

Changes to fleet logs compiled and ran. I couldn't verify if it shows in the actual phone log but it shows in the Xcode log.

Got transition T_VISIT_ENDED in state STATE_WAITING_FOR_TRIP_START with fleet mode, ignoring, no beacon found
DEBUG: Got transition T_VISIT_ENDED in state STATE_WAITING_FOR_TRIP_START with fleet mode, ignoring, no beacon found
shankari commented 2 months ago

🥳 Congratulations to @catarial for the first merge 🎉