Add device count to other tiles too

This commit is contained in:
Mygod
2020-06-16 10:22:57 +08:00
parent 6ae4207e32
commit 7b1f610f9a
4 changed files with 70 additions and 21 deletions

View File

@@ -46,7 +46,8 @@ enum class TetherType(@DrawableRes val icon: Int) {
.map { it.toPattern() }
@RequiresApi(30)
private fun updateRegexs() {
private fun updateRegexs() = synchronized(this) {
if (!requiresUpdate) return@synchronized
requiresUpdate = false
TetheringManager.registerTetheringEventCallback(null, this)
val tethering = "com.android.networkstack.tethering" to app.packageManager.getResourcesForApplication(
@@ -59,7 +60,8 @@ enum class TetherType(@DrawableRes val icon: Int) {
}
@RequiresApi(30)
override fun onTetherableInterfaceRegexpsChanged(args: Array<out Any?>?) {
override fun onTetherableInterfaceRegexpsChanged(args: Array<out Any?>?) = synchronized(this) {
if (requiresUpdate) return@synchronized
Timber.i("onTetherableInterfaceRegexpsChanged: ${args?.contentToString()}")
TetheringManager.unregisterTetheringEventCallback(this)
requiresUpdate = true
@@ -92,6 +94,7 @@ enum class TetherType(@DrawableRes val icon: Int) {
iface == null -> NONE
iface == p2pDev -> WIFI_P2P
requiresUpdate -> {
Timber.d("requiresUpdate")
if (Build.VERSION.SDK_INT >= 30) updateRegexs() else error("unexpected requiresUpdate")
ofInterface(iface, p2pDev)
}