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 "DrmManager(Native)" |
| 19 | #include "utils/Log.h" |
| 20 | |
| 21 | #include <utils/String8.h> |
| 22 | #include <drm/DrmInfo.h> |
| 23 | #include <drm/DrmInfoEvent.h> |
| 24 | #include <drm/DrmRights.h> |
| 25 | #include <drm/DrmConstraints.h> |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 26 | #include <drm/DrmMetadata.h> |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 27 | #include <drm/DrmInfoStatus.h> |
| 28 | #include <drm/DrmInfoRequest.h> |
| 29 | #include <drm/DrmSupportInfo.h> |
| 30 | #include <drm/DrmConvertedStatus.h> |
| 31 | #include <IDrmEngine.h> |
| 32 | |
| 33 | #include "DrmManager.h" |
| 34 | #include "ReadWriteUtils.h" |
| 35 | |
| 36 | #define DECRYPT_FILE_ERROR -1 |
| 37 | |
| 38 | using namespace android; |
| 39 | |
| 40 | const String8 DrmManager::EMPTY_STRING(""); |
| 41 | |
| 42 | DrmManager::DrmManager() : |
| 43 | mDecryptSessionId(0), |
| 44 | mConvertId(0) { |
| 45 | |
| 46 | } |
| 47 | |
| 48 | DrmManager::~DrmManager() { |
| 49 | |
| 50 | } |
| 51 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 52 | int DrmManager::addUniqueId(int uniqueId) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 53 | Mutex::Autolock _l(mLock); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 54 | if (0 == uniqueId) { |
| 55 | int temp = 0; |
| 56 | bool foundUniqueId = false; |
| 57 | srand(time(NULL)); |
| 58 | |
| 59 | while (!foundUniqueId) { |
| 60 | const int size = mUniqueIdVector.size(); |
| 61 | temp = rand() % 100; |
| 62 | |
| 63 | int index = 0; |
| 64 | for (; index < size; ++index) { |
| 65 | if (mUniqueIdVector.itemAt(index) == temp) { |
| 66 | foundUniqueId = false; |
| 67 | break; |
| 68 | } |
| 69 | } |
| 70 | if (index == size) { |
| 71 | foundUniqueId = true; |
| 72 | } |
| 73 | } |
| 74 | uniqueId = temp; |
| 75 | } |
| 76 | mUniqueIdVector.push(uniqueId); |
| 77 | return uniqueId; |
| 78 | } |
| 79 | |
| 80 | void DrmManager::removeUniqueId(int uniqueId) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 81 | Mutex::Autolock _l(mLock); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 82 | for (unsigned int i = 0; i < mUniqueIdVector.size(); i++) { |
| 83 | if (uniqueId == mUniqueIdVector.itemAt(i)) { |
| 84 | mUniqueIdVector.removeAt(i); |
| 85 | break; |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 90 | status_t DrmManager::loadPlugIns() { |
Glenn Kasten | fc4f5aa | 2011-01-11 17:15:49 -0800 | [diff] [blame] | 91 | String8 pluginDirPath("/system/lib/drm"); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 92 | return loadPlugIns(pluginDirPath); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 93 | } |
| 94 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 95 | status_t DrmManager::loadPlugIns(const String8& plugInDirPath) { |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 96 | if (mSupportInfoToPlugInIdMap.isEmpty()) { |
| 97 | mPlugInManager.loadPlugIns(plugInDirPath); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 98 | Vector<String8> plugInPathList = mPlugInManager.getPlugInIdList(); |
| 99 | for (unsigned int i = 0; i < plugInPathList.size(); ++i) { |
| 100 | String8 plugInPath = plugInPathList[i]; |
| 101 | DrmSupportInfo* info = mPlugInManager.getPlugIn(plugInPath).getSupportInfo(0); |
| 102 | if (NULL != info) { |
| 103 | mSupportInfoToPlugInIdMap.add(*info, plugInPath); |
James Dong | adfb559 | 2011-04-24 12:38:35 -0700 | [diff] [blame^] | 104 | delete info; |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 105 | } |
| 106 | } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 107 | } |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 108 | return DRM_NO_ERROR; |
| 109 | } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 110 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 111 | status_t DrmManager::unloadPlugIns() { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 112 | Mutex::Autolock _l(mLock); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 113 | mConvertSessionMap.clear(); |
| 114 | mDecryptSessionMap.clear(); |
| 115 | mPlugInManager.unloadPlugIns(); |
| 116 | mSupportInfoToPlugInIdMap.clear(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 117 | return DRM_NO_ERROR; |
| 118 | } |
| 119 | |
| 120 | status_t DrmManager::setDrmServiceListener( |
| 121 | int uniqueId, const sp<IDrmServiceListener>& drmServiceListener) { |
Gloria Wang | 0e0a5f9 | 2011-03-11 14:07:21 -0800 | [diff] [blame] | 122 | Mutex::Autolock _l(mListenerLock); |
Takeshi Aimi | c618b5a | 2010-11-30 16:27:42 +0900 | [diff] [blame] | 123 | if (NULL != drmServiceListener.get()) { |
| 124 | mServiceListeners.add(uniqueId, drmServiceListener); |
| 125 | } else { |
| 126 | mServiceListeners.removeItem(uniqueId); |
| 127 | } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 128 | return DRM_NO_ERROR; |
| 129 | } |
| 130 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 131 | void DrmManager::addClient(int uniqueId) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 132 | Mutex::Autolock _l(mLock); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 133 | if (!mSupportInfoToPlugInIdMap.isEmpty()) { |
| 134 | Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList(); |
| 135 | for (unsigned int index = 0; index < plugInIdList.size(); index++) { |
| 136 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInIdList.itemAt(index)); |
| 137 | rDrmEngine.initialize(uniqueId); |
| 138 | rDrmEngine.setOnInfoListener(uniqueId, this); |
| 139 | } |
| 140 | } |
| 141 | } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 142 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 143 | void DrmManager::removeClient(int uniqueId) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 144 | Mutex::Autolock _l(mLock); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 145 | Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList(); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 146 | for (unsigned int index = 0; index < plugInIdList.size(); index++) { |
| 147 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInIdList.itemAt(index)); |
| 148 | rDrmEngine.terminate(uniqueId); |
| 149 | } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | DrmConstraints* DrmManager::getConstraints(int uniqueId, const String8* path, const int action) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 153 | Mutex::Autolock _l(mLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 154 | const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, *path); |
| 155 | if (EMPTY_STRING != plugInId) { |
| 156 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); |
| 157 | return rDrmEngine.getConstraints(uniqueId, path, action); |
| 158 | } |
| 159 | return NULL; |
| 160 | } |
| 161 | |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 162 | DrmMetadata* DrmManager::getMetadata(int uniqueId, const String8* path) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 163 | Mutex::Autolock _l(mLock); |
Takeshi Aimi | 3473846 | 2010-11-16 13:56:11 +0900 | [diff] [blame] | 164 | const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, *path); |
| 165 | if (EMPTY_STRING != plugInId) { |
| 166 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); |
| 167 | return rDrmEngine.getMetadata(uniqueId, path); |
| 168 | } |
| 169 | return NULL; |
| 170 | } |
| 171 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 172 | status_t DrmManager::installDrmEngine(int uniqueId, const String8& absolutePath) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 173 | Mutex::Autolock _l(mLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 174 | mPlugInManager.loadPlugIn(absolutePath); |
| 175 | |
| 176 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(absolutePath); |
| 177 | rDrmEngine.initialize(uniqueId); |
| 178 | rDrmEngine.setOnInfoListener(uniqueId, this); |
| 179 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 180 | DrmSupportInfo* info = rDrmEngine.getSupportInfo(0); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 181 | mSupportInfoToPlugInIdMap.add(*info, absolutePath); |
James Dong | adfb559 | 2011-04-24 12:38:35 -0700 | [diff] [blame^] | 182 | delete info; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 183 | |
| 184 | return DRM_NO_ERROR; |
| 185 | } |
| 186 | |
| 187 | bool DrmManager::canHandle(int uniqueId, const String8& path, const String8& mimeType) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 188 | Mutex::Autolock _l(mLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 189 | const String8 plugInId = getSupportedPlugInId(mimeType); |
| 190 | bool result = (EMPTY_STRING != plugInId) ? true : false; |
| 191 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 192 | if (0 < path.length()) { |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 193 | if (result) { |
| 194 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); |
| 195 | result = rDrmEngine.canHandle(uniqueId, path); |
| 196 | } else { |
Gloria Wang | 7f89d09 | 2011-03-02 12:33:00 -0800 | [diff] [blame] | 197 | String8 extension = path.getPathExtension(); |
| 198 | if (String8("") != extension) { |
| 199 | result = canHandle(uniqueId, path); |
| 200 | } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 201 | } |
| 202 | } |
| 203 | return result; |
| 204 | } |
| 205 | |
| 206 | DrmInfoStatus* DrmManager::processDrmInfo(int uniqueId, const DrmInfo* drmInfo) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 207 | Mutex::Autolock _l(mLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 208 | const String8 plugInId = getSupportedPlugInId(drmInfo->getMimeType()); |
| 209 | if (EMPTY_STRING != plugInId) { |
| 210 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); |
| 211 | return rDrmEngine.processDrmInfo(uniqueId, drmInfo); |
| 212 | } |
| 213 | return NULL; |
| 214 | } |
| 215 | |
| 216 | bool DrmManager::canHandle(int uniqueId, const String8& path) { |
| 217 | bool result = false; |
| 218 | Vector<String8> plugInPathList = mPlugInManager.getPlugInIdList(); |
| 219 | |
| 220 | for (unsigned int i = 0; i < plugInPathList.size(); ++i) { |
| 221 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInPathList[i]); |
| 222 | result = rDrmEngine.canHandle(uniqueId, path); |
| 223 | |
| 224 | if (result) { |
| 225 | break; |
| 226 | } |
| 227 | } |
| 228 | return result; |
| 229 | } |
| 230 | |
| 231 | DrmInfo* DrmManager::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 232 | Mutex::Autolock _l(mLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 233 | const String8 plugInId = getSupportedPlugInId(drmInfoRequest->getMimeType()); |
| 234 | if (EMPTY_STRING != plugInId) { |
| 235 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); |
| 236 | return rDrmEngine.acquireDrmInfo(uniqueId, drmInfoRequest); |
| 237 | } |
| 238 | return NULL; |
| 239 | } |
| 240 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 241 | status_t DrmManager::saveRights(int uniqueId, const DrmRights& drmRights, |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 242 | const String8& rightsPath, const String8& contentPath) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 243 | Mutex::Autolock _l(mLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 244 | const String8 plugInId = getSupportedPlugInId(drmRights.getMimeType()); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 245 | status_t result = DRM_ERROR_UNKNOWN; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 246 | if (EMPTY_STRING != plugInId) { |
| 247 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 248 | result = rDrmEngine.saveRights(uniqueId, drmRights, rightsPath, contentPath); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 249 | } |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 250 | return result; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | String8 DrmManager::getOriginalMimeType(int uniqueId, const String8& path) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 254 | Mutex::Autolock _l(mLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 255 | const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, path); |
| 256 | if (EMPTY_STRING != plugInId) { |
| 257 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); |
| 258 | return rDrmEngine.getOriginalMimeType(uniqueId, path); |
| 259 | } |
| 260 | return EMPTY_STRING; |
| 261 | } |
| 262 | |
| 263 | int DrmManager::getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 264 | Mutex::Autolock _l(mLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 265 | const String8 plugInId = getSupportedPlugInId(uniqueId, path, mimeType); |
| 266 | if (EMPTY_STRING != plugInId) { |
| 267 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); |
| 268 | return rDrmEngine.getDrmObjectType(uniqueId, path, mimeType); |
| 269 | } |
| 270 | return DrmObjectType::UNKNOWN; |
| 271 | } |
| 272 | |
| 273 | int DrmManager::checkRightsStatus(int uniqueId, const String8& path, int action) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 274 | Mutex::Autolock _l(mLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 275 | const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, path); |
| 276 | if (EMPTY_STRING != plugInId) { |
| 277 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); |
| 278 | return rDrmEngine.checkRightsStatus(uniqueId, path, action); |
| 279 | } |
| 280 | return RightsStatus::RIGHTS_INVALID; |
| 281 | } |
| 282 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 283 | status_t DrmManager::consumeRights( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 284 | int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) { |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 285 | status_t result = DRM_ERROR_UNKNOWN; |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 286 | Mutex::Autolock _l(mDecryptLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 287 | if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) { |
| 288 | IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 289 | result = drmEngine->consumeRights(uniqueId, decryptHandle, action, reserve); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 290 | } |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 291 | return result; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 292 | } |
| 293 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 294 | status_t DrmManager::setPlaybackStatus( |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 295 | int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) { |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 296 | status_t result = DRM_ERROR_UNKNOWN; |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 297 | Mutex::Autolock _l(mDecryptLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 298 | if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) { |
| 299 | IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 300 | result = drmEngine->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 301 | } |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 302 | return result; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | bool DrmManager::validateAction( |
| 306 | int uniqueId, const String8& path, int action, const ActionDescription& description) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 307 | Mutex::Autolock _l(mLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 308 | const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, path); |
| 309 | if (EMPTY_STRING != plugInId) { |
| 310 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); |
| 311 | return rDrmEngine.validateAction(uniqueId, path, action, description); |
| 312 | } |
| 313 | return false; |
| 314 | } |
| 315 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 316 | status_t DrmManager::removeRights(int uniqueId, const String8& path) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 317 | Mutex::Autolock _l(mLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 318 | const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, path); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 319 | status_t result = DRM_ERROR_UNKNOWN; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 320 | if (EMPTY_STRING != plugInId) { |
| 321 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 322 | result = rDrmEngine.removeRights(uniqueId, path); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 323 | } |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 324 | return result; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 325 | } |
| 326 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 327 | status_t DrmManager::removeAllRights(int uniqueId) { |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 328 | Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList(); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 329 | status_t result = DRM_ERROR_UNKNOWN; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 330 | for (unsigned int index = 0; index < plugInIdList.size(); index++) { |
| 331 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInIdList.itemAt(index)); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 332 | result = rDrmEngine.removeAllRights(uniqueId); |
| 333 | if (DRM_NO_ERROR != result) { |
| 334 | break; |
| 335 | } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 336 | } |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 337 | return result; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | int DrmManager::openConvertSession(int uniqueId, const String8& mimeType) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 341 | Mutex::Autolock _l(mConvertLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 342 | int convertId = -1; |
| 343 | |
| 344 | const String8 plugInId = getSupportedPlugInId(mimeType); |
| 345 | if (EMPTY_STRING != plugInId) { |
| 346 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); |
| 347 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 348 | if (DRM_NO_ERROR == rDrmEngine.openConvertSession(uniqueId, mConvertId + 1)) { |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 349 | ++mConvertId; |
| 350 | convertId = mConvertId; |
| 351 | mConvertSessionMap.add(convertId, &rDrmEngine); |
| 352 | } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 353 | } |
| 354 | return convertId; |
| 355 | } |
| 356 | |
| 357 | DrmConvertedStatus* DrmManager::convertData( |
| 358 | int uniqueId, int convertId, const DrmBuffer* inputData) { |
| 359 | DrmConvertedStatus *drmConvertedStatus = NULL; |
| 360 | |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 361 | Mutex::Autolock _l(mConvertLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 362 | if (mConvertSessionMap.indexOfKey(convertId) != NAME_NOT_FOUND) { |
| 363 | IDrmEngine* drmEngine = mConvertSessionMap.valueFor(convertId); |
| 364 | drmConvertedStatus = drmEngine->convertData(uniqueId, convertId, inputData); |
| 365 | } |
| 366 | return drmConvertedStatus; |
| 367 | } |
| 368 | |
| 369 | DrmConvertedStatus* DrmManager::closeConvertSession(int uniqueId, int convertId) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 370 | Mutex::Autolock _l(mConvertLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 371 | DrmConvertedStatus *drmConvertedStatus = NULL; |
| 372 | |
| 373 | if (mConvertSessionMap.indexOfKey(convertId) != NAME_NOT_FOUND) { |
| 374 | IDrmEngine* drmEngine = mConvertSessionMap.valueFor(convertId); |
| 375 | drmConvertedStatus = drmEngine->closeConvertSession(uniqueId, convertId); |
| 376 | mConvertSessionMap.removeItem(convertId); |
| 377 | } |
| 378 | return drmConvertedStatus; |
| 379 | } |
| 380 | |
| 381 | status_t DrmManager::getAllSupportInfo( |
| 382 | int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) { |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 383 | Mutex::Autolock _l(mLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 384 | Vector<String8> plugInPathList = mPlugInManager.getPlugInIdList(); |
| 385 | int size = plugInPathList.size(); |
| 386 | int validPlugins = 0; |
| 387 | |
| 388 | if (0 < size) { |
| 389 | Vector<DrmSupportInfo> drmSupportInfoList; |
| 390 | |
| 391 | for (int i = 0; i < size; ++i) { |
| 392 | String8 plugInPath = plugInPathList[i]; |
| 393 | DrmSupportInfo* drmSupportInfo |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 394 | = mPlugInManager.getPlugIn(plugInPath).getSupportInfo(0); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 395 | if (NULL != drmSupportInfo) { |
| 396 | drmSupportInfoList.add(*drmSupportInfo); |
| 397 | delete drmSupportInfo; drmSupportInfo = NULL; |
| 398 | } |
| 399 | } |
| 400 | |
| 401 | validPlugins = drmSupportInfoList.size(); |
| 402 | if (0 < validPlugins) { |
| 403 | *drmSupportInfoArray = new DrmSupportInfo[validPlugins]; |
| 404 | for (int i = 0; i < validPlugins; ++i) { |
| 405 | (*drmSupportInfoArray)[i] = drmSupportInfoList[i]; |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | *length = validPlugins; |
| 410 | return DRM_NO_ERROR; |
| 411 | } |
| 412 | |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 413 | DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length) { |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 414 | Mutex::Autolock _l(mDecryptLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 415 | status_t result = DRM_ERROR_CANNOT_HANDLE; |
| 416 | Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList(); |
| 417 | |
| 418 | DecryptHandle* handle = new DecryptHandle(); |
| 419 | if (NULL != handle) { |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 420 | handle->decryptId = mDecryptSessionId + 1; |
| 421 | |
| 422 | for (unsigned int index = 0; index < plugInIdList.size(); index++) { |
| 423 | String8 plugInId = plugInIdList.itemAt(index); |
| 424 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); |
| 425 | result = rDrmEngine.openDecryptSession(uniqueId, handle, fd, offset, length); |
| 426 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 427 | if (DRM_NO_ERROR == result) { |
| 428 | ++mDecryptSessionId; |
| 429 | mDecryptSessionMap.add(mDecryptSessionId, &rDrmEngine); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 430 | break; |
| 431 | } |
| 432 | } |
| 433 | } |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 434 | if (DRM_NO_ERROR != result) { |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 435 | delete handle; handle = NULL; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 436 | } |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 437 | return handle; |
| 438 | } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 439 | |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 440 | DecryptHandle* DrmManager::openDecryptSession(int uniqueId, const char* uri) { |
| 441 | Mutex::Autolock _l(mDecryptLock); |
| 442 | status_t result = DRM_ERROR_CANNOT_HANDLE; |
| 443 | Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList(); |
| 444 | |
| 445 | DecryptHandle* handle = new DecryptHandle(); |
| 446 | if (NULL != handle) { |
| 447 | handle->decryptId = mDecryptSessionId + 1; |
| 448 | |
| 449 | for (unsigned int index = 0; index < plugInIdList.size(); index++) { |
| 450 | String8 plugInId = plugInIdList.itemAt(index); |
| 451 | IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); |
| 452 | result = rDrmEngine.openDecryptSession(uniqueId, handle, uri); |
| 453 | |
| 454 | if (DRM_NO_ERROR == result) { |
| 455 | ++mDecryptSessionId; |
| 456 | mDecryptSessionMap.add(mDecryptSessionId, &rDrmEngine); |
| 457 | break; |
| 458 | } |
| 459 | } |
| 460 | } |
| 461 | if (DRM_NO_ERROR != result) { |
| 462 | delete handle; handle = NULL; |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 463 | LOGV("DrmManager::openDecryptSession: no capable plug-in found"); |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 464 | } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 465 | return handle; |
| 466 | } |
| 467 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 468 | status_t DrmManager::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { |
Takeshi Aimi | e943f84 | 2010-10-08 23:05:49 +0900 | [diff] [blame] | 469 | Mutex::Autolock _l(mDecryptLock); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 470 | status_t result = DRM_ERROR_UNKNOWN; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 471 | if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) { |
| 472 | IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 473 | result = drmEngine->closeDecryptSession(uniqueId, decryptHandle); |
| 474 | if (DRM_NO_ERROR == result) { |
| 475 | mDecryptSessionMap.removeItem(decryptHandle->decryptId); |
| 476 | } |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 477 | } |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 478 | return result; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 479 | } |
| 480 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 481 | status_t DrmManager::initializeDecryptUnit( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 482 | int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) { |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 483 | status_t result = DRM_ERROR_UNKNOWN; |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 484 | Mutex::Autolock _l(mDecryptLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 485 | if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) { |
| 486 | IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 487 | result = drmEngine->initializeDecryptUnit(uniqueId, decryptHandle, decryptUnitId, headerInfo); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 488 | } |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 489 | return result; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 490 | } |
| 491 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 492 | status_t DrmManager::decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, |
| 493 | const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { |
| 494 | status_t result = DRM_ERROR_UNKNOWN; |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 495 | |
| 496 | Mutex::Autolock _l(mDecryptLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 497 | if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) { |
| 498 | IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 499 | result = drmEngine->decrypt( |
| 500 | uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 501 | } |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 502 | return result; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 503 | } |
| 504 | |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 505 | status_t DrmManager::finalizeDecryptUnit( |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 506 | int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) { |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 507 | status_t result = DRM_ERROR_UNKNOWN; |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 508 | Mutex::Autolock _l(mDecryptLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 509 | if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) { |
| 510 | IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId); |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 511 | result = drmEngine->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 512 | } |
Takeshi Aimi | 2272ee2 | 2010-09-20 23:40:41 +0900 | [diff] [blame] | 513 | return result; |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | ssize_t DrmManager::pread(int uniqueId, DecryptHandle* decryptHandle, |
Gloria Wang | a2cd44c | 2010-11-19 15:19:36 -0800 | [diff] [blame] | 517 | void* buffer, ssize_t numBytes, off64_t offset) { |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 518 | ssize_t result = DECRYPT_FILE_ERROR; |
| 519 | |
Gloria Wang | 6b610a3 | 2011-03-04 14:45:03 -0800 | [diff] [blame] | 520 | Mutex::Autolock _l(mDecryptLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 521 | if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) { |
| 522 | IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId); |
| 523 | result = drmEngine->pread(uniqueId, decryptHandle, buffer, numBytes, offset); |
| 524 | } |
| 525 | return result; |
| 526 | } |
| 527 | |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 528 | String8 DrmManager::getSupportedPlugInId( |
| 529 | int uniqueId, const String8& path, const String8& mimeType) { |
| 530 | String8 plugInId(""); |
| 531 | |
| 532 | if (EMPTY_STRING != mimeType) { |
| 533 | plugInId = getSupportedPlugInId(mimeType); |
| 534 | } else { |
| 535 | plugInId = getSupportedPlugInIdFromPath(uniqueId, path); |
| 536 | } |
| 537 | return plugInId; |
| 538 | } |
| 539 | |
| 540 | String8 DrmManager::getSupportedPlugInId(const String8& mimeType) { |
| 541 | String8 plugInId(""); |
| 542 | |
| 543 | if (EMPTY_STRING != mimeType) { |
| 544 | for (unsigned int index = 0; index < mSupportInfoToPlugInIdMap.size(); index++) { |
| 545 | const DrmSupportInfo& drmSupportInfo = mSupportInfoToPlugInIdMap.keyAt(index); |
| 546 | |
| 547 | if (drmSupportInfo.isSupportedMimeType(mimeType)) { |
| 548 | plugInId = mSupportInfoToPlugInIdMap.valueFor(drmSupportInfo); |
| 549 | break; |
| 550 | } |
| 551 | } |
| 552 | } |
| 553 | return plugInId; |
| 554 | } |
| 555 | |
| 556 | String8 DrmManager::getSupportedPlugInIdFromPath(int uniqueId, const String8& path) { |
| 557 | String8 plugInId(""); |
| 558 | const String8 fileSuffix = path.getPathExtension(); |
| 559 | |
| 560 | for (unsigned int index = 0; index < mSupportInfoToPlugInIdMap.size(); index++) { |
| 561 | const DrmSupportInfo& drmSupportInfo = mSupportInfoToPlugInIdMap.keyAt(index); |
| 562 | |
| 563 | if (drmSupportInfo.isSupportedFileSuffix(fileSuffix)) { |
| 564 | String8 key = mSupportInfoToPlugInIdMap.valueFor(drmSupportInfo); |
| 565 | IDrmEngine& drmEngine = mPlugInManager.getPlugIn(key); |
| 566 | |
| 567 | if (drmEngine.canHandle(uniqueId, path)) { |
| 568 | plugInId = key; |
| 569 | break; |
| 570 | } |
| 571 | } |
| 572 | } |
| 573 | return plugInId; |
| 574 | } |
| 575 | |
| 576 | void DrmManager::onInfo(const DrmInfoEvent& event) { |
Gloria Wang | 0e0a5f9 | 2011-03-11 14:07:21 -0800 | [diff] [blame] | 577 | Mutex::Autolock _l(mListenerLock); |
aimitakeshi | 27ed8ad | 2010-07-29 10:12:27 +0900 | [diff] [blame] | 578 | for (unsigned int index = 0; index < mServiceListeners.size(); index++) { |
| 579 | int uniqueId = mServiceListeners.keyAt(index); |
| 580 | |
| 581 | if (uniqueId == event.getUniqueId()) { |
| 582 | sp<IDrmServiceListener> serviceListener = mServiceListeners.valueFor(uniqueId); |
| 583 | serviceListener->notify(event); |
| 584 | } |
| 585 | } |
| 586 | } |
| 587 | |