Bump to foreground service unconditionally on Q
This commit is contained in:
@@ -46,8 +46,6 @@ class RepeaterService : Service(), CoroutineScope, WifiP2pManager.ChannelListene
|
|||||||
*/
|
*/
|
||||||
private const val PLACEHOLDER_NETWORK_NAME = "DIRECT-00-VPNHotspot"
|
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.
|
* This is only a "ServiceConnection" to system service and its impact on system is minimal.
|
||||||
*/
|
*/
|
||||||
@@ -256,10 +254,10 @@ class RepeaterService : Service(), CoroutineScope, WifiP2pManager.ChannelListene
|
|||||||
if (status != Status.IDLE) return START_NOT_STICKY
|
if (status != Status.IDLE) return START_NOT_STICKY
|
||||||
val channel = channel ?: return START_NOT_STICKY.also { stopSelf() }
|
val channel = channel ?: return START_NOT_STICKY.also { stopSelf() }
|
||||||
status = Status.STARTING
|
status = Status.STARTING
|
||||||
// show invisible foreground notification on television to avoid being killed
|
// bump self to foreground location service to use foreground location permission later
|
||||||
if (Build.VERSION.SDK_INT >= 26 && app.uiMode.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION ||
|
if (Build.VERSION.SDK_INT >= 29 ||
|
||||||
// or bump self to foreground location service to use foreground location permission
|
// or show invisible foreground notification on television to avoid being killed
|
||||||
Build.VERSION.SDK_INT >= 29 && intent?.getBooleanExtra(EXTRA_POSSIBLY_BACKGROUND, false) == true) {
|
Build.VERSION.SDK_INT >= 26 && app.uiMode.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION) {
|
||||||
showNotification()
|
showNotification()
|
||||||
}
|
}
|
||||||
launch {
|
launch {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class RepeaterTileService : KillableTileService() {
|
|||||||
if (binder == null) tapPending = true else when (binder.service.status) {
|
if (binder == null) tapPending = true else when (binder.service.status) {
|
||||||
RepeaterService.Status.ACTIVE -> binder.shutdown()
|
RepeaterService.Status.ACTIVE -> binder.shutdown()
|
||||||
RepeaterService.Status.IDLE -> ContextCompat.startForegroundService(this,
|
RepeaterService.Status.IDLE -> ContextCompat.startForegroundService(this,
|
||||||
Intent(this, RepeaterService::class.java).putExtra(RepeaterService.EXTRA_POSSIBLY_BACKGROUND, true))
|
Intent(this, RepeaterService::class.java))
|
||||||
else -> { }
|
else -> { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user