2010-07-29 10:12:27 +09:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <utils/String8.h>
|
|
|
|
#include <binder/IServiceManager.h>
|
|
|
|
#include <drm/DrmManagerClient.h>
|
|
|
|
|
|
|
|
#include "DrmManagerClientImpl.h"
|
|
|
|
|
|
|
|
using namespace android;
|
|
|
|
|
|
|
|
DrmManagerClient::DrmManagerClient() {
|
|
|
|
int uniqueId = 0;
|
|
|
|
mDrmManagerClientImpl = NULL;
|
|
|
|
|
|
|
|
mDrmManagerClientImpl = DrmManagerClientImpl::create(&uniqueId);
|
|
|
|
mUniqueId = uniqueId;
|
|
|
|
|
|
|
|
loadPlugIns();
|
|
|
|
}
|
|
|
|
|
|
|
|
DrmManagerClient::~DrmManagerClient() {
|
|
|
|
DrmManagerClientImpl::remove(mUniqueId);
|
2010-09-20 23:40:41 +09:00
|
|
|
unloadPlugIns();
|
2010-07-29 10:12:27 +09:00
|
|
|
|
|
|
|
delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
status_t DrmManagerClient::loadPlugIns() {
|
|
|
|
return mDrmManagerClientImpl->loadPlugIns(mUniqueId);
|
|
|
|
}
|
|
|
|
|
|
|
|
status_t DrmManagerClient::setOnInfoListener(
|
|
|
|
const sp<DrmManagerClient::OnInfoListener>& infoListener) {
|
|
|
|
return mDrmManagerClientImpl->setOnInfoListener(mUniqueId, infoListener);
|
|
|
|
}
|
|
|
|
|
|
|
|
status_t DrmManagerClient::unloadPlugIns() {
|
|
|
|
return mDrmManagerClientImpl->unloadPlugIns(mUniqueId);
|
|
|
|
}
|
|
|
|
|
|
|
|
DrmConstraints* DrmManagerClient::getConstraints(const String8* path, const int action) {
|
|
|
|
return mDrmManagerClientImpl->getConstraints(mUniqueId, path, action);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DrmManagerClient::canHandle(const String8& path, const String8& mimeType) {
|
|
|
|
return mDrmManagerClientImpl->canHandle(mUniqueId, path, mimeType);
|
|
|
|
}
|
|
|
|
|
|
|
|
DrmInfoStatus* DrmManagerClient::processDrmInfo(const DrmInfo* drmInfo) {
|
|
|
|
return mDrmManagerClientImpl->processDrmInfo(mUniqueId, drmInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
DrmInfo* DrmManagerClient::acquireDrmInfo(const DrmInfoRequest* drmInfoRequest) {
|
|
|
|
return mDrmManagerClientImpl->acquireDrmInfo(mUniqueId, drmInfoRequest);
|
|
|
|
}
|
|
|
|
|
2010-09-20 23:40:41 +09:00
|
|
|
status_t DrmManagerClient::saveRights(
|
2010-07-29 10:12:27 +09:00
|
|
|
const DrmRights& drmRights, const String8& rightsPath, const String8& contentPath) {
|
|
|
|
return mDrmManagerClientImpl->saveRights(mUniqueId, drmRights, rightsPath, contentPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
String8 DrmManagerClient::getOriginalMimeType(const String8& path) {
|
|
|
|
return mDrmManagerClientImpl->getOriginalMimeType(mUniqueId, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
int DrmManagerClient::getDrmObjectType(const String8& path, const String8& mimeType) {
|
|
|
|
return mDrmManagerClientImpl->getDrmObjectType( mUniqueId, path, mimeType);
|
|
|
|
}
|
|
|
|
|
|
|
|
int DrmManagerClient::checkRightsStatus(const String8& path, int action) {
|
|
|
|
return mDrmManagerClientImpl->checkRightsStatus(mUniqueId, path, action);
|
|
|
|
}
|
|
|
|
|
2010-09-20 23:40:41 +09:00
|
|
|
status_t DrmManagerClient::consumeRights(DecryptHandle* decryptHandle, int action, bool reserve) {
|
|
|
|
return mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve);
|
2010-07-29 10:12:27 +09:00
|
|
|
}
|
|
|
|
|
2010-09-20 23:40:41 +09:00
|
|
|
status_t DrmManagerClient::setPlaybackStatus(
|
2010-07-29 10:12:27 +09:00
|
|
|
DecryptHandle* decryptHandle, int playbackStatus, int position) {
|
2010-09-20 23:40:41 +09:00
|
|
|
return mDrmManagerClientImpl
|
|
|
|
->setPlaybackStatus(mUniqueId, decryptHandle, playbackStatus, position);
|
2010-07-29 10:12:27 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DrmManagerClient::validateAction(
|
|
|
|
const String8& path, int action, const ActionDescription& description) {
|
|
|
|
return mDrmManagerClientImpl->validateAction(mUniqueId, path, action, description);
|
|
|
|
}
|
|
|
|
|
2010-09-20 23:40:41 +09:00
|
|
|
status_t DrmManagerClient::removeRights(const String8& path) {
|
|
|
|
return mDrmManagerClientImpl->removeRights(mUniqueId, path);
|
2010-07-29 10:12:27 +09:00
|
|
|
}
|
|
|
|
|
2010-09-20 23:40:41 +09:00
|
|
|
status_t DrmManagerClient::removeAllRights() {
|
|
|
|
return mDrmManagerClientImpl->removeAllRights(mUniqueId);
|
2010-07-29 10:12:27 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
int DrmManagerClient::openConvertSession(const String8& mimeType) {
|
|
|
|
return mDrmManagerClientImpl->openConvertSession(mUniqueId, mimeType);
|
|
|
|
}
|
|
|
|
|
|
|
|
DrmConvertedStatus* DrmManagerClient::convertData(int convertId, const DrmBuffer* inputData) {
|
|
|
|
return mDrmManagerClientImpl->convertData(mUniqueId, convertId, inputData);
|
|
|
|
}
|
|
|
|
|
|
|
|
DrmConvertedStatus* DrmManagerClient::closeConvertSession(int convertId) {
|
|
|
|
return mDrmManagerClientImpl->closeConvertSession(mUniqueId, convertId);
|
|
|
|
}
|
|
|
|
|
|
|
|
status_t DrmManagerClient::getAllSupportInfo(int* length, DrmSupportInfo** drmSupportInfoArray) {
|
|
|
|
return mDrmManagerClientImpl->getAllSupportInfo(mUniqueId, length, drmSupportInfoArray);
|
|
|
|
}
|
|
|
|
|
|
|
|
DecryptHandle* DrmManagerClient::openDecryptSession(int fd, int offset, int length) {
|
|
|
|
return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length);
|
|
|
|
}
|
|
|
|
|
2010-09-20 23:40:41 +09:00
|
|
|
status_t DrmManagerClient::closeDecryptSession(DecryptHandle* decryptHandle) {
|
|
|
|
return mDrmManagerClientImpl->closeDecryptSession(mUniqueId, decryptHandle);
|
2010-07-29 10:12:27 +09:00
|
|
|
}
|
|
|
|
|
2010-09-20 23:40:41 +09:00
|
|
|
status_t DrmManagerClient::initializeDecryptUnit(
|
2010-07-29 10:12:27 +09:00
|
|
|
DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
|
2010-09-20 23:40:41 +09:00
|
|
|
return mDrmManagerClientImpl->initializeDecryptUnit(
|
|
|
|
mUniqueId, decryptHandle, decryptUnitId, headerInfo);
|
2010-07-29 10:12:27 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
status_t DrmManagerClient::decrypt(
|
|
|
|
DecryptHandle* decryptHandle, int decryptUnitId,
|
2010-09-20 23:40:41 +09:00
|
|
|
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
|
2010-07-29 10:12:27 +09:00
|
|
|
return mDrmManagerClientImpl->decrypt(
|
2010-09-20 23:40:41 +09:00
|
|
|
mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
|
2010-07-29 10:12:27 +09:00
|
|
|
}
|
|
|
|
|
2010-09-20 23:40:41 +09:00
|
|
|
status_t DrmManagerClient::finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId) {
|
|
|
|
return mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, decryptHandle, decryptUnitId);
|
2010-07-29 10:12:27 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
ssize_t DrmManagerClient::pread(
|
|
|
|
DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off_t offset) {
|
|
|
|
return mDrmManagerClientImpl->pread(mUniqueId, decryptHandle, buffer, numBytes, offset);
|
|
|
|
}
|
|
|
|
|