From 54b6cfa9a9e5b861a9930af873580d6dc20f773c Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Tue, 21 Oct 2008 07:00:00 -0700 Subject: Initial Contribution --- .../android/drm/mobile1/DrmConstraintInfo.java | 96 +++++ media/java/android/drm/mobile1/DrmException.java | 34 ++ media/java/android/drm/mobile1/DrmRawContent.java | 464 +++++++++++++++++++++ media/java/android/drm/mobile1/DrmRights.java | 136 ++++++ .../java/android/drm/mobile1/DrmRightsManager.java | 255 +++++++++++ media/java/android/drm/mobile1/package.html | 5 + 6 files changed, 990 insertions(+) create mode 100644 media/java/android/drm/mobile1/DrmConstraintInfo.java create mode 100644 media/java/android/drm/mobile1/DrmException.java create mode 100644 media/java/android/drm/mobile1/DrmRawContent.java create mode 100644 media/java/android/drm/mobile1/DrmRights.java create mode 100644 media/java/android/drm/mobile1/DrmRightsManager.java create mode 100644 media/java/android/drm/mobile1/package.html (limited to 'media/java/android/drm') diff --git a/media/java/android/drm/mobile1/DrmConstraintInfo.java b/media/java/android/drm/mobile1/DrmConstraintInfo.java new file mode 100644 index 0000000..50ae8bd --- /dev/null +++ b/media/java/android/drm/mobile1/DrmConstraintInfo.java @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2007 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.drm.mobile1; + +import java.util.Date; + +/** + * This class provides interfaces to access the DRM constraint. + */ +public class DrmConstraintInfo { + /** + * The constraint of count. + */ + private int count; + + /** + * The constraint of start date. + */ + private long startDate; + + /** + * The constraint of end date. + */ + private long endDate; + + /** + * The constraint of interval. + */ + private long interval; + + /** + * Construct the DrmConstraint. + */ + DrmConstraintInfo() { + count = -1; + startDate = -1; + endDate = -1; + interval = -1; + } + + /** + * Get the count constraint. + * + * @return the count or -1 if no limit. + */ + public int getCount() { + return count; + } + + /** + * Get the start date constraint. + * + * @return the start date or null if no limit. + */ + public Date getStartDate() { + if (startDate == -1) + return null; + + return new Date(startDate); + } + + /** + * Get the end date constraint. + * + * @return the end date or null if no limit. + */ + public Date getEndDate() { + if (endDate == -1) + return null; + + return new Date(endDate); + } + + /** + * Get the Interval constraint. + * + * @return the interval or -1 if no limit. + */ + public long getInterval() { + return interval; + } +} diff --git a/media/java/android/drm/mobile1/DrmException.java b/media/java/android/drm/mobile1/DrmException.java new file mode 100644 index 0000000..7b06c92 --- /dev/null +++ b/media/java/android/drm/mobile1/DrmException.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2007 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.drm.mobile1; + +import java.io.IOException; + +/** + * A DrmException is thrown to report errors specific to handle DRM content and rights. + */ +public class DrmException extends Exception +{ + // TODO: add more specific DRM error codes. + + private DrmException() { + } + + public DrmException(String message) { + super(message); + } +} diff --git a/media/java/android/drm/mobile1/DrmRawContent.java b/media/java/android/drm/mobile1/DrmRawContent.java new file mode 100644 index 0000000..046b84a --- /dev/null +++ b/media/java/android/drm/mobile1/DrmRawContent.java @@ -0,0 +1,464 @@ +/* + * Copyright (C) 2007 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.drm.mobile1; + +import java.io.*; + +/** + * This class provides interfaces to access the DRM raw content. + */ +public class DrmRawContent { + /** + * The "application/vnd.oma.drm.message" mime type. + */ + public static final String DRM_MIMETYPE_MESSAGE_STRING = "application/vnd.oma.drm.message"; + + /** + * The "application/vnd.oma.drm.content" mime type. + */ + public static final String DRM_MIMETYPE_CONTENT_STRING = "application/vnd.oma.drm.content"; + + /** + * The DRM delivery type: Forward-Lock + */ + public static final int DRM_FORWARD_LOCK = 1; + + /** + * The DRM delivery type: Combined Delivery + */ + public static final int DRM_COMBINED_DELIVERY = 2; + + /** + * The DRM delivery type: Separate Delivery + */ + public static final int DRM_SEPARATE_DELIVERY = 3; + + /** + * The DRM delivery type: Separate Delivery in DRM message + */ + public static final int DRM_SEPARATE_DELIVERY_DM = 4; + + /** + * The DRM media content length is unknown currently + */ + public static final int DRM_UNKNOWN_DATA_LEN = -1; + + + /** + * The id of "application/vnd.oma.drm.message" mime type. + */ + private static final int DRM_MIMETYPE_MESSAGE = 1; + + /** + * The id of "application/vnd.oma.drm.content" mime type. + */ + private static final int DRM_MIMETYPE_CONTENT = 2; + + /** + * Successful operation. + */ + private static final int JNI_DRM_SUCCESS = 0; + + /** + * General failure. + */ + private static final int JNI_DRM_FAILURE = -1; + + /** + * Indicates the end of the DRM content is reached. + */ + private static final int JNI_DRM_EOF = -2; + + /** + * The media content length is unknown from native method + */ + private static final int JNI_DRM_UNKNOWN_DATA_LEN = -3; + + /** + * The member to save the original InputStream data. + */ + private BufferedInputStream inData; + + /** + * The member to save the original InputStream data length. + */ + private int inDataLen; + + /** + * The unique id to this DRM content. It will be initialized + * in constructor by native method. And it will not be changed + * after initialization. + */ + private int id; + + /** + * The rights issuer address of this DRM object. + */ + private String rightsIssuer; + + /** + * The media content type of this DRM object. + */ + private String mediaType; + + /** + * The delivery method type of this DRM object. + */ + private int rawType; + + + /** + * Construct a DrmRawContent object. + * + * @param inRawdata object of DRM raw data stream. + * @param len the length of raw data can be read. + * @param mimeTypeStr the mime type of the DRM content. + */ + public DrmRawContent(InputStream inRawdata, int len, String mimeTypeStr) throws DrmException, IOException { + int mimeType; + + id = -1; + inData = new BufferedInputStream(inRawdata, 1024); + inDataLen = len; + + if (DRM_MIMETYPE_MESSAGE_STRING.equals(mimeTypeStr)) + mimeType = DRM_MIMETYPE_MESSAGE; + else if (DRM_MIMETYPE_CONTENT_STRING.equals(mimeTypeStr)) + mimeType = DRM_MIMETYPE_CONTENT; + else + throw new IllegalArgumentException("mimeType must be DRM_MIMETYPE_MESSAGE or DRM_MIMETYPE_CONTENT"); + + if (len <= 0) + throw new IllegalArgumentException("len must be > 0"); + + /* call native method to initialize this DRM content */ + id = nativeConstructDrmContent(inData, inDataLen, mimeType); + + if (JNI_DRM_FAILURE == id) + throw new DrmException("nativeConstructDrmContent() returned JNI_DRM_FAILURE"); + + /* init the rights issuer field. */ + rightsIssuer = nativeGetRightsAddress(); + + /* init the raw content type. */ + rawType = nativeGetDeliveryMethod(); + if (JNI_DRM_FAILURE == rawType) + throw new DrmException("nativeGetDeliveryMethod() returned JNI_DRM_FAILURE"); + + /* init the media content type. */ + mediaType = nativeGetContentType(); + if (null == mediaType) + throw new DrmException("nativeGetContentType() returned null"); + } + + /** + * Get rights address from raw Seperate Delivery content. + * + * @return the string of the rights issuer address, + * or null if no rights issuer. + */ + public String getRightsAddress() { + return rightsIssuer; + } + + /** + * Get the type of the raw DRM content. + * + * @return one of the following delivery type of this DRM content: + * #DRM_FORWARD_LOCK + * #DRM_COMBINED_DELIVERY + * #DRM_SEPARATE_DELIVERY + * #DRM_SEPARATE_DELIVERY_DM + */ + public int getRawType() { + return rawType; + } + + /** + * Get one InputStream object to read decrypted content. + * + * @param rights the rights object contain decrypted key. + * + * @return the InputStream object of decrypted media content. + */ + public InputStream getContentInputStream(DrmRights rights) { + if (null == rights) + throw new NullPointerException(); + + return new DrmInputStream(rights); + } + + /** + * Get the type of the decrypted media content. + * + * @return the decrypted media content type of this DRM content. + */ + public String getContentType() { + return mediaType; + } + + /** + * Get the length of the decrypted media content. + * + * @param rights the rights object contain decrypted key. + * + * @return the length of the decrypted media content. + * #DRM_UNKNOWN_DATA_LEN if the length is unknown currently. + */ + public int getContentLength(DrmRights rights) throws DrmException { + /** + * Because currently the media object associate with rights object + * has been handled in native logic, so here it is not need to deal + * the rights. But for the apps, it is mandatory for user to get + * the rights object before get the media content length. + */ + if (null == rights) + throw new NullPointerException(); + + int mediaLen = nativeGetContentLength(); + + if (JNI_DRM_FAILURE == mediaLen) + throw new DrmException("nativeGetContentLength() returned JNI_DRM_FAILURE"); + + if (JNI_DRM_UNKNOWN_DATA_LEN == mediaLen) + return DRM_UNKNOWN_DATA_LEN; + + return mediaLen; + } + + /** + * This class provide a InputStream to the DRM media content. + */ + class DrmInputStream extends InputStream + { + /** + * The flag to indicate whether this stream is closed or not. + */ + private boolean isClosed; + + /** + * The offset of this DRM content to be reset. + */ + private int offset; + + /** + * A byte of data to be readed. + */ + private byte[] b; + + /** + * Construct a DrmInputStream instance. + */ + public DrmInputStream(DrmRights rights) { + /** + * Because currently the media object associate with rights object + * has been handled in native logic, so here it is not need to deal + * the rights. But for the apps, it is mandatory for user to get + * the rights object before get the media content data. + */ + + isClosed = false; + offset = 0; + b = new byte[1]; + } + + /* Non-javadoc + * @see java.io.InputStream#available() + */ + public int available() throws IOException { + /* call native method to get this DRM decrypted media content length */ + int len = nativeGetContentLength(); + + if (JNI_DRM_FAILURE == len) + throw new IOException(); + + /* if the length is unknown, just return 0 for available value */ + if (JNI_DRM_UNKNOWN_DATA_LEN == len) + return 0; + + int availableLen = len - offset; + if (availableLen < 0) + throw new IOException(); + + return availableLen; + } + + /* Non-javadoc + * @see java.io.InputStream#read() + */ + public int read() throws IOException { + int res; + + res = read(b, 0, 1); + + if (-1 == res) + return -1; + + return b[0] & 0xff; + } + + /* Non-javadoc + * @see java.io.InputStream#read(byte) + */ + public int read(byte[] b) throws IOException { + return read(b, 0, b.length); + } + + /* Non-javadoc + * @see java.io.InputStream#read(byte, int, int) + */ + public int read(byte[] b, int off, int len) throws IOException { + if (null == b) + throw new NullPointerException(); + if (off < 0 || len < 0 || off + len > b.length) + throw new IndexOutOfBoundsException(); + if (true == isClosed) + throw new IOException(); + + if (0 == len) + return 0; + + len = nativeReadContent(b, off, len, offset); + + if (JNI_DRM_FAILURE == len) + throw new IOException(); + else if (JNI_DRM_EOF == len) + return -1; + + offset += len; + + return len; + } + + /* Non-javadoc + * @see java.io.InputStream#markSupported() + */ + public boolean markSupported() { + return false; + } + + /* Non-javadoc + * @see java.io.InputStream#mark(int) + */ + public void mark(int readlimit) { + } + + /* Non-javadoc + * @see java.io.InputStream#reset() + */ + public void reset() throws IOException { + throw new IOException(); + } + + /* Non-javadoc + * @see java.io.InputStream#skip() + */ + public long skip(long n) throws IOException { + return 0; + } + + /* Non-javadoc + * @see java.io.InputStream#close() + */ + public void close() { + isClosed = true; + } + } + + /** + * native method: construct a DRM content according the mime type. + * + * @param data input DRM content data to be parsed. + * @param len the length of the data. + * @param mimeType the mime type of this DRM content. the value of this field includes: + * #DRM_MIMETYPE_MESSAGE + * #DRM_MIMETYPE_CONTENT + * + * @return #the id of the DRM content if succeed. + * #JNI_DRM_FAILURE if fail. + */ + private native int nativeConstructDrmContent(InputStream data, int len, int mimeType); + + /** + * native method: get this DRM content rights issuer. + * + * @return the address of rights issuer if in case of separate delivery. + * null if not separete delivery, or otherwise. + */ + private native String nativeGetRightsAddress(); + + /** + * native method: get this DRM content delivery type. + * + * @return the delivery method, the value may be one of the following: + * #DRM_FORWARD_LOCK + * #DRM_COMBINED_DELIVERY + * #DRM_SEPARATE_DELIVERY + * #DRM_SEPARATE_DELIVERY_DM + * #JNI_DRM_FAILURE if fail. + */ + private native int nativeGetDeliveryMethod(); + + /** + * native method: get a piece of media content data. + * + * @param buf the buffer to save DRM media content data. + * @param bufOff the offset of the buffer to start to save data. + * @param len the number of byte to read. + * @param mediaOff the offset of the media content data to start to read. + * + * @return the length of the media content data has been read. + * #JNI_DRM_EOF if reach to end of the media content. + * #JNI_DRM_FAILURE if fail. + */ + private native int nativeReadContent(byte[] buf, int bufOff, int len, int mediaOff); + + /** + * native method: get this DRM content type. + * + * @return the decrypted media content type. + * null if fail. + */ + private native String nativeGetContentType(); + + /** + * native method: get this DRM decrypted media content length. + * + * @return the length of decrypted media content. + * #JNI_DRM_FAILURE if fail. + * #JNI_DRM_UNKNOWN_DATA_LEN if the length is unknown currently. + */ + private native int nativeGetContentLength(); + + /** + * The finalizer of the DRMRawContent. Do some cleanup. + */ + protected native void finalize(); + + + /** + * Load the shared library to link the native methods. + */ + static { + try { + System.loadLibrary("drm1_jni"); + } + catch (UnsatisfiedLinkError ule) { + System.err.println("WARNING: Could not load libdrm1_jni.so"); + } + } +} diff --git a/media/java/android/drm/mobile1/DrmRights.java b/media/java/android/drm/mobile1/DrmRights.java new file mode 100644 index 0000000..bcccb6a --- /dev/null +++ b/media/java/android/drm/mobile1/DrmRights.java @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2007 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.drm.mobile1; + +/** + * This class provides interfaces to access the DRM rights. + */ +public class DrmRights { + /** + * The DRM permission of play. + */ + public static final int DRM_PERMISSION_PLAY = 1; + + /** + * The DRM permission of display. + */ + public static final int DRM_PERMISSION_DISPLAY = 2; + + /** + * The DRM permission of execute. + */ + public static final int DRM_PERMISSION_EXECUTE = 3; + + /** + * The DRM permission of print. + */ + public static final int DRM_PERMISSION_PRINT = 4; + + /** + * Successful operation. + */ + private static final int JNI_DRM_SUCCESS = 0; + + /** + * General failure. + */ + private static final int JNI_DRM_FAILURE = -1; + + /** + * The uid of this rights object. + */ + private String roId = ""; + + + /** + * Construct the DrmRights. + */ + public DrmRights() { + } + + /** + * Get the constraint of the given permission on this rights object. + * + * @param permission the given permission. + * + * @return a DrmConstraint instance. + */ + public DrmConstraintInfo getConstraint(int permission) { + DrmConstraintInfo c = new DrmConstraintInfo(); + + /* call native method to get latest constraint information */ + int res = nativeGetConstraintInfo(permission, c); + + if (JNI_DRM_FAILURE == res) + return null; + + return c; + } + + /** + * Consume the rights of the given permission. + * + * @param permission the given permission. + * + * @return true if consume success. + * false if consume failure. + */ + public boolean consumeRights(int permission) { + /* call native method to consume and update rights */ + int res = nativeConsumeRights(permission); + + if (JNI_DRM_FAILURE == res) + return false; + + return true; + } + + + /** + * native method: get the constraint information of the given permission. + * + * @param permission the given permission. + * @param constraint the instance of constraint. + * + * @return #JNI_DRM_SUCCESS if succeed. + * #JNI_DRM_FAILURE if fail. + */ + private native int nativeGetConstraintInfo(int permission, DrmConstraintInfo constraint); + + /** + * native method: consume the rights of the given permission. + * + * @param permission the given permission. + * + * @return #JNI_DRM_SUCCESS if succeed. + * #JNI_DRM_FAILURE if fail. + */ + private native int nativeConsumeRights(int permission); + + + /** + * Load the shared library to link the native methods. + */ + static { + try { + System.loadLibrary("drm1_jni"); + } + catch (UnsatisfiedLinkError ule) { + System.err.println("WARNING: Could not load libdrm1_jni.so"); + } + } +} diff --git a/media/java/android/drm/mobile1/DrmRightsManager.java b/media/java/android/drm/mobile1/DrmRightsManager.java new file mode 100644 index 0000000..1bc36ec --- /dev/null +++ b/media/java/android/drm/mobile1/DrmRightsManager.java @@ -0,0 +1,255 @@ +/* + * Copyright (C) 2007 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.drm.mobile1; + +import java.io.*; +import java.util.*; + +/** + * This class provides interfaces to access the DRM right manager. + */ +public class DrmRightsManager { + /** + * The "application/vnd.oma.drm.rights+xml" mime type. + */ + public static final String DRM_MIMETYPE_RIGHTS_XML_STRING = "application/vnd.oma.drm.rights+xml"; + + /** + * The "application/vnd.oma.drm.rights+wbxml" mime type. + */ + public static final String DRM_MIMETYPE_RIGHTS_WBXML_STRING = "application/vnd.oma.drm.rights+wbxml"; + + /** + * The id of "application/vnd.oma.drm.rights+xml" mime type. + */ + private static final int DRM_MIMETYPE_RIGHTS_XML = 3; + + /** + * The id of "application/vnd.oma.drm.rights+wbxml" mime type. + */ + private static final int DRM_MIMETYPE_RIGHTS_WBXML = 4; + + /** + * The id of "application/vnd.oma.drm.message" mime type. + */ + private static final int DRM_MIMETYPE_MESSAGE = 1; + + /** + * Successful operation. + */ + private static final int JNI_DRM_SUCCESS = 0; + + /** + * General failure. + */ + private static final int JNI_DRM_FAILURE = -1; + + /** + * The instance of the rights manager. + */ + private static DrmRightsManager singleton = null; + + + /** + * Construct a DrmRightsManager + */ + protected DrmRightsManager() { + } + + /** + * Get the DrmRightsManager instance. + * + * @return the instance of DrmRightsManager. + */ + public static synchronized DrmRightsManager getInstance() { + if (singleton == null) { + singleton = new DrmRightsManager(); + } + + return singleton; + } + + /** + * Install one DRM rights and return one instance of DrmRights. + * + * @param rightsData raw rights data. + * @param mimeTypeStr the mime type of the rights object. + * + * @return the instance of the installed DrmRights. + */ + public synchronized DrmRights installRights(InputStream rightsData, int len, String mimeTypeStr) throws DrmException, IOException { + int mimeType = 0; + + if (DRM_MIMETYPE_RIGHTS_XML_STRING.equals(mimeTypeStr)) + mimeType = DRM_MIMETYPE_RIGHTS_XML; + else if (DRM_MIMETYPE_RIGHTS_WBXML_STRING.equals(mimeTypeStr)) + mimeType = DRM_MIMETYPE_RIGHTS_WBXML; + else if (DrmRawContent.DRM_MIMETYPE_MESSAGE_STRING.equals(mimeTypeStr)) + mimeType = DRM_MIMETYPE_MESSAGE; + else + throw new IllegalArgumentException("mimeType must be DRM_MIMETYPE_RIGHTS_XML or DRM_MIMETYPE_RIGHTS_WBXML or DRM_MIMETYPE_MESSAGE"); + + if (len <= 0) + return null; + + DrmRights rights = new DrmRights(); + + /* call native method to install this rights object. */ + int res = nativeInstallDrmRights(rightsData, len, mimeType, rights); + + if (JNI_DRM_FAILURE == res) + throw new DrmException("nativeInstallDrmRights() returned JNI_DRM_FAILURE"); + + return rights; + } + + /** + * Query DRM rights of specified DRM raw content. + * + * @param content raw content object. + * + * @return the instance of DrmRights, or null if there is no rights. + */ + public synchronized DrmRights queryRights(DrmRawContent content) { + DrmRights rights = new DrmRights(); + + /* call native method to query the rights */ + int res = nativeQueryRights(content, rights); + + if (JNI_DRM_FAILURE == res) + return null; + + return rights; + } + + /** + * Get the list of all DRM rights saved in local client. + * + * @return the list of all the rights object. + */ + public synchronized List getRightsList() { + List rightsList = new ArrayList(); + + /* call native method to get how many rights object in current agent */ + int num = nativeGetNumOfRights(); + + if (JNI_DRM_FAILURE == num) + return null; + + if (num > 0) { + DrmRights[] rightsArray = new DrmRights[num]; + int i; + + for (i = 0; i < num; i++) + rightsArray[i] = new DrmRights(); + + /* call native method to get all the rights information */ + num = nativeGetRightsList(rightsArray, num); + + if (JNI_DRM_FAILURE == num) + return null; + + /* add all rights informations to ArrayList */ + for (i = 0; i < num; i++) + rightsList.add(rightsArray[i]); + } + + return rightsList; + } + + /** + * Delete the specified DRM rights object. + * + * @param rights the specified rights object to be deleted. + */ + public synchronized void deleteRights(DrmRights rights) { + /* call native method to delete the specified rights object */ + int res = nativeDeleteRights(rights); + + if (JNI_DRM_FAILURE == res) + return; + } + + + /** + * native method: install rights object to local client. + * + * @param data input DRM rights object data to be installed. + * @param len the length of the data. + * @param mimeType the mime type of this DRM rights object. the value of this field includes: + * #DRM_MIMETYPE_RIGHTS_XML + * #DRM_MIMETYPE_RIGHTS_WBXML + * @parma rights the instance of DRMRights to be filled. + * + * @return #JNI_DRM_SUCCESS if succeed. + * #JNI_DRM_FAILURE if fail. + */ + private native int nativeInstallDrmRights(InputStream data, int len, int mimeType, DrmRights rights); + + /** + * native method: query the given DRM content's rights object. + * + * @param content the given DRM content. + * @param rights the instance of rights to set if have. + * + * @return #JNI_DRM_SUCCESS if succeed. + * #JNI_DRM_FAILURE if fail. + */ + private native int nativeQueryRights(DrmRawContent content, DrmRights rights); + + /** + * native method: get how many rights object in current DRM agent. + * + * @return the number of the rights object. + * #JNI_DRM_FAILURE if fail. + */ + private native int nativeGetNumOfRights(); + + /** + * native method: get all the rights object in current local agent. + * + * @param rights the array instance of rights object. + * @param numRights how many rights can be saved. + * + * @return the number of the rights object has been gotten. + * #JNI_DRM_FAILURE if fail. + */ + private native int nativeGetRightsList(DrmRights[] rights, int numRights); + + /** + * native method: delete a specified rights object. + * + * @param rights the specified rights object to be deleted. + * + * @return #JNI_DRM_SUCCESS if succeed. + * #JNI_DRM_FAILURE if fail. + */ + private native int nativeDeleteRights(DrmRights rights); + + + /** + * Load the shared library to link the native methods. + */ + static { + try { + System.loadLibrary("drm1_jni"); + } + catch (UnsatisfiedLinkError ule) { + System.err.println("WARNING: Could not load libdrm1_jni.so"); + } + } +} diff --git a/media/java/android/drm/mobile1/package.html b/media/java/android/drm/mobile1/package.html new file mode 100644 index 0000000..1c9bf9d --- /dev/null +++ b/media/java/android/drm/mobile1/package.html @@ -0,0 +1,5 @@ + + + {@hide} + + -- cgit v1.1