1. View mobile phone CPU Information
Cmd -- adb shell -- cd/proc ------ cat cpuinfo
2. the cpu is the arm instruction set, armv7 instruction set, or neon instruction set. <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + PC9wPgo8cHJlIGNsYXNzPQ = "brush: java;">/***** [obtain an array of three parameter types: CPU type and architecture] ** @ return, the first parameter indicates whether the ARM architecture is used, the second parameter indicates whether the V6 or V7 architecture is used, and the third parameter indicates whether the neon Instruction Set */public static Object [] getCpuArchitecture () {if (Integer) mArmArchitecture [1]! =-1) {return mArmArchitecture;} try {InputStream is = new FileInputStream ("/proc/cpuinfo"); InputStreamReader ir = new InputStreamReader (is ); bufferedReader br = new BufferedReader (ir); try {String nameProcessor = "Processor"; String nameFeatures = "Features"; String nameModel = "model name "; string nameCpuFamily = "cpu family"; while (true) {String line = br. readLine (); String [] pair = null; if (line = nu Ll) {break;} pair = line. split (":"); if (pair. length! = 2) continue; String key = pair [0]. trim (); String val = pair [1]. trim (); if (key. compareTo (nameProcessor) = 0) {String n = ""; for (int I = val. indexOf ("ARMv") + 4; I <val. length (); I ++) {String temp = val. charAt (I) + ""; if (temp. matches ("\ d") {n + = temp;} else {break;} marchitecture [0] = "ARM"; marchitecture [1] = Integer. parseInt (n); continue;} if (key. compareToIgnoreCase (nameFeatures) = 0) {if (val. contains ("neon") {marchitecture [2] = "neon";} continue;} if (key. compareToIgnoreCase (nameModel) = 0) {if (val. contains ("Intel") {mArmArchitecture [0] = "INTEL"; mArmArchitecture [2] = "atom" ;}continue;} if (key. compareToIgnoreCase (nameCpuFamily) = 0) {marchitecture [1] = Integer. parseInt (val); continue ;}} finally {br. close (); ir. close (); is. close () ;}} catch (Exception e) {e. printStackTrace ();} return mArmArchitecture ;}
Example method of calling this function
/** Obtain the name of the FFpeg decoder Library (if it is a plug-in, it will involve a backward compatibility problem. For example, if the current cpu is V7neo and there is no neon decoder library, it must be backward compatible. * if there is a V7 library, the V7 library will be loaded, and the V6 library will be loaded. */public static String getFFmpegLibName (Context context) {if (LIB_FFMPEG_NAME! = Null) {return LIB_FFMPEG_NAME;} Object [] arch = getCpuArchitecture (); String libDir = getNativeLibraryDir (context); String libSysDir = "/system/lib "; if ("ARM ". equals (arch [0]) {try {String ffmpeg = String. format ("ffmpeg-% d % s", (Integer) arch [1], (String) arch [2]); if (isFileExist (libDir + "/lib" + ffmpeg + ". so ") | isFileExist (libSysDir +"/lib "+ ffmpeg + ". so ") {return ffmpeg;} else {boolean isV7NeonCpu =" neon ". equals (arch [2]); boolean isV7 = (Integer) arch [1]) = 7 &&"". equals (arch [2]); boolean isV6 = (Integer) arch [1]) = 6; if (isV7NeonCpu) {if (isFileExist (libDir + "/libffmpeg-7neon.so ") | isFileExist (libSysDir + "/libffmpeg-7neon.so") {LIB_FFMPEG_NAME = "ffmpeg-7neon"; return "ffmpeg-7neon";} else if (isFileExist (libDir + "/libffmpeg-7.so ") | isFileExist (libSysDir + "/libffmpeg-7.so") {LIB_FFMPEG_NAME = "ffmpeg-7"; return "ffmpeg-7";} else if (isFileExist (libDir + "/libffmpeg-6.so ") | isFileExist (libSysDir + "/libffmpeg-6.so") {LIB_FFMPEG_NAME = "ffmpeg-6"; return "ffmpeg-6" ;}} else if (isV7) {if (isFileExist (libDir + "/libffmpeg-7.so") | isFileExist (libSysDir + "/libffmpeg-7.so") {LIB_FFMPEG_NAME = "ffmpeg-7"; return "ffmpeg-7 ";} else if (isFileExist (libDir + "/libffmpeg-6.so") | isFileExist (libSysDir + "/libffmpeg-6.so") {LIB_FFMPEG_NAME = "ffmpeg-6"; return "ffmpeg-6 ";}} else if (isV6) {if (isFileExist (libDir + "/libffmpeg-6.so") | isFileExist (libSysDir + "/libffmpeg-6.so") {LIB_FFMPEG_NAME = "ffmpeg-6 "; return "ffmpeg-6" ;}}} catch (Exception e) {e. printStackTrace () ;}} else if ("INTEL ". equals (arch [0]) {if (isFileExist (libDir + "/libffmpeg-x86atom.so") | isFileExist (libSysDir + "/libffmpeg-x86atom.so") {LIB_FFMPEG_NAME = "ffmpeg-x86atom "; return "ffmpeg-x86atom" ;}} LIB_FFMPEG_NAME = null; return null ;}