mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-15 23:35:06 +00:00
fix MiuiHelper npe
This commit is contained in:
parent
be23fe821d
commit
31162db145
1 changed files with 9 additions and 17 deletions
|
@ -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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue