Trail-Sense icon indicating copy to clipboard operation
Trail-Sense copied to clipboard

ForegroundServiceStartNotAllowedException on reboot

Open kylecorry31 opened this issue 1 year ago • 3 comments

If the device has foreground services disallowed, some of the background processes are disallowed.

On boot, foreground services aren't allowed to start. This can be mitigated by adding a check before starting the BackgroundWorkerService.

If the user has services enabled which require the background worker service, a notification should appear that allows them to start Trail Sense - this will ensure the user knows that backtrack/weather monitoring is not enabled when they think it is.

It looks like this may only happen on Samsung devices.

According to the documentation, this should be allowed: "After the device reboots and receives the ACTION_BOOT_COMPLETED, ACTION_LOCKED_BOOT_COMPLETED, or ACTION_MY_PACKAGE_REPLACED intent action in a broadcast receiver.

Your app receives the ACTION_TIMEZONE_CHANGED, ACTION_TIME_CHANGED, or ACTION_LOCALE_CHANGED intent action in a broadcast receiver."

So maybe they aren't starting within the window allocated?

This might be related to https://issuetracker.google.com/issues/286577520

kylecorry31 avatar Jun 19 '23 23:06 kylecorry31

I'm not able to reproduce this issue on my Pixel phone - I will try on the Samsung emulator if possible.

kylecorry31 avatar Jul 04 '23 11:07 kylecorry31

I'm unable to test this in the Samsung remote test lab - you can't reboot the device there. I'm going to say this is likely due to this bug: https://issuetracker.google.com/issues/286577520

Putting on hold until more details become available.

kylecorry31 avatar Jul 15 '23 19:07 kylecorry31

Here's a better issue to track this: https://issuetracker.google.com/issues/296567830

kylecorry31 avatar Jan 17 '24 23:01 kylecorry31

Upstream issue isn't resolved (I don't trust that it will ever be), but I implemented the same start error handling as when the location permission is not granted at boot.

kylecorry31 avatar Mar 10 '24 14:03 kylecorry31