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  * Defines constants that are used by the DRM framework.
21  *
22  */
23 public class DrmStore {
24     /**
25      * Interface definition for the columns that represent DRM constraints.
26      * {@link android.drm.DrmManagerClient#getConstraints DrmManagerClient.getConstraints()}
27      * can be called by an application to find out the contraints on the
28      * {@link android.drm.DrmStore.Action actions} that can be performed
29      * on right-protected content. The constants defined in this interface
30      * represent three most common types of constraints: count-based,
31      * date-based, and duration-based. Two or more constraints can be used
32      * at the same time to represent more sophisticated constraints.
33      * In addition, user-defined constraint,
34      * {@link #EXTENDED_METADATA extended metadata}, can be
35      * used if these three types of constraints are not sufficient.
36      */
37     public interface ConstraintsColumns {
38         /**
39          * This is a count-based constraint. It represents the maximum
40          * repeat count that can be performed on an
41          * {@link android.drm.DrmStore.Action action}.
42          * <p>
43          * Type: INTEGER
44          */
45         public static final String MAX_REPEAT_COUNT = "max_repeat_count";
46 
47         /**
48          * This is a count-based constraint. It represents the remaining
49          * repeat count that can be performed on an
50          * {@link android.drm.DrmStore.Action action}.
51          * <p>
52          * Type: INTEGER
53          */
54         public static final String REMAINING_REPEAT_COUNT = "remaining_repeat_count";
55 
56         /**
57          * This is a date-based constraint. It represents the time before which
58          * an {@link android.drm.DrmStore.Action action} can be performed on
59          * the rights-protected content.
60          * <p>
61          * Type: TEXT
62          */
63         public static final String LICENSE_START_TIME = "license_start_time";
64 
65         /**
66          * This is a date-based constaint. It represents the time after which
67          * an {@link android.drm.DrmStore.Action action} can not be performed on
68          * the rights-protected content.
69          * <p>
70          * Type: TEXT
71          */
72         public static final String LICENSE_EXPIRY_TIME = "license_expiry_time";
73 
74         /**
75          * This is a duration-based constaint. It represents the available time left
76          * before the license expires.
77          * <p>
78          * Type: TEXT
79          */
80         public static final String LICENSE_AVAILABLE_TIME = "license_available_time";
81 
82         /**
83          * This is a user-defined constraint. It represents the additional constraint
84          * using extended metadata.
85          * <p>
86          * Type: TEXT
87          */
88         public static final String EXTENDED_METADATA = "extended_metadata";
89     }
90 
91     /**
92      * Defines DRM object types.
93      */
94     public static class DrmObjectType {
95         /**
96          * An unknown object type.
97          */
98         public static final int UNKNOWN = 0x00;
99         /**
100          * A rights-protected file object type.
101          */
102         public static final int CONTENT = 0x01;
103         /**
104          * A rights information object type.
105          */
106         public static final int RIGHTS_OBJECT = 0x02;
107         /**
108          * A trigger information object type.
109          */
110         public static final int TRIGGER_OBJECT = 0x03;
111 
112         /**
113          * @deprecated This class should have been an interface instead.
114          * The default constuctor should have not been exposed.
115          */
DrmObjectType()116         public DrmObjectType() {}
117     }
118 
119     /**
120      * Defines playback states for content.
121      */
122     public static class Playback {
123         /**
124          * Playback started.
125          */
126         public static final int START = 0x00;
127         /**
128          * Playback stopped.
129          */
130         public static final int STOP = 0x01;
131         /**
132          * Playback paused.
133          */
134         public static final int PAUSE = 0x02;
135         /**
136          * Playback resumed.
137          */
138         public static final int RESUME = 0x03;
139 
isValid(int playbackStatus)140         /* package */ static boolean isValid(int playbackStatus) {
141             boolean isValid = false;
142 
143             switch (playbackStatus) {
144                 case START:
145                 case STOP:
146                 case PAUSE:
147                 case RESUME:
148                     isValid = true;
149             }
150             return isValid;
151         }
152 
153         /**
154          * @deprecated This class should have been an interface instead.
155          * The default constuctor should have not been exposed.
156          */
Playback()157         public Playback() {}
158     }
159 
160     /**
161      * Defines actions that can be performed on rights-protected content.
162      */
163     public static class Action {
164         /**
165          * The default action.
166          */
167         public static final int DEFAULT = 0x00;
168         /**
169          * The rights-protected content can be played.
170          */
171         public static final int PLAY = 0x01;
172         /**
173          * The rights-protected content can be set as a ringtone.
174          */
175         public static final int RINGTONE = 0x02;
176         /**
177          * The rights-protected content can be transferred.
178          */
179         public static final int TRANSFER = 0x03;
180         /**
181          * The rights-protected content can be set as output.
182          */
183         public static final int OUTPUT = 0x04;
184         /**
185          * The rights-protected content can be previewed.
186          */
187         public static final int PREVIEW = 0x05;
188         /**
189          * The rights-protected content can be executed.
190          */
191         public static final int EXECUTE = 0x06;
192         /**
193          * The rights-protected content can be displayed.
194          */
195         public static final int DISPLAY = 0x07;
196 
isValid(int action)197         /* package */ static boolean isValid(int action) {
198             boolean isValid = false;
199 
200             switch (action) {
201                 case DEFAULT:
202                 case PLAY:
203                 case RINGTONE:
204                 case TRANSFER:
205                 case OUTPUT:
206                 case PREVIEW:
207                 case EXECUTE:
208                 case DISPLAY:
209                     isValid = true;
210             }
211             return isValid;
212         }
213 
214         /**
215          * @deprecated This class should have been an interface instead.
216          * The default constuctor should have not been exposed.
217          */
Action()218         public Action() {}
219     }
220 
221     /**
222      * Defines status notifications for digital rights.
223      */
224     public static class RightsStatus {
225         /**
226          * The digital rights are valid.
227          */
228         public static final int RIGHTS_VALID = 0x00;
229         /**
230          * The digital rights are invalid.
231          */
232         public static final int RIGHTS_INVALID = 0x01;
233         /**
234          * The digital rights have expired.
235          */
236         public static final int RIGHTS_EXPIRED = 0x02;
237         /**
238          * The digital rights have not been acquired for the rights-protected content.
239          */
240         public static final int RIGHTS_NOT_ACQUIRED = 0x03;
241 
242         /**
243          * @deprecated This class should have been an interface instead.
244          * The default constuctor should have not been exposed.
245          */
RightsStatus()246         public RightsStatus() {}
247     }
248 
249     /**
250      * @deprecated This class should have been an interface instead.
251      * The default constuctor should have not been exposed.
252      */
DrmStore()253     public DrmStore() {}
254 }
255 
256