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