Android DrmManagerClient - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android DrmManagerClient class.

This code example shows how to use the following methods:canHandle, getOriginalMimeType
     * @return The original mime type of the file if DRM protected else the 
     *         currentMime 
     */ 
    public static String getOriginalMimeType(Context context, String path, String containingMime) {
        String result = containingMime;
        DrmManagerClient drmClient = new DrmManagerClient(context);
        try { 
            if (drmClient.canHandle(path, null)) {
                result = drmClient.getOriginalMimeType(path);
            } 
        } catch (IllegalArgumentException ex) {
            Log.w(TAG,
                    "Can't get original mime type since path is null or empty string."); 
        } catch (IllegalStateException ex) {
            Log.w(TAG, "DrmManagerClient didn't initialize properly.");
        } 
        return result;
    } 
} 
7
CodeRank
This code example shows how to use the following methods:openConvertSession
    public static DrmConvertSession open(Context context, String mimeType) {
        DrmManagerClient drmClient = null;
        int convertSessionId = -1;
        if (context != null && mimeType != null && !mimeType.equals("")) {
            try { 
                drmClient = new DrmManagerClient(context);
                try { 
                    convertSessionId = drmClient.openConvertSession(mimeType);
                } catch (IllegalArgumentException e) {
                    Log.w(TAG, "Conversion of Mimetype: " + mimeType
                            + " is not supported.", e);
                } catch (IllegalStateException e) {
                    Log.w(TAG, "Could not access Open DrmFramework.", e);
                } 
            } catch (IllegalArgumentException e) {
                Log.w(TAG,
                        "DrmManagerClient instance could not be created, context is Illegal."); 
            } catch (IllegalStateException e) {
                Log.w(TAG, "DrmManagerClient didn't initialize properly.");
            } 
7
CodeRank
This code example shows how to use the following methods:openConvertSession
    public static DrmConvertSession open(Context context, String mimeType) {
        DrmManagerClient drmClient = null;
        int convertSessionId = -1;
        if (context != null && mimeType != null && !mimeType.equals("")) {
            try { 
                drmClient = new DrmManagerClient(context);
                try { 
                    convertSessionId = drmClient.openConvertSession(mimeType);
                } catch (IllegalArgumentException e) {
                    Log.w(TAG, "Conversion of Mimetype: " + mimeType
                            + " is not supported.", e);
                } catch (IllegalStateException e) {
                    Log.w(TAG, "Could not access Open DrmFramework.", e);
                } 
            } catch (IllegalArgumentException e) {
                Log.w(TAG,
                        "DrmManagerClient instance could not be created, context is Illegal."); 
            } catch (IllegalStateException e) {
                Log.w(TAG, "DrmManagerClient didn't initialize properly.");
            } 
6
CodeRank
This code example shows how to use the following methods:canHandle, getOriginalMimeType, release
    /** 
     * Return the original MIME type of the given file, using the DRM framework 
     * if the file is protected content. 
     */ 
    public static String getOriginalMimeType(Context context, File file, String currentMime) {
        final DrmManagerClient client = new DrmManagerClient(context);
        try { 
            final String rawFile = file.toString();
            if (client.canHandle(rawFile, null)) {
                return client.getOriginalMimeType(rawFile);
            } else { 
                return currentMime;
            } 
        } finally { 
            client.release();
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:openConvertSession
    public static DrmConvertSession open(Context context, String mimeType) {
        DrmManagerClient drmClient = null;
        int convertSessionId = -1;
        if (context != null && mimeType != null && !mimeType.equals("")) {
            try { 
                drmClient = new DrmManagerClient(context);
                try { 
                    convertSessionId = drmClient.openConvertSession(mimeType);
                } catch (IllegalArgumentException e) {
                    Log.w(TAG, "Conversion of Mimetype: " + mimeType
                            + " is not supported.", e);
                } catch (IllegalStateException e) {
                    Log.w(TAG, "Could not access Open DrmFramework.", e);
                } 
            } catch (IllegalArgumentException e) {
                Log.w(TAG,
                        "DrmManagerClient instance could not be created, context is Illegal."); 
            } catch (IllegalStateException e) {
                Log.w(TAG, "DrmManagerClient didn't initialize properly.");
            } 
5
CodeRank
This code example shows how to use the following methods:
        return mCountryIso == null ? Locale.getDefault().getCountry() : mCountryIso;
    } 
 
    public DrmManagerClient getDrmManagerClient() {
        if (mDrmManagerClient == null) {
            mDrmManagerClient = new DrmManagerClient(getApplicationContext());
        } 
        return mDrmManagerClient;
    } 
 
} 
4
CodeRank
This code example shows how to use the following methods:checkRightsStatus
        return DcfDecoder.forceDecodeUri(cr, drmUri, options, consume);
    } 
 
    public static int checkRightsStatus(Context context, String path, int action) {
        if (null == mDrmManagerClient) {
            mDrmManagerClient = new DrmManagerClient(context);
        } 
        if (null == path) {
            Log.e(TAG,"checkRightsStatus:got null file path");
        } 
        return mDrmManagerClient.checkRightsStatus(path, action);
    } 
 
    public static DrmManagerClient getDrmManagerClient(Context context) {
        if (null == mDrmManagerClient) {
            mDrmManagerClient = new DrmManagerClient(context);
        } 
        return mDrmManagerClient;
    } 
 
4
CodeRank
This code example shows how to use the following methods:getOriginalMimeType
        } 
        Xlog.i(TAG, "ImageModel got file path: " + mPath);
        Xlog.i(TAG, "ImageModel got file extension: " + extension);
        mContentType = mimeTypeMap.getMimeTypeFromExtension(extension);
        if (mContentType == null && extension.equals("dcf")) {
        	DrmManagerClient drmManager= new DrmManagerClient(mContext);
        	mContentType = drmManager.getOriginalMimeType(mPath);
        	Xlog.i(TAG, "ImageModel got drm content, mContentType: " + mContentType);
        } 
        Xlog.i(TAG, "ImageModel got mContentType: " + mContentType);
        // It's ok if mContentType is null. Eventually we'll show a toast telling the 
        // user the picture couldn't be attached. 
    } 
 
    private void initFromContentUri(Context context, Uri uri) {
        Cursor c = SqliteWrapper.query(context, context.getContentResolver(),
                            uri, null, null, null, null);
 
        if (c == null) {
            throw new IllegalArgumentException(
4
CodeRank
This code example shows how to use the following methods:
     
    //for drm 
    private static DrmManagerClient mDrmClient;
    public static DrmManagerClient getDrmManager(Context context) {
        if (mDrmClient == null) {
            mDrmClient = new DrmManagerClient(context);
        } 
        return mDrmClient;
    } 
     
    public static boolean isSupportDrm() { 
        boolean support = com.mediatek.featureoption.FeatureOption.MTK_DRM_APP;
        MtkLog.w(TAG, "isSupportDrm() return " + support);
        return support;
    } 
     
    public static Bitmap overlayDrmIcon(Context context, String path, int action, Bitmap bkg) {
        Bitmap bitmap = getDrmManager(context).overlayDrmIcon(context.getResources(), path, action, bkg);
        if (LOG) MtkLog.v(TAG, "overlayDrmIcon(" + path + ") return " + path);
        //saveBitmap("overlayDrmIconSkew() ", path, bitmap); 
3
CodeRank
This code example shows how to use the following methods:
    } 
 
 
    public DrmManagerClient getDrmManagerClient() {
        if (mDrmManagerClient == null) {
            mDrmManagerClient = new DrmManagerClient(getApplicationContext());
        } 
        return mDrmManagerClient;
    } 
 
} 
4
CodeRank
See Code Examples for Android DrmManagerClient Methods: