From 0aac5ddfdf6e0f9afaa60e558ae9d822a28a5d64 Mon Sep 17 00:00:00 2001 From: Mygod Date: Wed, 4 Nov 2020 08:28:37 +0800 Subject: [PATCH] Allow ethernetRegex to be not found --- .../src/main/java/be/mygod/vpnhotspot/net/TetherType.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mobile/src/main/java/be/mygod/vpnhotspot/net/TetherType.kt b/mobile/src/main/java/be/mygod/vpnhotspot/net/TetherType.kt index eeb94c38..048d30d6 100644 --- a/mobile/src/main/java/be/mygod/vpnhotspot/net/TetherType.kt +++ b/mobile/src/main/java/be/mygod/vpnhotspot/net/TetherType.kt @@ -87,8 +87,12 @@ enum class TetherType(@DrawableRes val icon: Int) { bluetoothRegexs = system.getRegexs("config_tether_bluetooth_regexs") } // available since Android 4.0: https://android.googlesource.com/platform/frameworks/base/+/c96a667162fab44a250503caccb770109a9cb69a - ethernetRegex = system.second.getString(system.second.getIdentifier( - "config_ethernet_iface_regex", "string", system.first)).run { if (isEmpty()) null else toPattern() } + ethernetRegex = try { + system.second.getString(system.second.getIdentifier("config_ethernet_iface_regex", "string", + system.first)).run { if (isEmpty()) null else toPattern() } + } catch (_: Resources.NotFoundException) { + null + } } /**