Commit 797f094a authored by Geoffrey Métais's avatar Geoffrey Métais

Do not exit hasCompatibleCPU to early

parent 0f135d64
...@@ -132,29 +132,27 @@ public class VLCUtil { ...@@ -132,29 +132,27 @@ public class VLCUtil {
br = new BufferedReader(fileReader); br = new BufferedReader(fileReader);
String line; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
if (!hasArmV7 && line.contains("AArch64")) { if (line.contains("AArch64")) {
hasArmV7 = true; hasArmV7 = true;
hasArmV6 = true; /* Armv8 is backwards compatible to < v7 */ hasArmV6 = true; /* Armv8 is backwards compatible to < v7 */
} } else if (line.contains("ARMv7")) {
if (!hasArmV7 && line.contains("ARMv7")) {
hasArmV7 = true; hasArmV7 = true;
hasArmV6 = true; /* Armv7 is backwards compatible to < v6 */ hasArmV6 = true; /* Armv7 is backwards compatible to < v6 */
} } else if (line.contains("ARMv6"))
if (!hasArmV7 && !hasArmV6 && line.contains("ARMv6"))
hasArmV6 = true; hasArmV6 = true;
// "clflush size" is a x86-specific cpuinfo tag. // "clflush size" is a x86-specific cpuinfo tag.
// (see kernel sources arch/x86/kernel/cpu/proc.c) // (see kernel sources arch/x86/kernel/cpu/proc.c)
if (line.contains("clflush size")) else if (line.contains("clflush size"))
hasX86 = true; hasX86 = true;
if (line.contains("GenuineIntel")) else if (line.contains("GenuineIntel"))
hasX86 = true; hasX86 = true;
// "microsecond timers" is specific to MIPS. // "microsecond timers" is specific to MIPS.
// see arch/mips/kernel/proc.c // see arch/mips/kernel/proc.c
if (line.contains("microsecond timers")) else if (line.contains("microsecond timers"))
hasMips = true; hasMips = true;
if (!hasNeon && (line.contains("neon") || line.contains("asimd"))) if (line.contains("neon") || line.contains("asimd"))
hasNeon = true; hasNeon = true;
if (!hasFpu && (line.contains("vfp") || (line.contains("Features") && line.contains("fp")))) if (line.contains("vfp") || (line.contains("Features") && line.contains("fp")))
hasFpu = true; hasFpu = true;
if (line.startsWith("processor")) if (line.startsWith("processor"))
processors++; processors++;
...@@ -168,23 +166,18 @@ public class VLCUtil { ...@@ -168,23 +166,18 @@ public class VLCUtil {
} }
} }
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace();
errorMsg = "IOException whilst reading cpuinfo flags"; errorMsg = "IOException whilst reading cpuinfo flags";
Log.e(TAG, errorMsg, ex);
isCompatible = false; isCompatible = false;
return false;
} finally { } finally {
if (br != null) { if (br != null)
try { try {
br.close(); br.close();
} catch (IOException e) { } catch (IOException e) {}
} if (fileReader != null)
}
if (fileReader != null) {
try { try {
fileReader.close(); fileReader.close();
} catch (IOException e) { } catch (IOException e) {}
}
}
} }
if (processors == 0) if (processors == 0)
processors = 1; // possibly borked cpuinfo? processors = 1; // possibly borked cpuinfo?
...@@ -193,37 +186,30 @@ public class VLCUtil { ...@@ -193,37 +186,30 @@ public class VLCUtil {
if (elfHasX86 && !hasX86) { if (elfHasX86 && !hasX86) {
errorMsg = "x86 build on non-x86 device"; errorMsg = "x86 build on non-x86 device";
isCompatible = false; isCompatible = false;
return false;
} else if (elfHasArm && !hasArmV6) { } else if (elfHasArm && !hasArmV6) {
errorMsg = "ARM build on non ARM device"; errorMsg = "ARM build on non ARM device";
isCompatible = false; isCompatible = false;
return false;
} }
if (elfHasMips && !hasMips) { if (elfHasMips && !hasMips) {
errorMsg = "MIPS build on non-MIPS device"; errorMsg = "MIPS build on non-MIPS device";
isCompatible = false; isCompatible = false;
return false;
} else if (elfHasArm && hasMips) { } else if (elfHasArm && hasMips) {
errorMsg = "ARM build on MIPS device"; errorMsg = "ARM build on MIPS device";
isCompatible = false; isCompatible = false;
return false;
} }
if (elf.e_machine == EM_ARM && elf.att_arch.startsWith("v7") && !hasArmV7) { if (elf.e_machine == EM_ARM && elf.att_arch.startsWith("v7") && !hasArmV7) {
errorMsg = "ARMv7 build on non-ARMv7 device"; errorMsg = "ARMv7 build on non-ARMv7 device";
isCompatible = false; isCompatible = false;
return false;
} }
if (elf.e_machine == EM_ARM) { if (elf.e_machine == EM_ARM) {
if (elf.att_arch.startsWith("v6") && !hasArmV6) { if (elf.att_arch.startsWith("v6") && !hasArmV6) {
errorMsg = "ARMv6 build on non-ARMv6 device"; errorMsg = "ARMv6 build on non-ARMv6 device";
isCompatible = false; isCompatible = false;
return false;
} else if (elf.att_fpu && !hasFpu) { } else if (elf.att_fpu && !hasFpu) {
errorMsg = "FPU-enabled build on non-FPU device"; errorMsg = "FPU-enabled build on non-FPU device";
isCompatible = false; isCompatible = false;
return false;
} }
} }
if (elfIs64bits && !is64bits) { if (elfIs64bits && !is64bits) {
...@@ -247,22 +233,17 @@ public class VLCUtil { ...@@ -247,22 +233,17 @@ public class VLCUtil {
Log.w(TAG, "Could not parse maximum CPU frequency!"); Log.w(TAG, "Could not parse maximum CPU frequency!");
Log.w(TAG, "Failed to parse: " + line); Log.w(TAG, "Failed to parse: " + line);
} finally { } finally {
if (br != null) { if (br != null)
try { try {
br.close(); br.close();
} catch (IOException e) { } catch (IOException e) {}
} if (fileReader != null)
}
if (fileReader != null) {
try { try {
fileReader.close(); fileReader.close();
} catch (IOException e) { } catch (IOException e) {}
}
}
} }
errorMsg = null; isCompatible = errorMsg == null;
isCompatible = true;
// Store into MachineSpecs // Store into MachineSpecs
machineSpecs = new MachineSpecs(); machineSpecs = new MachineSpecs();
machineSpecs.hasArmV6 = hasArmV6; machineSpecs.hasArmV6 = hasArmV6;
...@@ -275,7 +256,7 @@ public class VLCUtil { ...@@ -275,7 +256,7 @@ public class VLCUtil {
machineSpecs.bogoMIPS = bogoMIPS; machineSpecs.bogoMIPS = bogoMIPS;
machineSpecs.processors = processors; machineSpecs.processors = processors;
machineSpecs.frequency = frequency; machineSpecs.frequency = frequency;
return true; return isCompatible;
} }
public static MachineSpecs getMachineSpecs() { public static MachineSpecs getMachineSpecs() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment