Declare location permission used by foreground properly

Fix #132.
This commit is contained in:
Mygod
2019-10-24 12:15:36 +08:00
parent 13c43f9b0e
commit e790e513e1
3 changed files with 13 additions and 6 deletions

View File

@@ -46,6 +46,8 @@ class RepeaterService : Service(), CoroutineScope, WifiP2pManager.ChannelListene
*/
private const val PLACEHOLDER_NETWORK_NAME = "DIRECT-00-VPNHotspot"
const val EXTRA_POSSIBLY_BACKGROUND = "possiblyBackground"
/**
* This is only a "ServiceConnection" to system service and its impact on system is minimal.
*/
@@ -255,7 +257,9 @@ class RepeaterService : Service(), CoroutineScope, WifiP2pManager.ChannelListene
val channel = channel ?: return START_NOT_STICKY.also { stopSelf() }
status = Status.STARTING
// show invisible foreground notification on television to avoid being killed
if (Build.VERSION.SDK_INT >= 26 && app.uiMode.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION) {
if (Build.VERSION.SDK_INT >= 26 && app.uiMode.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION ||
// or bump self to foreground location service to use foreground location permission
Build.VERSION.SDK_INT >= 29 && intent?.getBooleanExtra(EXTRA_POSSIBLY_BACKGROUND, false) == true) {
showNotification()
}
launch {