@@ -73,13 +73,16 @@
|
||||
|
||||
<service
|
||||
android:name=".LocalOnlyHotspotService"
|
||||
android:directBootAware="true"/>
|
||||
android:directBootAware="true"
|
||||
android:foregroundServiceType="location|connectedDevice"/>
|
||||
<service
|
||||
android:name=".RepeaterService"
|
||||
android:directBootAware="true"/>
|
||||
android:directBootAware="true"
|
||||
android:foregroundServiceType="location|connectedDevice"/>
|
||||
<service
|
||||
android:name=".TetheringService"
|
||||
android:directBootAware="true"/>
|
||||
android:directBootAware="true"
|
||||
android:foregroundServiceType="connectedDevice"/>
|
||||
|
||||
<service
|
||||
android:name=".manage.RepeaterTileService"
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -35,8 +35,8 @@ class RepeaterTileService : KillableTileService() {
|
||||
val binder = binder
|
||||
if (binder == null) tapPending = true else when (binder.service.status) {
|
||||
RepeaterService.Status.ACTIVE -> binder.shutdown()
|
||||
RepeaterService.Status.IDLE ->
|
||||
ContextCompat.startForegroundService(this, Intent(this, RepeaterService::class.java))
|
||||
RepeaterService.Status.IDLE -> ContextCompat.startForegroundService(this,
|
||||
Intent(this, RepeaterService::class.java).putExtra(RepeaterService.EXTRA_POSSIBLY_BACKGROUND, true))
|
||||
else -> { }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user