blob: 836ae0a428ee098e98235d92d315b93d31be5e86 [file] [log] [blame]
aimitakeshi27ed8ad2010-07-29 10:12:27 +09001/*
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
26namespace android {
27
aimitakeshi27ed8ad2010-07-29 10:12:27 +090028class DrmConstraints;
Takeshi Aimi34738462010-11-16 13:56:11 +090029class DrmMetadata;
aimitakeshi27ed8ad2010-07-29 10:12:27 +090030class DrmRights;
31class DrmInfo;
32class DrmInfoStatus;
33class DrmInfoRequest;
34class DrmSupportInfo;
35class DrmConvertedStatus;
36class String8;
37class ActionDescription;
38
39/**
40 * This is the interface class for DRM Manager service.
41 *
42 */
43class IDrmManagerService : public IInterface
44{
45public:
46 enum {
Takeshi Aimi2272ee22010-09-20 23:40:41 +090047 ADD_UNIQUEID = IBinder::FIRST_CALL_TRANSACTION,
48 REMOVE_UNIQUEID,
Takeshi Aimie943f842010-10-08 23:05:49 +090049 ADD_CLIENT,
50 REMOVE_CLIENT,
aimitakeshi27ed8ad2010-07-29 10:12:27 +090051 SET_DRM_SERVICE_LISTENER,
aimitakeshi27ed8ad2010-07-29 10:12:27 +090052 INSTALL_DRM_ENGINE,
53 GET_CONSTRAINTS_FROM_CONTENT,
Takeshi Aimi34738462010-11-16 13:56:11 +090054 GET_METADATA_FROM_CONTENT,
aimitakeshi27ed8ad2010-07-29 10:12:27 +090055 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,
Takeshi Aimie943f842010-10-08 23:05:49 +090072 OPEN_DECRYPT_SESSION_FROM_URI,
Kei Takahashicba7b322012-01-18 17:10:19 +090073 OPEN_DECRYPT_SESSION_FOR_STREAMING,
aimitakeshi27ed8ad2010-07-29 10:12:27 +090074 CLOSE_DECRYPT_SESSION,
75 INITIALIZE_DECRYPT_UNIT,
76 DECRYPT,
77 FINALIZE_DECRYPT_UNIT,
78 PREAD
79 };
80
81public:
82 DECLARE_META_INTERFACE(DrmManagerService);
83
84public:
Gloria Wang8f001512011-07-21 15:10:22 -070085 virtual int addUniqueId(bool isNative) = 0;
Takeshi Aimi2272ee22010-09-20 23:40:41 +090086
87 virtual void removeUniqueId(int uniqueId) = 0;
88
Takeshi Aimie943f842010-10-08 23:05:49 +090089 virtual void addClient(int uniqueId) = 0;
aimitakeshi27ed8ad2010-07-29 10:12:27 +090090
Takeshi Aimie943f842010-10-08 23:05:49 +090091 virtual void removeClient(int uniqueId) = 0;
aimitakeshi27ed8ad2010-07-29 10:12:27 +090092
93 virtual status_t setDrmServiceListener(
94 int uniqueId, const sp<IDrmServiceListener>& infoListener) = 0;
95
aimitakeshi27ed8ad2010-07-29 10:12:27 +090096 virtual DrmConstraints* getConstraints(
97 int uniqueId, const String8* path, const int action) = 0;
98
Takeshi Aimi34738462010-11-16 13:56:11 +090099 virtual DrmMetadata* getMetadata(int uniqueId, const String8* path) = 0;
100
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900101 virtual bool canHandle(int uniqueId, const String8& path, const String8& mimeType) = 0;
102
103 virtual DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo) = 0;
104
105 virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest) = 0;
106
Takeshi Aimi2272ee22010-09-20 23:40:41 +0900107 virtual status_t saveRights(int uniqueId, const DrmRights& drmRights,
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900108 const String8& rightsPath, const String8& contentPath) = 0;
109
James Dongbf5b3b22012-07-30 17:57:39 -0700110 virtual String8 getOriginalMimeType(int uniqueId, const String8& path, int fd) = 0;
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900111
112 virtual int getDrmObjectType(
113 int uniqueId, const String8& path, const String8& mimeType) = 0;
114
115 virtual int checkRightsStatus(int uniqueId, const String8& path, int action) = 0;
116
Takeshi Aimi2272ee22010-09-20 23:40:41 +0900117 virtual status_t consumeRights(
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700118 int uniqueId, sp<DecryptHandle>& decryptHandle, int action, bool reserve) = 0;
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900119
Takeshi Aimi2272ee22010-09-20 23:40:41 +0900120 virtual status_t setPlaybackStatus(
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700121 int uniqueId, sp<DecryptHandle>& decryptHandle, int playbackStatus,
122 int64_t position) = 0;
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900123
124 virtual bool validateAction(
125 int uniqueId, const String8& path,
126 int action, const ActionDescription& description) = 0;
127
Takeshi Aimi2272ee22010-09-20 23:40:41 +0900128 virtual status_t removeRights(int uniqueId, const String8& path) = 0;
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900129
Takeshi Aimi2272ee22010-09-20 23:40:41 +0900130 virtual status_t removeAllRights(int uniqueId) = 0;
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900131
132 virtual int openConvertSession(int uniqueId, const String8& mimeType) = 0;
133
134 virtual DrmConvertedStatus* convertData(
135 int uniqueId, int convertId, const DrmBuffer* inputData) = 0;
136
137 virtual DrmConvertedStatus* closeConvertSession(int uniqueId, int convertId) = 0;
138
139 virtual status_t getAllSupportInfo(
140 int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) = 0;
141
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700142 virtual sp<DecryptHandle> openDecryptSession(
James Dong9d2f3862012-01-10 08:24:37 -0800143 int uniqueId, int fd, off64_t offset,
144 off64_t length, const char* mime) = 0;
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900145
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700146 virtual sp<DecryptHandle> openDecryptSession(
James Dong9d2f3862012-01-10 08:24:37 -0800147 int uniqueId, const char* uri, const char* mime) = 0;
Takeshi Aimie943f842010-10-08 23:05:49 +0900148
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700149 virtual sp<DecryptHandle> openDecryptSession(
Kei Takahashicba7b322012-01-18 17:10:19 +0900150 int uniqueId, const DrmBuffer& buf, const String8& mimeType) = 0;
151
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700152 virtual status_t closeDecryptSession(int uniqueId, sp<DecryptHandle>& decryptHandle) = 0;
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900153
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700154 virtual status_t initializeDecryptUnit(int uniqueId, sp<DecryptHandle>& decryptHandle,
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900155 int decryptUnitId, const DrmBuffer* headerInfo) = 0;
156
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700157 virtual status_t decrypt(int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId,
Takeshi Aimi2272ee22010-09-20 23:40:41 +0900158 const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) = 0;
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900159
Takeshi Aimi2272ee22010-09-20 23:40:41 +0900160 virtual status_t finalizeDecryptUnit(
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700161 int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId) = 0;
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900162
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700163 virtual ssize_t pread(int uniqueId, sp<DecryptHandle>& decryptHandle,
Gloria Wanga2cd44c2010-11-19 15:19:36 -0800164 void* buffer, ssize_t numBytes,off64_t offset) = 0;
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900165};
166
167/**
168 * This is the Binder implementation class for DRM Manager service.
169 */
170class BpDrmManagerService: public BpInterface<IDrmManagerService>
171{
172public:
Chih-Hung Hsieh8c0164c2016-08-09 14:20:59 -0700173 explicit BpDrmManagerService(const sp<IBinder>& impl)
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900174 : BpInterface<IDrmManagerService>(impl) {}
175
Gloria Wang8f001512011-07-21 15:10:22 -0700176 virtual int addUniqueId(bool isNative);
Takeshi Aimi2272ee22010-09-20 23:40:41 +0900177
178 virtual void removeUniqueId(int uniqueId);
179
Takeshi Aimie943f842010-10-08 23:05:49 +0900180 virtual void addClient(int uniqueId);
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900181
Takeshi Aimie943f842010-10-08 23:05:49 +0900182 virtual void removeClient(int uniqueId);
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900183
184 virtual status_t setDrmServiceListener(
185 int uniqueId, const sp<IDrmServiceListener>& infoListener);
186
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900187 virtual DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action);
188
Takeshi Aimi34738462010-11-16 13:56:11 +0900189 virtual DrmMetadata* getMetadata(int uniqueId, const String8* path);
190
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900191 virtual bool canHandle(int uniqueId, const String8& path, const String8& mimeType);
192
193 virtual DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo);
194
195 virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest);
196
Takeshi Aimi2272ee22010-09-20 23:40:41 +0900197 virtual status_t saveRights(int uniqueId, const DrmRights& drmRights,
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900198 const String8& rightsPath, const String8& contentPath);
199
James Dongbf5b3b22012-07-30 17:57:39 -0700200 virtual String8 getOriginalMimeType(int uniqueId, const String8& path, int fd);
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900201
202 virtual int getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType);
203
204 virtual int checkRightsStatus(int uniqueId, const String8& path, int action);
205
Takeshi Aimi2272ee22010-09-20 23:40:41 +0900206 virtual status_t consumeRights(
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700207 int uniqueId, sp<DecryptHandle>& decryptHandle, int action, bool reserve);
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900208
Takeshi Aimi2272ee22010-09-20 23:40:41 +0900209 virtual status_t setPlaybackStatus(
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700210 int uniqueId, sp<DecryptHandle>& decryptHandle, int playbackStatus, int64_t position);
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900211
212 virtual bool validateAction(
213 int uniqueId, const String8& path, int action, const ActionDescription& description);
214
Takeshi Aimi2272ee22010-09-20 23:40:41 +0900215 virtual status_t removeRights(int uniqueId, const String8& path);
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900216
Takeshi Aimi2272ee22010-09-20 23:40:41 +0900217 virtual status_t removeAllRights(int uniqueId);
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900218
219 virtual int openConvertSession(int uniqueId, const String8& mimeType);
220
221 virtual DrmConvertedStatus* convertData(
222 int uniqueId, int convertId, const DrmBuffer* inputData);
223
224 virtual DrmConvertedStatus* closeConvertSession(int uniqueId, int convertId);
225
226 virtual status_t getAllSupportInfo(
227 int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
228
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700229 virtual sp<DecryptHandle> openDecryptSession(
James Dong9d2f3862012-01-10 08:24:37 -0800230 int uniqueId, int fd, off64_t offset, off64_t length,
231 const char* mime);
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900232
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700233 virtual sp<DecryptHandle> openDecryptSession(
James Dong9d2f3862012-01-10 08:24:37 -0800234 int uniqueId, const char* uri, const char* mime);
Takeshi Aimie943f842010-10-08 23:05:49 +0900235
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700236 virtual sp<DecryptHandle> openDecryptSession(
Kei Takahashicba7b322012-01-18 17:10:19 +0900237 int uniqueId, const DrmBuffer& buf, const String8& mimeType);
238
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700239 virtual status_t closeDecryptSession(int uniqueId, sp<DecryptHandle>& decryptHandle);
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900240
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700241 virtual status_t initializeDecryptUnit(int uniqueId, sp<DecryptHandle>& decryptHandle,
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900242 int decryptUnitId, const DrmBuffer* headerInfo);
243
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700244 virtual status_t decrypt(int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId,
Takeshi Aimi2272ee22010-09-20 23:40:41 +0900245 const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900246
Takeshi Aimi2272ee22010-09-20 23:40:41 +0900247 virtual status_t finalizeDecryptUnit(
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700248 int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId);
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900249
Jeff Tinker5d49bef2018-10-03 23:01:09 -0700250 virtual ssize_t pread(int uniqueId, sp<DecryptHandle>& decryptHandle,
Gloria Wanga2cd44c2010-11-19 15:19:36 -0800251 void* buffer, ssize_t numBytes, off64_t offset);
aimitakeshi27ed8ad2010-07-29 10:12:27 +0900252};
253
254/**
255 * This is the Binder implementation class for DRM Manager service.
256 */
257class BnDrmManagerService: public BnInterface<IDrmManagerService>
258{
259public:
260 virtual status_t onTransact(
261 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0);
262};
263
264};
265
266#endif /* __IDRM_MANAGER_SERVICE_H__ */
267