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 the result of communication between a device 21 * and an online DRM server. Specifically, when the 22 * {@link DrmManagerClient#processDrmInfo DrmManagerClient.processDrmInfo()} 23 * method is called, an instance of <code>DrmInfoStatus</code> is returned. 24 *<p> 25 * This class contains the {@link ProcessedData} object, which can be used 26 * to instantiate a {@link DrmRights} object during license acquisition. 27 * 28 * @deprecated Please use {@link android.media.MediaDrm} 29 */ 30 @Deprecated 31 public class DrmInfoStatus { 32 // The following status code constants must be in sync with DrmInfoStatus.cpp 33 // Please update isValidStatusCode() if more status codes are added. 34 /** 35 * Indicate successful communication. 36 */ 37 public static final int STATUS_OK = 1; 38 39 /** 40 * Indicate failed communication. 41 */ 42 public static final int STATUS_ERROR = 2; 43 44 /** 45 * The status of the communication. Must be one of the defined status 46 * constants above. 47 */ 48 public final int statusCode; 49 /** 50 * The type of DRM information processed. Must be one of the valid type 51 * constants defined in {@link DrmInfoRequest}. 52 */ 53 public final int infoType; 54 /** 55 * The MIME type of the content. Must not be null or an empty string. 56 */ 57 public final String mimeType; 58 /** 59 * The processed data. It is optional and thus could be null. When it 60 * is null, it indicates that a particular call to 61 * {@link DrmManagerClient#processDrmInfo DrmManagerClient.processDrmInfo()} 62 * does not return any additional useful information except for the status code. 63 */ 64 public final ProcessedData data; 65 66 /** 67 * Creates a <code>DrmInfoStatus</code> object with the specified parameters. 68 * 69 * @param statusCode The status of the communication. Must be one of the defined 70 * status constants above. 71 * @param infoType The type of the DRM information processed. Must be a valid 72 * type for {@link DrmInfoRequest}. 73 * @param data The processed data. 74 * @param mimeType The MIME type. 75 */ DrmInfoStatus(int statusCode, int infoType, ProcessedData data, String mimeType)76 public DrmInfoStatus(int statusCode, int infoType, ProcessedData data, String mimeType) { 77 if (!DrmInfoRequest.isValidType(infoType)) { 78 throw new IllegalArgumentException("infoType: " + infoType); 79 } 80 81 if (!isValidStatusCode(statusCode)) { 82 throw new IllegalArgumentException("Unsupported status code: " + statusCode); 83 } 84 85 if (mimeType == null || mimeType == "") { 86 throw new IllegalArgumentException("mimeType is null or an empty string"); 87 } 88 89 this.statusCode = statusCode; 90 this.infoType = infoType; 91 this.data = data; 92 this.mimeType = mimeType; 93 } 94 isValidStatusCode(int statusCode)95 private boolean isValidStatusCode(int statusCode) { 96 return statusCode == STATUS_OK || statusCode == STATUS_ERROR; 97 } 98 } 99 100