回答

1

我不知道圖書館然而,可以提取特定的硬件規格,Facebook的設備年級可以找到庫可以分類設備插入基於硬件規格「年」:

Github: Device-Year-Class

此外,你可以通過他們的代碼來檢測他們如何獲得信息,如最大頻率KHz:

public static int getCPUMaxFreqKHz() { 
int maxFreq = DEVICEINFO_UNKNOWN; 
try { 
    for (int i = 0; i < getNumberOfCPUCores(); i++) { 
    String filename = 
     "/sys/devices/system/cpu/cpu" + i + "/cpufreq/cpuinfo_max_freq"; 
    File cpuInfoMaxFreqFile = new File(filename); 
    if (cpuInfoMaxFreqFile.exists()) { 
     byte[] buffer = new byte[128]; 
     FileInputStream stream = new FileInputStream(cpuInfoMaxFreqFile); 
     try { 
     stream.read(buffer); 
     int endIndex = 0; 
     //Trim the first number out of the byte buffer. 
     while (Character.isDigit(buffer[endIndex]) && endIndex < buffer.length) { 
      endIndex++; 
     } 
     String str = new String(buffer, 0, endIndex); 
     Integer freqBound = Integer.parseInt(str); 
     if (freqBound > maxFreq) { 
      maxFreq = freqBound; 
     } 
     } catch (NumberFormatException e) { 
     //Fall through and use /proc/cpuinfo. 
     } finally { 
     stream.close(); 
     } 
    } 
    } 
    if (maxFreq == DEVICEINFO_UNKNOWN) { 
    FileInputStream stream = new FileInputStream("/proc/cpuinfo"); 
    try { 
     int freqBound = parseFileForValue("cpu MHz", stream); 
     freqBound *= 1000; //MHz -> kHz 
     if (freqBound > maxFreq) maxFreq = freqBound; 
    } finally { 
     stream.close(); 
    } 
    } 
} catch (IOException e) { 
    maxFreq = DEVICEINFO_UNKNOWN; //Fall through and return unknown. 
} 
return maxFreq; 
} 
相關問題