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