aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 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 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 28 | class DrmConstraints; |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 29 | class DrmMetadata; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 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 { |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 47 | ADD_UNIQUEID = IBinder::FIRST_CALL_TRANSACTION, |
| 48 | REMOVE_UNIQUEID, |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 49 | ADD_CLIENT, |
| 50 | REMOVE_CLIENT, |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 51 | SET_DRM_SERVICE_LISTENER, |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 52 | INSTALL_DRM_ENGINE, |
| 53 | GET_CONSTRAINTS_FROM_CONTENT, |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 54 | GET_METADATA_FROM_CONTENT, |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 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, |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 72 | OPEN_DECRYPT_SESSION_FROM_URI, |
Kei Takahashi | cba7b32 | 2012-01-18 17:10:19 +0900 | [diff] [blame] | 73 | OPEN_DECRYPT_SESSION_FOR_STREAMING, |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 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: |
Gloria Wang | 8f00151 | 2011-07-21 15:10:22 -0700 | [diff] [blame] | 85 | virtual int addUniqueId(bool isNative) = 0; |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 86 | |
| 87 | virtual void removeUniqueId(int uniqueId) = 0; |
| 88 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 89 | virtual void addClient(int uniqueId) = 0; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 90 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 91 | virtual void removeClient(int uniqueId) = 0; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 92 | |
| 93 | virtual status_t setDrmServiceListener( |
| 94 | int uniqueId, const sp<IDrmServiceListener>& infoListener) = 0; |
| 95 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 96 | virtual DrmConstraints* getConstraints( |
| 97 | int uniqueId, const String8* path, const int action) = 0; |
| 98 | |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 99 | virtual DrmMetadata* getMetadata(int uniqueId, const String8* path) = 0; |
| 100 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 101 | 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 Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 107 | virtual status_t saveRights(int uniqueId, const DrmRights& drmRights, |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 108 | const String8& rightsPath, const String8& contentPath) = 0; |
| 109 | |
James Dong | bf5b3b2 | 2012-07-30 17:57:39 -0700 | [diff] [blame] | 110 | virtual String8 getOriginalMimeType(int uniqueId, const String8& path, int fd) = 0; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 111 | |
| 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 Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 117 | virtual status_t consumeRights( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 118 | int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) = 0; |
| 119 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 120 | virtual status_t setPlaybackStatus( |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 121 | int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) = 0; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 122 | |
| 123 | virtual bool validateAction( |
| 124 | int uniqueId, const String8& path, |
| 125 | int action, const ActionDescription& description) = 0; |
| 126 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 127 | virtual status_t removeRights(int uniqueId, const String8& path) = 0; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 128 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 129 | virtual status_t removeAllRights(int uniqueId) = 0; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 130 | |
| 131 | virtual int openConvertSession(int uniqueId, const String8& mimeType) = 0; |
| 132 | |
| 133 | virtual DrmConvertedStatus* convertData( |
| 134 | int uniqueId, int convertId, const DrmBuffer* inputData) = 0; |
| 135 | |
| 136 | virtual DrmConvertedStatus* closeConvertSession(int uniqueId, int convertId) = 0; |
| 137 | |
| 138 | virtual status_t getAllSupportInfo( |
| 139 | int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) = 0; |
| 140 | |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 141 | virtual DecryptHandle* openDecryptSession( |
| 142 | int uniqueId, int fd, off64_t offset, |
| 143 | off64_t length, const char* mime) = 0; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 144 | |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 145 | virtual DecryptHandle* openDecryptSession( |
| 146 | int uniqueId, const char* uri, const char* mime) = 0; |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 147 | |
Kei Takahashi | cba7b32 | 2012-01-18 17:10:19 +0900 | [diff] [blame] | 148 | virtual DecryptHandle* openDecryptSession( |
| 149 | int uniqueId, const DrmBuffer& buf, const String8& mimeType) = 0; |
| 150 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 151 | virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 152 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 153 | virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 154 | int decryptUnitId, const DrmBuffer* headerInfo) = 0; |
| 155 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 156 | virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, |
| 157 | const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) = 0; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 158 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 159 | virtual status_t finalizeDecryptUnit( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 160 | int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0; |
| 161 | |
| 162 | virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle, |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 163 | void* buffer, ssize_t numBytes,off64_t offset) = 0; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 164 | }; |
| 165 | |
| 166 | /** |
| 167 | * This is the Binder implementation class for DRM Manager service. |
| 168 | */ |
| 169 | class BpDrmManagerService: public BpInterface<IDrmManagerService> |
| 170 | { |
| 171 | public: |
Chih-Hung Hsieh | 8c0164c | 2016-08-09 14:20:59 -0700 | [diff] [blame^] | 172 | explicit BpDrmManagerService(const sp<IBinder>& impl) |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 173 | : BpInterface<IDrmManagerService>(impl) {} |
| 174 | |
Gloria Wang | 8f00151 | 2011-07-21 15:10:22 -0700 | [diff] [blame] | 175 | virtual int addUniqueId(bool isNative); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 176 | |
| 177 | virtual void removeUniqueId(int uniqueId); |
| 178 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 179 | virtual void addClient(int uniqueId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 180 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 181 | virtual void removeClient(int uniqueId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 182 | |
| 183 | virtual status_t setDrmServiceListener( |
| 184 | int uniqueId, const sp<IDrmServiceListener>& infoListener); |
| 185 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 186 | virtual DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action); |
| 187 | |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 188 | virtual DrmMetadata* getMetadata(int uniqueId, const String8* path); |
| 189 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 190 | virtual bool canHandle(int uniqueId, const String8& path, const String8& mimeType); |
| 191 | |
| 192 | virtual DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo); |
| 193 | |
| 194 | virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest); |
| 195 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 196 | virtual status_t saveRights(int uniqueId, const DrmRights& drmRights, |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 197 | const String8& rightsPath, const String8& contentPath); |
| 198 | |
James Dong | bf5b3b2 | 2012-07-30 17:57:39 -0700 | [diff] [blame] | 199 | virtual String8 getOriginalMimeType(int uniqueId, const String8& path, int fd); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 200 | |
| 201 | virtual int getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType); |
| 202 | |
| 203 | virtual int checkRightsStatus(int uniqueId, const String8& path, int action); |
| 204 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 205 | virtual status_t consumeRights( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 206 | int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve); |
| 207 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 208 | virtual status_t setPlaybackStatus( |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 209 | int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 210 | |
| 211 | virtual bool validateAction( |
| 212 | int uniqueId, const String8& path, int action, const ActionDescription& description); |
| 213 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 214 | virtual status_t removeRights(int uniqueId, const String8& path); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 215 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 216 | virtual status_t removeAllRights(int uniqueId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 217 | |
| 218 | virtual int openConvertSession(int uniqueId, const String8& mimeType); |
| 219 | |
| 220 | virtual DrmConvertedStatus* convertData( |
| 221 | int uniqueId, int convertId, const DrmBuffer* inputData); |
| 222 | |
| 223 | virtual DrmConvertedStatus* closeConvertSession(int uniqueId, int convertId); |
| 224 | |
| 225 | virtual status_t getAllSupportInfo( |
| 226 | int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray); |
| 227 | |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 228 | virtual DecryptHandle* openDecryptSession( |
| 229 | int uniqueId, int fd, off64_t offset, off64_t length, |
| 230 | const char* mime); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 231 | |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 232 | virtual DecryptHandle* openDecryptSession( |
| 233 | int uniqueId, const char* uri, const char* mime); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 234 | |
Kei Takahashi | cba7b32 | 2012-01-18 17:10:19 +0900 | [diff] [blame] | 235 | virtual DecryptHandle* openDecryptSession( |
| 236 | int uniqueId, const DrmBuffer& buf, const String8& mimeType); |
| 237 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 238 | virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 239 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 240 | virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 241 | int decryptUnitId, const DrmBuffer* headerInfo); |
| 242 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 243 | virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, |
| 244 | const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 245 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 246 | virtual status_t finalizeDecryptUnit( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 247 | int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId); |
| 248 | |
| 249 | virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle, |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 250 | void* buffer, ssize_t numBytes, off64_t offset); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 251 | }; |
| 252 | |
| 253 | /** |
| 254 | * This is the Binder implementation class for DRM Manager service. |
| 255 | */ |
| 256 | class BnDrmManagerService: public BnInterface<IDrmManagerService> |
| 257 | { |
| 258 | public: |
| 259 | virtual status_t onTransact( |
| 260 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); |
| 261 | }; |
| 262 | |
| 263 | }; |
| 264 | |
| 265 | #endif /* __IDRM_MANAGER_SERVICE_H__ */ |
| 266 | |