1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.drm; 18 19 /** 20 * An entity class that wraps converted data, conversion status, and the 21 * offset for appending the header and body signature to the converted data. 22 * An instance of this class may be created two ways by the drm framework: 23 * a) a call to {@link DrmManagerClient#convertData DrmManagerClient.convertData()} and 24 * b) a call to {@link DrmManagerClient#closeConvertSession DrmManagerClient.closeConvertSession()}. 25 * An valid offset value is provided only from a success call to 26 * {@link DrmManagerClient#closeConvertSession DrmManagerClient.closeConvertSession()}. 27 * 28 * @deprecated Please use {@link android.media.MediaDrm} 29 */ 30 @Deprecated 31 public class DrmConvertedStatus { 32 // The following status code constants must be in sync with 33 // DrmConvertedStatus.cpp. Please also update isValidStatusCode() 34 // when more status code constants are added. 35 /** 36 * Indicate the conversion status is successful. 37 */ 38 public static final int STATUS_OK = 1; 39 /** 40 * Indicate a failed conversion status due to input data. 41 */ 42 public static final int STATUS_INPUTDATA_ERROR = 2; 43 /** 44 * Indicate a general failed conversion status. 45 */ 46 public static final int STATUS_ERROR = 3; 47 48 /** 49 * Status code for the conversion. Must be one of the defined status 50 * constants above. 51 */ 52 public final int statusCode; 53 /** 54 * Converted data. It is optional and thus can be null. 55 */ 56 public final byte[] convertedData; 57 /** 58 * Offset value for the body and header signature. 59 */ 60 public final int offset; 61 62 /** 63 * Creates a <code>DrmConvertedStatus</code> object with the specified parameters. 64 * 65 * @param statusCode Conversion status. Must be one of the status code constants 66 * defined above. 67 * @param convertedData Converted data. It can be null. 68 * @param offset Offset value for appending the header and body signature. 69 */ DrmConvertedStatus(int statusCode, byte[] convertedData, int offset)70 public DrmConvertedStatus(int statusCode, byte[] convertedData, int offset) { 71 if (!isValidStatusCode(statusCode)) { 72 throw new IllegalArgumentException("Unsupported status code: " + statusCode); 73 } 74 75 this.statusCode = statusCode; 76 this.convertedData = convertedData; 77 this.offset = offset; 78 } 79 isValidStatusCode(int statusCode)80 private boolean isValidStatusCode(int statusCode) { 81 return statusCode == STATUS_OK || 82 statusCode == STATUS_INPUTDATA_ERROR || 83 statusCode == STATUS_ERROR; 84 } 85 } 86 87