Last active
November 27, 2022 11:18
-
-
Save espio999/7b82c322fddfbae313591ae029ba071d to your computer and use it in GitHub Desktop.
output DRM security level properties at protection system level and content level - Widevine and others
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
package com.example.testrun20221122 | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.widget.Toast | |
import com.example.testrun20221122.databinding.ActivityMainBinding | |
import java.util.Date | |
import android.media.MediaDrm | |
import java.util.UUID | |
class MainActivity : AppCompatActivity() { | |
private lateinit var binding: ActivityMainBinding | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
binding = ActivityMainBinding.inflate(layoutInflater) | |
setContentView(binding.root) | |
val systemInfo = listOf( | |
UUID.fromString(getString(R.string.uuid_widevine)), | |
UUID.fromString(getString(R.string.uuid_playready)), | |
UUID.fromString(getString(R.string.uuid_fairplay)) | |
) | |
var myOutput = "" | |
systemInfo.map { sys_key -> | |
sys_key to MediaDrm.isCryptoSchemeSupported(sys_key) | |
}.forEach { (sys_key, sys_val) -> | |
myOutput += "----- status - protection system level\n" | |
myOutput += "$sys_key \t $sys_val\n" | |
if (sys_val){ | |
myOutput += outputSystemLevelStatus(sys_key) | |
myOutput += outputContentLevelStatus(sys_key) | |
} | |
} | |
binding.txtHello.text = myOutput | |
} | |
private fun outputSystemLevelStatus(myUuid: UUID):String{ | |
val mediaDrmInfo = listOf( | |
MediaDrm.PROPERTY_DESCRIPTION, | |
MediaDrm.PROPERTY_VERSION, | |
MediaDrm.PROPERTY_VENDOR, | |
MediaDrm.PROPERTY_ALGORITHMS, | |
"securityLevel" | |
) | |
val myMediaDrm = MediaDrm(myUuid) | |
var myOutput = "" | |
mediaDrmInfo.map { md_key -> | |
md_key to myMediaDrm.getPropertyString(md_key) | |
}.forEach { (md_key, md_val) -> | |
myOutput += "$md_key \t $md_val\n" | |
} | |
return myOutput | |
} | |
private fun outputContentLevelStatus(myUuid: UUID):String{ | |
val mimeInfo = listOf( | |
getString(R.string.mime_mp4), | |
getString(R.string.mime_webm) | |
) | |
val securityLevelInfo = listOf( | |
MediaDrm.SECURITY_LEVEL_UNKNOWN, | |
MediaDrm.SECURITY_LEVEL_SW_SECURE_CRYPTO, | |
MediaDrm.SECURITY_LEVEL_SW_SECURE_DECODE, | |
MediaDrm.SECURITY_LEVEL_HW_SECURE_CRYPTO, | |
MediaDrm.SECURITY_LEVEL_HW_SECURE_DECODE, | |
MediaDrm.SECURITY_LEVEL_HW_SECURE_ALL | |
) | |
var myOutput = "----- status - content type level\n" | |
mimeInfo.map { mime_key -> | |
mime_key to MediaDrm.isCryptoSchemeSupported(myUuid, mime_key) | |
}.forEach { (mime_key, mime_val) -> | |
myOutput += "$mime_key \t $mime_val\n" | |
if (mime_val){ | |
securityLevelInfo.map { sl_key -> | |
sl_key to MediaDrm.isCryptoSchemeSupported(myUuid, mime_key, sl_key) | |
}.forEach { (sl_key, sl_val) -> | |
myOutput += "$sl_key \t $sl_val\n" | |
} | |
} | |
} | |
return myOutput | |
} | |
} |
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
<resources> | |
<string name="app_name">TestRun20221122</string> | |
<string name="hello_text">temps plummet</string> | |
<string name="vertical_text">vertical</string> | |
<string name="horizontal_text">horizontal</string> | |
<string name="uuid_widevine">edef8ba9-79d6-4ace-a3c8-27dcd51d21ed</string> | |
<string name="uuid_playready">9a04f079-9840-4286-ab92-e65be0885f95</string> | |
<string name="uuid_fairplay">94ce86fb-07ff-4f43-adb8-93d2fa968ca2</string> | |
<string name="mime_mp4">video/mp4</string> | |
<string name="mime_webm">video/webm</string> | |
</resources> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment