Mute more SocketException

This commit is contained in:
Mygod
2019-01-03 23:51:16 +08:00
parent 615e7256d0
commit 719e8245a7
5 changed files with 6 additions and 10 deletions

View File

@@ -138,14 +138,13 @@ class SettingsPreferenceFragment : PreferenceFragmentCompat() {
.filter {
try {
it.isUp && !it.isLoopback && it.interfaceAddresses.isNotEmpty()
} catch (e: SocketException) {
Timber.d(e)
} catch (_: SocketException) {
false
}
}
.map { it.name }.sorted().toList().toTypedArray()
} catch (e: SocketException) {
Timber.d(e)
Timber.w(e)
emptyArray<String>()
})
setTargetFragment(this@SettingsPreferenceFragment, 0)

View File

@@ -50,7 +50,7 @@ class RepeaterManager(private val parent: TetheringFragment) : Manager(), Servic
val addresses: CharSequence @Bindable get() {
return try {
NetworkInterface.getByName(p2pInterface ?: return "")?.formatAddresses() ?: ""
} catch (e: SocketException) {
} catch (_: SocketException) {
""
}
}

View File

@@ -54,7 +54,7 @@ class TetheringFragment : Fragment(), ServiceConnection {
ifaceLookup = try {
NetworkInterface.getNetworkInterfaces().asSequence().associateBy { it.name }
} catch (e: SocketException) {
Timber.d(e)
Timber.w(e)
emptyMap()
}
this@TetheringFragment.enabledTypes =

View File

@@ -57,9 +57,7 @@ data class IpNeighbour(val ip: InetAddress, val dev: String, val lladdr: String,
val iface = NetworkInterface.getByIndex(index)
if (iface == null) Timber.w("Failed to find network interface #$index")
else return listOf(IpNeighbour(ip, iface.name, lladdr, state), result)
} catch (e: SocketException) {
Timber.d(e)
}
} catch (_: SocketException) { }
listOf(result)
} catch (e: Exception) {
Timber.w(IllegalArgumentException("Unable to parse line: $line", e))

View File

@@ -50,8 +50,7 @@ fun NetworkInterface.formatAddresses() =
.toList() +
listOfNotNull(try {
hardwareAddress?.joinToString(":") { "%02x".format(it) }
} catch (e: SocketException) {
Timber.w(e)
} catch (_: SocketException) {
null
}))
.joinToString("\n")