Improve quick settings tiles reliability
Android apparently can decide to kill TileService when there are too many. Therefore, let's check if our service is connected before doing anything. Source: https://android.googlesource.com/platform/frameworks/base/+/e1d13c9/packages/SystemUI/src/com/android/systemui/qs/external/TileServices.java#52
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package be.mygod.vpnhotspot.util
|
||||
|
||||
import android.content.ComponentName
|
||||
import android.content.ServiceConnection
|
||||
import android.os.IBinder
|
||||
import android.service.quicksettings.TileService
|
||||
import androidx.annotation.RequiresApi
|
||||
|
||||
@RequiresApi(24)
|
||||
abstract class KillableTileService : TileService(), ServiceConnection {
|
||||
protected var tapPending = false
|
||||
|
||||
override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
|
||||
if (tapPending) {
|
||||
tapPending = false
|
||||
onClick()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user