Android Get Processor Model

后端 未结 2 1241
感动是毒
感动是毒 2021-02-04 17:53

I want to get Processor Model similar to DU Booster. CPU model contains ARM processor version and revision. For Example: ARMv7 Processor rev 3 (v7l)

I have tried this

2条回答
  •  暖寄归人
    2021-02-04 18:17

    You don't need to implement separated methods to work with differ processors types, just simply replace the model_name key to cpu_model when it needed while getting /proc/cpuinfo file:

        public static Map getCPUInfo () throws IOException {
    
            BufferedReader br = new BufferedReader (new FileReader ("/proc/cpuinfo"));
    
            String str;
    
            Map output = new HashMap<> ();
    
            while ((str = br.readLine ()) != null) {
    
                String[] data = str.split (":");
    
                if (data.length > 1) {
    
                    String key = data[0].trim ().replace (" ", "_");
                    if (key.equals ("model_name")) key = "cpu_model";
    
                    output.put (key, data[1].trim ());
    
                }
    
            }
    
            br.close ();
    
            return output;
    
        }
    

提交回复
热议问题