DrmStore.java revision 365ce1db339db53cd5afb118ff867fe940644e45
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
17package android.drm;
18
19/**
20 * Defines constants that are used by the DRM framework.
21 *
22 */
23public 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    /**
114     * Defines playback states for content.
115     */
116    public static class Playback {
117        /**
118         * Playback started.
119         */
120        public static final int START = 0x00;
121        /**
122         * Playback stopped.
123         */
124        public static final int STOP = 0x01;
125        /**
126         * Playback paused.
127         */
128        public static final int PAUSE = 0x02;
129        /**
130         * Playback resumed.
131         */
132        public static final int RESUME = 0x03;
133
134        /* package */ static boolean isValid(int playbackStatus) {
135            boolean isValid = false;
136
137            switch (playbackStatus) {
138                case START:
139                case STOP:
140                case PAUSE:
141                case RESUME:
142                    isValid = true;
143            }
144            return isValid;
145        }
146    }
147
148    /**
149     * Defines actions that can be performed on rights-protected content.
150     */
151    public static class Action {
152        /**
153         * The default action.
154         */
155        public static final int DEFAULT = 0x00;
156        /**
157         * The rights-protected content can be played.
158         */
159        public static final int PLAY = 0x01;
160        /**
161         * The rights-protected content can be set as a ringtone.
162         */
163        public static final int RINGTONE = 0x02;
164        /**
165         * The rights-protected content can be transferred.
166         */
167        public static final int TRANSFER = 0x03;
168        /**
169         * The rights-protected content can be set as output.
170         */
171        public static final int OUTPUT = 0x04;
172        /**
173         * The rights-protected content can be previewed.
174         */
175        public static final int PREVIEW = 0x05;
176        /**
177         * The rights-protected content can be executed.
178         */
179        public static final int EXECUTE = 0x06;
180        /**
181         * The rights-protected content can be displayed.
182         */
183        public static final int DISPLAY = 0x07;
184
185        /* package */ static boolean isValid(int action) {
186            boolean isValid = false;
187
188            switch (action) {
189                case DEFAULT:
190                case PLAY:
191                case RINGTONE:
192                case TRANSFER:
193                case OUTPUT:
194                case PREVIEW:
195                case EXECUTE:
196                case DISPLAY:
197                    isValid = true;
198            }
199            return isValid;
200        }
201    }
202
203    /**
204     * Defines status notifications for digital rights.
205     */
206    public static class RightsStatus {
207        /**
208         * The digital rights are valid.
209         */
210        public static final int RIGHTS_VALID = 0x00;
211        /**
212         * The digital rights are invalid.
213         */
214        public static final int RIGHTS_INVALID = 0x01;
215        /**
216         * The digital rights have expired.
217         */
218        public static final int RIGHTS_EXPIRED = 0x02;
219        /**
220         * The digital rights have not been acquired for the rights-protected content.
221         */
222        public static final int RIGHTS_NOT_ACQUIRED = 0x03;
223    }
224}
225
226