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 #include <utils/String8.h> 18 #include <binder/IServiceManager.h> 19 #include <drm/DrmManagerClient.h> 20 21 #include "DrmManagerClientImpl.h" 22 23 using namespace android; 24 25 DrmManagerClient::DrmManagerClient(): 26 mUniqueId(0), mDrmManagerClientImpl(NULL) { 27 mDrmManagerClientImpl = DrmManagerClientImpl::create(&mUniqueId, true); 28 mDrmManagerClientImpl->addClient(mUniqueId); 29 } 30 31 DrmManagerClient::~DrmManagerClient() { 32 DrmManagerClientImpl::remove(mUniqueId); 33 mDrmManagerClientImpl->removeClient(mUniqueId); 34 mDrmManagerClientImpl->setOnInfoListener(mUniqueId, NULL); 35 } 36 37 status_t DrmManagerClient::setOnInfoListener( 38 const sp<DrmManagerClient::OnInfoListener>& infoListener) { 39 return mDrmManagerClientImpl->setOnInfoListener(mUniqueId, infoListener); 40 } 41 42 DrmConstraints* DrmManagerClient::getConstraints(const String8* path, const int action) { 43 return mDrmManagerClientImpl->getConstraints(mUniqueId, path, action); 44 } 45 46 DrmMetadata* DrmManagerClient::getMetadata(const String8* path) { 47 return mDrmManagerClientImpl->getMetadata(mUniqueId, path); 48 } 49 50 bool DrmManagerClient::canHandle(const String8& path, const String8& mimeType) { 51 return mDrmManagerClientImpl->canHandle(mUniqueId, path, mimeType); 52 } 53 54 DrmInfoStatus* DrmManagerClient::processDrmInfo(const DrmInfo* drmInfo) { 55 return mDrmManagerClientImpl->processDrmInfo(mUniqueId, drmInfo); 56 } 57 58 DrmInfo* DrmManagerClient::acquireDrmInfo(const DrmInfoRequest* drmInfoRequest) { 59 return mDrmManagerClientImpl->acquireDrmInfo(mUniqueId, drmInfoRequest); 60 } 61 62 status_t DrmManagerClient::saveRights( 63 const DrmRights& drmRights, const String8& rightsPath, const String8& contentPath) { 64 return mDrmManagerClientImpl->saveRights(mUniqueId, drmRights, rightsPath, contentPath); 65 } 66 67 String8 DrmManagerClient::getOriginalMimeType(const String8& path) { 68 return mDrmManagerClientImpl->getOriginalMimeType(mUniqueId, path); 69 } 70 71 int DrmManagerClient::getDrmObjectType(const String8& path, const String8& mimeType) { 72 return mDrmManagerClientImpl->getDrmObjectType( mUniqueId, path, mimeType); 73 } 74 75 int DrmManagerClient::checkRightsStatus(const String8& path, int action) { 76 return mDrmManagerClientImpl->checkRightsStatus(mUniqueId, path, action); 77 } 78 79 status_t DrmManagerClient::consumeRights( 80 sp<DecryptHandle> &decryptHandle, int action, bool reserve) { 81 return mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve); 82 } 83 84 status_t DrmManagerClient::setPlaybackStatus( 85 sp<DecryptHandle> &decryptHandle, int playbackStatus, int64_t position) { 86 return mDrmManagerClientImpl 87 ->setPlaybackStatus(mUniqueId, decryptHandle, playbackStatus, position); 88 } 89 90 bool DrmManagerClient::validateAction( 91 const String8& path, int action, const ActionDescription& description) { 92 return mDrmManagerClientImpl->validateAction(mUniqueId, path, action, description); 93 } 94 95 status_t DrmManagerClient::removeRights(const String8& path) { 96 return mDrmManagerClientImpl->removeRights(mUniqueId, path); 97 } 98 99 status_t DrmManagerClient::removeAllRights() { 100 return mDrmManagerClientImpl->removeAllRights(mUniqueId); 101 } 102 103 int DrmManagerClient::openConvertSession(const String8& mimeType) { 104 return mDrmManagerClientImpl->openConvertSession(mUniqueId, mimeType); 105 } 106 107 DrmConvertedStatus* DrmManagerClient::convertData(int convertId, const DrmBuffer* inputData) { 108 return mDrmManagerClientImpl->convertData(mUniqueId, convertId, inputData); 109 } 110 111 DrmConvertedStatus* DrmManagerClient::closeConvertSession(int convertId) { 112 return mDrmManagerClientImpl->closeConvertSession(mUniqueId, convertId); 113 } 114 115 status_t DrmManagerClient::getAllSupportInfo(int* length, DrmSupportInfo** drmSupportInfoArray) { 116 return mDrmManagerClientImpl->getAllSupportInfo(mUniqueId, length, drmSupportInfoArray); 117 } 118 119 sp<DecryptHandle> DrmManagerClient::openDecryptSession(int fd, off64_t offset, off64_t length) { 120 return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length); 121 } 122 123 sp<DecryptHandle> DrmManagerClient::openDecryptSession(const char* uri) { 124 return mDrmManagerClientImpl->openDecryptSession(mUniqueId, uri); 125 } 126 127 status_t DrmManagerClient::closeDecryptSession(sp<DecryptHandle> &decryptHandle) { 128 return mDrmManagerClientImpl->closeDecryptSession(mUniqueId, decryptHandle); 129 } 130 131 status_t DrmManagerClient::initializeDecryptUnit( 132 sp<DecryptHandle> &decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) { 133 return mDrmManagerClientImpl->initializeDecryptUnit( 134 mUniqueId, decryptHandle, decryptUnitId, headerInfo); 135 } 136 137 status_t DrmManagerClient::decrypt( 138 sp<DecryptHandle> &decryptHandle, int decryptUnitId, 139 const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { 140 return mDrmManagerClientImpl->decrypt( 141 mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV); 142 } 143 144 status_t DrmManagerClient::finalizeDecryptUnit( 145 sp<DecryptHandle> &decryptHandle, int decryptUnitId) { 146 return mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, 147 decryptHandle, decryptUnitId); 148 } 149 150 ssize_t DrmManagerClient::pread( 151 sp<DecryptHandle> &decryptHandle, void* buffer, ssize_t numBytes, off64_t offset) { 152 return mDrmManagerClientImpl->pread(mUniqueId, decryptHandle, buffer, numBytes, offset); 153 } 154 155