Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intermittent tracking due to missing foreground service in Malawi on Huawei phones #677

Open
shankari opened this issue Oct 8, 2021 · 29 comments

Comments

@shankari
Copy link
Contributor

shankari commented Oct 8, 2021

And the phone had been stuck in "ongoing trip" state for two days.

To recap:

  • There are two foreground notifications that the app generates:
    • “Ready for your next trip”
    • “Yay! You are on a trip, keep going!”
  • One of these notifications should be visible at all times for the tracking to work properly
  • The app checks for the existence of these notifications every hour and restarts them if they don’t exist. So we should miss no more than an hour’s worth of data.

Missing data from 24th to 26th; Phone was turned off
I don’t know when it was turned off, but I do get a notification when it is turned on. And it was turned on multiple times in that time period

110082,1632512172.794,2021-09-24T21:36:12.794000+02:00,BootReceiver : BootReceiver.onReceive called
110274,1632640710.6379998,2021-09-26T09:18:30.638000+02:00,BootReceiver : BootReceiver.onReceive called
114733,1632678813.2779999,2021-09-26T19:53:33.278000+02:00,BootReceiver : BootReceiver.onReceive called

** Missing data from the 28th to the 30th; the app appeared to have background restrictions **

I basically don’t see any logs between the 27th, when we got a location point, and the 30th, when he launched the app. This means that the app was not launched every hour, it did not check for the foreground service, it didn’t get any locations, etc.

116491,1632746879.236,2021-09-27T14:47:59.236000+02:00,"LocationChangeIntentService : last5MinsSpan = 284.83200001716614 secs, threshold + fuzz = 270"
116492,1632746879.238,2021-09-27T14:47:59.238000+02:00,LocationChangeIntentService : maxDistance = 1098.4273681640625 TRIP_END_RADIUS = 100
116493,1632746879.2410002,2021-09-27T14:47:59.241000+02:00,LocationChangeIntentService : stoppedMoving: stoppedMoving = false
116494,1632746879.2429998,2021-09-27T14:47:59.243000+02:00,LocationChangeIntentService : isTripEnded: stoppedMoving = false
116495,1632746879.2470002,2021-09-27T14:47:59.247000+02:00,LocationChangeIntentService : onDestroy called

116496,1633018129.322,2021-09-30T18:08:49.322000+02:00,UnifiedLogger : finished init of android native code
116497,1633018129.336,2021-09-30T18:08:49.336000+02:00,truncating obsolete entries before 1.630426129336E9
116498,1633018129.927,2021-09-30T18:08:49.927000+02:00,BuiltinUserCache : Added value for key stats/client_nav_event at time 1.633018129925E9
116499,1633018129.931,2021-09-30T18:08:49.931000+02:00,TripDiaryStateMachineRcvr : Comparing installed version 15 with new version 15
116500,1633018129.9320002,2021-09-30T18:08:49.932000+02:00,"TripDiaryStateMachineRcvr : Setup complete, skipping initialize"
116501,1633018133.322,2021-09-30T18:08:53.322000+02:00,js : ionicPlatform is ready

There were definitely stretches of time before this where the period sync ran successfully.

110139,1632640627.6460001,2021-09-26T09:17:07.646000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
110326,1632646172.14,2021-09-26T10:49:32.140000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
111644,1632649693.6620002,2021-09-26T11:48:13.662000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
111780,1632655365.004,2021-09-26T13:22:45.004000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
113418,1632658688.393,2021-09-26T14:18:08.393000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
113964,1632663139.217,2021-09-26T15:32:19.217000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
114080,1632663142.3639998,2021-09-26T15:32:22.364000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
114129,1632668987.455,2021-09-26T17:09:47.455000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
114230,1632668995.051,2021-09-26T17:09:55.051000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
114333,1632668998.301,2021-09-26T17:09:58.301000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
114438,1632678740.417,2021-09-26T19:52:20.417000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
114620,1632678771.258,2021-09-26T19:52:51.258000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
114797,1632678842.012,2021-09-26T19:54:02.012000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
114916,1632678847.1239998,2021-09-26T19:54:07.124000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
115106,1632678894.2910001,2021-09-26T19:54:54.291000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY

So also checked with the user on whether they changed any app settings.

@shankari
Copy link
Contributor Author

shankari commented Oct 8, 2021

Response from the user:

  • did not reboot
    • wondered if app had automatically rebooted to apply software updates
    • also wondered if update had automatically reset any settings
    • Response: last update was from February
  • did not change any app settings
    • asked to check app settings against dontkillmyapp
    • asked to send screenshots to double check

@shankari
Copy link
Contributor Author

shankari commented Oct 8, 2021

Digging a bit deeper into the reboots, we see that most of them are very short (~ 2 mins long). The only exception is the one at 2021-09-23T19:31:13 -> 2021-09-24T21:36:12. That is an upper bound on the time the phone was off; the actual time off could be much shorter, given that we also have issues with consistent background logging.

This does seem to argue for automatic restarts, but I am not sure why these restarts occur.

$ grep --before-context=1 BootReceiver /tmp/loggerDB.wilfred.upload_issues.withdate.log
1243,1630496719.283,2021-09-01T13:45:19.283000+02:00,js : Retrieved 32 points
1244,1630500428.174,2021-09-01T14:47:08.174000+02:00,BootReceiver : BootReceiver.onReceive called
--
109253,1631645086.387,2021-09-14T20:44:46.387000+02:00,BuiltinUserCache : Added value for key stats/client_time at time 1.631645086364E9
109254,1631645178.204,2021-09-14T20:46:18.204000+02:00,BootReceiver : BootReceiver.onReceive called
--
110081,1632418273.911,2021-09-23T19:31:13.911000+02:00,BuiltinUserCache : Added value for key stats/client_time at time 1.632418273909E9
110082,1632512172.794,2021-09-24T21:36:12.794000+02:00,BootReceiver : BootReceiver.onReceive called
--
110273,1632640636.9129999,2021-09-26T09:17:16.913000+02:00,BuiltinUserCache : Added value for key stats/client_time at time 1.632640636901E9
110274,1632640710.6379998,2021-09-26T09:18:30.638000+02:00,BootReceiver : BootReceiver.onReceive called
--
114732,1632678786.7270002,2021-09-26T19:53:06.727000+02:00,BuiltinUserCache : Added value for key stats/client_time at time 1.632678786589E9
114733,1632678813.2779999,2021-09-26T19:53:33.278000+02:00,BootReceiver : BootReceiver.onReceive called

@shankari
Copy link
Contributor Author

shankari commented Oct 8, 2021

Apparently, some phones do reboot periodically, although the link focuses on the P10.
https://thedroidguy.com/how-to-fix-a-huawei-p10-that-keeps-rebooting-randomly-troubleshooting-guide-1088905

We can in fact see the "last reboot" in the android settings; asking the user to check that as well. This is typically under Settings -> About device -> Status. Or similar. However, if the reboots are of short duration, they are unlikely to affect the sensing in any serious way.

So the check is purely to understand if the reboots are a symptom of a more serious issue, which may lead to increased foreground service killing, etc.

@shankari
Copy link
Contributor Author

shankari commented Oct 9, 2021

Next, let's look at the gaps in periodic execution and what they are linked with. I pick gaps that are 24 hours apart. so there is a jump in the days of adjacent execution attempts.

This gives us:

57000,1631077603.196,2021-09-08T07:06:43.196000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
57239,1631167829.542,2021-09-09T08:10:29.542000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY


108421,1631492099.5370002,2021-09-13T02:14:59.537000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
108477,1631591363.94,2021-09-14T05:49:23.940000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY


109117,1631645078.958,2021-09-14T20:44:38.958000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
109434,1631763165.803,2021-09-16T05:32:45.803000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
109577,1632107894.62,2021-09-20T05:18:14.620000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY

109729,1632111211.5470002,2021-09-20T06:13:31.547000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
109874,1632418266.726,2021-09-23T19:31:06.726000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY

110010,1632418270.248,2021-09-23T19:31:10.248000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
110139,1632640627.6460001,2021-09-26T09:17:07.646000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY

@shankari
Copy link
Contributor Author

shankari commented Oct 9, 2021

Trying to combine these gaps with the foreground service killed notification is inconclusive.

$ egrep "^57239|^108477|^109117|^109434|^109577|^109874|^110139|killed" /tmp/loggerDB.xxxx.upload_issues.withdate.log

after restarting with every gap the foreground service had been killed.

57239,1631167829.542,2021-09-09T08:10:29.542000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
57246,1631167829.6,2021-09-09T08:10:29.600000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"

108477,1631591363.94,2021-09-14T05:49:23.940000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
108484,1631591364.024,2021-09-14T05:49:24.024000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"

109117,1631645078.958,2021-09-14T20:44:38.958000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
109124,1631645079.019,2021-09-14T20:44:39.019000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"

109434,1631763165.803,2021-09-16T05:32:45.803000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
109441,1631763165.938,2021-09-16T05:32:45.938000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"

109577,1632107894.62,2021-09-20T05:18:14.620000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
109584,1632107895.881,2021-09-20T05:18:15.881000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"

109874,1632418266.726,2021-09-23T19:31:06.726000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
109881,1632418266.785,2021-09-23T19:31:06.785000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"

110139,1632640627.6460001,2021-09-26T09:17:07.646000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
110146,1632640628.1279998,2021-09-26T09:17:08.128000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"

But there are plenty of instances where the foreground service was killed and there was no gap - e.g.

8332,1630641541.8620002,2021-09-03T05:59:01.862000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
8439,1630644864.258,2021-09-03T06:54:24.258000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
9843,1630681542.13,2021-09-03T17:05:42.130000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
15258,1630692346.605,2021-09-03T20:05:46.605000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
15981,1630696052.927,2021-09-03T21:07:32.927000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
16134,1630697125.7329998,2021-09-03T21:25:25.733000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
16979,1630701540.732,2021-09-03T22:39:00.732000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"

And plenty of syncs without a killed notification.

