From 4fe1909800b0193c2b25d0727cced7a0fdcf7b74 Mon Sep 17 00:00:00 2001 From: Mygod Date: Tue, 21 Jul 2020 12:42:37 -0400 Subject: [PATCH] Fix getByName returns null --- mobile/src/main/java/be/mygod/vpnhotspot/util/Utils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/util/Utils.kt b/mobile/src/main/java/be/mygod/vpnhotspot/util/Utils.kt index 9e81b99e..df82ddc6 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/util/Utils.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/util/Utils.kt @@ -168,5 +168,5 @@ fun if_nametoindex(ifname: String) = if (Build.VERSION.SDK_INT >= 26) { } else try { File("/sys/class/net/$ifname/ifindex").inputStream().bufferedReader().use { it.readLine().toInt() } } catch (_: FileNotFoundException) { - NetworkInterface.getByName(ifname).index + NetworkInterface.getByName(ifname)?.index ?: 0 }