Revert "Lazily start IpNeighbourMonitor in qs tiles"
This reverts commit 490f6c5115.
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package be.mygod.vpnhotspot.manage
|
package be.mygod.vpnhotspot.manage
|
||||||
|
|
||||||
import android.service.quicksettings.Tile
|
import android.service.quicksettings.Tile
|
||||||
import androidx.annotation.CallSuper
|
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import be.mygod.vpnhotspot.R
|
import be.mygod.vpnhotspot.R
|
||||||
import be.mygod.vpnhotspot.net.IpNeighbour
|
import be.mygod.vpnhotspot.net.IpNeighbour
|
||||||
@@ -12,28 +11,15 @@ import java.net.Inet4Address
|
|||||||
@RequiresApi(24)
|
@RequiresApi(24)
|
||||||
abstract class IpNeighbourMonitoringTileService : KillableTileService(), IpNeighbourMonitor.Callback {
|
abstract class IpNeighbourMonitoringTileService : KillableTileService(), IpNeighbourMonitor.Callback {
|
||||||
private var neighbours: Collection<IpNeighbour> = emptyList()
|
private var neighbours: Collection<IpNeighbour> = emptyList()
|
||||||
private var canRegister = false
|
|
||||||
abstract fun updateTile()
|
abstract fun updateTile()
|
||||||
|
|
||||||
@CallSuper
|
|
||||||
override fun onStartListening() {
|
override fun onStartListening() {
|
||||||
super.onStartListening()
|
super.onStartListening()
|
||||||
synchronized(this) { canRegister = true }
|
IpNeighbourMonitor.registerCallback(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Lazily start [IpNeighbourMonitor], which could invoke root.
|
|
||||||
*/
|
|
||||||
protected fun listenForClients() = synchronized(this) {
|
|
||||||
if (canRegister) IpNeighbourMonitor.registerCallback(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
@CallSuper
|
|
||||||
override fun onStopListening() {
|
override fun onStopListening() {
|
||||||
synchronized(this) {
|
IpNeighbourMonitor.unregisterCallback(this)
|
||||||
canRegister = false
|
|
||||||
IpNeighbourMonitor.unregisterCallback(this)
|
|
||||||
}
|
|
||||||
super.onStopListening()
|
super.onStopListening()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ class LocalOnlyHotspotTileService : IpNeighbourMonitoringTileService() {
|
|||||||
state = Tile.STATE_ACTIVE
|
state = Tile.STATE_ACTIVE
|
||||||
label = binder.configuration?.ssid ?: getText(R.string.tethering_temp_hotspot)
|
label = binder.configuration?.ssid ?: getText(R.string.tethering_temp_hotspot)
|
||||||
subtitleDevices { it == iface }
|
subtitleDevices { it == iface }
|
||||||
listenForClients()
|
|
||||||
}
|
}
|
||||||
updateTile()
|
updateTile()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ sealed class TetheringTileService : IpNeighbourMonitoringTileService(), Tetherin
|
|||||||
state = Tile.STATE_ACTIVE
|
state = Tile.STATE_ACTIVE
|
||||||
icon = if (interested.all(binder::isActive)) tileOn else tileOff
|
icon = if (interested.all(binder::isActive)) tileOn else tileOff
|
||||||
subtitleDevices(interested::contains)
|
subtitleDevices(interested::contains)
|
||||||
listenForClients()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
label = getText(labelString)
|
label = getText(labelString)
|
||||||
@@ -180,7 +179,6 @@ sealed class TetheringTileService : IpNeighbourMonitoringTileService(), Tetherin
|
|||||||
state = Tile.STATE_ACTIVE
|
state = Tile.STATE_ACTIVE
|
||||||
icon = if (interested.isNotEmpty() && interested.all(binder::isActive)) tileOn else tileOff
|
icon = if (interested.isNotEmpty() && interested.all(binder::isActive)) tileOn else tileOff
|
||||||
subtitleDevices(interested::contains)
|
subtitleDevices(interested::contains)
|
||||||
listenForClients()
|
|
||||||
}
|
}
|
||||||
false -> {
|
false -> {
|
||||||
state = Tile.STATE_INACTIVE
|
state = Tile.STATE_INACTIVE
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import android.os.Build
|
|||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.service.quicksettings.Tile
|
import android.service.quicksettings.Tile
|
||||||
import android.service.quicksettings.TileService
|
import android.service.quicksettings.TileService
|
||||||
import androidx.annotation.CallSuper
|
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
|
|
||||||
@RequiresApi(24)
|
@RequiresApi(24)
|
||||||
@@ -20,7 +19,6 @@ abstract class KillableTileService : TileService(), ServiceConnection {
|
|||||||
if (Build.VERSION.SDK_INT >= 29) subtitle = value
|
if (Build.VERSION.SDK_INT >= 29) subtitle = value
|
||||||
}
|
}
|
||||||
|
|
||||||
@CallSuper
|
|
||||||
override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
|
override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
|
||||||
if (tapPending) {
|
if (tapPending) {
|
||||||
tapPending = false
|
tapPending = false
|
||||||
|
|||||||
Reference in New Issue
Block a user