summaryrefslogtreecommitdiffstats
path: root/drm/java/android/drm/DrmConvertedStatus.java
diff options
context:
space:
mode:
Diffstat (limited to 'drm/java/android/drm/DrmConvertedStatus.java')
-rwxr-xr-xdrm/java/android/drm/DrmConvertedStatus.java61
1 files changed, 46 insertions, 15 deletions
diff --git a/drm/java/android/drm/DrmConvertedStatus.java b/drm/java/android/drm/DrmConvertedStatus.java
index cecb135..f6e570a 100755
--- a/drm/java/android/drm/DrmConvertedStatus.java
+++ b/drm/java/android/drm/DrmConvertedStatus.java
@@ -18,36 +18,67 @@ package android.drm;
/**
* An entity class that wraps converted data, conversion status, and the
- * offset for appending the header and body signature to the converted data. An instance of this
- * class is returned by the {@link DrmManagerClient#convertData convertData()} and
- * {@link DrmManagerClient#closeConvertSession closeConvertSession()} methods. The offset is provided only when a
- * conversion session is closed by calling {@link DrmManagerClient#closeConvertSession closeConvertSession()}.
+ * offset for appending the header and body signature to the converted data.
+ * An instance of this class may be created two ways by the drm framework:
+ * a) a call to {@link DrmManagerClient#convertData DrmManagerClient.convertData()} and
+ * b) a call to {@link DrmManagerClient#closeConvertSession DrmManagerClient.closeConvertSession()}.
+ * An valid offset value is provided only from a success call to
+ * {@link DrmManagerClient#closeConvertSession DrmManagerClient.closeConvertSession()}.
*
*/
public class DrmConvertedStatus {
- // Should be in sync with DrmConvertedStatus.cpp
+ // The following status code constants must be in sync with
+ // DrmConvertedStatus.cpp. Please also update isValidStatusCode()
+ // when more status code constants are added.
+ /**
+ * Indicate the conversion status is successful.
+ */
public static final int STATUS_OK = 1;
+ /**
+ * Indicate a failed conversion status due to input data.
+ */
public static final int STATUS_INPUTDATA_ERROR = 2;
+ /**
+ * Indicate a general failed conversion status.
+ */
public static final int STATUS_ERROR = 3;
- /** Status code for the conversion.*/
+ /**
+ * Status code for the conversion. Must be one of the defined status
+ * constants above.
+ */
public final int statusCode;
- /** Converted data.*/
+ /**
+ * Converted data. It is optional and thus can be null.
+ */
public final byte[] convertedData;
- /** Offset value for the body and header signature.*/
+ /**
+ * Offset value for the body and header signature.
+ */
public final int offset;
/**
* Creates a <code>DrmConvertedStatus</code> object with the specified parameters.
*
- * @param _statusCode Conversion status.
- * @param _convertedData Converted data.
- * @param _offset Offset value for appending the header and body signature.
+ * @param statusCode Conversion status. Must be one of the status code constants
+ * defined above.
+ * @param convertedData Converted data. It can be null.
+ * @param offset Offset value for appending the header and body signature.
*/
- public DrmConvertedStatus(int _statusCode, byte[] _convertedData, int _offset) {
- statusCode = _statusCode;
- convertedData = _convertedData;
- offset = _offset;
+ public DrmConvertedStatus(int statusCode, byte[] convertedData, int offset) {
+ if (!isValidStatusCode(statusCode)) {
+ throw new IllegalArgumentException("Unsupported status code: " + statusCode);
+ }
+
+ this.statusCode = statusCode;
+ this.convertedData = convertedData;
+ this.offset = offset;
+ }
+
+ private boolean isValidStatusCode(int statusCode) {
+ return statusCode == STATUS_OK ||
+ statusCode == STATUS_INPUTDATA_ERROR ||
+ statusCode == STATUS_ERROR;
}
}