Salahuddin
Salahuddin

Reputation: 174

Android MediaDrm unique id

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.

Upvotes: 5

Views: 7428

Answers (1)

Momin Khan
Momin Khan

Reputation: 157

I have faced the same situation, and I just removed this check. But I think you can try to concatenate all different UUIDs provided by MediaDrm and then check if these ID's changes after reset factory or not?

You can check this link for reference also: USING MEDIADRM FOR DEVICE ID TRACKING

Also, you can share results with us, so anyone needing it in future may get help.

Upvotes: 2

Related Questions