tags:

views:

437

answers:

2

Is there any Java API for that? How can I read this information.

+3  A: 

not MHz, but at least something. bogoMIPS value can be useful for you.

private String ReadCPUinfo()
 {
  ProcessBuilder cmd;
  String result="";

  try{
   String[] args = {"/system/bin/cat", "/proc/cpuinfo"};
   cmd = new ProcessBuilder(args);

   Process process = cmd.start();
   InputStream in = process.getInputStream();
   byte[] re = new byte[1024];
   while(in.read(re) != -1){
    System.out.println(new String(re));
    result = result + new String(re);
   }
   in.close();
  } catch(IOException ex){
   ex.printStackTrace();
  }
  return result;
 }
zed_0xff
Thanks, but is there any way to convert it to MHz or read it somewhere?
michael
Any reason you're not just opening /proc/cpuinfo as a file and reading it directly?
fadden
michael, read a wiki page about bogoMIPS, there's a formula. fadden, I'm not sure that file could be simply read from java, just found this code laying around.
zed_0xff
+2  A: 

To have frequency on Android, just read these special files in /sys directory:

#cat "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq"
#cat "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq"
#cat "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"

You will have current, min and max Frequency allowed.

Ellis