8087,1630621784.1339998,2021-09-03T00:29:44.134000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
8128,1630625511.495,2021-09-03T01:31:51.495000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
8176,1630637789.125,2021-09-03T04:56:29.125000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
8217,1630637792.492,2021-09-03T04:56:32.492000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
8325,1630641541.742,2021-09-03T05:59:01.742000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
8332,1630641541.8620002,2021-09-03T05:59:01.862000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
8432,1630644864.224,2021-09-03T06:54:24.224000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
8439,1630644864.258,2021-09-03T06:54:24.258000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
8675,1630645009.948,2021-09-03T06:56:49.948000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
8869,1630648443.6529999,2021-09-03T07:54:03.653000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
8920,1630652537.857,2021-09-03T09:02:17.857000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
9193,1630655843.8470001,2021-09-03T09:57:23.847000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
9244,1630660236.795,2021-09-03T11:10:36.795000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
9295,1630663543.498,2021-09-03T12:05:43.498000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
9576,1630666246.591,2021-09-03T12:50:46.591000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
9632,1630667143.177,2021-09-03T13:05:43.177000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
9683,1630670952.28,2021-09-03T14:09:12.280000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
9734,1630674342.504,2021-09-03T15:05:42.504000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
9785,1630677953.734,2021-09-03T16:05:53.734000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
9836,1630681542.083,2021-09-03T17:05:42.083000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
9843,1630681542.13,2021-09-03T17:05:42.130000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
11570,1630685283.1039999,2021-09-03T18:08:03.104000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
13736,1630688741.8079998,2021-09-03T19:05:41.808000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
15251,1630692346.5670002,2021-09-03T20:05:46.567000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
15258,1630692346.605,2021-09-03T20:05:46.605000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
15974,1630696052.842,2021-09-03T21:07:32.842000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
15981,1630696052.927,2021-09-03T21:07:32.927000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
16081,1630696343.1320002,2021-09-03T21:12:23.132000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
16127,1630697125.704,2021-09-03T21:25:25.704000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
16134,1630697125.7329998,2021-09-03T21:25:25.733000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
16972,1630701540.668,2021-09-03T22:39:00.668000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
16979,1630701540.732,2021-09-03T22:39:00.732000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
19412,1630704848.2489998,2021-09-03T23:34:08.249000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY

Concretely, it looks like on the 3rd, the periodic activity was invoked 26 times and the foreground service was detected as killed 7 times. That is an order of magnitude greater than what I have seen before.

$ head -n2 /tmp/sep-3
8087,1630621784.1339998,2021-09-03T00:29:44.134000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
8128,1630625511.495,2021-09-03T01:31:51.495000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY


$ tail -n2 /tmp/sep-3
16979,1630701540.732,2021-09-03T22:39:00.732000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
19412,1630704848.2489998,2021-09-03T23:34:08.249000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY

$ grep PERIODIC /tmp/sep-3 | wc -l
      26
$ grep killed /tmp/sep-3 | wc -l
       7

@shankari
Copy link
Contributor Author

shankari commented Oct 9, 2021

Got reply from the user:

I have changed the settings as per the instructions given. Screenshot attached.

Ignore optimization Modify launch settings
Screenshot_20211009-074626 Screenshot_20211009-065929

@shankari
Copy link
Contributor Author

We also had a second Malawi user upload their logs. They have an android 10 phone from TECNO MOBILE LIMITED. Let's see how the background and foreground work in their case.

@shankari
Copy link
Contributor Author

shankari commented Oct 12, 2021

This second user had the foreground service killed only rarely

$ egrep "killed" first_user.withdate.log | wc -l
     121
$ egrep "killed" second_user.withdate.log | wc -l
       4

And even when they were killed, the service was only off for an hour or so. The max was 3 hours at around 5am.

9021,1630494273.686,2021-09-01T13:04:33.686000+02:00,"TripDiaryStateMachineForegroundService : In checkForegroundNotification, found 1 active notifications"
10134,1630498159.0110002,2021-09-01T14:09:19.011000+02:00,"TripDiaryStateMachineForegroundService : In checkForegroundNotification, found 0 active notifications"
10140,1630498159.8539999,2021-09-01T14:09:19.854000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
10299,1630503201.6529999,2021-09-01T15:33:21.653000+02:00,"TripDiaryStateMachineForegroundService : In checkForegroundNotification, found 0 active notifications"
10305,1630503202.085,2021-09-01T15:33:22.085000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"


31707,1630813088.97,2021-09-05T05:38:08.970000+02:00,"TripDiaryStateMachineForegroundService : In checkForegroundNotification, found 1 active notifications"
32742,1630822326.8070002,2021-09-05T08:12:06.807000+02:00,"TripDiaryStateMachineForegroundService : In checkForegroundNotification, found 0 active notifications"
32748,1630822327.21,2021-09-05T08:12:07.210000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"

143578,1632593168.008,2021-09-25T20:06:08.008000+02:00,"TripDiaryStateMachineForegroundService : In checkForegroundNotification, found 1 active notifications"
143622,1632598983.5279999,2021-09-25T21:43:03.528000+02:00,"TripDiaryStateMachineForegroundService : In checkForegroundNotification, found 0 active notifications"
143628,1632598986.2710001,2021-09-25T21:43:06.271000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"

Number of reboots is around the same

$ egrep "BootReceiver" first.user.withdate.log | wc -l
       5
$ egrep "BootReceiver" second.user.withdate.log | wc -l
       7

@shankari
Copy link
Contributor Author

shankari commented Oct 12, 2021

Looking through the periodic calls, we see that they are fairly regular for the second user, much more so than for the first user.

>>> import pandas as pd
>>> all_sync = pd.read_csv("/tmp/foo", header=None)
>>> all_sync.columns = ["id", "ts", "fmt_time", "msg"]
>>> all_sync.ts.diff().describe()
count       306.000000
mean       6796.056882
std       30788.981102
min           1.253000
25%           7.291500
50%        3308.726500
75%        3703.175500
max      344728.817000
Name: ts, dtype: float64
>>> import pandas as pd
>>> all_sync = pd.read_csv("/tmp/fo", header=None)
>>> all_sync.columns = ["id", "ts", "fmt_time", "msg"]
>>> all_sync.ts.diff().describe()
count      531.000000
mean      4879.399896
std       5468.768758
min          6.776000
25%       3582.053500
50%       3600.314000
75%       3628.706500
max      36069.890000
Name: ts, dtype: float64

Looking at the outliers in both cases....

Gap of at least 24 hours between runs

>>> all_sync_1[all_sync_ts_diff_1 > (3600  *24)][["id", "fmt_time"]]
         id                          fmt_time
185   57239  2021-09-09T08:10:29.542000+02:00
277  108477  2021-09-14T05:49:23.940000+02:00
287  109434  2021-09-16T05:32:45.803000+02:00
288  109577  2021-09-20T05:18:14.620000+02:00
290  109874  2021-09-23T19:31:06.726000+02:00
292  110139  2021-09-26T09:17:07.646000+02:00

>>> all_sync_2[all_sync_ts_diff_2 > (3600  *24)][["id", "fmt_time"]]
__main__:1: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
Empty DataFrame
Columns: [id, fmt_time]
Index: []

Gap of at least 12 hours between runs

>>> all_sync_1[all_sync_ts_diff_1 > (3600  *12)][["id", "fmt_time"]]
         id                          fmt_time
185   57239  2021-09-09T08:10:29.542000+02:00
277  108477  2021-09-14T05:49:23.940000+02:00
287  109434  2021-09-16T05:32:45.803000+02:00
288  109577  2021-09-20T05:18:14.620000+02:00
290  109874  2021-09-23T19:31:06.726000+02:00
292  110139  2021-09-26T09:17:07.646000+02:00

>>> all_sync_2[all_sync_ts_diff_2 > (3600  *12)][["id", "fmt_time"]]
Empty DataFrame
Columns: [id, fmt_time]
Index: []

Gap of at least 6 hours between runs

>>> all_sync_1[all_sync_ts_diff_1 > (3600  *6)][["id", "fmt_time"]]
         id                          fmt_time
70    26176  2021-09-05T04:14:42.403000+02:00
172   54177  2021-09-08T07:04:37.512000+02:00
185   57239  2021-09-09T08:10:29.542000+02:00
212   94742  2021-09-10T08:52:48.703000+02:00
227   96644  2021-09-11T07:19:44.216000+02:00
248  102782  2021-09-12T05:09:16.635000+02:00
277  108477  2021-09-14T05:49:23.940000+02:00
287  109434  2021-09-16T05:32:45.803000+02:00
288  109577  2021-09-20T05:18:14.620000+02:00
290  109874  2021-09-23T19:31:06.726000+02:00
292  110139  2021-09-26T09:17:07.646000+02:00

>>> all_sync_2[all_sync_ts_diff_2 > (3600  *6)][["id", "fmt_time"]]
         id                          fmt_time
5       304  2021-09-01T06:27:55.181000+02:00
22    11237  2021-09-02T06:58:37.641000+02:00
37    20298  2021-09-03T05:27:09.121000+02:00
54    30505  2021-09-04T05:27:48.417000+02:00
72    31657  2021-09-05T03:42:58.501000+02:00
91    39483  2021-09-06T06:55:50.943000+02:00
124   57002  2021-09-08T06:33:03.772000+02:00
159   65850  2021-09-10T06:41:51.563000+02:00
175   79015  2021-09-11T05:50:41.485000+02:00
195   80006  2021-09-12T06:13:52.610000+02:00
212   87626  2021-09-13T06:38:18.884000+02:00
230  106076  2021-09-14T07:01:59.523000+02:00
245  108871  2021-09-15T06:12:39.810000+02:00
264  117241  2021-09-16T07:26:21.054000+02:00
279  122915  2021-09-17T06:22:50.468000+02:00
300  128968  2021-09-18T07:06:14.155000+02:00
318  130226  2021-09-19T08:39:38.243000+02:00
334  137022  2021-09-20T06:41:28.657000+02:00
373  140241  2021-09-22T06:12:44.335000+02:00
410  142035  2021-09-24T06:34:49.764000+02:00
425  142814  2021-09-25T05:41:00.859000+02:00
445  143886  2021-09-26T07:03:04.340000+02:00
464  145306  2021-09-27T05:55:42.746000+02:00
482  146328  2021-09-28T06:01:43.011000+02:00
501  147595  2021-09-29T05:42:55.776000+02:00
516  148669  2021-09-30T05:57:01.093000+02:00

So the second user doesn't have any really egregious gaps, but does have a lot more small gaps.

Looking at some of the timestamps in detail...

262,1630443884.935,2021-08-31T23:04:44.935000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
304,1630470475.181,2021-09-01T06:27:55.181000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY


148614,1632947808.752,2021-09-29T22:36:48.752000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
148669,1632974221.093,2021-09-30T05:57:01.093000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY

For the second user, the gaps don't seem to be related to either the foreground service killed or the reboots.

$ egrep "killed|BootReceiver" /tmp/second.user.withdate.log
9677,1630496925.391,2021-09-01T13:48:45.391000+02:00,BootReceiver : BootReceiver.onReceive called
10140,1630498159.8539999,2021-09-01T14:09:19.854000+02:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"

144410,1632647743.947,2021-09-26T11:15:43.947000+02:00,BootReceiver : BootReceiver.onReceive called
145355,1632719820.5170002,2021-09-27T07:17:00.517000+02:00,BootReceiver : BootReceiver.onReceive called

Given that the gaps seem to principally occur overnight for the second user (the sync after the gap is consistently between 5:30am and 7:30am), the gaps for the second user seem to be primarily related to doze mode.

