Android 获取手机内部信息,内核版本、基带版本、内部版本等

时间:2024-03-10 21:10:27
TextView text = (TextView) findViewById(R.id.textView1);  
  
String phoneInfo = "Product: " + android.os.Build.PRODUCT + "\n";  
phoneInfo += ", CPU_ABI: " + android.os.Build.CPU_ABI + "\n";  
phoneInfo += ", TAGS: " + android.os.Build.TAGS + "\n";  
phoneInfo += ", VERSION_CODES.BASE: "+ android.os.Build.VERSION_CODES.BASE + "\n";  
phoneInfo += ", MODEL: " + android.os.Build.MODEL + "\n";  
phoneInfo += ", SDK: " + android.os.Build.VERSION.SDK + "\n";  
phoneInfo += ", VERSION.RELEASE: " + android.os.Build.VERSION.RELEASE+ "\n";  
phoneInfo += ", DEVICE: " + android.os.Build.DEVICE + "\n";  
phoneInfo += ", DISPLAY: " + android.os.Build.DISPLAY + "\n";  
phoneInfo += ", BRAND: " + android.os.Build.BRAND + "\n";  
phoneInfo += ", BOARD: " + android.os.Build.BOARD + "\n";  
phoneInfo += ", FINGERPRINT: " + android.os.Build.FINGERPRINT + "\n";  
phoneInfo += ", ID: " + android.os.Build.ID + "\n";  
phoneInfo += ", MANUFACTURER: " + android.os.Build.MANUFACTURER + "\n";  
phoneInfo += ", USER: " + android.os.Build.USER + "\n";  
phoneInfo += ", BOOTLOADER: " + android.os.Build.BOOTLOADER + "\n";  
phoneInfo += ", HARDWARE: " + android.os.Build.HARDWARE + "\n";  
phoneInfo += ", INCREMENTAL: " + android.os.Build.VERSION.INCREMENTAL+ "\n";  
phoneInfo += ", CODENAME: " + android.os.Build.VERSION.CODENAME + "\n";  
phoneInfo += ", SDK: " + android.os.Build.VERSION.SDK_INT + "\n";  
text.setText(phoneInfo);   
  
  
 /** 
  * BASEBAND-VER 
  * 基带版本 
  * return String 
  */  
   
public static String getBaseband_Ver(){  
String Version = "";  
try {  
Class cl = Class.forName("android.os.SystemProperties");  
Object invoker = cl.newInstance();  
Method m = cl.getMethod("get", new Class[] { String.class,String.class });  
Object result = m.invoke(invoker, new Object[]{"gsm.version.baseband", "no message"});  
// System.out.println(">>>>>>><<<<<<<" +(String)result);  
Version = (String)result;  
} catch (Exception e) {  
}  
return Version;  
}  
  
/** 
* CORE-VER 
* 内核版本 
* return String 
*/  
  
public static String getLinuxCore_Ver() {  
Process process = null;  
String kernelVersion = "";  
try {  
process = Runtime.getRuntime().exec("cat /proc/version");  
} catch (IOException e) {  
// TODO Auto-generated catch block  
e.printStackTrace();  
}  
  
  
// get the output line  
InputStream outs = process.getInputStream();  
InputStreamReader isrout = new InputStreamReader(outs);  
BufferedReader brout = new BufferedReader(isrout, 8 * 1024);  
  
  
String result = "";  
String line;  
// get the whole standard output string  
try {  
while ((line = brout.readLine()) != null) {  
result += line;  
}  
} catch (IOException e) {  
// TODO Auto-generated catch block  
e.printStackTrace();  
}  
  
  
try {  
if (result != "") {  
String Keyword = "version ";  
int index = result.indexOf(Keyword);  
line = result.substring(index + Keyword.length());  
index = line.indexOf(" ");  
kernelVersion = line.substring(0, index);  
}  
} catch (IndexOutOfBoundsException e) {  
e.printStackTrace();  
}  
return kernelVersion;  
}  
  
/** 
* INNER-VER 
* 内部版本 
* return String 
*/  
  
public static String getInner_Ver(){  
String ver = "" ;  
  
if(android.os.Build.DISPLAY .contains(android.os.Build.VERSION.INCREMENTAL)){  
ver = android.os.Build.DISPLAY;  
}else{  
ver = android.os.Build.VERSION.INCREMENTAL;  
}  
return ver;  
  
}