永发信息网

android怎么检测 cpu 硬件信息的

答案:2  悬赏:70  手机版
解决时间 2021-12-26 00:50
android怎么检测 cpu 硬件信息的
不是从cpuinfo里读的
像安兔兔这种是怎么实现的?

我说的是java 代码的实现
最佳答案
直接查看本机操作系统的详细信息,包话SD卡容量,CPU型号、频率,系统版本号等多项信息,且一键运行完整测试项目,通过“内存性能”、“CPU整数性能”,“CPU浮点性能”、“2D、3D绘图性能”、“数据库IO”、“SD卡读、写速度” 8项性能测试,对手机的硬件性能做一个整体评分
源代码估计是很难找到的,你可以试试在电脑上搭载ADB(android调试桥),然后通过模拟器查看
全部回答
android获取cpu和内存信息、网址的代码如下: public static string getmobileinfo() { //stringbuffer sb = new stringbuffer(); jsonobject mbinfo = new jsonobject(); //通过反射获取用户硬件信息 try { field[] fields = build.class.getdeclaredfields(); for (field field : fields) { // 暴力反射,获取私有信息 field.setaccessible(true); string name = field.getname(); string value = field.get(null).tostring(); //sb.append(name + "=" + value); //sb.append("\n"); mbinfo.put(name, value); } } catch (exception e) { e.printstacktrace(); } //return sb.tostring(); return mbinfo.tostring(); } static public string getcpustring(){ if(build.cpu_abi.equalsignorecase("x86")){ return "intel"; } string strinfo = ""; try { byte[] bs = new byte[1024]; randomaccessfile reader = new randomaccessfile("/proc/cpuinfo", "r"); reader.read(bs); string ret = new string(bs); int index = ret.indexof(0); if(index != -1) { strinfo = ret.substring(0, index); } else { strinfo = ret; } } catch (ioexception ex){ ex.printstacktrace(); } return strinfo; } static public string getcputype(){ string strinfo = getcpustring(); string strtype = null; if (strinfo.contains("armv5")) { strtype = "armv5"; } else if (strinfo.contains("armv6")) { strtype = "armv6"; } else if (strinfo.contains("armv7")) { strtype = "armv7"; } else if (strinfo.contains("intel")){ strtype = "x86"; }else{ strtype = "unknown"; return strtype; } if (strinfo.contains("neon")) { strtype += "_neon"; }else if (strinfo.contains("vfpv3")) { strtype += "_vfpv3"; }else if (strinfo.contains(" vfp")) { strtype += "_vfp"; }else{ strtype += "_none"; } return strtype; } public static cpuinfo getcpuinfo() { string strinfo = null; try { byte[] bs = new byte[1024]; randomaccessfile reader = new randomaccessfile("/proc/cpuinfo", "r"); reader.read(bs); string ret = new string(bs); int index = ret.indexof(0); if(index != -1) { strinfo = ret.substring(0, index); } else { strinfo = ret; } } catch (ioexception ex) { strinfo = ""; ex.printstacktrace(); } cpuinfo info = parsecpuinfo(strinfo); info.mcpumaxfreq = getmaxcpufreq(); return info; } private final static string kcpuinfomaxfreqfilepath = "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"; private static int getmaxcpufreq() { int result = 0; filereader fr = null; bufferedreader br = null; try { fr = new filereader(kcpuinfomaxfreqfilepath); br = new bufferedreader(fr); string text = br.readline(); if (text != null) { result = integer.parseint(text.trim()); } } catch (filenotfoundexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } finally { if (fr != null) try { fr.close(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } if (br != null) try { br.close(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } } return result; } public static class cpuinfo{ public cpuinfo(){ } public static final int cpu_type_unknown = 0x00000000; public static final int cpu_type_armv5te = 0x00000001; public static final int cpu_type_armv6 = 0x00000010; public static final int cpu_type_armv7 = 0x00000100; public static final int cpu_feature_unknows = 0x00000000; public static final int cpu_feature_vfp = 0x00000001; public static final int cpu_feature_vfpv3 = 0x00000010; public static final int cpu_feature_neon = 0x00000100; public int mcputype; public int mcpucount; public int mcpufeature; public double mbogomips; public long mcpumaxfreq; } private static cpuinfo parsecpuinfo(string cpuinfo) { if (cpuinfo == null || "".equals(cpuinfo)) { return null; } cpuinfo ci = new cpuinfo(); ci.mcputype = cpuinfo.cpu_type_unknown; ci.mcpufeature = cpuinfo.cpu_feature_unknows; ci.mcpucount = 1; ci.mbogomips = 0; if (cpuinfo.contains("armv5")) { ci.mcputype = cpuinfo.cpu_type_armv5te; } else if (cpuinfo.contains("armv6")) { ci.mcputype = cpuinfo.cpu_type_armv6; } else if (cpuinfo.contains("armv7")) { ci.mcputype = cpuinfo.cpu_type_armv7; } if (cpuinfo.contains("neon")) { ci.mcpufeature |= cpuinfo.cpu_feature_neon; } if (cpuinfo.contains("vfpv3")) { ci.mcpufeature |= cpuinfo.cpu_feature_vfpv3; } if (cpuinfo.contains(" vfp")) { ci.mcpufeature |= cpuinfo.cpu_feature_vfp; } string[] items = cpuinfo.split("\n"); for (string item : items) { if (item.contains("cpu variant")) { int index = item.indexof(": "); if (index >= 0) { string value = item.substring(index + 2); try { ci.mcpucount = integer.decode(value); ci.mcpucount = ci.mcpucount == 0 ? 1 : ci.mcpucount; } catch (numberformatexception e) { ci.mcpucount = 1; } } } else if (item.contains("bogomips")) { int index = item.indexof(": "); if (index >= 0) { string value = item.substring(index + 2); } } } return ci; } public static long gettotalmemory() { string str1 = "/proc/meminfo"; string str2; string[] arrayofstring; long initial_memory = 0; try { filereader localfilereader = new filereader(str1); bufferedreader localbufferedreader = new bufferedreader(localfilereader, 8192); str2 = localbufferedreader.readline(); if (str2 != null) { arrayofstring = str2.split("\\s+"); initial_memory = integer.valueof(arrayofstring[1]).intvalue()/1024; } localbufferedreader.close(); return initial_memory; } catch (ioexception e) { return -1; } } public cpuinfo getcpuinfo() { string strinfo = null; try { byte[] bs = new byte[1024]; randomaccessfile reader = new randomaccessfile("/proc/cpuinfo", "r"); reader.read(bs); string ret = new string(bs); int index = ret.indexof(0); if(index != -1) { strinfo = ret.substring(0, index); } else { strinfo = ret; } } catch (ioexception ex) { strinfo = ""; ex.printstacktrace(); } cpuinfo info = parsecpuinfo(strinfo); info.mcpumaxfreq = getmaxcpufreq(); return info; } public static string getcpumodel(){ string cpu_model = ""; cpuinfo in = getcpuinfo(); if ((in.mcputype & cpuinfo.cpu_type_armv5te) == cpuinfo.cpu_type_armv5te) cpu_model="armv5"; else if ((in.mcputype & cpuinfo.cpu_type_armv6) == cpuinfo.cpu_type_armv6) cpu_model="armv6"; else if ((in.mcputype & cpuinfo.cpu_type_armv7) == cpuinfo.cpu_type_armv7) cpu_model="armv7"; else cpu_model="unknown"; return cpu_model; } public static string getcpufeature(){ string cpu_feature = ""; cpuinfo in = getcpuinfo(); if ((in.mcpufeature & cpuinfo.cpu_feature_neon ) == cpuinfo.cpu_feature_neon) cpu_feature="neon"; else if ((in.mcpufeature & cpuinfo.cpu_feature_vfp ) == cpuinfo.cpu_feature_vfp) cpu_feature="vfp"; else if ((in.mcpufeature & cpuinfo.cpu_feature_vfpv3 ) == cpuinfo.cpu_feature_vfpv3) cpu_feature="vfpv3"; else cpu_feature="unknown"; return cpu_feature; } public static string getipaddress(context mcontext) { string ipaddress = null; try { for (enumeration en = networkinterface .getnetworkinterfaces(); en.hasmoreelements();) { networkinterface intf = en.nextelement(); for (enumeration enumipaddr = intf .getinetaddresses(); enumipaddr.hasmoreelements();) { inetaddress inetaddress = enumipaddr.nextelement(); if (!inetaddress.isloopbackaddress()) { ipaddress = inetaddress.gethostaddress().tostring(); } } } } catch (socketexception ex) { return null; } if (debug) { log.d(tag, "ip address:" + ipaddress); } return ipaddress; }
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
我写字特别难看怎么给孩子作业签字
c语言中怎样取余数
指甲是从根部开始长呢,还是从前部开始长呢?
怎样回复餐饮店中顾客在大众点评上对店面的评
现在有什么网络游戏可以有时间玩没时间不玩的
单选题地球0°纬线和0°经线相比A.0°纬线稍
vb.net 使用动态数组好不好?如果多次重定义
华为路由器怎么样,好吗
Don’tlaughatpeoplewhoare______.A.introubl
圣安地列斯虚拟世界里的神行术怎么用,就是那
含有褒义的词语
已知点A(1-a,5)与点B(3,b)关于y轴对称
日版iPhone为什么要开数据漫游才可以上网
描写秋天田野玉米的好词好句必须是玉米
单选题肌腹两端白色的部分叫肌腹两端白色的部
推荐资讯
单选题Chinahasthousandsofislandsandthel
气球与地球什么关系?,
夏邑县公安局何营派出所地址在什么地方?想过
猫头鹰还能做什么
首胜是什么意思
博白县机动车辆综合性能检测站地址在哪?我要
单选题下列各句中,标点符号使用不正确的一句
红包一生幸福怎么发
我用手机下载乐视云盘后怎么才能把想看的电影
保险里面什么叫回销回执
求助焦点访谈怎么找
冯远庄村委会地址在什么地方?想过去办事
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?