1、判断手机的Rom类型

public class OSUtils {    public static final String ROM_MIUI = "MIUI";    public static final String ROM_EMUI = "EMUI";    public static final String ROM_FLYME = "FLYME";    public static final String ROM_OPPO = "OPPO";    public static final String ROM_SMARTISAN = "SMARTISAN";    public static final String ROM_VIVO = "VIVO";    public static final String ROM_QIKU = "QIKU";    private static final String KEY_VERSION_MIUI = "ro.miui.ui.version.name";    private static final String KEY_VERSION_EMUI = "ro.build.version.emui";    private static final String KEY_VERSION_OPPO = "ro.build.version.opporom";    private static final String KEY_VERSION_SMARTISAN = "ro.smartisan.version";    private static final String KEY_VERSION_VIVO = "ro.vivo.os.version";    private static String sName;    private static String sVersion;    public static boolean isEmui() {        return check(ROM_EMUI);    }    public static boolean isMiui() {        return check(ROM_MIUI);    }    public static boolean isVivo() {        return check(ROM_VIVO);    }    public static boolean isOppo() {        return check(ROM_OPPO);    }    public static boolean isFlyme() {        return check(ROM_FLYME);    }    public static boolean is360() {        return check(ROM_QIKU) || check("360");    }    public static boolean isSmartisan() {        return check(ROM_SMARTISAN);    }    public static String getName() {        if (sName == null) {            check("");        }        return sName;    }    public static String getVersion() {        if (sVersion == null) {            check("");        }        return sVersion;    }    public static boolean check(String rom) {        if (sName != null) {            return sName.equals(rom);        }        if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_MIUI))) {            sName = ROM_MIUI;        } else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_EMUI))) {            sName = ROM_EMUI;        } else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_OPPO))) {            sName = ROM_OPPO;        } else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_VIVO))) {            sName = ROM_VIVO;        } else if (!TextUtils.isEmpty(sVersion = getProp(KEY_VERSION_SMARTISAN))) {            sName = ROM_SMARTISAN;        } else {            sVersion = Build.DISPLAY;            if (sVersion.toUpperCase().contains(ROM_FLYME)) {                sName = ROM_FLYME;            } else {                sVersion = Build.UNKNOWN;                sName = Build.MANUFACTURER.toUpperCase();            }        }        return sName.equals(rom);    }    public static String getProp(String name) {        String line = null;        BufferedReader input = null;        try {            Process p = Runtime.getRuntime().exec("getprop " + name);            input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);            line = input.readLine();            input.close();        } catch (IOException ex) {            return null;        } finally {            if (input != null) {                try {                    input.close();                } catch (IOException e) {                    e.printStackTrace();                }            }        }        return line;    }}

更多相关文章

  1. android 判断应用程序是否已安装
  2. android手机状态解释,比如android.os.Build.VERSION.SDK
  3. Android(安卓)OKHttp3 超时设置和异常捕获
  4. android O 手机关机流程与时间
  5. android真机调试看不到logcat信息
  6. android 手机判断是否在充电 如断电自动打电话提醒功能
  7. Android(安卓)判断数据库中是否存在某个表
  8. 获取android手机信息
  9. Android(安卓)常用的SDCARD和内存操作

随机推荐

  1. 【Android】源码项目编译ccache配置
  2. 【Android】九宫格手势锁简单实现
  3. 如何利用Eclipse运行android程序
  4. [android]android权限体系深入分析
  5. android:gravity与.android:layout_gravi
  6. android——抓取网页的android课表
  7. Android中组件的动画效果之平移动画
  8. Android(安卓)学习笔记之二 Netspeed
  9. Android UI控件之ListView实现圆角效果
  10. Android之UI学习篇十二:ListView控件学习(