Check in Java if NEON is present.

This commit is contained in:
Themaister 2013-01-24 23:29:47 +01:00
parent 3139b98be7
commit 784bafdb19

View File

@ -80,29 +80,27 @@ public class RetroArch extends Activity implements
return rate; return rate;
} }
private String ReadCPUinfo() private String readCPUInfo() {
{
ProcessBuilder cmd;
String result = ""; String result = "";
try { try {
String[] args = {"/system/bin/cat", "/proc/cpuinfo"}; BufferedReader br = new BufferedReader(new InputStreamReader(
cmd = new ProcessBuilder(args); new FileInputStream("/proc/cpuinfo")));
Process process = cmd.start(); String line;
InputStream in = process.getInputStream(); while ((line = br.readLine()) != null)
byte[] re = new byte[1024]; result += line + "\n";
while(in.read(re) != -1){ br.close();
System.out.println(new String(re));
result = result + new String(re);
}
in.close();
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
return result; return result;
} }
private boolean cpuInfoIsNeon(String info) {
return info.contains("neon");
}
private byte[] loadAsset(String asset) throws IOException { private byte[] loadAsset(String asset) throws IOException {
String path = asset; String path = asset;
InputStream stream = getAssets().open(path); InputStream stream = getAssets().open(path);
@ -160,6 +158,12 @@ public class RetroArch extends Activity implements
config = new ConfigFile(); config = new ConfigFile();
} }
String cpuInfo = readCPUInfo();
boolean cpuIsNeon = cpuInfoIsNeon(cpuInfo);
if (cpuIsNeon) {
Toast.makeText(this, "CPU is NEON capable: " + (cpuIsNeon ? "yes" : "no"), Toast.LENGTH_SHORT).show();
}
// Extracting assets appears to take considerable amount of time, so // Extracting assets appears to take considerable amount of time, so
// move extraction to a thread. // move extraction to a thread.
Thread assetThread = new Thread(new Runnable() { Thread assetThread = new Thread(new Runnable() {