FileDocCategorySizeDatePackage
DrmUtils.javaAPI DocAndroid 5.1 API7220Thu Mar 12 22:22:30 GMT 2015android.drm

DrmUtils

public class DrmUtils extends Object
A utility class that provides operations for parsing extended metadata embedded in DRM constraint information. If a DRM scheme has specific constraints beyond the standard constraints, the constraints will show up in the {@link DrmStore.ConstraintsColumns#EXTENDED_METADATA} key. You can use {@link DrmUtils.ExtendedMetadataParser} to iterate over those values.

Fields Summary
Constructors Summary
Methods Summary
public static android.drm.DrmUtils$ExtendedMetadataParsergetExtendedMetadataParser(byte[] extendedMetadata)
Gets an instance of {@link DrmUtils.ExtendedMetadataParser}, which can be used to parse extended metadata embedded in DRM constraint information.

param
extendedMetadata Object in which key-value pairs of extended metadata are embedded.

        return new ExtendedMetadataParser(extendedMetadata);
    
private static voidquietlyDispose(java.io.InputStream stream)

        try {
            if (null != stream) {
                stream.close();
            }
        } catch (IOException e) {
            // no need to care, at least as of now
        }
    
private static voidquietlyDispose(java.io.OutputStream stream)

        try {
            if (null != stream) {
                stream.close();
            }
        } catch (IOException e) {
            // no need to care
        }
    
static byte[]readBytes(java.lang.String path)

        File file = new File(path);
        return readBytes(file);
    
static byte[]readBytes(java.io.File file)

        FileInputStream inputStream = new FileInputStream(file);
        BufferedInputStream bufferedStream = new BufferedInputStream(inputStream);
        byte[] data = null;

        try {
            int length = bufferedStream.available();
            if (length > 0) {
                data = new byte[length];
                // read the entire data
                bufferedStream.read(data);
             }
        } finally {
            quietlyDispose(bufferedStream);
            quietlyDispose(inputStream);
        }
        return data;
    
static voidremoveFile(java.lang.String path)

        File file = new File(path);
        file.delete();
    
static voidwriteToFile(java.lang.String path, byte[] data)

        /* check for invalid inputs */
        FileOutputStream outputStream = null;

        if (null != path && null != data) {
            try {
                outputStream = new FileOutputStream(path);
                outputStream.write(data);
            } finally {
                quietlyDispose(outputStream);
            }
        }