get Min Cpu frequency - Android Hardware

Android examples for Hardware:CPU Frequency

Description

get Min Cpu frequency

Demo Code


//package com.java2s;

import java.io.IOException;
import java.io.InputStream;

public class Main {
    public static String getMinCpuFreq(int cpuNo) {
        String result = "";
        String path = "/sys/devices/system/cpu/cpu%d/cpufreq/cpuinfo_min_freq";
        ProcessBuilder cmd;/*from  w w  w.  j  a va 2 s  .  c om*/
        try {
            String[] args = { "/system/bin/cat", String.format(path, cpuNo) };
            cmd = new ProcessBuilder(args);
            Process process = cmd.start();
            InputStream in = process.getInputStream();
            byte[] re = new byte[24];
            while (in.read(re) != -1) {
                result += new String(re);
            }
            in.close();
        } catch (IOException ex) {
            ex.printStackTrace();
            result = "N/A";
        }
        return result.trim();
    }
}

Related Tutorials