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