Fix ANR caused by temp hotspot

Fixes #126.
This commit is contained in:
Mygod
2019-09-19 11:06:41 +08:00
parent 650b06beae
commit e2aeae9e2f
5 changed files with 39 additions and 26 deletions

View File

@@ -79,7 +79,6 @@ class LocalOnlyHotspotManager(private val parent: TetheringFragment) : Manager()
return lookup[binder?.iface ?: return ""]?.formatAddresses() ?: ""
}
override val active get() = binder?.iface != null
override val enabled get() = binder?.iface != ""
override val selectable get() = active
}

View File

@@ -31,10 +31,10 @@ class LocalOnlyHotspotTileService : KillableTileService() {
override fun onClick() {
val binder = binder
if (binder == null) tapPending = true
else when (binder.iface) {
null -> ContextCompat.startForegroundService(this, Intent(this, LocalOnlyHotspotService::class.java))
"" -> { } // STARTING, ignored
when {
binder == null -> tapPending = true
binder.iface == null -> ContextCompat.startForegroundService(this,
Intent(this, LocalOnlyHotspotService::class.java))
else -> binder.stop()
}
}
@@ -44,19 +44,12 @@ class LocalOnlyHotspotTileService : KillableTileService() {
service.ifaceChanged[this] = {
qsTile?.run {
icon = tile
when (it) {
null -> {
state = Tile.STATE_INACTIVE
label = getText(R.string.tethering_temp_hotspot)
}
"" -> {
state = Tile.STATE_UNAVAILABLE
label = getText(R.string.tethering_temp_hotspot)
}
else -> {
state = Tile.STATE_ACTIVE
label = service.configuration?.SSID ?: getText(R.string.tethering_temp_hotspot)
}
if (it.isNullOrEmpty()) {
state = Tile.STATE_INACTIVE
label = getText(R.string.tethering_temp_hotspot)
} else {
state = Tile.STATE_ACTIVE
label = service.configuration?.SSID ?: getText(R.string.tethering_temp_hotspot)
}
updateTile()
}