How is Serial number (unique) is set on an android devices? - android

In Android devices how is the unique Serial number is assigned to each device? Most of the Samsung devices have a unique serial number on each device. When is this serial number is inserted? Is this serial number assigned before firmware installation or after installing the firmware? Or it has some mechanisim/ algorithm to assign the serial number during firmware is installed.
I want to burn firmware to devices but need some algorithm which helps me to assign the unique serial number to each device and it will remain same even if the firmware is burned multiple times.

There are several options to identify a unique serial number in a android device. One of them being IMEI and another most commonly used is MAC. But from Android M version google has restrictions on people using MAC for unique identity and moreover you will need to have WIFI to be ON to read the MAC.
And also it is not advisable to use MAC/IMEI for secure reasons.
One other possible solution is to generate a unique global identifier in your code.
String uniqueID = UUID.randomUUID().toString.
At the highest level, a globally unique identifier will never have a collision - even on other devices/apps.
Source : https://developer.android.com/training/articles/user-data-ids.html#working_with_instance_ids_&_guids.
You can also try using android serial number which is unique number generated on first ever boot. But, please note that the serial number changes on Factory data reset.
For detailed insight into unique identifier please also look into android device id confusion
Hope I have answered your query.

The unique number is called IMEI. It is a unique number inserted in phone by the manufacturers. Every phone on earth has a different IMEI. Though with rooting your phone you can spoof it.
Hope this helps.

Related

Differentiate between Bluetooth connection to Mac or Windows/Linux device

