小米 MIX 3 Android 9.0
//添加依赖
implementation 'com.walkud.rom.checker:RomChecker:1.0.0'
//读取当前手机ROM
Rom rom = RomIdentifier.getRom();
//打印Rom信息
Log.d("AndroidRomChecker", "Rom:" + rom.toString());
已适配Rom在cc包下都会存在对应的Checker识别器。
public enum Rom {
//目前已适配
MIUI("xiaomi"), // 小米
Flyme("meizu"), // 魅族
EMUI("huawei"), // 华为
ColorOS("oppo"), // OPPO
FuntouchOS("vivo"), // vivo
SmartisanOS("smartisan"), // 锤子
AmigoOS("amigo"), // 金立
EUI("letv"), // 乐视
Sense("sense"), // HTC
Google("google"), // 原生
NubiaUI("nubia"), // 努比亚
//未适配
_360OS(""), // 奇酷360
H2OS(""), // 一加
YunOS(""), // 阿里巴巴
YuLong("yulong"), // 酷派
SamSung("samsung"), // 三星
Sony("sony"), // 索尼
Lenovo("lenovo"), // 联想
LG("lg"), // LG
ZTE("zte"),//中兴
Other(""); // 其它
……
}
//获取默认识别器
List<Checker> checkers = RomIdentifier.getRom.getChecker();
//checkers.add();//添加自定义识别器
//读取当前手机ROM
Rom rom = RomIdentifier.getRom(checkers);
执行getprop命令,获取到系统配置文件属性,根据判断不同属性值是否存在,来达到判断Rom的类型;再根据对应Rom的属性值来获取版本信息。
SenhLinsh/Android-ROM-Identifier
Copyright [2018] [Walkud]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.