Allow ethernetRegex to be not found

This commit is contained in:
Mygod
2020-11-04 08:28:37 +08:00
parent 73929f08e9
commit 0aac5ddfdf

View File

@@ -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
}
}
/**