Is it possible to check if a connected device is manufactured by Apple / runs macOS?
I saw some info on the UUID might containing that information but I haven't found a way to extract that information from it.
https://www.bluetooth.com/specifications/assigned-numbers/
There are assigned numbers but I haven't found out if I can rely on the UUID always having that information and if it even contains a way to check.
In my case I'm developing an Android App, but I guess that and the programming language doesn't matter here. If given a UUID, how do I check if it's manufactured by apple?
So I either need a general way to figure out if a UUID is from apple, or an Android specific way of getting that information, mostly only having access to a BluetoothDevice object (without advertising or other lower level stuff because I don't access the connection directly)
To be more specific, I am using BluetoothHidDevice for the connection https://developer.android.com/reference/android/bluetooth/BluetoothHidDevice
Edit: I am provided with a device.uuids variable, that hold multiple UUIDs
Each one of them has the following methods:
What exactly can I do with the values to check if the manufacturer is apple.
The toString method generates a uuid String as expected
So to give an example, a Windows device has multiple UUIDS, one of which looks like this:
toString: 0000111f-0000-1000-8000-00805f9b34fb
leastSignificantBits: -9223371485494954757
mostSignificantBits: 18824841662464
There are around 32 UUIDs provided
I found a hackish way to do this, but the devices must have Bluetooth discovery activated, what you can do using android is to call upon the method startDiscovery() that allows you to scan nearby discoverable devices. This allows you to create a list of Bluetooth names that you can filter using regex to search whatever contains the term mac, macos, osx, macbook, etc., considering that most people don't really change their Bluetooth device name, this could be a good enough solution to your problem.
Here's a very detailed answer from another question that might help you find what you need
Find all Bluetooth devices (headsets, phones etc) nearby, without forcing the devices in discoverable mode
I don't think apple would violate the Bluetooth Specifications, so I think it is safe to assume that the company identifier in the UUID is a reliable source of information.
You can check the UUID for the Assigned Company Identifiers as provided by Bluetooth SIG. The Apple identifier is 0x004C. I don't see a way you could get hold of information regarding the operating system though. Maybe if you further described your use case, there might be a more convenient way to what you intend.
Please open this 16-bit UUID Numbers Document. Here on 3rd page you can see a table of UUID Allocation with Allocated devices. You can use 16-bit UUID for Members list to know which device is connected i.e. Apple, Samsung, Huawei etc. So we can find Apple based 16-Bit UUIDs as Apple is only platform to use IOS. All others UUIDs will relatively Android, Windows or Ubuntu etc. devices.

How to get Nexus 7 serial number programmatically?

We've developed an app that needs to identify every device uniquely. We first thought of using IMEI and we're obtaining it using the TelefonyManager's getDeviceId() method.
But one user reported that the app doesn't work and it seems we weren't able to get the IMEI. I read here that some Nexus 7 don't have an IMEI, that they use another way for serial number: CSSN. How can I obtain it? Or, even better, is there a preferable way to uniquely identify every android device?
PS: We do have one Nexus 7 here for testing and it works perfectly, that's why before I said some Nexus 7.
It's recommended to identify every installation instead of every device. There are indeed several ways of identifying device, for example, Mac address, IMEI, Serial Number, ANDROID_ID , however, due to different OS Versions, devices an vender implementations, none of these are truly reliable. Check this out.
Try the below code to get the device serial number :
Log.i("TAG","android.os.Build.SERIAL: " + Build.SERIAL);
You may go through the Android Documentation.

Using android MAC address as unique identifier

I have been reading a number of posts here on stackoverflow about android not having unique identifiers. But could I not use the MAC address of the device as a unique id? If not, why not? If yes, does anyone know how to get it programmatically (i.e. a piece of code [please])?
FYI:
My app requires network so devices without networks won't be able to install it.
But could I not use the MAC address of the device as a unique id?
Not 100% reliably.
If not, why not?
Here is what Google has to say on the subject:
It may be possible to retrieve a Mac address from a device’s WiFi or Bluetooth hardware. We do not recommend using this as a unique identifier. To start with, not all devices have WiFi. Also, if the WiFi is not turned on, the hardware may not report the Mac address.
Also, you are assuming that all devices will accurately report the MAC address by one means or another. I would assume that custom ROMs, and perhaps rooted devices, might be able to spoof the MAC address. This may or may not be a concern for you -- I'm just pointing it out.
My app requires network
At best, it can require WiFi. It cannot require that WiFi is turned on.
does anyone know how to get it programmatically (i.e. a piece of code [please])?
See this answer.
MAC is unique, but can be spoofed by the user to any value, which would make it very insecure. If that's not a problem, you're probably good to go !

how does pay-per-install work on android?

I'm thinking to have a third party to promo my app, and I'll pay them per install. In order to avoid fraud, I need to have a unique ID stored in my database. My problem here is that I can't find a reliable unique ID.
IMEI - only works on phone
Android ID - can be changed even not a rooted device
WLAN MAC - not all devices have wifi, or the device has wifi turned off.
Bluetooth MAC - same as above
I know device with root access can easily change the IDs, but let's not worry about it now. I assume no one has a rooted device. How do I get a unique ID???
Please help. Thanks
Try looking into OpenUDID for Android, there doesn't seem to be a better way to do what you want for the time being:
https://github.com/vieux/OpenUDID

Is IMSI number unique for each phone

Is IMSI number unique for each phone ?
I want to know the answer with respect to Android.
Please help.
Wikipdia:
An International Mobile Subscriber Identity or IMSI (play /ˈɪmziː/) is a unique identification associated with all GSM and UMTS network mobile phone users.
Not all android devices are on GSM or UMTS. So I would guess that the ones that don't use those networks aren't going to have any value at all for IMSI. But I would be really really carful relying on something like that to be unique. I've found that different manufacturers/carriers sometimes put the same # as the value on every device for some of the supposedly unique IDs. Which will cause you major headaches if it turns out that there are thousands of devices out there using the same ID.
That being said, I have no experience working specifically with IMSI so this is just my guess.
Edit: there is no one end all be all "correct" value to use as unique ID as far as I am aware. Here are some links that can give you some ideas though:
Is Secure.ANDROID_ID unique for each device?
Is there a unique Android device ID?
If possible I think you are better off generating your own UUID and storing it yourself. But this of course means that it won't persist through uninstallation of your application (or through SDcard wipe if you choose to store it there)
IMSI is the subscriber identifier and is associated with the SIM, not the phone. If you move the SIM from one phone to another you are moving the IMSI also, so no, it is not unique per phone if this was what you were looking for.
There is an identifier associated with the phone itself - it's the IMEI (International Mobile Equipment Identity). This should be unique per phone - one key use is by operators to detect stolen handsets.
See: http://en.wikipedia.org/wiki/International_Mobile_Equipment_Identity

Categories

Resources