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 import java.util.HashMap; 20 21 /** 22 * An entity class that is passed to the 23 * {@link DrmManagerClient.OnInfoListener#onInfo onInfo()} callback. 24 * 25 * @deprecated Please use {@link android.media.MediaDrm} 26 */ 27 @Deprecated 28 public class DrmInfoEvent extends DrmEvent { 29 30 // Please add newly defined type constants to the end of the list, 31 // and modify checkTypeValidity() accordingly. 32 33 /** 34 * The registration has already been done by another account ID. 35 */ 36 public static final int TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT = 1; 37 /** 38 * The rights need to be removed completely. 39 */ 40 public static final int TYPE_REMOVE_RIGHTS = 2; 41 /** 42 * The rights have been successfully downloaded and installed. 43 */ 44 public static final int TYPE_RIGHTS_INSTALLED = 3; 45 /** 46 * The rights object is being delivered to the device. You must wait before 47 * calling {@link DrmManagerClient#acquireRights acquireRights()} again. 48 */ 49 public static final int TYPE_WAIT_FOR_RIGHTS = 4; 50 /** 51 * The registration has already been done for the given account. 52 */ 53 public static final int TYPE_ACCOUNT_ALREADY_REGISTERED = 5; 54 /** 55 * The rights have been removed. 56 */ 57 public static final int TYPE_RIGHTS_REMOVED = 6; 58 59 // Add more type constants here... 60 61 // FIXME: 62 // We may want to add a user-defined type constant, such as 63 // TYPE_VENDOR_SPECIFIC, to take care vendor specific use 64 // cases. 65 66 /** 67 * Creates a <code>DrmInfoEvent</code> object with the specified parameters. 68 * 69 * @param uniqueId Unique session identifier. 70 * @param type Type of the event. Must be any of the event types defined above, 71 * or the constants defined in {@link DrmEvent}. 72 * @param message Message description. It can be null. 73 */ DrmInfoEvent(int uniqueId, int type, String message)74 public DrmInfoEvent(int uniqueId, int type, String message) { 75 super(uniqueId, type, message); 76 checkTypeValidity(type); 77 } 78 79 /** 80 * Creates a <code>DrmInfoEvent</code> object with the specified parameters. 81 * 82 * @param uniqueId Unique session identifier. 83 * @param type Type of the event. Must be any of the event types defined above, 84 * or the constants defined in {@link DrmEvent} 85 * @param message Message description. It can be null. 86 * @param attributes Attributes for extensible information. Could be any 87 * information provided by the plug-in. 88 */ DrmInfoEvent(int uniqueId, int type, String message, HashMap<String, Object> attributes)89 public DrmInfoEvent(int uniqueId, int type, String message, 90 HashMap<String, Object> attributes) { 91 super(uniqueId, type, message, attributes); 92 checkTypeValidity(type); 93 } 94 95 /* 96 * Check the validity of the given type. 97 * To overcome a design flaw, we need also accept the type constants 98 * defined in super class, DrmEvent. 99 */ checkTypeValidity(int type)100 private void checkTypeValidity(int type) { 101 if (type < TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT || 102 type > TYPE_RIGHTS_REMOVED) { 103 104 if (type != TYPE_ALL_RIGHTS_REMOVED && 105 type != TYPE_DRM_INFO_PROCESSED) { 106 final String msg = "Unsupported type: " + type; 107 throw new IllegalArgumentException(msg); 108 } 109 } 110 } 111 } 112 113