@shankari
Copy link
Contributor Author

Response from the user: no foreground service kills for three days after settings change. However, app was incorrectly stuck in ongoing_trip for a whole day. Is uploading logs to investigate.

@shankari
Copy link
Contributor Author

Final investigation on network issues, since we had problems with the upload:
When we attempt to communicate with the server, we either get response 200 (everything was fine)

38,1630429477.4770002,2021-08-31T19:04:37.477000+02:00,CommunicationHelper : Got response org.apache.http.message.BasicHttpResponse@57536a8 with status HTTP/1.1 200 OK

or an IO Error.

297,1630443945.4589999,2021-08-31T23:05:45.459000+02:00,ServerSyncAdapter : IO Error org.apache.http.conn.ConnectTimeoutException: Connect to /3.142.96.31:443 timed out while posting converted trips to JSON

For user1, the ratio was 2.56

$ grep "200 OK" /tmp/foo | wc -l
     405
$ grep "IO Error" /tmp/foo | wc -l
     158

For user2, the ratio was 0.53

$ grep "200 OK" /tmp/fo | wc -l
     277
$ grep "IO Error" /tmp/fo | wc -l
     514

However, in both cases, we recovered from the network errors, and the last logs were from successful attempts. So, at least for these two users, it looks like the network issues are intermittent typically resolve themselves.

$ tail -n3 /tmp/foo
116652,1633018156.941,2021-09-30T18:09:16.941000+02:00,CommunicationHelper : Got response org.apache.http.message.BasicHttpResponse@95225f9 with status HTTP/1.1 200 OK
116678,1633018233.061,2021-09-30T18:10:33.061000+02:00,CommunicationHelper : Got response org.apache.http.message.BasicHttpResponse@7ed6dee with status HTTP/1.1 200 OK
116723,1633018265.8879998,2021-09-30T18:11:05.888000+02:00,CommunicationHelper : Got response org.apache.http.message.BasicHttpResponse@d5414c with status HTTP/1.1 200 OK

$ tail -n3 /tmp/fo
150617,1633020422.0470002,2021-09-30T18:47:02.047000+02:00,CommunicationHelper : Got response org.apache.http.message.BasicHttpResponse@ea517fb with status HTTP/1.1 200 OK
150627,1633020423.768,2021-09-30T18:47:03.768000+02:00,CommunicationHelper : Got response org.apache.http.message.BasicHttpResponse@5e7f5eb with status HTTP/1.1 200 OK
150711,1633020438.41,2021-09-30T18:47:18.410000+02:00,CommunicationHelper : Got response org.apache.http.message.BasicHttpResponse@2375342 with status HTTP/1.1 200 OK

@shankari
Copy link
Contributor Author

To summarize, there were three potential issues with the end-to-end pipeline:

  1. the data was not being sensed
  2. the data was sensed but not uploaded
  3. the data was not properly post-processed

