[Android] src: Use FileReader instead of scraping system commands
Edward Wang
git at videolan.org
Fri Jul 6 21:24:21 CEST 2012
android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Fri Jul 6 15:16:41 2012 -0400| [1154a307dc5afd2c5e4c26285fa5b3ece52003da] | committer: Edward Wang
src: Use FileReader instead of scraping system commands
> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=1154a307dc5afd2c5e4c26285fa5b3ece52003da
---
vlc-android/src/org/videolan/vlc/Util.java | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/Util.java b/vlc-android/src/org/videolan/vlc/Util.java
index 5456ffb..ba0f315 100644
--- a/vlc-android/src/org/videolan/vlc/Util.java
+++ b/vlc-android/src/org/videolan/vlc/Util.java
@@ -23,6 +23,7 @@ package org.videolan.vlc;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
+import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -219,28 +220,24 @@ public class Util {
boolean NO_FPU = properties.getProperty("NO_FPU").equals("1");
boolean NO_ARMV6 = properties.getProperty("NO_ARMV6").equals("1");
boolean hasNeon = false, hasFpu = false, hasArmV6 = false, hasArmV7 = false;
- ProcessBuilder cmd;
try {
- String[] args = {"/system/bin/cat", "/proc/cpuinfo"};
- cmd = new ProcessBuilder(args);
-
- Process process = cmd.start();
- InputStream in = process.getInputStream();
- byte[] re = new byte[1024];
- while(in.read(re) != -1){
- if(!hasNeon && new String(re).contains("neon"))
+ FileReader fileReader = new FileReader("/proc/cpuinfo");
+ BufferedReader br = new BufferedReader(fileReader);
+ String line;
+ while((line = br.readLine()) != null) {
+ if(!hasNeon && line.contains("neon"))
hasNeon = true;
- if(!hasArmV7 && new String(re).contains("ARMv7")) {
+ if(!hasArmV7 && line.contains("ARMv7")) {
hasArmV7 = true;
hasArmV6 = true; /* Armv7 is backwards compatible to < v6 */
}
- if(!hasArmV7 && !hasArmV6 && new String(re).contains("ARMv6"))
+ if(!hasArmV7 && !hasArmV6 && line.contains("ARMv6"))
hasArmV6 = true;
- if(!hasFpu && new String(re).contains("vfp"))
+ if(!hasFpu && line.contains("vfp"))
hasFpu = true;
}
- in.close();
+ fileReader.close();
} catch(IOException ex){
ex.printStackTrace();
errorMsg = "IOException whilst reading cpuinfo flags";
More information about the Android
mailing list