When broadcasting the STOP intent (on Android Oreo), if you have not previously STARTed the service, gnirehtet will crash with the following message in logcat: ActivityManager: Background start not allowed: service Intent { act=com.genymobile.gnirehtet.CLOSE_VPN cmp=com.genymobile.gnirehtet/.GnirehtetService } to com.genymobile.gnirehtet/.GnirehtetService from pid=15146 uid=10471 pkg=com.genymobile.gnirehtet
I think all that is needed is a similar check as made when STARTing the service:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { context.startForegroundService(createStopIntent(context)); } else { context.startService(createStopIntent(context)); }
or similar. My testing confirms this seems to work - what do you think?
When broadcasting the STOP intent (on Android Oreo), if you have not previously STARTed the service, gnirehtet will crash with the following message in logcat:
ActivityManager: Background start not allowed: service Intent { act=com.genymobile.gnirehtet.CLOSE_VPN cmp=com.genymobile.gnirehtet/.GnirehtetService } to com.genymobile.gnirehtet/.GnirehtetService from pid=15146 uid=10471 pkg=com.genymobile.gnirehtet
I think all that is needed is a similar check as made when STARTing the service:if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { context.startForegroundService(createStopIntent(context)); } else { context.startService(createStopIntent(context)); }
or similar. My testing confirms this seems to work - what do you think?