| 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 |  | 
 | 28 | class DrmContentIds; | 
 | 29 | class DrmConstraints; | 
 | 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, | 
 | 49 |         LOAD_PLUGINS, | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 50 |         LOAD_PLUGINS_FROM_PATH, | 
 | 51 |         SET_DRM_SERVICE_LISTENER, | 
 | 52 |         UNLOAD_PLUGINS, | 
 | 53 |         INSTALL_DRM_ENGINE, | 
 | 54 |         GET_CONSTRAINTS_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 |         CLOSE_DECRYPT_SESSION, | 
 | 73 |         INITIALIZE_DECRYPT_UNIT, | 
 | 74 |         DECRYPT, | 
 | 75 |         FINALIZE_DECRYPT_UNIT, | 
 | 76 |         PREAD | 
 | 77 |     }; | 
 | 78 |  | 
 | 79 | public: | 
 | 80 |     DECLARE_META_INTERFACE(DrmManagerService); | 
 | 81 |  | 
 | 82 | public: | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame^] | 83 |     virtual int addUniqueId(int uniqueId) = 0; | 
 | 84 |  | 
 | 85 |     virtual void removeUniqueId(int uniqueId) = 0; | 
 | 86 |  | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 87 |     virtual status_t loadPlugIns(int uniqueId) = 0; | 
 | 88 |  | 
 | 89 |     virtual status_t loadPlugIns(int uniqueId, const String8& plugInDirPath) = 0; | 
 | 90 |  | 
 | 91 |     virtual status_t setDrmServiceListener( | 
 | 92 |             int uniqueId, const sp<IDrmServiceListener>& infoListener) = 0; | 
 | 93 |  | 
 | 94 |     virtual status_t unloadPlugIns(int uniqueId) = 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 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 |  | 
 | 110 |     virtual String8 getOriginalMimeType(int uniqueId, const String8& path) = 0; | 
 | 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( | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 121 |             int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) = 0; | 
 | 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 |  | 
 | 141 |     virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length) = 0; | 
 | 142 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame^] | 143 |     virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0; | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 144 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame^] | 145 |     virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 146 |             int decryptUnitId, const DrmBuffer* headerInfo) = 0; | 
 | 147 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame^] | 148 |     virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, | 
 | 149 |             const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) = 0; | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 150 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame^] | 151 |     virtual status_t finalizeDecryptUnit( | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 152 |             int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0; | 
 | 153 |  | 
 | 154 |     virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle, | 
 | 155 |             void* buffer, ssize_t numBytes,off_t offset) = 0; | 
 | 156 | }; | 
 | 157 |  | 
 | 158 | /** | 
 | 159 |  * This is the Binder implementation class for DRM Manager service. | 
 | 160 |  */ | 
 | 161 | class BpDrmManagerService: public BpInterface<IDrmManagerService> | 
 | 162 | { | 
 | 163 | public: | 
 | 164 |     BpDrmManagerService(const sp<IBinder>& impl) | 
 | 165 |             : BpInterface<IDrmManagerService>(impl) {} | 
 | 166 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame^] | 167 |     virtual int addUniqueId(int uniqueId); | 
 | 168 |  | 
 | 169 |     virtual void removeUniqueId(int uniqueId); | 
 | 170 |  | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 171 |     virtual status_t loadPlugIns(int uniqueId); | 
 | 172 |  | 
 | 173 |     virtual status_t loadPlugIns(int uniqueId, const String8& plugInDirPath); | 
 | 174 |  | 
 | 175 |     virtual status_t setDrmServiceListener( | 
 | 176 |             int uniqueId, const sp<IDrmServiceListener>& infoListener); | 
 | 177 |  | 
 | 178 |     virtual status_t unloadPlugIns(int uniqueId); | 
 | 179 |  | 
 | 180 |     virtual status_t installDrmEngine(int uniqueId, const String8& drmEngineFile); | 
 | 181 |  | 
 | 182 |     virtual DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action); | 
 | 183 |  | 
 | 184 |     virtual bool canHandle(int uniqueId, const String8& path, const String8& mimeType); | 
 | 185 |  | 
 | 186 |     virtual DrmInfoStatus* processDrmInfo(int uniqueId, const DrmInfo* drmInfo); | 
 | 187 |  | 
 | 188 |     virtual DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInforequest); | 
 | 189 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame^] | 190 |     virtual status_t saveRights(int uniqueId, const DrmRights& drmRights, | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 191 |             const String8& rightsPath, const String8& contentPath); | 
 | 192 |  | 
 | 193 |     virtual String8 getOriginalMimeType(int uniqueId, const String8& path); | 
 | 194 |  | 
 | 195 |     virtual int getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType); | 
 | 196 |  | 
 | 197 |     virtual int checkRightsStatus(int uniqueId, const String8& path, int action); | 
 | 198 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame^] | 199 |     virtual status_t consumeRights( | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 200 |             int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve); | 
 | 201 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame^] | 202 |     virtual status_t setPlaybackStatus( | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 203 |             int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position); | 
 | 204 |  | 
 | 205 |     virtual bool validateAction( | 
 | 206 |             int uniqueId, const String8& path, int action, const ActionDescription& description); | 
 | 207 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame^] | 208 |     virtual status_t removeRights(int uniqueId, const String8& path); | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 209 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame^] | 210 |     virtual status_t removeAllRights(int uniqueId); | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 211 |  | 
 | 212 |     virtual int openConvertSession(int uniqueId, const String8& mimeType); | 
 | 213 |  | 
 | 214 |     virtual DrmConvertedStatus* convertData( | 
 | 215 |             int uniqueId, int convertId, const DrmBuffer* inputData); | 
 | 216 |  | 
 | 217 |     virtual DrmConvertedStatus* closeConvertSession(int uniqueId, int convertId); | 
 | 218 |  | 
 | 219 |     virtual status_t getAllSupportInfo( | 
 | 220 |             int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray); | 
 | 221 |  | 
 | 222 |     virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length); | 
 | 223 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame^] | 224 |     virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle); | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 225 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame^] | 226 |     virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 227 |             int decryptUnitId, const DrmBuffer* headerInfo); | 
 | 228 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame^] | 229 |     virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, | 
 | 230 |             const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV); | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 231 |  | 
| Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame^] | 232 |     virtual status_t finalizeDecryptUnit( | 
| aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 233 |             int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId); | 
 | 234 |  | 
 | 235 |     virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle, | 
 | 236 |             void* buffer, ssize_t numBytes, off_t offset); | 
 | 237 | }; | 
 | 238 |  | 
 | 239 | /** | 
 | 240 |  * This is the Binder implementation class for DRM Manager service. | 
 | 241 |  */ | 
 | 242 | class BnDrmManagerService: public BnInterface<IDrmManagerService> | 
 | 243 | { | 
 | 244 | public: | 
 | 245 |     virtual status_t onTransact( | 
 | 246 |             uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); | 
 | 247 | }; | 
 | 248 |  | 
 | 249 | }; | 
 | 250 |  | 
 | 251 | #endif /* __IDRM_MANAGER_SERVICE_H__ */ | 
 | 252 |  |