Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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