0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-15 23:35:06 +00:00

fix MiuiHelper npe

This commit is contained in:
HaliksaR 2020-11-15 06:24:15 +07:00
parent be23fe821d
commit 31162db145

View file

@ -6,28 +6,20 @@ import java.io.InputStreamReader
object MiuiHelper { object MiuiHelper {
fun isMiui(): Boolean = getSystemProps("ro.miui.ui.version.name")!!.isNotEmpty() private const val MIUI_PROP_NAME = "ro.miui.ui.version.name"
fun isMiui(): Boolean = !getSystemProps(MIUI_PROP_NAME).isNullOrEmpty()
private fun getSystemProps(propname: String): String? { private fun getSystemProps(propname: String): String? {
val line: String
var input: BufferedReader? = null var input: BufferedReader? = null
try { return try {
val p = Runtime.getRuntime().exec("getprop $propname") val process = Runtime.getRuntime().exec("getprop $propname")
input = BufferedReader(InputStreamReader(p.inputStream), 1024) input = BufferedReader(InputStreamReader(process.inputStream), 1024)
line = input.readLine() input.readLine()
input.close()
} catch (e: IOException) { } catch (e: IOException) {
return null null
} finally { } finally {
if (input != null) { input?.close()
try {
input.close()
} catch (e: IOException) {
e.printStackTrace()
}
}
} }
return line
} }
} }