Created
April 17, 2019 07:24
-
-
Save huewu/ed8bf1485864e3ca1768740c740e19f6 to your computer and use it in GitHub Desktop.
Get a Widevine DEVICE UNIQUE ID by using MediaDrm API in Android (28+)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val WIDEVINE_UUID = UUID(-0x121074568629b532L, -0x5c37d8232ae2de13L) | |
val wvDrm = try { | |
MediaDrm(WIDEVINE_UUID) | |
} catch (e: UnsupportedSchemeException) { | |
//WIDEVINE is not available | |
null | |
} | |
wvDrm!!.apply { | |
val widevineId = wvDrm.getPropertyByteArray(MediaDrm.PROPERTY_DEVICE_UNIQUE_ID) | |
val encodedWidevineId = Base64.getEncoder().encodeToString(widevineId).trim() | |
Log.d("DRM", "Widevine ID:$encodedWidevineId") | |
wvDrm.close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Developers can check a Widevine DRM security level by getting the security property value (from ExoPlayer Test)
private static final String WIDEVINE_SECURITY_LEVEL_1 = "L1";
private static final String WIDEVINE_SECURITY_LEVEL_3 = "L3";
private static final String SECURITY_LEVEL_PROPERTY = "securityLevel";
String securityProperty = mediaDrm.getPropertyString(SECURITY_LEVEL_PROPERTY);