aimitakeshi | d074e30 | 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 | |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 17 | //#define LOG_NDEBUG 0 |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 18 | #define LOG_TAG "DrmManagerService(Native)" |
| 19 | #include <utils/Log.h> |
| 20 | |
| 21 | #include <errno.h> |
| 22 | #include <utils/threads.h> |
| 23 | #include <binder/IServiceManager.h> |
| 24 | #include <sys/stat.h> |
| 25 | #include "DrmManagerService.h" |
| 26 | #include "DrmManager.h" |
| 27 | |
| 28 | using namespace android; |
| 29 | |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 30 | void DrmManagerService::instantiate() { |
| 31 | LOGV("instantiate"); |
Takeshi Aimi | c7b3ccc | 2010-10-08 23:05:49 +0900 | [diff] [blame^] | 32 | defaultServiceManager()->addService(String16("drm.drmManager"), new DrmManagerService()); |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 33 | } |
| 34 | |
Takeshi Aimi | c7b3ccc | 2010-10-08 23:05:49 +0900 | [diff] [blame^] | 35 | DrmManagerService::DrmManagerService() : |
| 36 | mDrmManager(NULL) { |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 37 | LOGV("created"); |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 38 | mDrmManager = new DrmManager(); |
Takeshi Aimi | c7b3ccc | 2010-10-08 23:05:49 +0900 | [diff] [blame^] | 39 | mDrmManager->loadPlugIns(); |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | DrmManagerService::~DrmManagerService() { |
| 43 | LOGV("Destroyed"); |
Takeshi Aimi | c7b3ccc | 2010-10-08 23:05:49 +0900 | [diff] [blame^] | 44 | mDrmManager->unloadPlugIns(); |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 45 | delete mDrmManager; mDrmManager = NULL; |
| 46 | } |
| 47 | |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 48 | int DrmManagerService::addUniqueId(int uniqueId) { |
| 49 | return mDrmManager->addUniqueId(uniqueId); |
| 50 | } |
| 51 | |
| 52 | void DrmManagerService::removeUniqueId(int uniqueId) { |
| 53 | mDrmManager->removeUniqueId(uniqueId); |
| 54 | } |
| 55 | |
Takeshi Aimi | c7b3ccc | 2010-10-08 23:05:49 +0900 | [diff] [blame^] | 56 | void DrmManagerService::addClient(int uniqueId) { |
| 57 | mDrmManager->addClient(uniqueId); |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 58 | } |
| 59 | |
Takeshi Aimi | c7b3ccc | 2010-10-08 23:05:49 +0900 | [diff] [blame^] | 60 | void DrmManagerService::removeClient(int uniqueId) { |
| 61 | mDrmManager->removeClient(uniqueId); |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | status_t DrmManagerService::setDrmServiceListener( |
| 65 | int uniqueId, const sp<IDrmServiceListener>& drmServiceListener) { |
| 66 | LOGV("Entering setDrmServiceListener"); |
| 67 | mDrmManager->setDrmServiceListener(uniqueId, drmServiceListener); |
| 68 | return DRM_NO_ERROR; |
| 69 | } |
| 70 | |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 71 | status_t DrmManagerService::installDrmEngine(int uniqueId, const String8& drmEngineFile) { |
| 72 | LOGV("Entering installDrmEngine"); |
| 73 | return mDrmManager->installDrmEngine(uniqueId, drmEngineFile); |
| 74 | } |
| 75 | |
| 76 | DrmConstraints* DrmManagerService::getConstraints( |
| 77 | int uniqueId, const String8* path, const int action) { |
| 78 | LOGV("Entering getConstraints from content"); |
| 79 | return mDrmManager->getConstraints(uniqueId, path, action); |
| 80 | } |
| 81 | |
| 82 | bool DrmManagerService::canHandle(int uniqueId, const String8& path, const String8& mimeType) { |
| 83 | LOGV("Entering canHandle"); |
| 84 | return mDrmManager->canHandle(uniqueId, path, mimeType); |
| 85 | } |
| 86 | |
| 87 | DrmInfoStatus* DrmManagerService::processDrmInfo(int uniqueId, const DrmInfo* drmInfo) { |
| 88 | LOGV("Entering processDrmInfo"); |
| 89 | return mDrmManager->processDrmInfo(uniqueId, drmInfo); |
| 90 | } |
| 91 | |
| 92 | DrmInfo* DrmManagerService::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) { |
| 93 | LOGV("Entering acquireDrmInfo"); |
| 94 | return mDrmManager->acquireDrmInfo(uniqueId, drmInfoRequest); |
| 95 | } |
| 96 | |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 97 | status_t DrmManagerService::saveRights( |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 98 | int uniqueId, const DrmRights& drmRights, |
| 99 | const String8& rightsPath, const String8& contentPath) { |
| 100 | LOGV("Entering saveRights"); |
| 101 | return mDrmManager->saveRights(uniqueId, drmRights, rightsPath, contentPath); |
| 102 | } |
| 103 | |
| 104 | String8 DrmManagerService::getOriginalMimeType(int uniqueId, const String8& path) { |
| 105 | LOGV("Entering getOriginalMimeType"); |
| 106 | return mDrmManager->getOriginalMimeType(uniqueId, path); |
| 107 | } |
| 108 | |
| 109 | int DrmManagerService::getDrmObjectType( |
| 110 | int uniqueId, const String8& path, const String8& mimeType) { |
| 111 | LOGV("Entering getDrmObjectType"); |
| 112 | return mDrmManager->getDrmObjectType(uniqueId, path, mimeType); |
| 113 | } |
| 114 | |
| 115 | int DrmManagerService::checkRightsStatus( |
| 116 | int uniqueId, const String8& path, int action) { |
| 117 | LOGV("Entering checkRightsStatus"); |
| 118 | return mDrmManager->checkRightsStatus(uniqueId, path, action); |
| 119 | } |
| 120 | |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 121 | status_t DrmManagerService::consumeRights( |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 122 | int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) { |
| 123 | LOGV("Entering consumeRights"); |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 124 | return mDrmManager->consumeRights(uniqueId, decryptHandle, action, reserve); |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 125 | } |
| 126 | |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 127 | status_t DrmManagerService::setPlaybackStatus( |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 128 | int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) { |
| 129 | LOGV("Entering setPlaybackStatus"); |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 130 | return mDrmManager->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position); |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | bool DrmManagerService::validateAction( |
| 134 | int uniqueId, const String8& path, |
| 135 | int action, const ActionDescription& description) { |
| 136 | LOGV("Entering validateAction"); |
| 137 | return mDrmManager->validateAction(uniqueId, path, action, description); |
| 138 | } |
| 139 | |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 140 | status_t DrmManagerService::removeRights(int uniqueId, const String8& path) { |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 141 | LOGV("Entering removeRights"); |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 142 | return mDrmManager->removeRights(uniqueId, path); |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 143 | } |
| 144 | |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 145 | status_t DrmManagerService::removeAllRights(int uniqueId) { |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 146 | LOGV("Entering removeAllRights"); |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 147 | return mDrmManager->removeAllRights(uniqueId); |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | int DrmManagerService::openConvertSession(int uniqueId, const String8& mimeType) { |
| 151 | LOGV("Entering openConvertSession"); |
| 152 | return mDrmManager->openConvertSession(uniqueId, mimeType); |
| 153 | } |
| 154 | |
| 155 | DrmConvertedStatus* DrmManagerService::convertData( |
| 156 | int uniqueId, int convertId, const DrmBuffer* inputData) { |
| 157 | LOGV("Entering convertData"); |
| 158 | return mDrmManager->convertData(uniqueId, convertId, inputData); |
| 159 | } |
| 160 | |
| 161 | DrmConvertedStatus* DrmManagerService::closeConvertSession(int uniqueId, int convertId) { |
| 162 | LOGV("Entering closeConvertSession"); |
| 163 | return mDrmManager->closeConvertSession(uniqueId, convertId); |
| 164 | } |
| 165 | |
| 166 | status_t DrmManagerService::getAllSupportInfo( |
| 167 | int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) { |
| 168 | LOGV("Entering getAllSupportInfo"); |
| 169 | return mDrmManager->getAllSupportInfo(uniqueId, length, drmSupportInfoArray); |
| 170 | } |
| 171 | |
| 172 | DecryptHandle* DrmManagerService::openDecryptSession( |
| 173 | int uniqueId, int fd, int offset, int length) { |
| 174 | LOGV("Entering DrmManagerService::openDecryptSession"); |
| 175 | return mDrmManager->openDecryptSession(uniqueId, fd, offset, length); |
| 176 | } |
| 177 | |
Takeshi Aimi | c7b3ccc | 2010-10-08 23:05:49 +0900 | [diff] [blame^] | 178 | DecryptHandle* DrmManagerService::openDecryptSession( |
| 179 | int uniqueId, const char* uri) { |
| 180 | LOGV("Entering DrmManagerService::openDecryptSession with uri"); |
| 181 | return mDrmManager->openDecryptSession(uniqueId, uri); |
| 182 | } |
| 183 | |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 184 | status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 185 | LOGV("Entering closeDecryptSession"); |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 186 | return mDrmManager->closeDecryptSession(uniqueId, decryptHandle); |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 187 | } |
| 188 | |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 189 | status_t DrmManagerService::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 190 | int decryptUnitId, const DrmBuffer* headerInfo) { |
| 191 | LOGV("Entering initializeDecryptUnit"); |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 192 | return mDrmManager->initializeDecryptUnit(uniqueId,decryptHandle, decryptUnitId, headerInfo); |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 193 | } |
| 194 | |
| 195 | status_t DrmManagerService::decrypt( |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 196 | int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, |
| 197 | const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 198 | LOGV("Entering decrypt"); |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 199 | return mDrmManager->decrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV); |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 200 | } |
| 201 | |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 202 | status_t DrmManagerService::finalizeDecryptUnit( |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 203 | int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) { |
| 204 | LOGV("Entering finalizeDecryptUnit"); |
Takeshi Aimi | dc549d6 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 205 | return mDrmManager->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId); |
aimitakeshi | d074e30 | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle, |
| 209 | void* buffer, ssize_t numBytes, off_t offset) { |
| 210 | LOGV("Entering pread"); |
| 211 | return mDrmManager->pread(uniqueId, decryptHandle, buffer, numBytes, offset); |
| 212 | } |
| 213 | |