function cpuInfo(cpuInfo, type) {
var temp = '',
cpuHardware;
var fileReader = plus.android.importClass("java.io.FileReader");
var bufferedReader = plus.android.importClass("java.io.BufferedReader");
var FileReader = new fileReader(cpuInfo);
var BufferedReader = new bufferedReader(FileReader, 8192);
while ((temp = BufferedReader.readLine()) != null) {
if (type != 1) {
cpuHardware = temp.substr(0)
} else {
if (-1 != temp.indexOf('Hardware')) {
cpuHardware = temp.substr(parseInt(temp.indexOf(":")) + 1);
}
}
}
return cpuHardware
}
var cpuInfoArr = '/proc/cpuinfo';
var cpuInfoMax = '/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq';
var cpuInfoMin = '/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq';
var cpuven = cpuInfo(cpuInfoArr, '1')
//cpu型号
var cpuVendor = cpuven.trim()
//cpu频率
var cpuFreq = cpuInfo(cpuInfoMax, '2')
//获取CPU条数
function getCpuCount() {
var Runtime = plus.android.importClass("java.lang.Runtime");
var cpuCount = Runtime.getRuntime().availableProcessors();
return cpuCount;
}
var cpuCount = getCpuCount()
获取cpu相关信息
最新推荐文章于 2023-01-30 17:41:38 发布