Commit 3d56d585 authored by Daniel Wolf's avatar Daniel Wolf

Fix class

parent 26fb44a7
Pipeline #7653 passed with stage
in 1 minute and 42 seconds
......@@ -58,13 +58,13 @@ class NoConnectionDnsHandle(
val request = NetworkRequest.Builder().addCapability(NetworkCapabilities.NET_CAPABILITY_NOT_VPN).build()
synchronized(this) {
networkCallback = object:ConnectivityManager.NetworkCallback() {
override fun onAvailable(network: Network?) {
override fun onAvailable(network: Network) {
super.onAvailable(network)
packetProxy.tunnelHandle?.proxy?.logger?.info { "[NoConnectionDnsHandle] Network $network became available" }
handleChange(network)
}
override fun onLost(network: Network?) {
override fun onLost(network: Network) {
super.onLost(network)
packetProxy.tunnelHandle?.proxy?.logger?.info { "[NoConnectionDnsHandle] Network $network lost" }
handleChange(null)
......@@ -83,7 +83,7 @@ class NoConnectionDnsHandle(
handleNetworkInfo(activeNetwork)
}
}
connectivityManager.registerNetworkCallback(request, networkCallback)
networkCallback?.also { connectivityManager.registerNetworkCallback(request, it) }
}
handleNetworkInfo(connectivityManager.activeNetworkInfo)
if(regularConnectionCheckIntervalMs != null) {
......@@ -145,10 +145,8 @@ class NoConnectionDnsHandle(
override fun cleanup() {
synchronized(this) {
if(networkCallback != null) {
connectivityManager.unregisterNetworkCallback(networkCallback)
networkCallback = null
}
networkCallback?.also { connectivityManager.unregisterNetworkCallback(it) }
networkCallback = null
regularConnectionCheckJob?.cancel()
regularConnectionCheckJob = null
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment