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 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 17 | //#define LOG_NDEBUG 0 |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 18 | #define LOG_TAG "DrmManagerService(Native)" |
| 19 | #include <utils/Log.h> |
| 20 | |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 21 | #include <private/android_filesystem_config.h> |
James Dong | 8635b7b | 2011-03-14 17:01:38 -0700 | [diff] [blame] | 22 | #include <media/MemoryLeakTrackUtil.h> |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 23 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 24 | #include <errno.h> |
| 25 | #include <utils/threads.h> |
| 26 | #include <binder/IServiceManager.h> |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 27 | #include <binder/IPCThreadState.h> |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 28 | #include <sys/stat.h> |
| 29 | #include "DrmManagerService.h" |
| 30 | #include "DrmManager.h" |
| 31 | |
| 32 | using namespace android; |
| 33 | |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 34 | static Vector<uid_t> trustedUids; |
| 35 | |
| 36 | static bool isProtectedCallAllowed() { |
| 37 | // TODO |
| 38 | // Following implementation is just for reference. |
| 39 | // Each OEM manufacturer should implement/replace with their own solutions. |
| 40 | bool result = false; |
| 41 | |
| 42 | IPCThreadState* ipcState = IPCThreadState::self(); |
| 43 | uid_t uid = ipcState->getCallingUid(); |
| 44 | |
| 45 | for (unsigned int i = 0; i < trustedUids.size(); ++i) { |
| 46 | if (trustedUids[i] == uid) { |
| 47 | result = true; |
| 48 | break; |
| 49 | } |
| 50 | } |
| 51 | return result; |
| 52 | } |
| 53 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 54 | void DrmManagerService::instantiate() { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 55 | ALOGV("instantiate"); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 56 | defaultServiceManager()->addService(String16("drm.drmManager"), new DrmManagerService()); |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 57 | |
| 58 | if (0 >= trustedUids.size()) { |
| 59 | // TODO |
| 60 | // Following implementation is just for reference. |
| 61 | // Each OEM manufacturer should implement/replace with their own solutions. |
| 62 | |
| 63 | // Add trusted uids here |
| 64 | trustedUids.push(AID_MEDIA); |
| 65 | } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 66 | } |
| 67 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 68 | DrmManagerService::DrmManagerService() : |
| 69 | mDrmManager(NULL) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 70 | ALOGV("created"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 71 | mDrmManager = new DrmManager(); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 72 | mDrmManager->loadPlugIns(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | DrmManagerService::~DrmManagerService() { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 76 | ALOGV("Destroyed"); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 77 | mDrmManager->unloadPlugIns(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 78 | delete mDrmManager; mDrmManager = NULL; |
| 79 | } |
| 80 | |
Gloria Wang | 8f00151 | 2011-07-21 15:10:22 -0700 | [diff] [blame] | 81 | int DrmManagerService::addUniqueId(bool isNative) { |
| 82 | return mDrmManager->addUniqueId(isNative); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | void DrmManagerService::removeUniqueId(int uniqueId) { |
| 86 | mDrmManager->removeUniqueId(uniqueId); |
| 87 | } |
| 88 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 89 | void DrmManagerService::addClient(int uniqueId) { |
| 90 | mDrmManager->addClient(uniqueId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 91 | } |
| 92 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 93 | void DrmManagerService::removeClient(int uniqueId) { |
| 94 | mDrmManager->removeClient(uniqueId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | status_t DrmManagerService::setDrmServiceListener( |
| 98 | int uniqueId, const sp<IDrmServiceListener>& drmServiceListener) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 99 | ALOGV("Entering setDrmServiceListener"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 100 | mDrmManager->setDrmServiceListener(uniqueId, drmServiceListener); |
| 101 | return DRM_NO_ERROR; |
| 102 | } |
| 103 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 104 | status_t DrmManagerService::installDrmEngine(int uniqueId, const String8& drmEngineFile) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 105 | ALOGV("Entering installDrmEngine"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 106 | return mDrmManager->installDrmEngine(uniqueId, drmEngineFile); |
| 107 | } |
| 108 | |
| 109 | DrmConstraints* DrmManagerService::getConstraints( |
| 110 | int uniqueId, const String8* path, const int action) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 111 | ALOGV("Entering getConstraints from content"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 112 | return mDrmManager->getConstraints(uniqueId, path, action); |
| 113 | } |
| 114 | |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 115 | DrmMetadata* DrmManagerService::getMetadata(int uniqueId, const String8* path) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 116 | ALOGV("Entering getMetadata from content"); |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 117 | return mDrmManager->getMetadata(uniqueId, path); |
| 118 | } |
| 119 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 120 | bool DrmManagerService::canHandle(int uniqueId, const String8& path, const String8& mimeType) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 121 | ALOGV("Entering canHandle"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 122 | return mDrmManager->canHandle(uniqueId, path, mimeType); |
| 123 | } |
| 124 | |
| 125 | DrmInfoStatus* DrmManagerService::processDrmInfo(int uniqueId, const DrmInfo* drmInfo) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 126 | ALOGV("Entering processDrmInfo"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 127 | return mDrmManager->processDrmInfo(uniqueId, drmInfo); |
| 128 | } |
| 129 | |
| 130 | DrmInfo* DrmManagerService::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 131 | ALOGV("Entering acquireDrmInfo"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 132 | return mDrmManager->acquireDrmInfo(uniqueId, drmInfoRequest); |
| 133 | } |
| 134 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 135 | status_t DrmManagerService::saveRights( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 136 | int uniqueId, const DrmRights& drmRights, |
| 137 | const String8& rightsPath, const String8& contentPath) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 138 | ALOGV("Entering saveRights"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 139 | return mDrmManager->saveRights(uniqueId, drmRights, rightsPath, contentPath); |
| 140 | } |
| 141 | |
| 142 | String8 DrmManagerService::getOriginalMimeType(int uniqueId, const String8& path) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 143 | ALOGV("Entering getOriginalMimeType"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 144 | return mDrmManager->getOriginalMimeType(uniqueId, path); |
| 145 | } |
| 146 | |
| 147 | int DrmManagerService::getDrmObjectType( |
| 148 | int uniqueId, const String8& path, const String8& mimeType) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 149 | ALOGV("Entering getDrmObjectType"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 150 | return mDrmManager->getDrmObjectType(uniqueId, path, mimeType); |
| 151 | } |
| 152 | |
| 153 | int DrmManagerService::checkRightsStatus( |
| 154 | int uniqueId, const String8& path, int action) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 155 | ALOGV("Entering checkRightsStatus"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 156 | return mDrmManager->checkRightsStatus(uniqueId, path, action); |
| 157 | } |
| 158 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 159 | status_t DrmManagerService::consumeRights( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 160 | int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 161 | ALOGV("Entering consumeRights"); |
James Dong | 328745b | 2012-02-28 13:55:55 -0800 | [diff] [blame] | 162 | if (!isProtectedCallAllowed()) { |
| 163 | return DRM_ERROR_NO_PERMISSION; |
| 164 | } |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 165 | return mDrmManager->consumeRights(uniqueId, decryptHandle, action, reserve); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 166 | } |
| 167 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 168 | status_t DrmManagerService::setPlaybackStatus( |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 169 | int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 170 | ALOGV("Entering setPlaybackStatus"); |
James Dong | 328745b | 2012-02-28 13:55:55 -0800 | [diff] [blame] | 171 | if (!isProtectedCallAllowed()) { |
| 172 | return DRM_ERROR_NO_PERMISSION; |
| 173 | } |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 174 | return mDrmManager->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | bool DrmManagerService::validateAction( |
| 178 | int uniqueId, const String8& path, |
| 179 | int action, const ActionDescription& description) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 180 | ALOGV("Entering validateAction"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 181 | return mDrmManager->validateAction(uniqueId, path, action, description); |
| 182 | } |
| 183 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 184 | status_t DrmManagerService::removeRights(int uniqueId, const String8& path) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 185 | ALOGV("Entering removeRights"); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 186 | return mDrmManager->removeRights(uniqueId, path); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 187 | } |
| 188 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 189 | status_t DrmManagerService::removeAllRights(int uniqueId) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 190 | ALOGV("Entering removeAllRights"); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 191 | return mDrmManager->removeAllRights(uniqueId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | int DrmManagerService::openConvertSession(int uniqueId, const String8& mimeType) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 195 | ALOGV("Entering openConvertSession"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 196 | return mDrmManager->openConvertSession(uniqueId, mimeType); |
| 197 | } |
| 198 | |
| 199 | DrmConvertedStatus* DrmManagerService::convertData( |
| 200 | int uniqueId, int convertId, const DrmBuffer* inputData) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 201 | ALOGV("Entering convertData"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 202 | return mDrmManager->convertData(uniqueId, convertId, inputData); |
| 203 | } |
| 204 | |
| 205 | DrmConvertedStatus* DrmManagerService::closeConvertSession(int uniqueId, int convertId) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 206 | ALOGV("Entering closeConvertSession"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 207 | return mDrmManager->closeConvertSession(uniqueId, convertId); |
| 208 | } |
| 209 | |
| 210 | status_t DrmManagerService::getAllSupportInfo( |
| 211 | int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 212 | ALOGV("Entering getAllSupportInfo"); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 213 | return mDrmManager->getAllSupportInfo(uniqueId, length, drmSupportInfoArray); |
| 214 | } |
| 215 | |
| 216 | DecryptHandle* DrmManagerService::openDecryptSession( |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 217 | int uniqueId, int fd, off64_t offset, off64_t length, const char* mime) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 218 | ALOGV("Entering DrmManagerService::openDecryptSession"); |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 219 | if (isProtectedCallAllowed()) { |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 220 | return mDrmManager->openDecryptSession(uniqueId, fd, offset, length, mime); |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | return NULL; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 224 | } |
| 225 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 226 | DecryptHandle* DrmManagerService::openDecryptSession( |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 227 | int uniqueId, const char* uri, const char* mime) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 228 | ALOGV("Entering DrmManagerService::openDecryptSession with uri"); |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 229 | if (isProtectedCallAllowed()) { |
James Dong | 9d2f386 | 2012-01-10 08:24:37 -0800 | [diff] [blame] | 230 | return mDrmManager->openDecryptSession(uniqueId, uri, mime); |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | return NULL; |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 234 | } |
| 235 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 236 | status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 237 | ALOGV("Entering closeDecryptSession"); |
James Dong | 328745b | 2012-02-28 13:55:55 -0800 | [diff] [blame] | 238 | if (!isProtectedCallAllowed()) { |
| 239 | return DRM_ERROR_NO_PERMISSION; |
| 240 | } |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 241 | return mDrmManager->closeDecryptSession(uniqueId, decryptHandle); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 242 | } |
| 243 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 244 | status_t DrmManagerService::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 245 | int decryptUnitId, const DrmBuffer* headerInfo) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 246 | ALOGV("Entering initializeDecryptUnit"); |
James Dong | 328745b | 2012-02-28 13:55:55 -0800 | [diff] [blame] | 247 | if (!isProtectedCallAllowed()) { |
| 248 | return DRM_ERROR_NO_PERMISSION; |
| 249 | } |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 250 | return mDrmManager->initializeDecryptUnit(uniqueId,decryptHandle, decryptUnitId, headerInfo); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | status_t DrmManagerService::decrypt( |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 254 | int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, |
| 255 | const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 256 | ALOGV("Entering decrypt"); |
James Dong | 328745b | 2012-02-28 13:55:55 -0800 | [diff] [blame] | 257 | if (!isProtectedCallAllowed()) { |
| 258 | return DRM_ERROR_NO_PERMISSION; |
| 259 | } |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 260 | return mDrmManager->decrypt(uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 261 | } |
| 262 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 263 | status_t DrmManagerService::finalizeDecryptUnit( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 264 | int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 265 | ALOGV("Entering finalizeDecryptUnit"); |
James Dong | 328745b | 2012-02-28 13:55:55 -0800 | [diff] [blame] | 266 | if (!isProtectedCallAllowed()) { |
| 267 | return DRM_ERROR_NO_PERMISSION; |
| 268 | } |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 269 | return mDrmManager->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle, |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 273 | void* buffer, ssize_t numBytes, off64_t offset) { |
Steve Block | 3856b09 | 2011-10-20 11:56:00 +0100 | [diff] [blame] | 274 | ALOGV("Entering pread"); |
James Dong | 328745b | 2012-02-28 13:55:55 -0800 | [diff] [blame] | 275 | if (!isProtectedCallAllowed()) { |
| 276 | return DRM_ERROR_NO_PERMISSION; |
| 277 | } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 278 | return mDrmManager->pread(uniqueId, decryptHandle, buffer, numBytes, offset); |
| 279 | } |
| 280 | |
James Dong | 8635b7b | 2011-03-14 17:01:38 -0700 | [diff] [blame] | 281 | status_t DrmManagerService::dump(int fd, const Vector<String16>& args) |
| 282 | { |
| 283 | const size_t SIZE = 256; |
| 284 | char buffer[SIZE]; |
| 285 | String8 result; |
| 286 | if (checkCallingPermission(String16("android.permission.DUMP")) == false) { |
| 287 | snprintf(buffer, SIZE, "Permission Denial: " |
| 288 | "can't dump DrmManagerService from pid=%d, uid=%d\n", |
| 289 | IPCThreadState::self()->getCallingPid(), |
| 290 | IPCThreadState::self()->getCallingUid()); |
| 291 | result.append(buffer); |
| 292 | } else { |
| 293 | #if DRM_MEMORY_LEAK_TRACK |
| 294 | bool dumpMem = false; |
| 295 | for (size_t i = 0; i < args.size(); i++) { |
| 296 | if (args[i] == String16("-m")) { |
| 297 | dumpMem = true; |
| 298 | } |
| 299 | } |
| 300 | if (dumpMem) { |
| 301 | dumpMemoryAddresses(fd); |
| 302 | } |
| 303 | #endif |
| 304 | } |
| 305 | write(fd, result.string(), result.size()); |
| 306 | return NO_ERROR; |
| 307 | } |
| 308 | |