I am creating an app where only one person can create one account in one device, He can not create or use another account on that device. I was tracking devices through ANDROID_ID but it changes with factory reset. The solution i found to handle factory reset was to use MediaDrm unique id. This is how i am getting the unique id
public static String getUniqueID() {
UUID wideVineUuid = new UUID(-0x121074568629b532L, -0x5c37d8232ae2de13L);
try {
MediaDrm wvDrm = new MediaDrm(wideVineUuid);
byte[] wideVineId = wvDrm.getPropertyByteArray(MediaDrm.PROPERTY_DEVICE_UNIQUE_ID);
return android.util.Base64.encodeToString(wideVineId, Base64.NO_WRAP);
} catch (Exception e) {
return null;
}
}
The problem with MediaDrm is it's not globally unique (My assumption) because many users are reporting that they can't create account in a newly bought device and when i check logs some other users is already registered with that id. My question is, is it globally unique as it is supposed to be or am i doing something wrong while getting it? If it's not globally unique, is there any workaround to handle this issue.