@@ -73,13 +73,16 @@
|
|||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".LocalOnlyHotspotService"
|
android:name=".LocalOnlyHotspotService"
|
||||||
android:directBootAware="true"/>
|
android:directBootAware="true"
|
||||||
|
android:foregroundServiceType="location|connectedDevice"/>
|
||||||
<service
|
<service
|
||||||
android:name=".RepeaterService"
|
android:name=".RepeaterService"
|
||||||
android:directBootAware="true"/>
|
android:directBootAware="true"
|
||||||
|
android:foregroundServiceType="location|connectedDevice"/>
|
||||||
<service
|
<service
|
||||||
android:name=".TetheringService"
|
android:name=".TetheringService"
|
||||||
android:directBootAware="true"/>
|
android:directBootAware="true"
|
||||||
|
android:foregroundServiceType="connectedDevice"/>
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".manage.RepeaterTileService"
|
android:name=".manage.RepeaterTileService"
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ 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.
|
||||||
*/
|
*/
|
||||||
@@ -255,7 +257,9 @@ class RepeaterService : Service(), CoroutineScope, WifiP2pManager.ChannelListene
|
|||||||
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
|
// 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()
|
showNotification()
|
||||||
}
|
}
|
||||||
launch {
|
launch {
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ class RepeaterTileService : KillableTileService() {
|
|||||||
val binder = binder
|
val binder = binder
|
||||||
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 ->
|
RepeaterService.Status.IDLE -> ContextCompat.startForegroundService(this,
|
||||||
ContextCompat.startForegroundService(this, Intent(this, RepeaterService::class.java))
|
Intent(this, RepeaterService::class.java).putExtra(RepeaterService.EXTRA_POSSIBLY_BACKGROUND, true))
|
||||||
else -> { }
|
else -> { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user