Skip to content

Commit

Permalink
Merge pull request #57 from Shahar2k5/master
Browse files Browse the repository at this point in the history
Add support for 64bit devices
  • Loading branch information
hiteshsondhi88 committed Apr 19, 2016
2 parents 3ed9b5c + 64f7314 commit 81db8a6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
import static org.assertj.core.api.Assertions.assertThat;

public class CpuArchHelperTest extends TestCase {

public void testGetCpuArch() throws Exception {
CpuArch cpuArch = CpuArchHelper.getCpuArch();
assertNotNull(cpuArch);
if (Build.CPU_ABI.equals(CpuArchHelper.getx86CpuAbi())) {
if (Build.CPU_ABI.equals(CpuArchHelper.getx86CpuAbi()) || Build.CPU_ABI.equals(CpuArchHelper.getx86_64CpuAbi())) {
assertEquals(cpuArch, CpuArch.x86);
} else if (Build.CPU_ABI.equals(CpuArchHelper.getArmeabiv7CpuAbi())) {
assertThat(cpuArch == CpuArch.ARMv7 || cpuArch == CpuArch.ARMv7_NEON).isTrue();
} else {
} else if (Build.CPU_ABI.equals(CpuArchHelper.getArm64CpuAbi())) {
assertEquals(cpuArch, CpuArch.ARMv7);
}else {
assertEquals(cpuArch, CpuArch.NONE);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import android.os.Build;

class CpuArchHelper {

static CpuArch getCpuArch() {
// check if device is x86
if (Build.CPU_ABI.equals(getx86CpuAbi())) {
Log.d("Build.CPU_ABI : " + Build.CPU_ABI);
// check if device is x86 or x86_64
if (Build.CPU_ABI.equals(getx86CpuAbi()) || Build.CPU_ABI.equals(getx86_64CpuAbi())) {
return CpuArch.x86;
} else {
// check if device is armeabi
Expand All @@ -21,15 +22,26 @@ static CpuArch getCpuArch() {
}
return CpuArch.ARMv7;
}
// check if device is arm64 which is supported by ARMV7
} else if (Build.CPU_ABI.equals(getArm64CpuAbi())) {
return CpuArch.ARMv7;
}
}
return CpuArch.NONE;
}

static String getx86CpuAbi() {
return "x86";
}


static String getx86_64CpuAbi() {
return "x86_64";
}

static String getArm64CpuAbi() {
return "arm64-v8a";
}

static String getArmeabiv7CpuAbi() {
return "armeabi-v7a";
}
Expand Down

0 comments on commit 81db8a6

Please sign in to comment.