List of usage examples for android.drm DrmManagerClient DrmManagerClient
public DrmManagerClient(Context context)
DrmManagerClient
. From source file:Main.java
/** * Return the original MIME type of the given file, using the DRM framework * if the file is protected content.//from w w w. jav a 2 s .c om */ 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(); } }
From source file:Main.java
/** * Checks if the Media Type is a DRM Media Type * * @param drmManagerClient A DrmManagerClient * @param mimetype Media Type to check/* w w w . j a v a2 s.co m*/ * @return True if the Media Type is DRM else false */ public static boolean isDrmMimeType(Context context, String mimetype) { boolean result = false; if (context != null) { try { DrmManagerClient drmClient = new DrmManagerClient(context); if (drmClient != null && mimetype != null && mimetype.length() > 0) { result = drmClient.canHandle("", mimetype); } } 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."); } } return result; }
From source file:Main.java
/** * Gets the original mime type of DRM protected content. * * @param context The context// www .ja v a 2s . c o m * @param path Path to the file * @param containingMime The current mime type of of the file i.e. the * containing mime type * @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; }