Example #1
0
 /** Print cpu info. */
 public static String printCpuInfo() {
   String info = FileUtil.getFileOutputString(CPU_INFO_PATH);
   if (Log.isPrint) {
     Log.i(TAG, "_______  CPU :   \n" + info);
   }
   return info;
 }
Example #2
0
 /** Get CPU name. */
 public static String getCpuName() {
   if (!Check.isEmpty(CPU_NAME)) {
     return CPU_NAME;
   }
   try {
     BufferedReader bufferedReader = new BufferedReader(new FileReader(CPU_INFO_PATH), 8192);
     String line = bufferedReader.readLine();
     bufferedReader.close();
     String[] array = line.split(":\\s+", 2);
     if (array.length > 1) {
       if (Log.isPrint) {
         Log.i(TAG, array[1]);
       }
       CPU_NAME = array[1];
     }
   } catch (IOException e) {
     e.printStackTrace();
   }
   return CPU_NAME;
 }
Example #3
0
 /** Get command output string. */
 public static String getCMDOutputString(String[] args) {
   try {
     ProcessBuilder cmd = new ProcessBuilder(args);
     Process process = cmd.start();
     InputStream in = process.getInputStream();
     StringBuilder sb = new StringBuilder();
     byte[] re = new byte[64];
     int len;
     while ((len = in.read(re)) != -1) {
       sb.append(new String(re, 0, len));
     }
     in.close();
     process.destroy();
     if (Log.isPrint) {
       Log.i(TAG, "CMD: " + sb.toString());
     }
     return sb.toString();
   } catch (IOException ex) {
     ex.printStackTrace();
   }
   return null;
 }
Example #4
0
 /** Print duration. */
 public void printDurationRestart(String tag) {
   Log.i(TAG, tag + " :  " + durationRestart());
 }