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