Allow null interfaceName in onLinkPropertiesChanged

This commit is contained in:
Mygod
2018-10-10 20:15:57 +08:00
parent e564b262fd
commit 47366b982e
2 changed files with 10 additions and 2 deletions

View File

@@ -41,7 +41,11 @@ object DefaultNetworkMonitor : UpstreamMonitor() {
if (currentNetwork != network) return
val oldProperties = currentLinkProperties!!
currentLinkProperties = properties
val ifname = properties.interfaceName!!
val ifname = properties.interfaceName
if (ifname == null) {
onLost(network)
return
}
check(ifname == oldProperties.interfaceName)
if (properties.dnsServers != oldProperties.dnsServers)
callbacks.forEach { it.onAvailable(ifname, properties.dnsServers) }

View File

@@ -44,7 +44,11 @@ object VpnMonitor : UpstreamMonitor() {
synchronized(this@VpnMonitor) {
if (currentNetwork != network) return
val oldProperties = available.put(network, properties)!!
val ifname = properties.interfaceName!!
val ifname = properties.interfaceName
if (ifname == null) {
onLost(network)
return
}
check(ifname == oldProperties.interfaceName)
if (properties.dnsServers != oldProperties.dnsServers)
callbacks.forEach { it.onAvailable(ifname, properties.dnsServers) }