• 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 #ifndef __IDRM_MANAGER_SERVICE_H__
18 #define __IDRM_MANAGER_SERVICE_H__
19 
20 #include <utils/RefBase.h>
21 #include <binder/IInterface.h>
22 #include <binder/Parcel.h>
23 #include <drm/drm_framework_common.h>
24 #include "IDrmServiceListener.h"
25 
26 namespace android {
27 
28 class DrmConstraints;
29 class DrmMetadata;
30 class DrmRights;
31 class DrmInfo;
32 class DrmInfoStatus;
33 class DrmInfoRequest;
34 class DrmSupportInfo;
35 class DrmConvertedStatus;
36 class String8;
37 class ActionDescription;
38 
39 /**
40  * This is the interface class for DRM Manager service.
41  *
42  */
43 class IDrmManagerService : public IInterface
44 {
45 public:
46     enum {
47         ADD_UNIQUEID = IBinder::FIRST_CALL_TRANSACTION,
48         REMOVE_UNIQUEID,
49         ADD_CLIENT,
50         REMOVE_CLIENT,
51         SET_DRM_SERVICE_LISTENER,
52         INSTALL_DRM_ENGINE,
53         GET_CONSTRAINTS_FROM_CONTENT,
54         GET_METADATA_FROM_CONTENT,
55         CAN_HANDLE,
56         PROCESS_DRM_INFO,
57         ACQUIRE_DRM_INFO,
58         SAVE_RIGHTS,
59         GET_ORIGINAL_MIMETYPE,
60         GET_DRM_OBJECT_TYPE,
61         CHECK_RIGHTS_STATUS,
62         CONSUME_RIGHTS,
63         SET_PLAYBACK_STATUS,
64         VALIDATE_ACTION,
65         REMOVE_RIGHTS,
66         REMOVE_ALL_RIGHTS,
67         OPEN_CONVERT_SESSION,
68         CONVERT_DATA,
69         CLOSE_CONVERT_SESSION,
70         GET_ALL_SUPPORT_INFO,
71         OPEN_DECRYPT_SESSION,
72         OPEN_DECRYPT_SESSION_FROM_URI,
73         OPEN_DECRYPT_SESSION_FOR_STREAMING,
74         CLOSE_DECRYPT_SESSION,
75         INITIALIZE_DECRYPT_UNIT,
76         DECRYPT,
77         FINALIZE_DECRYPT_UNIT,
78         PREAD
79     };
80 
81 public:
82     DECLARE_META_INTERFACE(DrmManagerService);
83 
84 public:
85     virtual int addUniqueId(bool isNative) = 0;
86 
87     virtual void removeUniqueId(int uniqueId) = 0;
88 
89     virtual void addClient(int uniqueId) = 0;
90 
91     virtual void removeClient(int uniqueId) = 0;
92 
93     virtual status_t setDrmServiceListener(
94             int uniqueId, const sp<IDrmServiceListener>& infoListener) = 0;
95 
96     virtual status_t installDrmEngine(int uniqueId, const String8& drmEngineFile) = 0;
97 
98     virtual DrmConstraints* getConstraints(
99             int uniqueId, const String8* path, const int action) = 0;
100 
101     virtual DrmMetadata* getMetadata(int uniqueId, const String8* path) = 0;
102 
103     virtual bool canHandle(int uniqueId, const String8& path, const String8& mimeType) = 0;
104 
105     virtual DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo) = 0;
106 
107     virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest) = 0;
108 
109     virtual status_t saveRights(int uniqueId, const DrmRights& drmRights,
110             const String8& rightsPath, const String8& contentPath) = 0;
111 
112     virtual String8 getOriginalMimeType(int uniqueId, const String8& path, int fd) = 0;
113 
114     virtual int getDrmObjectType(
115             int uniqueId, const String8& path, const String8& mimeType) = 0;
116 
117     virtual int checkRightsStatus(int uniqueId, const String8& path, int action) = 0;
118 
119     virtual status_t consumeRights(
120             int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) = 0;
121 
122     virtual status_t setPlaybackStatus(
123             int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) = 0;
124 
125     virtual bool validateAction(
126             int uniqueId, const String8& path,
127             int action, const ActionDescription& description) = 0;
128 
129     virtual status_t removeRights(int uniqueId, const String8& path) = 0;
130 
131     virtual status_t removeAllRights(int uniqueId) = 0;
132 
133     virtual int openConvertSession(int uniqueId, const String8& mimeType) = 0;
134 
135     virtual DrmConvertedStatus* convertData(
136             int uniqueId, int convertId, const DrmBuffer* inputData) = 0;
137 
138     virtual DrmConvertedStatus* closeConvertSession(int uniqueId, int convertId) = 0;
139 
140     virtual status_t getAllSupportInfo(
141             int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) = 0;
142 
143     virtual DecryptHandle* openDecryptSession(
144                 int uniqueId, int fd, off64_t offset,
145                 off64_t length, const char* mime) = 0;
146 
147     virtual DecryptHandle* openDecryptSession(
148                 int uniqueId, const char* uri, const char* mime) = 0;
149 
150     virtual DecryptHandle* openDecryptSession(
151             int uniqueId, const DrmBuffer& buf, const String8& mimeType) = 0;
152 
153     virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
154 
155     virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
156             int decryptUnitId, const DrmBuffer* headerInfo) = 0;
157 
158     virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
159             const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) = 0;
160 
161     virtual status_t finalizeDecryptUnit(
162             int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
163 
164     virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
165             void* buffer, ssize_t numBytes,off64_t offset) = 0;
166 };
167 
168 /**
169  * This is the Binder implementation class for DRM Manager service.
170  */
171 class BpDrmManagerService: public BpInterface<IDrmManagerService>
172 {
173 public:
BpDrmManagerService(const sp<IBinder> & impl)174     BpDrmManagerService(const sp<IBinder>& impl)
175             : BpInterface<IDrmManagerService>(impl) {}
176 
177     virtual int addUniqueId(bool isNative);
178 
179     virtual void removeUniqueId(int uniqueId);
180 
181     virtual void addClient(int uniqueId);
182 
183     virtual void removeClient(int uniqueId);
184 
185     virtual status_t setDrmServiceListener(
186             int uniqueId, const sp<IDrmServiceListener>& infoListener);
187 
188     virtual status_t installDrmEngine(int uniqueId, const String8& drmEngineFile);
189 
190     virtual DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action);
191 
192     virtual DrmMetadata* getMetadata(int uniqueId, const String8* path);
193 
194     virtual bool canHandle(int uniqueId, const String8& path, const String8& mimeType);
195 
196     virtual DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo);
197 
198     virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest);
199 
200     virtual status_t saveRights(int uniqueId, const DrmRights& drmRights,
201             const String8& rightsPath, const String8& contentPath);
202 
203     virtual String8 getOriginalMimeType(int uniqueId, const String8& path, int fd);
204 
205     virtual int getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType);
206 
207     virtual int checkRightsStatus(int uniqueId, const String8& path, int action);
208 
209     virtual status_t consumeRights(
210             int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
211 
212     virtual status_t setPlaybackStatus(
213             int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position);
214 
215     virtual bool validateAction(
216             int uniqueId, const String8& path, int action, const ActionDescription& description);
217 
218     virtual status_t removeRights(int uniqueId, const String8& path);
219 
220     virtual status_t removeAllRights(int uniqueId);
221 
222     virtual int openConvertSession(int uniqueId, const String8& mimeType);
223 
224     virtual DrmConvertedStatus* convertData(
225             int uniqueId, int convertId, const DrmBuffer* inputData);
226 
227     virtual DrmConvertedStatus* closeConvertSession(int uniqueId, int convertId);
228 
229     virtual status_t getAllSupportInfo(
230             int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
231 
232     virtual DecryptHandle* openDecryptSession(
233                 int uniqueId, int fd, off64_t offset, off64_t length,
234                 const char* mime);
235 
236     virtual DecryptHandle* openDecryptSession(
237                 int uniqueId, const char* uri, const char* mime);
238 
239     virtual DecryptHandle* openDecryptSession(
240             int uniqueId, const DrmBuffer& buf, const String8& mimeType);
241 
242     virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
243 
244     virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
245             int decryptUnitId, const DrmBuffer* headerInfo);
246 
247     virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
248             const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
249 
250     virtual status_t finalizeDecryptUnit(
251             int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
252 
253     virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
254             void* buffer, ssize_t numBytes, off64_t offset);
255 };
256 
257 /**
258  * This is the Binder implementation class for DRM Manager service.
259  */
260 class BnDrmManagerService: public BnInterface<IDrmManagerService>
261 {
262 public:
263     virtual status_t onTransact(
264             uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0);
265 };
266 
267 };
268 
269 #endif /* __IDRM_MANAGER_SERVICE_H__ */
270 
271