From the investigation above, it seems pretty clear that the primary problem is (1). It appears as though (1) can largely be mitigated by fixing the background settings so that the foreground service is not killed as often (manual report from user 1 + #677 (comment) + #677 (comment))

Pending issues/additional follow-ups:

  • Day-long trip reported by user 1 (pending log upload)
  • Verification from user 2 that their trips were actually accurate

LMK if there is anything else that you can think of.

@shankari
Copy link
Contributor Author

shankari commented Oct 12, 2021

Some more data from a third chinese phone. This time, it is a OnePlus in the US.
Lots more reboots than the first two, although a lot fewer "killed" entries.

$ grep "BootReceiver" /tmp/2021-10-07_No_trips_America_Denver.loggerDB.withdate.log | wc -l
      33
$ grep "killed" /tmp/2021-10-07_No_trips_America_Denver.loggerDB.withdate.log | wc -l
      26

Large gap in periodic sync is typically overnight (restarting between 4am and 8am), similar to user 2 and consistent with doze mode.

>>> all_sync[all_sync_ts_diff > (3600 * 24)][["id", "fmt_time"]]
Empty DataFrame
Columns: [id, fmt_time]
Index: []
>>> all_sync[all_sync_ts_diff > (3600 * 12)][["id", "fmt_time"]]
         id                          fmt_time
51    12820  2021-09-17T06:59:56.239000-06:00
74    20740  2021-09-19T07:18:47.847000-06:00
320  244907  2021-10-04T07:05:32.769000-06:00
361  281845  2021-10-06T07:22:14.988000-06:00
396  288823  2021-10-07T07:34:11.440000-06:00


>>> all_sync[all_sync_ts_diff > (3600 * 6)][["id", "fmt_time"]]
         id                          fmt_time
5      1987  2021-09-14T04:09:51.023000-06:00
20     4951  2021-09-15T04:48:28.930000-06:00
36     8624  2021-09-16T04:48:37.825000-06:00
51    12820  2021-09-17T06:59:56.239000-06:00
63    16668  2021-09-18T07:06:26.495000-06:00
74    20740  2021-09-19T07:18:47.847000-06:00
87    30483  2021-09-20T04:05:45.987000-06:00
102   41659  2021-09-21T04:15:03.980000-06:00
118   55379  2021-09-22T04:20:21.478000-06:00
135   73181  2021-09-23T04:16:02.340000-06:00
151   85421  2021-09-24T06:24:49.015000-06:00
164  107602  2021-09-25T07:07:09.665000-06:00
177  122342  2021-09-26T06:01:06.602000-06:00
191  136030  2021-09-27T04:18:48.968000-06:00
210  157755  2021-09-28T04:19:07.128000-06:00
231  169850  2021-09-29T04:26:12.776000-06:00
253  181491  2021-09-30T04:22:25.254000-06:00
272  195170  2021-10-01T07:10:47.333000-06:00
286  211527  2021-10-02T06:45:35.380000-06:00
303  227954  2021-10-03T05:10:46.462000-06:00
320  244907  2021-10-04T07:05:32.769000-06:00
339  267999  2021-10-05T04:41:26.731000-06:00
361  281845  2021-10-06T07:22:14.988000-06:00
396  288823  2021-10-07T07:34:11.440000-06:00

Most of the killed notifications were also in this range, indicating that the app resources had been "cleaned up" overnight.

1994,1631614191.262,2021-09-14T04:09:51.262000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
4958,1631702909.3920002,2021-09-15T04:48:29.392000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
more, more
8631,1631789319.1629999,2021-09-16T04:48:39.163000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
12827,1631883596.929,2021-09-17T06:59:56.929000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
16675,1631970386.5679998,2021-09-18T07:06:26.568000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
20747,1632057528.073,2021-09-19T07:18:48.073000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
30136,1632094373.832,2021-09-19T17:32:53.832000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
30490,1632132346.485,2021-09-20T04:05:46.485000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
41666,1632219304.25,2021-09-21T04:15:04.250000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
55386,1632306022.627,2021-09-22T04:20:22.627000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
73188,1632392162.611,2021-09-23T04:16:02.611000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
85428,1632486290.559,2021-09-24T06:24:50.559000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
107609,1632575229.71,2021-09-25T07:07:09.710000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
122349,1632657666.7389998,2021-09-26T06:01:06.739000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
136037,1632737929.2810001,2021-09-27T04:18:49.281000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
157762,1632824348.1920002,2021-09-28T04:19:08.192000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
169857,1632911173.4429998,2021-09-29T04:26:13.443000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
181498,1632997345.505,2021-09-30T04:22:25.505000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
195177,1633093847.794,2021-10-01T07:10:47.794000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
211534,1633178735.561,2021-10-02T06:45:35.561000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
244469,1633304561.8779998,2021-10-03T17:42:41.878000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
244914,1633352732.856,2021-10-04T07:05:32.856000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
268006,1633430487.051,2021-10-05T04:41:27.051000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
281852,1633526535.7470002,2021-10-06T07:22:15.747000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
287261,1633552587.971,2021-10-06T14:36:27.971000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"
288830,1633613651.7670002,2021-10-07T07:34:11.767000-06:00,"NotificationHelper : Generating notify with id 6646465 and message Foreground service killed, report at Profile -> Upload Log"

And so are the reboots.

2175,1631614245.296,2021-09-14T04:10:45.296000-06:00,BootReceiver : BootReceiver.onReceive called
5075,1631702955.845,2021-09-15T04:49:15.845000-06:00,BootReceiver : BootReceiver.onReceive called
more, more
8801,1631789366.496,2021-09-16T04:49:26.496000-06:00,BootReceiver : BootReceiver.onReceive called
13047,1631883646.044,2021-09-17T07:00:46.044000-06:00,BootReceiver : BootReceiver.onReceive called
16936,1631970434.981,2021-09-18T07:07:14.981000-06:00,BootReceiver : BootReceiver.onReceive called
21046,1632057575.8720002,2021-09-19T07:19:35.872000-06:00,BootReceiver : BootReceiver.onReceive called
30186,1632094406.792,2021-09-19T17:33:26.792000-06:00,BootReceiver : BootReceiver.onReceive called
30542,1632132394.986,2021-09-20T04:06:34.986000-06:00,BootReceiver : BootReceiver.onReceive called
34451,1632160399.332,2021-09-20T11:53:19.332000-06:00,BootReceiver : BootReceiver.onReceive called
41718,1632219354.093,2021-09-21T04:15:54.093000-06:00,BootReceiver : BootReceiver.onReceive called
56084,1632306083.5979998,2021-09-22T04:21:23.598000-06:00,BootReceiver : BootReceiver.onReceive called
57486,1632320498.175,2021-09-22T08:21:38.175000-06:00,BootReceiver : BootReceiver.onReceive called
72667,1632350489.333,2021-09-22T16:41:29.333000-06:00,BootReceiver : BootReceiver.onReceive called
73246,1632392218.418,2021-09-23T04:16:58.418000-06:00,BootReceiver : BootReceiver.onReceive called
80892,1632425662.1339998,2021-09-23T13:34:22.134000-06:00,BootReceiver : BootReceiver.onReceive called
85055,1632444278.951,2021-09-23T18:44:38.951000-06:00,BootReceiver : BootReceiver.onReceive called
85487,1632486337.485,2021-09-24T06:25:37.485000-06:00,BootReceiver : BootReceiver.onReceive called
106777,1632521663.32,2021-09-24T16:14:23.320000-06:00,BootReceiver : BootReceiver.onReceive called
107670,1632575270.853,2021-09-25T07:07:50.853000-06:00,BootReceiver : BootReceiver.onReceive called
122411,1632657715.6520002,2021-09-26T06:01:55.652000-06:00,BootReceiver : BootReceiver.onReceive called
136345,1632737987.24,2021-09-27T04:19:47.240000-06:00,BootReceiver : BootReceiver.onReceive called
157824,1632824398.967,2021-09-28T04:19:58.967000-06:00,BootReceiver : BootReceiver.onReceive called
170033,1632911222.074,2021-09-29T04:27:02.074000-06:00,BootReceiver : BootReceiver.onReceive called
181560,1632997399.658,2021-09-30T04:23:19.658000-06:00,BootReceiver : BootReceiver.onReceive called
170033,1632911222.074,2021-09-29T04:27:02.074000-06:00,BootReceiver : BootReceiver.onReceive called
181560,1632997399.658,2021-09-30T04:23:19.658000-06:00,BootReceiver : BootReceiver.onReceive called
195241,1633093897.056,2021-10-01T07:11:37.056000-06:00,BootReceiver : BootReceiver.onReceive called
210814,1633127928.3379998,2021-10-01T16:38:48.338000-06:00,BootReceiver : BootReceiver.onReceive called
212703,1633178786.11,2021-10-02T06:46:26.110000-06:00,BootReceiver : BootReceiver.onReceive called
244444,1633304561.697,2021-10-03T17:42:41.697000-06:00,BootReceiver : BootReceiver.onReceive called
244978,1633352777.721,2021-10-04T07:06:17.721000-06:00,BootReceiver : BootReceiver.onReceive called
268070,1633430535.2770002,2021-10-05T04:42:15.277000-06:00,BootReceiver : BootReceiver.onReceive called
281916,1633526586.188,2021-10-06T07:23:06.188000-06:00,BootReceiver : BootReceiver.onReceive called
287580,1633552608.283,2021-10-06T14:36:48.283000-06:00,BootReceiver : BootReceiver.onReceive called
288896,1633613698.181,2021-10-07T07:34:58.181000-06:00,BootReceiver : BootReceiver.onReceive called

Although the user was in the US, they also periodically encountered network errors, but the ratio was very low (~ 2%)

$ grep "200 OK" /tmp/2021-10-07_No_trips_America_Denver.loggerDB.withdate.log | wc -l
    1160
$ grep "IO Error" /tmp/2021-10-07_No_trips_America_Denver.loggerDB.withdate.log | wc -l
      22

@shankari
Copy link
Contributor Author

Day-long trip reported by user 1 (pending log upload)

This log has now been uploaded.

We seem to have only a few periodic calls on all the three recorded days.

21952,1633764685.2979999,2021-10-09T09:31:25.298000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
22243,1633786038.0110002,2021-10-09T15:27:18.011000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY


22533,1633839472.8979998,2021-10-10T06:17:52.898000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
27142,1633848497.694,2021-10-10T08:48:17.694000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY

51112,1633979177.6020002,2021-10-11T21:06:17.602000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY
51414,1633979772.27,2021-10-11T21:16:12.270000+02:00,TripDiaryStateMachineRcvr : START PERIODIC ACTIVITY

@shankari
Copy link
Contributor Author

The first geofence exit in this time range was on the 10th at 7am.

22891,1633844498.429,2021-10-10T07:41:38.429000+02:00,GeofenceExitIntentService : onCreate called

So what was going on for the duration of the 9th? We started off in the ongoing
trip state. Not sure what launched the foreground service, but something did.

21390,1633755047.292,2021-10-09T06:50:47.292000+02:00,"TripDiaryStateMachineForegroundService : onStartCommand called on oreo+, with msg Yay! You are on a trip, keep going! starting foreground service"

It detected that we were on an ongoing trip and generated an initialize. Actually, we generated multiple initialize transitions, but I am not quite sure why.

21399,1633755047.365,2021-10-09T06:50:47.365000+02:00,"TripDiaryStateMachineService : handleAction(local.state.ongoing_trip, local.transition.initialize) called"
21402,1633755047.431,2021-10-09T06:50:47.431000+02:00,"TripDiaryStateMachineService : handleAction(local.state.ongoing_trip, local.transition.initialize) completed, waiting for async operations to complete"

21462,1633755047.619,2021-10-09T06:50:47.619000+02:00,"TripDiaryStateMachineService : handleAction(local.state.ongoing_trip, local.transition.initialize) called"
21465,1633755047.631,2021-10-09T06:50:47.631000+02:00,"TripDiaryStateMachineService : handleAction(local.state.ongoing_trip, local.transition.initialize) completed, waiting for async operations to complete"

At this point, we start trying to create a geofence (since we have an initialize transition during an ongoing trip).

        // The current state is stored in the shared preferences, so on reboot, for example, we would
        // store that we are in ongoing_trip, but no listeners would be registered. We can have
        // the broadcast receiver generate an initialize transition, but the states other than
        // start don't handle initialize. So if we get an initialize, we manually call the start method.

        if (actionString.equals(ctxt.getString(R.string.transition_initialize))) {
            handleStart(ctxt, actionString);

And we fail consistently due to poor quality location points although all the settings seem to be correct. We only get a good quality location point on the morning of the 10th.

21470,1633755047.6660001,2021-10-09T06:50:47.666000+02:00,CreateGeofenceAction : testLoc.getAccuracy 2000.0 > 200 isValidLocation = false
21471,1633755047.669,2021-10-09T06:50:47.669000+02:00,"SensorControlBackgroundChecker : All settings are valid, checking current state"

21476,1633755047.671,2021-10-09T06:50:47.671000+02:00,CreateGeofenceAction : testLoc.getAccuracy 2000.0 > 200 isValidLocation = false
21651,1633755054.029,2021-10-09T06:50:54.029000+02:00,GeofenceLocationIntentService : Extras values are [LocationAvailability[isLocationAvailable: false]]

21713,1633755054.194,2021-10-09T06:50:54.194000+02:00,CreateGeofenceAction : testLoc.getAccuracy 2000.0 > 200 isValidLocation = false
21739,1633755054.2329998,2021-10-09T06:50:54.233000+02:00,CreateGeofenceAction : testLoc.getAccuracy 2000.0 > 200 isValidLocation = false
21767,1633755054.275,2021-10-09T06:50:54.275000+02:00,CreateGeofenceAction : testLoc.getAccuracy 2000.0 > 200 isValidLocation = false
21795,1633755054.3179998,2021-10-09T06:50:54.318000+02:00,CreateGeofenceAction : testLoc.getAccuracy 2000.0 > 200 isValidLocation = false

22023,1633764685.447,2021-10-09T09:31:25.447000+02:00,CreateGeofenceAction : testLoc.getAccuracy 2099.999 > 200 isValidLocation = false

22328,1633786038.234,2021-10-09T15:27:18.234000+02:00,CreateGeofenceAction : testLoc.getAccuracy 2400.0 > 200 isValidLocation = false

22609,1633839473.269,2021-10-10T06:17:53.269000+02:00,CreateGeofenceAction : isValidLocation = true. Yay!

@shankari
Copy link
Contributor Author

Not sure what launched the foreground service, but something did.
It detected that we were on an ongoing trip and generated an initialize. Actually, we generated multiple initialize transitions, but I am not quite sure why.

The launches were apparently due to the system automatically restarting the service.

If we manually launch the service after it is killed, we pass in an intent.

6638,1630599301.274,2021-09-02T18:15:01.274000+02:00,TripDiaryStateMachineForegroundService : onStartCommand called with intent = Intent { cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.TripDiaryStateMachineForegroundService } flags = 0 and startId = 1

In this case, there is no intent passed in, and the startId keeps increasing. We return START_STICKY from the onStartCommand, so the system will attempt to restart the service.

21381,1633755047.228,2021-10-09T06:50:47.228000+02:00,TripDiaryStateMachineForegroundService : onStartCommand called with intent = null flags = 0 and startId = 15
21390,1633755047.292,2021-10-09T06:50:47.292000+02:00,"TripDiaryStateMachineForegroundService : onStartCommand called on oreo+, with msg Yay! You are on a trip, keep going! starting foreground service"

In subsequent calls, it was launched with an intent.

21988,1633764685.38,2021-10-09T09:31:25.380000+02:00,TripDiaryStateMachineForegroundService : onStartCommand called with intent = Intent { cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.TripDiaryStateMachineForegroundService } flags = 0 and startId = 16
21990,1633764685.381,2021-10-09T09:31:25.381000+02:00,"TripDiaryStateMachineForegroundService : onStartCommand called on oreo+, with msg Yay! You are on a trip, keep going! starting foreground service"


22282,1633786038.125,2021-10-09T15:27:18.125000+02:00,TripDiaryStateMachineForegroundService : onStartCommand called with intent = Intent { cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.TripDiaryStateMachineForegroundService } flags = 0 and startId = 18
22284,1633786038.129,2021-10-09T15:27:18.129000+02:00,"TripDiaryStateMachineForegroundService : onStartCommand called on oreo+, with msg Yay! You are on a trip, keep going! starting foreground service"


22571,1633839473.121,2021-10-10T06:17:53.121000+02:00,TripDiaryStateMachineForegroundService : onStartCommand called with intent = Intent { cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.TripDiaryStateMachineForegroundService } flags = 0 and startId = 20
22573,1633839473.1279998,2021-10-10T06:17:53.128000+02:00,"TripDiaryStateMachineForegroundService : onStartCommand called on oreo+, with msg Yay! You are on a trip, keep going! starting foreground service"

Except for this one.

27335,1633848674.674,2021-10-10T08:51:14.674000+02:00,TripDiaryStateMachineForegroundService : onStartCommand called with intent = null flags = 0 and startId = 23
27344,1633848674.764,2021-10-10T08:51:14.764000+02:00,"TripDiaryStateMachineForegroundService : onStartCommand called on oreo+, with msg Ready for your next trip starting foreground service"

The ones with the intent seem to be launched because we received an initialize message, which in turn, is launched because we are in the ongoing state, but have not received any points recently.

21967,1633764685.323,2021-10-09T09:31:25.323000+02:00,"TripDiaryStateMachineRcvr : Found zero points while in 'ongoing_trip' state, re-initializing"
21982,1633764685.3660002,2021-10-09T09:31:25.366000+02:00,"TripDiaryStateMachineRcvr : TripDiaryStateMachineReciever onReceive(android.app.ReceiverRestrictedContext@f2c112e, Intent { act=local.transition.initialize flg=0x2010 pkg=gov.colorado.energyoffice.emission cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.TripDiaryStateMachineReceiver }) called"
21984,1633764685.3720002,2021-10-09T09:31:25.372000+02:00,"TripDiaryStateMachineRcvr : 2016-07-14 is the current consented version, sending msg to service..."

@shankari
Copy link
Contributor Author

After we got the bad location, we tried to read a new location, but it was consistently null

21548,1633755049.15,2021-10-09T06:50:49.150000+02:00,GeofenceLocationIntentService : Read location null from intent
21555,1633755049.4129999,2021-10-09T06:50:49.413000+02:00,GeofenceLocationIntentService : Read location null from intent
21556,1633755049.4329998,2021-10-09T06:50:49.433000+02:00,GeofenceLocationIntentService : availability = false

21604,1633755050.1339998,2021-10-09T06:50:50.134000+02:00,GeofenceLocationIntentService : Read location null from intent
21665,1633755054.072,2021-10-09T06:50:54.072000+02:00,GeofenceLocationIntentService : Read location null from intent
21682,1633755054.1139998,2021-10-09T06:50:54.114000+02:00,GeofenceLocationIntentService : availability = false
22081,1633764685.851,2021-10-09T09:31:25.851000+02:00,GeofenceLocationIntentService : Read location null from intent
22086,1633764685.904,2021-10-09T09:31:25.904000+02:00,GeofenceLocationIntentService : Read location null from intent
22087,1633764685.907,2021-10-09T09:31:25.907000+02:00,GeofenceLocationIntentService : availability = false


22367,1633786038.3479998,2021-10-09T15:27:18.348000+02:00,GeofenceLocationIntentService : Read location null from intent
22381,1633786038.476,2021-10-09T15:27:18.476000+02:00,GeofenceLocationIntentService : Read location null from intent
22384,1633786038.506,2021-10-09T15:27:18.506000+02:00,GeofenceLocationIntentService : availability = false

@shankari
Copy link
Contributor Author

Note also that, although we did turn on the background settings, there were only a few periodic calls.
#677 (comment)

Maybe the location was available more often, but we just didn't check because of the lack of periodic calls. Should explore silent push notifications on android as well so that we can check more often.

@shankari
Copy link
Contributor Author

Response from tester about the differences between Sat/Sun/Mon

I am not sure why the app was stuck in "ongoing trip" on Saturday. But the locations I went to on Saturday are the same locations I went to on Sunday and Monday (before the 5-hour trip at 3pm).

@shankari
Copy link
Contributor Author

shankari commented Oct 13, 2021

Confirmed that:

  • at ~ 6:50am on Saturday tester was at their lodging place and we weren’t able to get the location.
  • at ~ 6:50am on Sunday tester was at the same place, and we were able to get the location.

Further, the tester traveled to another location on Saturday, and the location was not available either during the drive or at the new location.

That seems to indicate some phone-specific/location services-specific issue on Saturday. Not sure there is an easy resolution for that…

@shankari
Copy link
Contributor Author

One interesting note is that on Sun morning, we didn't read a new location. Instead, we read the last location and it was valid.

Sat morning

21469,1633755047.661,2021-10-09T06:50:47.661000+02:00,"CreateGeofenceAction : Last location would have been Location[fused -16******,35****** hAcc=2000 et=+3d17h7m40s819ms alt=1003.829911860006 vAcc=3 sAcc=??? bAcc=???] if we hadn't reset it"
21470,1633755047.6660001,2021-10-09T06:50:47.666000+02:00,CreateGeofenceAction : testLoc.getAccuracy 2000.0 > 200 isValidLocation = false

Sat late morning

22021,1633764685.4420002,2021-10-09T09:31:25.442000+02:00,"CreateGeofenceAction : Last location would have been Location[fused -16******,35****** hAcc=2100 et=+3d19h39m27s400ms alt=1003.829911860006 vAcc=3 sAcc=??? bAcc=???] if we hadn't reset it"
22023,1633764685.447,2021-10-09T09:31:25.447000+02:00,CreateGeofenceAction : testLoc.getAccuracy 2099.999 > 200 isValidLocation = false

Sat afternoon

22326,1633786038.232,2021-10-09T15:27:18.232000+02:00,"CreateGeofenceAction : Last location would have been Location[fused -16******,35****** hAcc=2400 et=+4d1h33m45s263ms vAcc=??? sAcc=??? bAcc=???] if we hadn't reset it"
22328,1633786038.234,2021-10-09T15:27:18.234000+02:00,CreateGeofenceAction : testLoc.getAccuracy 2400.0 > 200 isValidLocation = false

Sun morning

22607,1633839473.264,2021-10-10T06:17:53.264000+02:00,"CreateGeofenceAction : Last location would have been Location[fused -16******,35****** hAcc=3 et=+4d16h33m37s492ms alt=1053.586075639245 vel=0.26 bear=281.0 vAcc=6 sAcc=??? bAcc=???] if we hadn't reset it"
22609,1633839473.269,2021-10-10T06:17:53.269000+02:00,CreateGeofenceAction : isValidLocation = true. Yay!

So I wonder if there's some weirdness with reading locations in the background or something.

@shankari
Copy link
Contributor Author

It looks like the geofence location reading code fails more often that it works.

$ grep "GeofenceLocationIntentService.*Read location" /tmp/....loggerDB.withdate.log
86,1631481005.198,2021-09-12T23:10:05.198000+02:00,GeofenceLocationIntentService : Read location null from intent
441,1631481788.431,2021-09-12T23:23:08.431000+02:00,GeofenceLocationIntentService : Read location null from intent

629,1631484605.3760002,2021-09-13T00:10:05.376000+02:00,GeofenceLocationIntentService : Read location null from intent
1247,1631492097.816,2021-09-13T02:14:57.816000+02:00,GeofenceLocationIntentService : Read location null from intent

1418,1631591365.285,2021-09-14T05:49:25.285000+02:00,GeofenceLocationIntentService : Read location null from intent
1423,1631591365.349,2021-09-14T05:49:25.349000+02:00,GeofenceLocationIntentService : Read location null from intent
2058,1631645080.47,2021-09-14T20:44:40.470000+02:00,GeofenceLocationIntentService : Read location null from intent
2152,1631645185.889,2021-09-14T20:46:25.889000+02:00,GeofenceLocationIntentService : Read location null from intent

2378,1631763167.6829998,2021-09-16T05:32:47.683000+02:00,GeofenceLocationIntentService : Read location null from intent
2383,1631763167.7029998,2021-09-16T05:32:47.703000+02:00,GeofenceLocationIntentService : Read location null from intent

2491,1632107900.0210001,2021-09-20T05:18:20.021000+02:00,GeofenceLocationIntentService : Read location null from intent
2680,1632111212.255,2021-09-20T06:13:32.255000+02:00,GeofenceLocationIntentService : Read location null from intent

2816,1632418267.3839998,2021-09-23T19:31:07.384000+02:00,GeofenceLocationIntentService : Read location null from intent
2824,1632418267.551,2021-09-23T19:31:07.551000+02:00,GeofenceLocationIntentService : Read location null from intent

2960,1632512174.9220002,2021-09-24T21:36:14.922000+02:00,GeofenceLocationIntentService : Read location null from intent

But occasionally, we do get some values, after a long time of getting no values. Again, this indicates issues with the phone/location services.

7376,1632678747.8,2021-09-26T19:52:27.800000+02:00,GeofenceLocationIntentService : Read location null from intent
7393,1632678747.94,2021-09-26T19:52:27.940000+02:00,GeofenceLocationIntentService : Read location null from intent
7420,1632678748.6139998,2021-09-26T19:52:28.614000+02:00,GeofenceLocationIntentService : Read location null from intent
7431,1632678748.674,2021-09-26T19:52:28.674000+02:00,GeofenceLocationIntentService : Read location null from intent
7446,1632678749.141,2021-09-26T19:52:29.141000+02:00,GeofenceLocationIntentService : Read location null from intent
7536,1632678780.1320002,2021-09-26T19:53:00.132000+02:00,GeofenceLocationIntentService : Read location null from intent
7542,1632678780.5479999,2021-09-26T19:53:00.548000+02:00,GeofenceLocationIntentService : Read location null from intent
7565,1632678781.6139998,2021-09-26T19:53:01.614000+02:00,GeofenceLocationIntentService : Read location null from intent
7610,1632678814.9029999,2021-09-26T19:53:34.903000+02:00,GeofenceLocationIntentService : Read location null from intent
7615,1632678815.1179998,2021-09-26T19:53:35.118000+02:00,GeofenceLocationIntentService : Read location null from intent
7717,1632678843.5979998,2021-09-26T19:54:03.598000+02:00,GeofenceLocationIntentService : Read location null from intent
7723,1632678843.728,2021-09-26T19:54:03.728000+02:00,GeofenceLocationIntentService : Read location null from intent
7738,1632678844.0410001,2021-09-26T19:54:04.041000+02:00,GeofenceLocationIntentService : Read location null from intent
7837,1632678852.843,2021-09-26T19:54:12.843000+02:00,GeofenceLocationIntentService : Read location null from intent
7847,1632678856.24,2021-09-26T19:54:16.240000+02:00,GeofenceLocationIntentService : Read location null from intent
7862,1632678862.924,2021-09-26T19:54:22.924000+02:00,GeofenceLocationIntentService : Read location null from intent
7881,1632678866.9329998,2021-09-26T19:54:26.933000+02:00,"GeofenceLocationIntentService : Read location Location[fused -14******,34****** hAcc=24 et=+3m25s787ms alt=1025.1310974108542 vel=0.0068229944 bear=195.87578 vAcc=50 sAcc=??? bAcc=???] from intent"

or

11642,1633117212.181,2021-10-01T21:40:12.181000+02:00,GeofenceLocationIntentService : Read location null from intent
11686,1633117217.9529998,2021-10-01T21:40:17.953000+02:00,GeofenceLocationIntentService : Read location null from intent
11691,1633117217.9989998,2021-10-01T21:40:17.999000+02:00,GeofenceLocationIntentService : Read location null from intent
11709,1633117218.1239998,2021-10-01T21:40:18.124000+02:00,"GeofenceLocationIntentService : Read location Location[fused -14******,34****** hAcc=63 et=+1m12s614ms alt=1023.030419256748 vel=2.2374477 bear=172.16019 vAcc=123 sAcc=??? bAcc=???] from intent"

@shankari
Copy link
Contributor Author

shankari commented Oct 13, 2021

This does not appear to happen at the same rate for the three users here. Not sure why it happens more often for the first user, but again lends credence to the theory that there is something wrong with their environment/phone.

$ grep "Was not able to" /tmp/first.user_Africa_Blantyre.loggerDB.withdate.log | wc -l
     111

$ grep "Was not able to" /tmp/second.user_Africa_Blantyre.loggerDB.withdate.log | wc -l
      12

$ grep "Was not able to" /tmp/third.user_America_Denver.loggerDB.withdate.log | wc -l
      12

In contrast, the first user in #678 had encountered it exactly once, which was the time that they reported. They have subsequently seen it two more times. But this is two orders of magnitude less that the first user.

$ grep "Was not able to" /tmp/2021-09-04_Not_showing_trip_today_Africa_Blantyre.loggerDB.withdate.log | wc -l
       1

$ grep "Was not able to" /tmp/2021-10-11_Routine_upload_Los_Angeles.loggerDB.withdate.log | wc -l
       3

@shankari
Copy link
Contributor Author

shankari commented Oct 14, 2021

Digging a bit further into this, it looks like the option to read the location specially to create the geofence doesn't often work. The number of times we launch the callback and the number of times the new location read fails are pretty much identical.

10234,1630499683.207,2021-09-01T14:34:43.207000+02:00,"CreateGeofenceAction : mLastLocationTime = null, launching callback to read it and thencreate the geofence"

149338,1633004939.8979998,2021-09-30T14:28:59.898000+02:00,"CreateGeofenceAction : Was not able to read new location, skipping geofence creation"
$ grep "mLastLocationTime = null" /tmp/2021-10-12_first.user_Africa_Blantyre.loggerDB.withdate.log | wc -l
     111
$ grep "Was not able to" /tmp/2021-10-12_first.user_Africa_Blantyre.loggerDB.withdate.log | wc -l
     111

$ grep "mLastLocationTime = null" /tmp/2021-09-30_Failure_uploading_data_Africa_Blantyre.loggerDB.withdate.log | wc -l
      16

$ grep "Was not able to" /tmp/2021-09-30_Failure_uploading_data_Africa_Blantyre.loggerDB.withdate.log | wc -l
      12

$ grep "mLastLocationTime = null" /tmp/2021-10-11_Routine_upload_America_Los_Angeles.loggerDB.withdate.log | wc -l
       3

$ grep "Was not able to" /tmp/2021-10-11_Routine_upload_America_Los_Angeles.loggerDB.withdate.log | wc -l
       3

$ grep "mLastLocationTime = null" /tmp/2021-10-07_No_trips_America_Denver.loggerDB.withdate.log | wc -l
      12

$ grep "Was not able to" /tmp/2021-10-07_No_trips_America_Denver.loggerDB.withdate.log | wc -l
      12

This could be because:

  • there really is some location sensing issue. Note that we only launch the callback if we can't find a valid location. Maybe if we can't find a valid last location, we can't find valid locations in the callback.
  • there is a bug in the geofence location reading callback. This seems unlikely because it does work sometimes (e.g. for Failure_uploading_data, it worked 4 times. But it could also be that there is a non-100% reproducible bug in this codepath, which is also exercised infrequently.

@shankari
Copy link
Contributor Author

I note that most of the failures seem to be because the availability = false. I found some issues with when availability = false is invoked https://stackoverflow.com/a/57871835/4040267. I don't think any of them apply, but I should figure out a way to always invoke the geofence location callback and test it out.

@shankari
Copy link
Contributor Author

Let us look at the three potential failure scenarios from stackoverflow and see if any of them applied.
Let's use the user from the US to avoid real issues with location sensing.

** About to call .requestLocationUpdates **

24451,1632084062.631,2021-09-19T14:41:02.631000-06:00,"CreateGeofenceAction : mLastLocationTime = null, launching callback to read it and thencreate the geofence"

** Called requestLocationUpdates **

24452,1632084062.645,2021-09-19T14:41:02.645000-06:00,"CreateGeofenceAction : Successfully started tracking location, about to start waiting for location update"

** In the synchronized block **

24453,1632084062.6460001,2021-09-19T14:41:02.646000-06:00,CreateGeofenceAction : About to start waiting for location

Intent service broadcasts null

24462,1632084062.774,2021-09-19T14:41:02.774000-06:00,"GeofenceLocationIntentService : location is not available, broadcast null result"

Create action receives it and generates a notify call

24464,1632084062.7779999,2021-09-19T14:41:02.778000-06:00,CreateGeofenceAction : recieved broadcast intent Intent { act=GEOFENCE_LOCATION_RESULT (has extras) }

Waiting code is notified and calls .removeLocationUpdate

24465,1632084062.779,2021-09-19T14:41:02.779000-06:00,"CreateGeofenceAction : After waiting for location reading result, location is null"

And bails out completely

24466,1632084062.7810001,2021-09-19T14:41:02.781000-06:00,"CreateGeofenceAction : Was not able to read new location, skipping geofence creation"

So we definitely call remove after register within one cycle.

We use PRIORITY_HIGH_ACCURACY because we check that the settings are correct.

24469,1632084062.784,2021-09-19T14:41:02.784000-06:00,"LocationHandler : after applying config, value is Request[PRIORITY_HIGH_ACCURACY requested=30000ms fastest=5000ms]"
24478,1632084062.815,2021-09-19T14:41:02.815000-06:00,"SensorControlBackgroundChecker : All settings are valid, checking current state"

And it looks like we do have a location update triggered by the listener although the update is invalid before we call the next request (at least around the 9am call).

Request location updates

$ grep "09T09.*Geofence" /tmp/manual_tracking_match

22021,1633764685.4420002,2021-10-09T09:31:25.442000+02:00,"CreateGeofenceAction : Last location would have been Location[fused -16******,35****** hAcc=2100 et=+3d19h39m27s400ms alt=1003.829911860006 vAcc=3 sAcc=??? bAcc=???] if we hadn't reset it"
22023,1633764685.447,2021-10-09T09:31:25.447000+02:00,CreateGeofenceAction : testLoc.getAccuracy 2099.999 > 200 isValidLocation = false
22025,1633764685.45,2021-10-09T09:31:25.450000+02:00,"CreateGeofenceAction : mLastLocationTime = null, launching callback to read it and thencreate the geofence"
22032,1633764685.466,2021-10-09T09:31:25.466000+02:00,"CreateGeofenceAction : Successfully started tracking location, about to start waiting for location update"

Get intent callback

22071,1633764685.76,2021-10-09T09:31:25.760000+02:00,GeofenceLocationIntentService : onCreate called
22072,1633764685.779,2021-10-09T09:31:25.779000+02:00,GeofenceLocationIntentService : onStart called with Intent { hwFlg=0x100 cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.actions.GeofenceLocationIntentService (has extras) } startId 1
22073,1633764685.784,2021-10-09T09:31:25.784000+02:00,GeofenceLocationIntentService : onStart called with Intent { hwFlg=0x100 cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.actions.GeofenceLocationIntentService (has extras) } startId 2
22074,1633764685.7879999,2021-10-09T09:31:25.788000+02:00,"GeofenceLocationIntentService : FINALLY! Got location update, intent is Intent { hwFlg=0x100 cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.actions.GeofenceLocationIntentService (has extras) }"


22076,1633764685.794,2021-10-09T09:31:25.794000+02:00,GeofenceLocationIntentService : Extras bundle = Bundle[mParcelledData.dataSize=672]
22077,1633764685.8170002,2021-10-09T09:31:25.817000+02:00,"GeofenceLocationIntentService : Extras keys are [com.google.android.location.LOCATION, com.google.android.gms.location.EXTRA_LOCATION_RESULT]"
22079,1633764685.826,2021-10-09T09:31:25.826000+02:00,"GeofenceLocationIntentService : Extras values are [Location[fused -16******,35****** hAcc=2100 et=+3d19h39m27s400ms alt=1003.829911860006 vAcc=3 sAcc=??? bAcc=???], LocationResult[locations: [Location[fused -16******,35****** hAcc=2100 et=+3d19h39m27s400ms alt=1003.829911860006 vAcc=3 sAcc=??? bAcc=???]]]]"
22080,1633764685.849,2021-10-09T09:31:25.849000+02:00,CreateGeofenceAction : testLoc.getAccuracy 2099.999 > 200 isValidLocation = false
22081,1633764685.851,2021-10-09T09:31:25.851000+02:00,GeofenceLocationIntentService : Read location null from intent

22082,1633764685.885,2021-10-09T09:31:25.885000+02:00,"GeofenceLocationIntentService : FINALLY! Got location update, intent is Intent { hwFlg=0x100 cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.actions.GeofenceLocationIntentService (has extras) }"
22083,1633764685.894,2021-10-09T09:31:25.894000+02:00,GeofenceLocationIntentService : Extras bundle = Bundle[mParcelledData.dataSize=288]
22084,1633764685.897,2021-10-09T09:31:25.897000+02:00,GeofenceLocationIntentService : Extras keys are [com.google.android.gms.location.EXTRA_LOCATION_AVAILABILITY]
22085,1633764685.901,2021-10-09T09:31:25.901000+02:00,GeofenceLocationIntentService : Extras values are [LocationAvailability[isLocationAvailable: false]]
22086,1633764685.904,2021-10-09T09:31:25.904000+02:00,GeofenceLocationIntentService : Read location null from intent
22087,1633764685.907,2021-10-09T09:31:25.907000+02:00,GeofenceLocationIntentService : availability = false

22088,1633764685.928,2021-10-09T09:31:25.928000+02:00,"GeofenceLocationIntentService : location is not available, broadcast null result"
22090,1633764685.941,2021-10-09T09:31:25.941000+02:00,GeofenceLocationIntentService : broadcasting intent Intent { act=GEOFENCE_LOCATION_RESULT (has extras) }

At this point, we unregister the listener.

22109,1633764685.9970002,2021-10-09T09:31:25.997000+02:00,"CreateGeofenceAction : After waiting for location reading result, location is null"
22110,1633764686.0029998,2021-10-09T09:31:26.003000+02:00,GeofenceLocationIntentService : onDestroy called
22111,1633764686.0129998,2021-10-09T09:31:26.013000+02:00,"CreateGeofenceAction : Was not able to read new location, skipping geofence creation"

@shankari
Copy link
Contributor Author

Edited the code to always set the last location to null so that the GeofenceLocationIntentService is always invoked.

        Location mLastLocation = Tasks.await(LocationServices.getFusedLocationProviderClient(mCtxt).getLastLocation(), 30, TimeUnit.SECONDS);
        Log.d(mCtxt, TAG, "Last location would have been " + mLastLocation +" if we hadn't reset it");
        mLastLocation = null;

Started and ended trips in the emulator a few times, don't see any issues.

2021-10-13 21:17:01.012 2035-2567/gov.colorado.energyoffice.emission E/CreateGeofenceAction: Reading last location failed with error java.lang.SecurityException: Client must have ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to perform any location operations. while creating geofence
2021-10-13 21:18:05.275 2035-3671/gov.colorado.energyoffice.emission D/CreateGeofenceAction: Last location would have been Location[fused 37.861290,-119.985810 hAcc=520 et=+13d17h21m14s418ms alt=0.0 vAcc=1 sAcc=-1 bAcc=-1 {Bundle[mParcelledData.dataSize=52]}] if we hadn't reset it
2021-10-13 21:18:05.290 2035-3671/gov.colorado.energyoffice.emission I/CreateGeofenceAction: null location, valid = false
2021-10-13 21:18:05.305 2035-3671/gov.colorado.energyoffice.emission W/CreateGeofenceAction: mLastLocationTime = null, launching callback to read it and thencreate the geofence
2021-10-13 21:18:05.354 2035-3671/gov.colorado.energyoffice.emission D/CreateGeofenceAction: Successfully started tracking location, about to start waiting for location update
2021-10-13 21:18:05.369 2035-3671/gov.colorado.energyoffice.emission D/CreateGeofenceAction: About to start waiting for location
2021-10-13 21:18:05.434 2035-2035/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: onCreate called
2021-10-13 21:18:05.448 2035-2035/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: onStart called with Intent { cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.actions.GeofenceLocationIntentService (has extras) } startId 1
2021-10-13 21:18:05.461 2035-3672/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: FINALLY! Got location update, intent is Intent { cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.actions.GeofenceLocationIntentService (has extras) }
2021-10-13 21:18:05.471 2035-3672/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Extras bundle = Bundle[mParcelledData.dataSize=288]
2021-10-13 21:18:05.485 2035-3672/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Extras keys are [com.google.android.gms.location.EXTRA_LOCATION_AVAILABILITY]
2021-10-13 21:18:05.499 2035-3672/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Extras values are [LocationAvailability[isLocationAvailable: true]]
2021-10-13 21:18:05.510 2035-3672/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Read location null from intent
2021-10-13 21:18:05.522 2035-3672/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: availability = true
2021-10-13 21:18:05.534 2035-3672/gov.colorado.energyoffice.emission I/CreateGeofenceAction: null location, valid = false
2021-10-13 21:18:05.550 2035-2035/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: onDestroy called
2021-10-13 21:18:06.169 2035-2035/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: onCreate called
2021-10-13 21:18:06.185 2035-2035/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: onStart called with Intent { cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.actions.GeofenceLocationIntentService (has extras) } startId 1
2021-10-13 21:18:06.201 2035-3686/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: FINALLY! Got location update, intent is Intent { cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.actions.GeofenceLocationIntentService (has extras) }
2021-10-13 21:18:06.220 2035-3686/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Extras bundle = Bundle[mParcelledData.dataSize=688]
2021-10-13 21:18:06.232 2035-3686/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Extras keys are [com.google.android.location.LOCATION, com.google.android.gms.location.EXTRA_LOCATION_RESULT]
2021-10-13 21:18:06.241 2035-3686/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Extras values are [Location[fused 37.861290,-119.985810 hAcc=5 et=+13d17h31m7s81ms alt=0.0 vel=26.401266 bear=243.0 vAcc=1 sAcc=1 bAcc=30 {Bundle[mParcelledData.dataSize=52]}], LocationResult[locations: [Location[fused 37.861290,-119.985810 hAcc=5 et=+13d17h31m7s81ms alt=0.0 vel=26.401266 bear=243.0 vAcc=1 sAcc=1 bAcc=30 {Bundle[mParcelledData.dataSize=52]}]]]]
2021-10-13 21:18:06.253 2035-3686/gov.colorado.energyoffice.emission I/CreateGeofenceAction: isValidLocation = true. Yay!
2021-10-13 21:18:06.263 2035-3686/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Found most recent valid location = null
2021-10-13 21:18:06.272 2035-3686/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Read location Location[fused 37.861290,-119.985810 hAcc=5 et=+13d17h31m7s81ms alt=0.0 vel=26.401266 bear=243.0 vAcc=1 sAcc=1 bAcc=30 {Bundle[mParcelledData.dataSize=52]}] from intent
2021-10-13 21:18:06.283 2035-3686/gov.colorado.energyoffice.emission I/CreateGeofenceAction: isValidLocation = true. Yay!
2021-10-13 21:18:06.293 2035-3686/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: location is valid, broadcast it Location[fused 37.861290,-119.985810 hAcc=5 et=+13d17h31m7s81ms alt=0.0 vel=26.401266 bear=243.0 vAcc=1 sAcc=1 bAcc=30 {Bundle[mParcelledData.dataSize=52]}]
2021-10-13 21:18:06.303 2035-3686/gov.colorado.energyoffice.emission I/GeofenceLocationIntentService: broadcasting intent Intent { act=GEOFENCE_LOCATION_RESULT (has extras) }
2021-10-13 21:18:06.315 2035-2035/gov.colorado.energyoffice.emission I/CreateGeofenceAction: recieved broadcast intent Intent { act=GEOFENCE_LOCATION_RESULT (has extras) }
2021-10-13 21:18:06.327 2035-2035/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: onDestroy called
2021-10-13 21:18:06.342 2035-3671/gov.colorado.energyoffice.emission D/CreateGeofenceAction: After waiting for location reading result, location is Location[fused 37.861290,-119.985810 hAcc=5 et=+13d17h31m7s81ms alt=0.0 vel=26.401266 bear=243.0 vAcc=1 sAcc=1 bAcc=30 {Bundle[mParcelledData.dataSize=52]}]
2021-10-13 21:18:06.355 2035-3671/gov.colorado.energyoffice.emission D/CreateGeofenceAction: New last location is Location[fused 37.861290,-119.985810 hAcc=5 et=+13d17h31m7s81ms alt=0.0 vel=26.401266 bear=243.0 vAcc=1 sAcc=1 bAcc=30 {Bundle[mParcelledData.dataSize=52]}] using it
2021-10-13 21:18:06.369 2035-3671/gov.colorado.energyoffice.emission D/CreateGeofenceAction: creating geofence at location Location[fused 37.861290,-119.985810 hAcc=5 et=+13d17h31m7s81ms alt=0.0 vel=26.401266 bear=243.0 vAcc=1 sAcc=1 bAcc=30 {Bundle[mParcelledData.dataSize=52]}]
2021-10-13 21:18:06.405 2035-3671/gov.colorado.energyoffice.emission D/CreateGeofenceAction: creating geofence at location 37.86129, -119.98581
2021-10-13 21:20:04.354 2035-2035/gov.colorado.energyoffice.emission D/CreateGeofenceAction: Removing geofence with ID = DYNAMIC_EXIT_GEOFENCE
2021-10-13 21:20:04.358 2973-3301/com.google.android.gms I/GeofencerStateMachine: removeGeofences: removeRequest=RemoveGeofencingRequest[REMOVE_BY_IDS Ids=[DYNAMIC_EXIT_GEOFENCE], packageName=gov.colorado.energyoffice.emission]
2021-10-13 21:20:13.618 2035-5811/gov.colorado.energyoffice.emission D/CreateGeofenceAction: Last location would have been Location[fused 37.861290,-119.985810 hAcc=5 et=+13d17h33m5s551ms alt=0.0 vel=26.401266 bear=243.0 vAcc=1 sAcc=1 bAcc=30 {Bundle[mParcelledData.dataSize=52]}] if we hadn't reset it
2021-10-13 21:20:13.633 2035-5811/gov.colorado.energyoffice.emission I/CreateGeofenceAction: null location, valid = false
2021-10-13 21:20:13.645 2035-5811/gov.colorado.energyoffice.emission W/CreateGeofenceAction: mLastLocationTime = null, launching callback to read it and thencreate the geofence
2021-10-13 21:20:13.672 2035-5811/gov.colorado.energyoffice.emission D/CreateGeofenceAction: Successfully started tracking location, about to start waiting for location update
2021-10-13 21:20:13.686 2035-5811/gov.colorado.energyoffice.emission D/CreateGeofenceAction: About to start waiting for location
2021-10-13 21:20:13.757 2035-2035/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: onCreate called
2021-10-13 21:20:13.768 2035-2035/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: onStart called with Intent { cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.actions.GeofenceLocationIntentService (has extras) } startId 1
2021-10-13 21:20:13.780 2035-5812/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: FINALLY! Got location update, intent is Intent { cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.actions.GeofenceLocationIntentService (has extras) }
2021-10-13 21:20:13.788 2035-5812/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Extras bundle = Bundle[mParcelledData.dataSize=288]
2021-10-13 21:20:13.800 2035-5812/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Extras keys are [com.google.android.gms.location.EXTRA_LOCATION_AVAILABILITY]
2021-10-13 21:20:13.813 2035-5812/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Extras values are [LocationAvailability[isLocationAvailable: true]]
2021-10-13 21:20:13.822 2035-5812/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Read location null from intent
2021-10-13 21:20:13.834 2035-5812/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: availability = true
2021-10-13 21:20:13.848 2035-5812/gov.colorado.energyoffice.emission I/CreateGeofenceAction: null location, valid = false
2021-10-13 21:20:13.861 2035-2035/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: onDestroy called
2021-10-13 21:20:14.629 2035-2035/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: onCreate called
2021-10-13 21:20:14.642 2035-2035/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: onStart called with Intent { cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.actions.GeofenceLocationIntentService (has extras) } startId 1
2021-10-13 21:20:14.655 2035-5828/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: FINALLY! Got location update, intent is Intent { cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.actions.GeofenceLocationIntentService (has extras) }
2021-10-13 21:20:14.669 2035-5828/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Extras bundle = Bundle[mParcelledData.dataSize=688]
2021-10-13 21:20:14.685 2035-5828/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Extras keys are [com.google.android.location.LOCATION, com.google.android.gms.location.EXTRA_LOCATION_RESULT]
2021-10-13 21:20:14.698 2035-5828/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Extras values are [Location[fused 37.861290,-119.985810 hAcc=124 et=+13d17h33m14s744ms alt=0.0 vel=0.0 bear=90.0 vAcc=1 sAcc=-1 bAcc=-1 {Bundle[mParcelledData.dataSize=52]}], LocationResult[locations: [Location[fused 37.861290,-119.985810 hAcc=124 et=+13d17h33m14s744ms alt=0.0 vel=0.0 bear=90.0 vAcc=1 sAcc=-1 bAcc=-1 {Bundle[mParcelledData.dataSize=52]}]]]]
2021-10-13 21:20:14.711 2035-5828/gov.colorado.energyoffice.emission I/CreateGeofenceAction: isValidLocation = true. Yay!
2021-10-13 21:20:14.724 2035-2035/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: onStart called with Intent { cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.actions.GeofenceLocationIntentService (has extras) } startId 2
2021-10-13 21:20:14.734 2035-5828/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Found most recent valid location = null
2021-10-13 21:20:14.744 2035-5828/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Read location Location[fused 37.861290,-119.985810 hAcc=124 et=+13d17h33m14s744ms alt=0.0 vel=0.0 bear=90.0 vAcc=1 sAcc=-1 bAcc=-1 {Bundle[mParcelledData.dataSize=52]}] from intent
2021-10-13 21:20:14.753 2035-5828/gov.colorado.energyoffice.emission I/CreateGeofenceAction: isValidLocation = true. Yay!
2021-10-13 21:20:14.764 2035-5828/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: location is valid, broadcast it Location[fused 37.861290,-119.985810 hAcc=124 et=+13d17h33m14s744ms alt=0.0 vel=0.0 bear=90.0 vAcc=1 sAcc=-1 bAcc=-1 {Bundle[mParcelledData.dataSize=52]}]
2021-10-13 21:20:14.773 2035-5828/gov.colorado.energyoffice.emission I/GeofenceLocationIntentService: broadcasting intent Intent { act=GEOFENCE_LOCATION_RESULT (has extras) }
2021-10-13 21:20:14.783 2035-2035/gov.colorado.energyoffice.emission I/CreateGeofenceAction: recieved broadcast intent Intent { act=GEOFENCE_LOCATION_RESULT (has extras) }
2021-10-13 21:20:14.792 2035-5828/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: FINALLY! Got location update, intent is Intent { cmp=gov.colorado.energyoffice.emission/edu.berkeley.eecs.emission.cordova.tracker.location.actions.GeofenceLocationIntentService (has extras) }
2021-10-13 21:20:14.802 2035-2035/gov.colorado.energyoffice.emission I/CreateGeofenceAction: recieved broadcast intent Intent { act=GEOFENCE_LOCATION_RESULT (has extras) }
2021-10-13 21:20:14.818 2035-5828/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Extras bundle = Bundle[mParcelledData.dataSize=688]
2021-10-13 21:20:14.831 2035-5811/gov.colorado.energyoffice.emission D/CreateGeofenceAction: After waiting for location reading result, location is Location[fused 37.861290,-119.985810 hAcc=124 et=+13d17h33m14s744ms alt=0.0 vel=0.0 bear=90.0 vAcc=1 sAcc=-1 bAcc=-1 {Bundle[mParcelledData.dataSize=52]}]
2021-10-13 21:20:14.841 2035-5828/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Extras keys are [com.google.android.location.LOCATION, com.google.android.gms.location.EXTRA_LOCATION_RESULT]
2021-10-13 21:20:14.854 2035-5811/gov.colorado.energyoffice.emission D/CreateGeofenceAction: New last location is Location[fused 37.861290,-119.985810 hAcc=124 et=+13d17h33m14s744ms alt=0.0 vel=0.0 bear=90.0 vAcc=1 sAcc=-1 bAcc=-1 {Bundle[mParcelledData.dataSize=52]}] using it
2021-10-13 21:20:14.865 2035-5828/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Extras values are [Location[fused 37.861289,-119.985814 hAcc=65 et=+13d17h33m15s631ms alt=0.0 vel=14.59569 bear=256.51047 vAcc=1 sAcc=1 bAcc=30 {Bundle[mParcelledData.dataSize=52]}], LocationResult[locations: [Location[fused 37.861289,-119.985814 hAcc=65 et=+13d17h33m15s631ms alt=0.0 vel=14.59569 bear=256.51047 vAcc=1 sAcc=1 bAcc=30 {Bundle[mParcelledData.dataSize=52]}]]]]
2021-10-13 21:20:14.874 2035-5811/gov.colorado.energyoffice.emission D/CreateGeofenceAction: creating geofence at location Location[fused 37.861290,-119.985810 hAcc=124 et=+13d17h33m14s744ms alt=0.0 vel=0.0 bear=90.0 vAcc=1 sAcc=-1 bAcc=-1 {Bundle[mParcelledData.dataSize=52]}]
2021-10-13 21:20:14.885 2035-5828/gov.colorado.energyoffice.emission I/CreateGeofenceAction: isValidLocation = true. Yay!
2021-10-13 21:20:14.895 2035-5828/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Found most recent valid location = null
2021-10-13 21:20:14.914 2035-5828/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: Read location Location[fused 37.861289,-119.985814 hAcc=65 et=+13d17h33m15s631ms alt=0.0 vel=14.59569 bear=256.51047 vAcc=1 sAcc=1 bAcc=30 {Bundle[mParcelledData.dataSize=52]}] from intent
2021-10-13 21:20:14.924 2035-5811/gov.colorado.energyoffice.emission D/CreateGeofenceAction: creating geofence at location 37.86129, -119.98581
2021-10-13 21:20:14.929 2973-6249/com.google.android.gms I/GeofencerStateMachine: addGeofences called by gov.colorado.energyoffice.emission
2021-10-13 21:20:14.939 2035-5828/gov.colorado.energyoffice.emission I/CreateGeofenceAction: isValidLocation = true. Yay!
2021-10-13 21:20:14.956 2035-5828/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: location is valid, broadcast it Location[fused 37.861289,-119.985814 hAcc=65 et=+13d17h33m15s631ms alt=0.0 vel=14.59569 bear=256.51047 vAcc=1 sAcc=1 bAcc=30 {Bundle[mParcelledData.dataSize=52]}]
2021-10-13 21:20:14.995 2973-2973/com.google.android.gms I/GeofencerStateMachine: sendNewTransitions called.
2021-10-13 21:20:14.997 2973-3049/com.google.android.gms I/GeofencerStateMachine: Inaccurate location dropped.
2021-10-13 21:20:14.999 2035-5828/gov.colorado.energyoffice.emission I/GeofenceLocationIntentService: broadcasting intent Intent { act=GEOFENCE_LOCATION_RESULT (has extras) }
2021-10-13 21:20:15.016 2973-2973/com.google.android.gms I/GeofencerStateMachine: sendNewLocationAvailability: availability=LocationAvailability[isLocationAvailable: true]
2021-10-13 21:20:15.053 2973-2973/com.google.android.gms I/GeofencerStateMachine: sendNewTransitions called.
2021-10-13 21:20:15.230 2035-2035/gov.colorado.energyoffice.emission I/CreateGeofenceAction: recieved broadcast intent Intent { act=GEOFENCE_LOCATION_RESULT (has extras) }
2021-10-13 21:20:15.252 2035-2035/gov.colorado.energyoffice.emission I/CreateGeofenceAction: recieved broadcast intent Intent { act=GEOFENCE_LOCATION_RESULT (has extras) }
2021-10-13 21:20:15.271 2035-2035/gov.colorado.energyoffice.emission D/GeofenceLocationIntentService: onDestroy called
2021-10-13 21:20:21.046 2973-2973/com.google.android.gms I/GeofencerStateMachine: sendNewTransitions 

So there doesn't seem to be anything obviously wrong with the code. Will try to set this as a config setting to make it easier to test on actual phones, but at this point, this seems to be a rare, intermittent issue on most phones.

@shankari
Copy link
Contributor Author

shankari commented Nov 4, 2021

Some additional manual data. Mostly accurate, except for some areas where the trip end was not correctly detected.

Let's look at each of these individually

Time Notification Ground truth (on trip)
15:00 Yay! You are on a trip Yes
16:00 Yay! You are on a trip Yes
17:00 Yay! You are on a trip No
18:00 Yay! You are on a trip No
19:00 Yay! You are on a trip Yes
20:00 Yay! You are on a trip No
21:00 Yay! You are on a trip Yes
22:00 Yay! You are on a trip No
23:00 Yay! You are on a trip No

First, although the trip end was apparently not detected for multiple hours, the trip were in fact segmented reasonably correctly.

Couple of issues:

Potential issue Preliminary investigation
Not on trip at 22:00 per ground truth Postprocessed trip detected: 21:45:12 -> 22:11:24, Geofence exit at 22:06, then a mix of good and poor quality points until 22:25, Trip ended at 22:25:30 in waiting_for_trip_start No logs during the 2300 hour. Not sure why notification message was not changed. Wonder if ground truth reporting of the notification is actually correct?
Missing trips on Saturday No logs between Friday 19:30:25 and Sunday 12:01:36. This is due to #678 (see logs below)
Extra long trip on Sunday (13:00 -> 17:00) (1) Ongoing notification at 14:00; trip only started at 14:30, handled in postprocessing, similar to 22:00 above, geofence exit at 14:29:08, previous state was waiting_for_trip_start at 13:27:59. Wonder if ground truth reporting of the notification is correct?
(2) Missing trip at 17:00 On the phone, trip lasted from 17:45:08 to 18:23:16. No logs between 14:48:07 and 17:45. Bad:good location points = 15:39. Distances were consistently under 100 m (see logs below). We probably ignored the trip

waiting for trip start error logs

19:30:21.820000+02:00,GeofenceLocationIntentService : Read location null from intent
19:30:21.860000+02:00,GeofenceLocationIntentService : availability = false
19:30:21.862000+02:00,"GeofenceLocationIntentService : location is not available, broadcast null result"
...
19:30:22.151000+02:00,"CreateGeofenceAction : After waiting for location reading result, location is null"
19:30:22.267000+02:00,GeofenceLocationIntentService : Extras bundle = Bundle[mParcelledData.dataSize=560]
19:30:22.351000+02:00,"CreateGeofenceAction : Was not able to read new location, skipping geofence creation"
...
19:30:25.130000+02:00,SensorControlBackgroundChecker : Current location settings are com.google.android.gms.location.LocationSettingsResponse@4ac5bd7
19:30:25.228000+02:00,NotificationHelper : Cancelling notify with id 87225377
19:30:25.428000+02:00,"SensorControlBackgroundChecker : in restartFSMIfStartState, currState = local.state.waiting_for_trip_start"

missing_geofence_error.gz

filtered out erroneous trip

17:56:28.684000+02:00,"LocationChangeIntentService : last9Distances = [0.0, 20.387250900268555, 39.01094055175781, 39.01094055175781, 39.56361770629883, 39.729522705078125, 39.729522705078125, 20.831350326538086, 39.56361770629883]"
...
18:23:16.902000+02:00,"LocationChangeIntentService : last9Distances = [0.06186052784323692, 0.06186052784323692, 0.06186052784323692, 0.2055169641971588, 0.19532178342342377, 0.0, 0.0, 0.0, 0.0]"

distances_on_missing_sun_trip.gz

@shankari
Copy link
Contributor Author

shankari commented Nov 4, 2021

Foreground service issue resolved after background restrictions were removed.
Most recent logs indicate #678
and a lot of location errors.

Follow ups:

  • Although the background restrictions have been removed, the background periodic call only seems to happen roughly every day. But this does not seem to affect operation substantially except for the next item.
  • Note also that even fixing [bug] Failure in recreating the geofence after reboot causes the app to be stuck in waiting_for_trip_start forever #678 would not fix the missing data on Saturday because of this lack of periodic calls. We would not detect that the app was in waiting_for_trip_start state and would not be able to re-initialize. Another argument for silent push notifications.
  • wrt periodic checks, we may want to check location availability on every periodic call (even if the geofence was correctly created) to ensure that the location is available. If not, we can warn the user that some trips may be missing. We could also re-create the geofence if it has moved, although we have waffled on that decision multiple times before.
  • wrt "bad points", I wonder if we have to relax the threshold under certain circumstances if there are a lot of errors. Should the threshold actually be phone-specific? Need to look at the "spurious" trips above and see how meaningful they are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant