• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  * A base class that is used to send asynchronous event information from the DRM framework.
23  *
24  * @deprecated Please use {@link android.media.MediaDrm}
25  */
26 @Deprecated
27 public class DrmEvent {
28 
29     // Please do not add type constants in this class. More event type constants
30     // should go to DrmInfoEvent or DrmErrorEvent classes.
31 
32     /**
33      * All of the rights information associated with all DRM schemes have been successfully removed.
34      */
35     public static final int TYPE_ALL_RIGHTS_REMOVED = 1001;
36     /**
37      * The given DRM information has been successfully processed.
38      */
39     public static final int TYPE_DRM_INFO_PROCESSED = 1002;
40     /**
41      * The key that is used in the <code>attributes</code> HashMap to pass the return status.
42      */
43     public static final String DRM_INFO_STATUS_OBJECT = "drm_info_status_object";
44     /**
45      * The key that is used in the <code>attributes</code> HashMap to pass the
46      * {@link DrmInfo} object.
47      */
48     public static final String DRM_INFO_OBJECT = "drm_info_object";
49 
50     private final int mUniqueId;
51     private final int mType;
52     private String mMessage = "";
53 
54     private HashMap<String, Object> mAttributes = new HashMap<String, Object>();
55 
56     /**
57      * Creates a <code>DrmEvent</code> object with the specified parameters.
58      *
59      * @param uniqueId Unique session identifier.
60      * @param type Type of information.
61      * @param message Message description.
62      * @param attributes Attributes for extensible information.
63      */
DrmEvent(int uniqueId, int type, String message, HashMap<String, Object> attributes)64     protected DrmEvent(int uniqueId, int type, String message,
65                             HashMap<String, Object> attributes) {
66         mUniqueId = uniqueId;
67         mType = type;
68 
69         if (null != message) {
70             mMessage = message;
71         }
72 
73         if (null != attributes) {
74             mAttributes = attributes;
75         }
76     }
77 
78     /**
79      * Creates a <code>DrmEvent</code> object with the specified parameters.
80      *
81      * @param uniqueId Unique session identifier.
82      * @param type Type of information.
83      * @param message Message description.
84      */
DrmEvent(int uniqueId, int type, String message)85     protected DrmEvent(int uniqueId, int type, String message) {
86         mUniqueId = uniqueId;
87         mType = type;
88 
89         if (null != message) {
90             mMessage = message;
91         }
92     }
93 
94     /**
95      * Retrieves the unique session identifier associated with this object.
96      *
97      * @return The unique session identifier.
98      */
getUniqueId()99     public int getUniqueId() {
100         return mUniqueId;
101     }
102 
103     /**
104      * Retrieves the type of information that is associated with this object.
105      *
106      * @return The type of information.
107      */
getType()108     public int getType() {
109         return mType;
110     }
111 
112     /**
113      * Retrieves the message description associated with this object.
114      *
115      * @return The message description.
116      */
getMessage()117     public String getMessage() {
118         return mMessage;
119     }
120 
121     /**
122      * Retrieves the attribute associated with the specified key.
123      *
124      * @return One of the attributes or null if no mapping for
125      * the key is found.
126      */
getAttribute(String key)127     public Object getAttribute(String key) {
128         return mAttributes.get(key);
129     }
130 }
131