Trail-Sense
Trail-Sense copied to clipboard
ForegroundServiceStartNotAllowedException on reboot
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
I'm not able to reproduce this issue on my Pixel phone - I will try on the Samsung emulator if possible.
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.
Here's a better issue to track this: https://issuetracker.google.com/issues/296567830
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.