Genymobile / gnirehtet

Gnirehtet provides reverse tethering for Android
Apache License 2.0
6.13k stars 565 forks source link

Crash when broadcasting STOP before START #128

Closed jo215 closed 6 years ago

jo215 commented 6 years ago

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?

rom1v commented 6 years ago

Yes. Please submit a PR. :wink:

jo215 commented 6 years ago

Thanks, done - hopefully all OK!

rom1v commented 6 years ago

https://github.com/Genymobile/gnirehtet/pull/129 merged