diff --git a/app/src/main/java/com/vanced/manager/utils/MiuiHelper.kt b/app/src/main/java/com/vanced/manager/utils/MiuiHelper.kt index 96434f46..07fe9624 100644 --- a/app/src/main/java/com/vanced/manager/utils/MiuiHelper.kt +++ b/app/src/main/java/com/vanced/manager/utils/MiuiHelper.kt @@ -6,28 +6,20 @@ import java.io.InputStreamReader 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? { - val line: String var input: BufferedReader? = null - try { - val p = Runtime.getRuntime().exec("getprop $propname") - input = BufferedReader(InputStreamReader(p.inputStream), 1024) - line = input.readLine() - input.close() + return try { + val process = Runtime.getRuntime().exec("getprop $propname") + input = BufferedReader(InputStreamReader(process.inputStream), 1024) + input.readLine() } catch (e: IOException) { - return null + null } finally { - if (input != null) { - try { - input.close() - } catch (e: IOException) { - e.printStackTrace() - } - } + input?.close() } - return line } - } \ No newline at end of file