How to check HDCP Level on Android (TV) for API < 28?

1.3k views Asked by At

I have a Android TV stick and I would like to distinguish what HDCP version is supported?

I already have found something and it seems to work:

    try {
        val uuid = UUID.fromString("1f83e1e8-6ee9-4f0d-ba2f-5ec4e3ed1a66")
        val mediaDrm = MediaDrm(uuid)
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
            mediaDrm.connectedHdcpLevel
        }
    } catch (use : UnsupportedSchemeException) {
        Log(use.localizedMessage)
    }

But the documentation says

Added in API level 28

How can read the HDCP level for older API < 28?

1

There are 1 answers

0
Transformer On

As per your questions only On API V28 or before see here...

You can get away with this, but may have to check your version level before getting into this.


// CHECK if V28 or before... ONLY then enter the REST of the below code...
val algorithms = mediaDrm.getPropertyString("maxHdcpLevel")

// you also Then manually suppress the warning error/constant


// get your maxHdcpLevel manually
val stringProperties = arrayOf(
                MediaDrm.PROPERTY_VENDOR,
                MediaDrm.PROPERTY_VERSION,
                MediaDrm.PROPERTY_DESCRIPTION,
                MediaDrm.PROPERTY_ALGORITHMS,
                "maxHdcpLevel")

val devicePropertiesMap = ... MapOf<String, String>()

for (attributes in stringProperties) {
     devicePropertiesMap [attributes ] = mediaDrm.getPropertyString(attributes )
     Log.mydebug(attributes , mediaDrm.getPropertyString(attributes ))
     }

Log.mydebug("maxHdcpLevel:", "${devicePropertiesMap ["maxHdcpLevel"]}")

Now you can access this stuff easily.. with the code sample below

 val myDeviceHdcpLevel    = mediaDrm.getPropertyString("hdcpLevel")
 val myDeviceMaxHdcpLevel = mediaDrm.getPropertyString("maxHdcpLevel")