MCPcopy Create free account
hub / github.com/afkT/DevUtils / getMaxCpuFreq

Method getMaxCpuFreq

lib/DevApp/src/main/java/dev/utils/app/CPUUtils.java:115–141  ·  view source on GitHub ↗

获取 CPU 最大频率 ( 单位 KHZ ) @return CPU 最大频率 ( 单位 KHZ )

()

Source from the content-addressed store, hash-verified

113 * @return CPU 最大频率 ( 单位 KHZ )
114 */
115 public static String getMaxCpuFreq() {
116 ProcessBuilder cmd;
117 InputStream is = null;
118 try {
119 StringBuilder builder = new StringBuilder();
120 String[] args = {
121 "/system/bin/cat",
122 "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"
123 };
124 cmd = new ProcessBuilder(args);
125 Process process = cmd.start();
126 is = process.getInputStream();
127 byte[] re = new byte[24];
128 while (is.read(re) != -1) {
129 builder.append(new String(re));
130 }
131 return Formatter.formatFileSize(
132 DevUtils.getContext(),
133 Long.parseLong(builder.toString().trim()) * 1024
134 ) + " Hz";
135 } catch (Exception e) {
136 LogPrintUtils.eTag(TAG, e, "getMaxCpuFreq");
137 } finally {
138 CloseUtils.closeIOQuietly(is);
139 }
140 return "unknown";
141 }
142
143 /**
144 * 获取 CPU 最小频率 ( 单位 KHZ )

Callers

nothing calls this directly

Calls 9

getContextMethod · 0.95
eTagMethod · 0.95
closeIOQuietlyMethod · 0.95
readMethod · 0.80
startMethod · 0.45
appendMethod · 0.45
formatFileSizeMethod · 0.45
parseLongMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected