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