Get MIUI version

This commit is contained in:
M66B
2023-08-29 18:44:26 +02:00
parent 74eff71cae
commit 0034267565
2 changed files with 16 additions and 0 deletions

View File

@@ -148,6 +148,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
@@ -1582,6 +1583,18 @@ public class Helper {
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S);
}
static String getMIUIVersion() {
try {
Class<?> c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class);
String miui = (String) get.invoke(c, "ro.miui.ui.version.code");
return (TextUtils.isEmpty(miui) ? null : miui);
} catch (Throwable ex) {
Log.w(ex);
return null;
}
}
static String getUiModeType(Context context) {
try {
UiModeManager uimm = Helper.getSystemService(context, UiModeManager.class);