Now the simulator's function is too powerful, from Bluetooth, sensors and other accessories to Imei,mac, as well as mobile hardware information can simulate anything
In order to prevent users to use simulator simulation machine to brush a single, brush flow and other malicious operations.
Need to obtain some information returned by the device to identify the authenticity of the device.
Here is the difference between the finishing simulator and the real machine.
Although most can imitate, forge, but if all dimensions are integrated to monitor, there should be no big problem.
One, native way.
Read configuration and hardware-related information in the device through C code.
1,diskstats
Gets the partition state information for the flash memory.
int fd = open ("/proc/diskstats", o_rdonly);
bytes = Read (fd, buf, bytes);
Difference: There are mmcblk0 partitions under the real machine, but the emulator does not have partition information.
2,mac address.
Read MAC addresses through sockets and IOCTL.
SOCKFD = socket (af_inet, SOCK_DGRAM, 0);
IOCTL (SOCKFD, siocgifconf, (char*) &ifc);
IOCTL (SOCKFD, SIOCGIFADDR, &ifr[i])
ioctl (SOCKFD, SIOCGIFHWADDR, (char*) &ifr[i])
Difference: The real machine can get Wlan0 IP and MAC address, the simulator can only get eth0 IP and MAC address;
3, useful prop information.
__system_property_get (key, BUF);
Difference: The simulator has no Ro.boot.serialno and Ro.serialno attributes, and the machine serial number is in the real machine.
The simulator Ro.hardware property is goldfish, the real machine is the respective model.
4,CPU information.
int fd = open ("/proc/cpuinfo", o_rdonly);
bytes = Read (fd, buf, bytes);
Difference: The Cpuinfo hardware in the simulator is goldfish.
5,drivers
int fd = open ("/proc/tty/drivers", o_rdonly);
Difference: The simulator contains goldfish drivers
6, simulator-specific files.
int fd = open ("/dev/socket/qemud", o_rdonly);
int fd = open ("/dev/qemu_pipe", o_rdonly);
Difference: Simulator proprietary files that are not in the real machine.
Two, the traditional way:
From the Java Layer Code acquisition, you can have the following ways:
1,imei and IMSI
IMEI mobile device International identity code.
IMSI IMSI International Mobile Subscriber Identification code, stored in SIM card
Final Telephonymanager TM = (Telephonymanager) getbasecontext (). Getsystemservice (Context.telephony_service);
String IMEI = Tm.getdeviceid ();
String IMSI = Tm.getsubscriberid ();
Equipment 1:354273055927169/null (no card)
Equipment 2:862966024243759/460011040618938
Simulator: 000000000000000/310260000000000
2,serial Serial Number
String serial = Android.os.Build.SERIAL;
Equipment 1:4df78680771b117b
Equipment 2:OBAI5HDQZPDIRCQG
Simulator: Unknown
3,android_id
String android_id = secure.getstring (Getcontentresolver (), secure.android_id);
Equipment and simulators are available, 16-bit.
4,mac Address
Wifimanager wifimanage= (Wifimanager) Getsystemservice (Context.wifi_service); Wifiinfo wifiinfo= wifimanage.getconnectioninfo ();
Equipment 1:88:32:9B:1E:49:20
Equipment 2:f8:a4:5f:fd:56:17
Emulator: null
The above is the Android difference between the real machine and the simulator method of collation and comparison, the need for friends can refer to.