日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > windows >内容正文

windows

判断小米华为等系统 MD

發(fā)布時(shí)間:2024/10/12 windows 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 判断小米华为等系统 MD 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Markdown版本筆記我的GitHub首頁(yè)我的博客我的微信我的郵箱
MyAndroidBlogsbaiqiantaobaiqiantaobqt20094baiqiantao@sina.com

目錄

目錄
判斷小米華為系統(tǒng)
工具類(lèi):獲取系統(tǒng)信息
QMUI庫(kù)中提供的方法

判斷小米華為系統(tǒng)

工具類(lèi):獲取系統(tǒng)信息

public class SimpleDeviceUtils {public enum SystemType {/*** 小米手機(jī)(MIUI系統(tǒng))*/SYS_MIUI,/*** 華為手機(jī)(EMUI系統(tǒng))*/SYS_EMUI,/*** 魅族手機(jī),FLYME系統(tǒng)*/SYS_FLYME,/*** 其他系統(tǒng)*/SYS_OTHER}private static final String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name";private static final String KEY_MIUI_VERSION_CODE = "ro.miui.ui.version.code";private static final String KEY_MIUI_INTERNAL_STORAGE = "ro.miui.internal.storage";private static final String KEY_EMUI_API_LEVEL = "ro.build.hw_emui_api_level";private static final String KEY_EMUI_VERSION = "ro.build.version.emui";private static final String KEY_EMUI_CONFIG_HW_SYS_VERSION = "ro.confg.hw_systemversion";/*** 8.0之后有些系統(tǒng)信息獲取不到,沒(méi)有在各種版本手機(jī)上逐一測(cè)試*/public static SystemType getSystemType() {try {Properties prop = new Properties();prop.load(new FileInputStream(new File(Environment.getRootDirectory(), "build.prop")));if (Build.MANUFACTURER.toLowerCase().equals("xiaomi")//官方提供的判斷是否為小米手機(jī)(而非MIUI系統(tǒng))的方法|| prop.getProperty(KEY_MIUI_VERSION_NAME, null) != null//QMUI提供的判斷是否是MIUI的方法|| prop.getProperty(KEY_MIUI_VERSION_CODE, null) != null//下面兩個(gè)是網(wǎng)上補(bǔ)充的方法,感覺(jué)沒(méi)必要的|| prop.getProperty(KEY_MIUI_INTERNAL_STORAGE, null) != null) {return SystemType.SYS_MIUI;} else if (isEMUI()//華為|| prop.getProperty(KEY_EMUI_API_LEVEL, null) != null|| prop.getProperty(KEY_EMUI_VERSION, null) != null|| prop.getProperty(KEY_EMUI_CONFIG_HW_SYS_VERSION, null) != null) {return SystemType.SYS_EMUI;} else if (isMeizu()//魅族推送SDK中提供的判斷是否是魅族的方法|| DeviceHelper.isMeizu()) {//QMUI提供的判斷是否是魅族的方法return SystemType.SYS_FLYME;}} catch (IOException e) {e.printStackTrace();}return SystemType.SYS_OTHER;}@SuppressLint("PrivateApi")private static boolean isEMUI() {Class<?>[] clsArray = new Class<?>[]{String.class};Object[] objArray = new Object[]{"ro.build.version.emui"};try {Class<?> SystemPropertiesClass = Class.forName("android.os.SystemProperties");Method get = SystemPropertiesClass.getDeclaredMethod("get", clsArray);String version = (String) get.invoke(SystemPropertiesClass, objArray);Log.i("bqt", "EMUI version is:" + version);return !TextUtils.isEmpty(version);} catch (Exception e) {e.printStackTrace();}return false;}/*** 判斷是否為魅族設(shè)備*/private static boolean isMeizu() {String model = SystemProperties.get("ro.meizu.product.model");return (!TextUtils.isEmpty(model)) || "meizu".equalsIgnoreCase(Build.BRAND) || "22c4185e".equalsIgnoreCase(Build.BRAND);} }

QMUI庫(kù)中提供的方法

//判斷系統(tǒng)廠商,里面的內(nèi)容基本都來(lái)自QMUI庫(kù) public class DeviceHelper {private final static String KEY_MIUI_VERSION_NAME = "ro.miui.ui.version.name";private static final String KEY_FLYME_VERSION_NAME = "ro.build.display.id";private final static String FLYME = "flyme";private final static String MEIZUBOARD[] = {"m9", "M9", "mx", "MX"};private static String sMiuiVersionName;private static String sFlymeVersionName;static {Properties properties = new Properties();if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {// android 8.0,讀取 /system/build.prop 會(huì)報(bào) permission deniedFileInputStream fileInputStream = null;try {fileInputStream = new FileInputStream(new File(Environment.getRootDirectory(), "build.prop"));properties.load(fileInputStream);} catch (Exception e) {e.printStackTrace();} finally {if (fileInputStream != null) {try {fileInputStream.close();} catch (IOException e) {e.printStackTrace();}}}}try {Class<?> clzSystemProperties = Class.forName("android.os.SystemProperties");Method getMethod = clzSystemProperties.getDeclaredMethod("get", String.class);sMiuiVersionName = getLowerCaseName(properties, getMethod, KEY_MIUI_VERSION_NAME);sFlymeVersionName = getLowerCaseName(properties, getMethod, KEY_FLYME_VERSION_NAME);} catch (Exception e) {e.printStackTrace();}}private static String getLowerCaseName(Properties p, Method get, String key) {String name = p.getProperty(key);if (name == null) {try {name = (String) get.invoke(null, key);} catch (Exception e) {e.printStackTrace();}}if (name != null) name = name.toLowerCase();return name;}private static boolean sIsTabletChecked = false;private static boolean sIsTabletValue = false;/*** 判斷是否為平板設(shè)備*/public static boolean isTablet(Context context) {if (sIsTabletChecked) {return sIsTabletValue;} else {sIsTabletChecked = true;sIsTabletValue = (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >=Configuration.SCREENLAYOUT_SIZE_LARGE;return sIsTabletValue;}}/*** 判斷是否是flyme系統(tǒng)*/public static boolean isFlyme() {return !TextUtils.isEmpty(sFlymeVersionName) && sFlymeVersionName.contains(FLYME);}/*** 判斷是否是MIUI系統(tǒng)*/public static boolean isMIUI() {return !TextUtils.isEmpty(sMiuiVersionName);}public static boolean isMIUIV5() {return "v5".equals(sMiuiVersionName);}public static boolean isMIUIV6() {return "v6".equals(sMiuiVersionName);}public static boolean isMIUIV7() {return "v7".equals(sMiuiVersionName);}public static boolean isMIUIV8() {return "v8".equals(sMiuiVersionName);}public static boolean isMIUIV9() {return "v9".equals(sMiuiVersionName);}public static boolean isFlymeVersionHigher5_2_4() {//查不到默認(rèn)高于5.2.4boolean isHigher = true;if (sFlymeVersionName != null && !sFlymeVersionName.equals("")) {Pattern pattern = Pattern.compile("(\\d+\\.){2}\\d");Matcher matcher = pattern.matcher(sFlymeVersionName);if (matcher.find()) {String versionString = matcher.group();if (versionString != null && !versionString.equals("")) {String[] version = versionString.split("\\.");if (version.length == 3) {if (Integer.valueOf(version[0]) < 5) {isHigher = false;} else if (Integer.valueOf(version[0]) > 5) {isHigher = true;} else {if (Integer.valueOf(version[1]) < 2) {isHigher = false;} else if (Integer.valueOf(version[1]) > 2) {isHigher = true;} else {if (Integer.valueOf(version[2]) < 4) {isHigher = false;} else if (Integer.valueOf(version[2]) >= 5) {isHigher = true;}}}}}}}return isMeizu() && isHigher;}/*** 判斷是否為魅族*/public static boolean isMeizu() {return isSpecialBoardPhone(MEIZUBOARD) || isFlyme();}/*** 判斷是否為小米,詳見(jiàn)https://dev.mi.com/doc/?p=254*/public static boolean isXiaomi() {return Build.MANUFACTURER.toLowerCase().equals("xiaomi");}/*** 是否是指定型號(hào)的手機(jī)*/private static boolean isSpecialBoardPhone(String[] boards) {String board = android.os.Build.BOARD;if (board != null) {for (String b : boards) {if (board.equals(b)) {return true;}}}return false;} }

2018-4-20

轉(zhuǎn)載于:https://www.cnblogs.com/baiqiantao/p/b97c04c79912e606c917429fdf6533fb.html

總結(jié)

以上是生活随笔為你收集整理的判断小米华为等系统 MD的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。