When mtk6573 is used, the ADB, eclipse, and 91 assistants are connected, and 0123456789 abcdef is displayed.
This is the serial number of the mobile phone. How to obtain a sequence number that uniquely identifies each Android device?
There are many answers to this question, but most of them are valid only in some cases.
Based on tests:
1) All devices can return oneTelephonyManager.getDeviceId()
2) All GSM devices (the test devices are loaded with SIM cards) can return oneTelephonyManager.getSimSerialNumber()
3) All CDMA DevicesgetSimSerialNumber()
Returns a null value!
4) all devices with a Google account can return oneANDROID_ID
5) All CDMA DevicesANDROID_ID
AndTelephonyManager.getDeviceId()
Returns the same value (as long as a Google account is added at the time of setup)
6) not tested: GSM devices without SIM cards, GSM devices without Google accounts, and devices in flight mode.
So if you want to get the unique serial number of the device,TelephonyManager.getDeviceId()
That's enough. However, obviously exposing DeviceID will make some users dissatisfied, so it is best to encrypt these IDs. In fact, the encrypted serial number can still uniquely identify the device and does not explicitly expose the user's specific device. For example
String. hashcode (), combined with UUID:
1 |
final TelephonyManager tm = (TelephonyManager) getBaseContext().getSystemService(Context.TELEPHONY_SERVICE);
|
3 |
final
String tmDevice, tmSerial, tmPhone, androidId; |
4 |
tmDevice =
"" + tm.getDeviceId();
|
5 |
tmSerial =
"" + tm.getSimSerialNumber();
|
6 |
androidId =
"" + android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
|
8 |
UUID deviceUuid =
new UUID(androidId.hashCode(), (( long )tmDevice.hashCode() <<
32 ) | tmSerial.hashCode());
|
9 |
String uniqueId = deviceUuid.toString(); |
The final DeviceID may be as follows:00000000-54b3-e7c7-0000-000046bffd97
In general, the device serial number is filled with xxx_hsusb_pdata in this struct, or
Search for serial_number under the kernel, or directly search for your own device number.
"0123456789abcdef.
Modify mtk6573 in mt6573_devs.c (mediatek \ platform \ mt6573 \ kernel \ core): memcpy (serial_number, "0123456789 abcdef", 16 ).