问题
In order to identify the platform of an Android device, it seems that the java system property "os.arch" will suffice:
Log.i("mytag", "os.arch: " + System.getProperty("os.arch"));
most ARM devices respond: os.arch: armv7l
An x86 emulator responds: os.arch: i686
What are the outputs of this for real Intel and MIPS devices?
x86 Android device: ??????
mips Android device: ??????
Any other platforms and variants?
EDIT for Google TV:
It looks like Google TV uses 'none' for Build code.
Vizio Co-Star: os.arch: armv7l , Build.CPU_ABI/Build.CPU_ABI2: none/unknown
Logitech Revue: os.arch: i686 , Build.CPU_ABI/Build.CPU_ABI2: none/unknown
EDIT for clarifying intent:
The goal here is to crowdsource the compilation of a list of real devices with their output. The expected output from AOSP code is interesting, but device manufacturers, like the old Google TV units above, may deviate from supplying the output expected from AOSP code.
回答1:
According to what I can find in the Android source tree the ro.product.cpu.abi
property (which you can access as CPU_ABI
through the Build class) should have the following architecture-to-value mapping:
32-bit ABIs:
ARM: "armeabi-v7a" (or possibly "armeabi" if it's a really old / low-end device)
x86: "x86"
MIPS: "mips"
64-bit ABIs:
ARM: "arm64-v8a"
x86: "x86_64"
MIPS: "mips64"
回答2:
These values come from a Linux structure. They can be displayed from a shell by cat /proc/cpuinfo
. The ARM defines them in the arch/arm/mm
directory. From this directory,
grep cpu_arch_name * | grep string | cut -d \, -f2 | sort | uniq
- armv4
- armv4t
- armv5t
- armv5te
- armv5tej
- armv6
- armv7
The arm7l indicates "little endian" mode, but this is selectable and depends on the kernel. I would think most ARM kernels will be "little endian", unless it is a network centric product (like an Android router). This is the same as uname -m
. On the x86, it returns "i686" on a PowerPC, it returns "ppc". I don't have a MIPS system, but my guess is "mips", but it could be the assortment found in cpu-probe.c
There are over 20 architectures in Linux all with different CPU versions. The answer is far less for current Android ports. However, it is possible that any of them can be used in the future. I think that the ARM is the only one sending a sub-architechure.
See also: uname() man page, Wikipedia's Uname, Server faults's uname machines, OpenJdk mailing list
回答3:
This may be help
- Build.CPU_ABI The name of the instruction set (CPU type + ABI convention) of native code.
- Build.CPU_ABI2 The name of the second instruction set (CPU type + ABI convention) of native code.
More Info Android Build Class
来源:https://stackoverflow.com/questions/14859954/android-os-arch-output-for-arm-mips-x86