Chinaunix首页 | 论坛 | 博客
  • 博客访问: 465611
  • 博文数量: 145
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1060
  • 用 户 组: 普通用户
  • 注册时间: 2013-08-22 11:52
个人简介

专注计算机技术: Linux Android 云计算 虚拟化 网络

文章分类

全部博文(145)

文章存档

2016年(3)

2015年(21)

2014年(75)

2013年(46)

我的朋友

分类: Android平台

2015-03-03 10:06:13

IMEI

The IMEI is the 'MAC' for the telephony module - the unique ID that the telephone uses when it connects via GSM/GPRS/HSPDA/etc. The GSM network uses it to route calls and data from the phone over the GSM network right up to the gateway into the Internet (which is an IP network).

A telephony module is a chip or circuit board that handles the telephone network, either GSM or CMDA, and often has a slot for a removable SIM card. Some phones have more than one telephony module (active dual- or multi-SIM phones). Each telephony module has its own IMEI.

Manufacturers give each phone (strictly the telephony module) a unique IMEI during manufacturing. However the number can normally be rewritten if you have the right software. This is often done after a phone has been stolen to give the phone a new identity and bipass stolen phone blocking system.

The IMEI can be programmatically obtained using the TelephonyManager.getDeviceId() API.

CDMA phones have a ESN or MEID which are different lengths and formats, even though it is retrieved using the same API.

Android devices without telephony modules - for example many tablets and TV devices - do not have an IMEI. As Schlangi commented, some devices that do not have a telephony module fake the IMEI, so the presence of an IMEI does not (always) guarantee the device has a telephony module.

ANDROID_ID

The ANDROID_ID is another unique number on the phone - this is automatically generated by the OS as it boots for the first time (doing it this way makes it much easier for the manufacturers by removing a step from the production line).

The ANDROID_ID can (and does) change, for example:
?Factory reset (including when reflashing the OS)
?In software: eg

It is mainly used by developers (eg identifying and connecting to devices using adb)

ANDROID_ID can be used to identify an Android device given the caveats above, realistically meaning that it uniquely identifies the device over significant portions of the device lifetime, but cannot be relied on.

Also note that there was a bug in Froyo where many devices gave themselves the same ANDROID_ID. This is the bug

Other identifiers

There are a number of other things that can be used identify the device:
?MAC address of the WiFi module: WifiManager.getConnectionInfo() -> WifiInfo.getMacAddress(). This can often be changed in software, but generally is constant over the device lifetime. Also it can only be read if the WiFi module is switched on.
?MAC address of the BlueTooth module: BluetoothAdaptor.getAddress(). Like WiFi MAC, this can often be changed in software and may be off when you need it
?The subscriber's telephone number. This may change if the user requests a new number from the telco, or if the user switches SIMs. It is obtained from TelephonyManager.getLine1Number(). This is only present for Android phone devices with a current SIM installed and a paid service with a telco.
?The SIM contains its own identifying number (IMSI). This is obtained from the TelephonyManager.getSubscriberId() API. Obviously the SIM may not be present at any specific time, and it changes when the SIM is changed - and users can upgrade/replace their SIM while keeping the same number, so you can't say that this is one-to-one to a specific phone or user.
?Related to the IMSI is the MSISDN. This functions as the identification of a subscription (your contract for a specific telephone number with your mobile provider) and therefore gives the device its telephone number. The MSISDN may be associated with several SIM cards, and therefore several phones. It comes with all the caveats for reading the SIM above. This may be retrieved with TelephonyManager.getSimSerialNumber(). Thanks Schlangi for the corrections and additions
?Gingerbread and later has android.os.Build.SERIAL which many manufacturers set (but not all. Bugger).

Other notes

You need specific permissions to access each and every API, so if you try for all of them, your app's permissions in the Google Play store look fairly permissive.


shareimprove this answer
 

edited Oct 12 '13 at 8:18

 

 

 

answered Dec 12 '12 at 0:59

 

 
Andrew Alcock
11.6k22146
 
 
 


1    
 
Great answer +1 –  Eng.Fouad May 24 '13 at 17:09
 

1    
 
Although you are right with your statement that devices without telephony module do not have an IMEI, there are manufacturers that give their devices fake-IMEIs. One example for that is a low cost device of Odys named Loox plus - so if you try to handle those devices in a special way, do not count on getting null or empty string when calling TelephonyManager.getDeviceId()! –  Schlangi Oct 10 '13 at 12:18
 

1    
 
I found one minor mistake in your explanation: the IMSI is reported by TelephonyManager.getSubscriberId(), the serial number of the SIM card is a different thing: It is possible to make multiple copies of a SIM card, all using the same IMSI but different serial numbers. The result are SIM cards, which can be used in different phones to have the same phone number (e.g. smartphone and car phone) but only one at a time. This was a common use case before the mobile network could handle multiple IMSIs per phone number that can be used simultaniously. –  Schlangi Oct 10 '13 at 12:30
 

      
 
@Schlangi: Thanks for your comments - I've updated my answer to clarify all those details. Please let me know if I've munged things up :) –  Andrew Alcock Oct 12 '13 at 8:16 
 

阅读(736) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~