resolved conflicts for merge of a8d7b747 to master

Change-Id: I8a4b72c9f9a10de8bbc285e00e2dd5cb9f498349
This commit is contained in:
Gloria Wang
2010-11-03 11:39:04 -07:00
18 changed files with 275 additions and 227 deletions

View File

@@ -120,6 +120,11 @@ status_t DrmEngineBase::openDecryptSession(
return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length); return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length);
} }
status_t DrmEngineBase::openDecryptSession(
int uniqueId, DecryptHandle* decryptHandle, const char* uri) {
return onOpenDecryptSession(uniqueId, decryptHandle, uri);
}
status_t DrmEngineBase::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { status_t DrmEngineBase::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
return onCloseDecryptSession(uniqueId, decryptHandle); return onCloseDecryptSession(uniqueId, decryptHandle);
} }

View File

@@ -19,8 +19,9 @@
using namespace android; using namespace android;
DrmInfoStatus::DrmInfoStatus( DrmInfoStatus::DrmInfoStatus(
int _statusCode, const DrmBuffer* _drmBuffer, const String8& _mimeType) : int _statusCode, int _infoType, const DrmBuffer* _drmBuffer, const String8& _mimeType) :
statusCode(_statusCode), statusCode(_statusCode),
infoType(_infoType),
drmBuffer(_drmBuffer), drmBuffer(_drmBuffer),
mimeType(_mimeType) { mimeType(_mimeType) {

View File

@@ -53,27 +53,18 @@ void BpDrmManagerService::removeUniqueId(int uniqueId) {
remote()->transact(REMOVE_UNIQUEID, data, &reply); remote()->transact(REMOVE_UNIQUEID, data, &reply);
} }
status_t BpDrmManagerService::loadPlugIns(int uniqueId) { void BpDrmManagerService::addClient(int uniqueId) {
LOGV("load plugins");
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
data.writeInt32(uniqueId); data.writeInt32(uniqueId);
remote()->transact(ADD_CLIENT, data, &reply);
remote()->transact(LOAD_PLUGINS, data, &reply);
return reply.readInt32();
} }
status_t BpDrmManagerService::loadPlugIns(int uniqueId, const String8& plugInDirPath) { void BpDrmManagerService::removeClient(int uniqueId) {
LOGV("load plugins from path");
Parcel data, reply; Parcel data, reply;
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
data.writeInt32(uniqueId); data.writeInt32(uniqueId);
data.writeString8(plugInDirPath); remote()->transact(REMOVE_CLIENT, data, &reply);
remote()->transact(LOAD_PLUGINS_FROM_PATH, data, &reply);
return reply.readInt32();
} }
status_t BpDrmManagerService::setDrmServiceListener( status_t BpDrmManagerService::setDrmServiceListener(
@@ -88,17 +79,6 @@ status_t BpDrmManagerService::setDrmServiceListener(
return reply.readInt32(); return reply.readInt32();
} }
status_t BpDrmManagerService::unloadPlugIns(int uniqueId) {
LOGV("unload plugins");
Parcel data, reply;
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
data.writeInt32(uniqueId);
remote()->transact(UNLOAD_PLUGINS, data, &reply);
return reply.readInt32();
}
status_t BpDrmManagerService::installDrmEngine(int uniqueId, const String8& drmEngineFile) { status_t BpDrmManagerService::installDrmEngine(int uniqueId, const String8& drmEngineFile) {
LOGV("Install DRM Engine"); LOGV("Install DRM Engine");
Parcel data, reply; Parcel data, reply;
@@ -191,6 +171,7 @@ DrmInfoStatus* BpDrmManagerService::processDrmInfo(int uniqueId, const DrmInfo*
if (0 != reply.dataAvail()) { if (0 != reply.dataAvail()) {
//Filling DRM Info Status //Filling DRM Info Status
const int statusCode = reply.readInt32(); const int statusCode = reply.readInt32();
const int infoType = reply.readInt32();
const String8 mimeType = reply.readString8(); const String8 mimeType = reply.readString8();
DrmBuffer* drmBuffer = NULL; DrmBuffer* drmBuffer = NULL;
@@ -203,7 +184,7 @@ DrmInfoStatus* BpDrmManagerService::processDrmInfo(int uniqueId, const DrmInfo*
} }
drmBuffer = new DrmBuffer(data, bufferSize); drmBuffer = new DrmBuffer(data, bufferSize);
} }
drmInfoStatus = new DrmInfoStatus(statusCode, drmBuffer, mimeType); drmInfoStatus = new DrmInfoStatus(statusCode, infoType, drmBuffer, mimeType);
} }
return drmInfoStatus; return drmInfoStatus;
} }
@@ -538,8 +519,7 @@ DecryptHandle* BpDrmManagerService::openDecryptSession(
LOGV("Entering BpDrmManagerService::openDecryptSession"); LOGV("Entering BpDrmManagerService::openDecryptSession");
Parcel data, reply; Parcel data, reply;
const String16 interfaceDescriptor = IDrmManagerService::getInterfaceDescriptor(); data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
data.writeInterfaceToken(interfaceDescriptor);
data.writeInt32(uniqueId); data.writeInt32(uniqueId);
data.writeFileDescriptor(fd); data.writeFileDescriptor(fd);
data.writeInt32(offset); data.writeInt32(offset);
@@ -563,6 +543,34 @@ DecryptHandle* BpDrmManagerService::openDecryptSession(
return handle; return handle;
} }
DecryptHandle* BpDrmManagerService::openDecryptSession(int uniqueId, const char* uri) {
LOGV("Entering BpDrmManagerService::openDecryptSession");
Parcel data, reply;
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
data.writeInt32(uniqueId);
data.writeString8(String8(uri));
remote()->transact(OPEN_DECRYPT_SESSION_FROM_URI, data, &reply);
DecryptHandle* handle = NULL;
if (0 != reply.dataAvail()) {
handle = new DecryptHandle();
handle->decryptId = reply.readInt32();
handle->mimeType = reply.readString8();
handle->decryptApiType = reply.readInt32();
handle->status = reply.readInt32();
handle->decryptInfo = NULL;
if (0 != reply.dataAvail()) {
handle->decryptInfo = new DecryptInfo();
handle->decryptInfo->decryptBufferLength = reply.readInt32();
}
} else {
LOGE("no decryptHandle is generated in service side");
}
return handle;
}
status_t BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { status_t BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
LOGV("closeDecryptSession"); LOGV("closeDecryptSession");
Parcel data, reply; Parcel data, reply;
@@ -744,25 +752,19 @@ status_t BnDrmManagerService::onTransact(
return DRM_NO_ERROR; return DRM_NO_ERROR;
} }
case LOAD_PLUGINS: case ADD_CLIENT:
{ {
LOGV("BnDrmManagerService::onTransact :LOAD_PLUGINS"); LOGV("BnDrmManagerService::onTransact :ADD_CLIENT");
CHECK_INTERFACE(IDrmManagerService, data, reply); CHECK_INTERFACE(IDrmManagerService, data, reply);
addClient(data.readInt32());
status_t status = loadPlugIns(data.readInt32());
reply->writeInt32(status);
return DRM_NO_ERROR; return DRM_NO_ERROR;
} }
case LOAD_PLUGINS_FROM_PATH: case REMOVE_CLIENT:
{ {
LOGV("BnDrmManagerService::onTransact :LOAD_PLUGINS_FROM_PATH"); LOGV("BnDrmManagerService::onTransact :REMOVE_CLIENT");
CHECK_INTERFACE(IDrmManagerService, data, reply); CHECK_INTERFACE(IDrmManagerService, data, reply);
removeClient(data.readInt32());
status_t status = loadPlugIns(data.readInt32(), data.readString8());
reply->writeInt32(status);
return DRM_NO_ERROR; return DRM_NO_ERROR;
} }
@@ -781,18 +783,6 @@ status_t BnDrmManagerService::onTransact(
return DRM_NO_ERROR; return DRM_NO_ERROR;
} }
case UNLOAD_PLUGINS:
{
LOGV("BnDrmManagerService::onTransact :UNLOAD_PLUGINS");
CHECK_INTERFACE(IDrmManagerService, data, reply);
const int uniqueId = data.readInt32();
status_t status = unloadPlugIns(uniqueId);
reply->writeInt32(status);
return DRM_NO_ERROR;
}
case INSTALL_DRM_ENGINE: case INSTALL_DRM_ENGINE:
{ {
LOGV("BnDrmManagerService::onTransact :INSTALL_DRM_ENGINE"); LOGV("BnDrmManagerService::onTransact :INSTALL_DRM_ENGINE");
@@ -879,6 +869,7 @@ status_t BnDrmManagerService::onTransact(
if (NULL != drmInfoStatus) { if (NULL != drmInfoStatus) {
//Filling DRM Info Status contents //Filling DRM Info Status contents
reply->writeInt32(drmInfoStatus->statusCode); reply->writeInt32(drmInfoStatus->statusCode);
reply->writeInt32(drmInfoStatus->infoType);
reply->writeString8(drmInfoStatus->mimeType); reply->writeString8(drmInfoStatus->mimeType);
if (NULL != drmInfoStatus->drmBuffer) { if (NULL != drmInfoStatus->drmBuffer) {
@@ -1235,6 +1226,32 @@ status_t BnDrmManagerService::onTransact(
return DRM_NO_ERROR; return DRM_NO_ERROR;
} }
case OPEN_DECRYPT_SESSION_FROM_URI:
{
LOGV("BnDrmManagerService::onTransact :OPEN_DECRYPT_SESSION_FROM_URI");
CHECK_INTERFACE(IDrmManagerService, data, reply);
const int uniqueId = data.readInt32();
const String8 uri = data.readString8();
DecryptHandle* handle = openDecryptSession(uniqueId, uri.string());
if (NULL != handle) {
reply->writeInt32(handle->decryptId);
reply->writeString8(handle->mimeType);
reply->writeInt32(handle->decryptApiType);
reply->writeInt32(handle->status);
if (NULL != handle->decryptInfo) {
reply->writeInt32(handle->decryptInfo->decryptBufferLength);
delete handle->decryptInfo; handle->decryptInfo = NULL;
}
} else {
LOGE("NULL decryptHandle is returned");
}
delete handle; handle = NULL;
return DRM_NO_ERROR;
}
case CLOSE_DECRYPT_SESSION: case CLOSE_DECRYPT_SESSION:
{ {
LOGV("BnDrmManagerService::onTransact :CLOSE_DECRYPT_SESSION"); LOGV("BnDrmManagerService::onTransact :CLOSE_DECRYPT_SESSION");

View File

@@ -85,22 +85,31 @@ void DrmManager::removeUniqueId(int uniqueId) {
} }
} }
status_t DrmManager::loadPlugIns(int uniqueId) { status_t DrmManager::loadPlugIns() {
String8 pluginDirPath("/system/lib/drm/plugins/native"); String8 pluginDirPath("/system/lib/drm/plugins/native");
return loadPlugIns(uniqueId, pluginDirPath); return loadPlugIns(pluginDirPath);
} }
status_t DrmManager::loadPlugIns(int uniqueId, const String8& plugInDirPath) { status_t DrmManager::loadPlugIns(const String8& plugInDirPath) {
if (mSupportInfoToPlugInIdMap.isEmpty()) { if (mSupportInfoToPlugInIdMap.isEmpty()) {
mPlugInManager.loadPlugIns(plugInDirPath); mPlugInManager.loadPlugIns(plugInDirPath);
Vector<String8> plugInPathList = mPlugInManager.getPlugInIdList();
initializePlugIns(uniqueId); for (unsigned int i = 0; i < plugInPathList.size(); ++i) {
String8 plugInPath = plugInPathList[i];
populate(uniqueId); DrmSupportInfo* info = mPlugInManager.getPlugIn(plugInPath).getSupportInfo(0);
} else { if (NULL != info) {
initializePlugIns(uniqueId); mSupportInfoToPlugInIdMap.add(*info, plugInPath);
}
}
} }
return DRM_NO_ERROR;
}
status_t DrmManager::unloadPlugIns() {
mConvertSessionMap.clear();
mDecryptSessionMap.clear();
mPlugInManager.unloadPlugIns();
mSupportInfoToPlugInIdMap.clear();
return DRM_NO_ERROR; return DRM_NO_ERROR;
} }
@@ -111,21 +120,23 @@ status_t DrmManager::setDrmServiceListener(
return DRM_NO_ERROR; return DRM_NO_ERROR;
} }
status_t DrmManager::unloadPlugIns(int uniqueId) { void DrmManager::addClient(int uniqueId) {
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList(); if (!mSupportInfoToPlugInIdMap.isEmpty()) {
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
for (unsigned int index = 0; index < plugInIdList.size(); index++) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInIdList.itemAt(index));
rDrmEngine.initialize(uniqueId);
rDrmEngine.setOnInfoListener(uniqueId, this);
}
}
}
void DrmManager::removeClient(int uniqueId) {
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
for (unsigned int index = 0; index < plugInIdList.size(); index++) { for (unsigned int index = 0; index < plugInIdList.size(); index++) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInIdList.itemAt(index)); IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInIdList.itemAt(index));
rDrmEngine.terminate(uniqueId); rDrmEngine.terminate(uniqueId);
} }
if (0 >= mUniqueIdVector.size()) {
mConvertSessionMap.clear();
mDecryptSessionMap.clear();
mSupportInfoToPlugInIdMap.clear();
mPlugInManager.unloadPlugIns();
}
return DRM_NO_ERROR;
} }
DrmConstraints* DrmManager::getConstraints(int uniqueId, const String8* path, const int action) { DrmConstraints* DrmManager::getConstraints(int uniqueId, const String8* path, const int action) {
@@ -144,7 +155,7 @@ status_t DrmManager::installDrmEngine(int uniqueId, const String8& absolutePath)
rDrmEngine.initialize(uniqueId); rDrmEngine.initialize(uniqueId);
rDrmEngine.setOnInfoListener(uniqueId, this); rDrmEngine.setOnInfoListener(uniqueId, this);
DrmSupportInfo* info = rDrmEngine.getSupportInfo(uniqueId); DrmSupportInfo* info = rDrmEngine.getSupportInfo(0);
mSupportInfoToPlugInIdMap.add(*info, absolutePath); mSupportInfoToPlugInIdMap.add(*info, absolutePath);
return DRM_NO_ERROR; return DRM_NO_ERROR;
@@ -154,7 +165,7 @@ bool DrmManager::canHandle(int uniqueId, const String8& path, const String8& mim
const String8 plugInId = getSupportedPlugInId(mimeType); const String8 plugInId = getSupportedPlugInId(mimeType);
bool result = (EMPTY_STRING != plugInId) ? true : false; bool result = (EMPTY_STRING != plugInId) ? true : false;
if (NULL != path) { if (0 < path.length()) {
if (result) { if (result) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
result = rDrmEngine.canHandle(uniqueId, path); result = rDrmEngine.canHandle(uniqueId, path);
@@ -340,7 +351,7 @@ status_t DrmManager::getAllSupportInfo(
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
String8 plugInPath = plugInPathList[i]; String8 plugInPath = plugInPathList[i];
DrmSupportInfo* drmSupportInfo DrmSupportInfo* drmSupportInfo
= mPlugInManager.getPlugIn(plugInPath).getSupportInfo(uniqueId); = mPlugInManager.getPlugIn(plugInPath).getSupportInfo(0);
if (NULL != drmSupportInfo) { if (NULL != drmSupportInfo) {
drmSupportInfoList.add(*drmSupportInfo); drmSupportInfoList.add(*drmSupportInfo);
delete drmSupportInfo; drmSupportInfo = NULL; delete drmSupportInfo; drmSupportInfo = NULL;
@@ -360,12 +371,12 @@ status_t DrmManager::getAllSupportInfo(
} }
DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, int offset, int length) { DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, int offset, int length) {
Mutex::Autolock _l(mDecryptLock);
status_t result = DRM_ERROR_CANNOT_HANDLE; status_t result = DRM_ERROR_CANNOT_HANDLE;
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList(); Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
DecryptHandle* handle = new DecryptHandle(); DecryptHandle* handle = new DecryptHandle();
if (NULL != handle) { if (NULL != handle) {
Mutex::Autolock _l(mDecryptLock);
handle->decryptId = mDecryptSessionId + 1; handle->decryptId = mDecryptSessionId + 1;
for (unsigned int index = 0; index < plugInIdList.size(); index++) { for (unsigned int index = 0; index < plugInIdList.size(); index++) {
@@ -380,15 +391,42 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, int offset,
} }
} }
} }
if (DRM_NO_ERROR != result) { if (DRM_NO_ERROR != result) {
delete handle; handle = NULL; delete handle; handle = NULL;
} }
return handle;
}
DecryptHandle* DrmManager::openDecryptSession(int uniqueId, const char* uri) {
Mutex::Autolock _l(mDecryptLock);
status_t result = DRM_ERROR_CANNOT_HANDLE;
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
DecryptHandle* handle = new DecryptHandle();
if (NULL != handle) {
handle->decryptId = mDecryptSessionId + 1;
for (unsigned int index = 0; index < plugInIdList.size(); index++) {
String8 plugInId = plugInIdList.itemAt(index);
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
result = rDrmEngine.openDecryptSession(uniqueId, handle, uri);
if (DRM_NO_ERROR == result) {
++mDecryptSessionId;
mDecryptSessionMap.add(mDecryptSessionId, &rDrmEngine);
break;
}
}
}
if (DRM_NO_ERROR != result) {
delete handle; handle = NULL;
LOGE("DrmManager::openDecryptSession: no capable plug-in found");
}
return handle; return handle;
} }
status_t DrmManager::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { status_t DrmManager::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
Mutex::Autolock _l(mDecryptLock);
status_t result = DRM_ERROR_UNKNOWN; status_t result = DRM_ERROR_UNKNOWN;
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) { if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId); IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
@@ -442,28 +480,6 @@ ssize_t DrmManager::pread(int uniqueId, DecryptHandle* decryptHandle,
return result; return result;
} }
void DrmManager::initializePlugIns(int uniqueId) {
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
for (unsigned int index = 0; index < plugInIdList.size(); index++) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInIdList.itemAt(index));
rDrmEngine.initialize(uniqueId);
rDrmEngine.setOnInfoListener(uniqueId, this);
}
}
void DrmManager::populate(int uniqueId) {
Vector<String8> plugInPathList = mPlugInManager.getPlugInIdList();
for (unsigned int i = 0; i < plugInPathList.size(); ++i) {
String8 plugInPath = plugInPathList[i];
DrmSupportInfo* info = mPlugInManager.getPlugIn(plugInPath).getSupportInfo(uniqueId);
if (NULL != info) {
mSupportInfoToPlugInIdMap.add(*info, plugInPath);
}
}
}
String8 DrmManager::getSupportedPlugInId( String8 DrmManager::getSupportedPlugInId(
int uniqueId, const String8& path, const String8& mimeType) { int uniqueId, const String8& path, const String8& mimeType) {
String8 plugInId(""); String8 plugInId("");

View File

@@ -27,21 +27,21 @@
using namespace android; using namespace android;
#define SUCCESS 0
void DrmManagerService::instantiate() { void DrmManagerService::instantiate() {
LOGV("instantiate"); LOGV("instantiate");
defaultServiceManager()->addService(String16("drm.drmManager"), new DrmManagerService()); defaultServiceManager()->addService(String16("drm.drmManager"), new DrmManagerService());
} }
DrmManagerService::DrmManagerService() { DrmManagerService::DrmManagerService() :
mDrmManager(NULL) {
LOGV("created"); LOGV("created");
mDrmManager = NULL;
mDrmManager = new DrmManager(); mDrmManager = new DrmManager();
mDrmManager->loadPlugIns();
} }
DrmManagerService::~DrmManagerService() { DrmManagerService::~DrmManagerService() {
LOGV("Destroyed"); LOGV("Destroyed");
mDrmManager->unloadPlugIns();
delete mDrmManager; mDrmManager = NULL; delete mDrmManager; mDrmManager = NULL;
} }
@@ -53,14 +53,12 @@ void DrmManagerService::removeUniqueId(int uniqueId) {
mDrmManager->removeUniqueId(uniqueId); mDrmManager->removeUniqueId(uniqueId);
} }
status_t DrmManagerService::loadPlugIns(int uniqueId) { void DrmManagerService::addClient(int uniqueId) {
LOGV("Entering load plugins"); mDrmManager->addClient(uniqueId);
return mDrmManager->loadPlugIns(uniqueId);
} }
status_t DrmManagerService::loadPlugIns(int uniqueId, const String8& plugInDirPath) { void DrmManagerService::removeClient(int uniqueId) {
LOGV("Entering load plugins from path"); mDrmManager->removeClient(uniqueId);
return mDrmManager->loadPlugIns(uniqueId, plugInDirPath);
} }
status_t DrmManagerService::setDrmServiceListener( status_t DrmManagerService::setDrmServiceListener(
@@ -70,11 +68,6 @@ status_t DrmManagerService::setDrmServiceListener(
return DRM_NO_ERROR; return DRM_NO_ERROR;
} }
status_t DrmManagerService::unloadPlugIns(int uniqueId) {
LOGV("Entering unload plugins");
return mDrmManager->unloadPlugIns(uniqueId);
}
status_t DrmManagerService::installDrmEngine(int uniqueId, const String8& drmEngineFile) { status_t DrmManagerService::installDrmEngine(int uniqueId, const String8& drmEngineFile) {
LOGV("Entering installDrmEngine"); LOGV("Entering installDrmEngine");
return mDrmManager->installDrmEngine(uniqueId, drmEngineFile); return mDrmManager->installDrmEngine(uniqueId, drmEngineFile);
@@ -182,6 +175,12 @@ DecryptHandle* DrmManagerService::openDecryptSession(
return mDrmManager->openDecryptSession(uniqueId, fd, offset, length); return mDrmManager->openDecryptSession(uniqueId, fd, offset, length);
} }
DecryptHandle* DrmManagerService::openDecryptSession(
int uniqueId, const char* uri) {
LOGV("Entering DrmManagerService::openDecryptSession with uri");
return mDrmManager->openDecryptSession(uniqueId, uri);
}
status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
LOGV("Entering closeDecryptSession"); LOGV("Entering closeDecryptSession");
return mDrmManager->closeDecryptSession(uniqueId, decryptHandle); return mDrmManager->closeDecryptSession(uniqueId, decryptHandle);

View File

@@ -22,36 +22,23 @@
using namespace android; using namespace android;
DrmManagerClient::DrmManagerClient() { DrmManagerClient::DrmManagerClient():
int uniqueId = 0; mUniqueId(0), mDrmManagerClientImpl(NULL) {
mDrmManagerClientImpl = NULL; mDrmManagerClientImpl = DrmManagerClientImpl::create(&mUniqueId);
mDrmManagerClientImpl->addClient(mUniqueId);
mDrmManagerClientImpl = DrmManagerClientImpl::create(&uniqueId);
mUniqueId = uniqueId;
loadPlugIns();
} }
DrmManagerClient::~DrmManagerClient() { DrmManagerClient::~DrmManagerClient() {
DrmManagerClientImpl::remove(mUniqueId); DrmManagerClientImpl::remove(mUniqueId);
unloadPlugIns(); mDrmManagerClientImpl->removeClient(mUniqueId);
delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL; delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL;
} }
status_t DrmManagerClient::loadPlugIns() {
return mDrmManagerClientImpl->loadPlugIns(mUniqueId);
}
status_t DrmManagerClient::setOnInfoListener( status_t DrmManagerClient::setOnInfoListener(
const sp<DrmManagerClient::OnInfoListener>& infoListener) { const sp<DrmManagerClient::OnInfoListener>& infoListener) {
return mDrmManagerClientImpl->setOnInfoListener(mUniqueId, infoListener); return mDrmManagerClientImpl->setOnInfoListener(mUniqueId, infoListener);
} }
status_t DrmManagerClient::unloadPlugIns() {
return mDrmManagerClientImpl->unloadPlugIns(mUniqueId);
}
DrmConstraints* DrmManagerClient::getConstraints(const String8* path, const int action) { DrmConstraints* DrmManagerClient::getConstraints(const String8* path, const int action) {
return mDrmManagerClientImpl->getConstraints(mUniqueId, path, action); return mDrmManagerClientImpl->getConstraints(mUniqueId, path, action);
} }
@@ -86,6 +73,7 @@ int DrmManagerClient::checkRightsStatus(const String8& path, int action) {
} }
status_t DrmManagerClient::consumeRights(DecryptHandle* decryptHandle, int action, bool reserve) { status_t DrmManagerClient::consumeRights(DecryptHandle* decryptHandle, int action, bool reserve) {
Mutex::Autolock _l(mDecryptLock);
return mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve); return mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve);
} }
@@ -128,12 +116,17 @@ DecryptHandle* DrmManagerClient::openDecryptSession(int fd, int offset, int leng
return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length); return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length);
} }
DecryptHandle* DrmManagerClient::openDecryptSession(const char* uri) {
return mDrmManagerClientImpl->openDecryptSession(mUniqueId, uri);
}
status_t DrmManagerClient::closeDecryptSession(DecryptHandle* decryptHandle) { status_t DrmManagerClient::closeDecryptSession(DecryptHandle* decryptHandle) {
return mDrmManagerClientImpl->closeDecryptSession(mUniqueId, decryptHandle); return mDrmManagerClientImpl->closeDecryptSession(mUniqueId, decryptHandle);
} }
status_t DrmManagerClient::initializeDecryptUnit( status_t DrmManagerClient::initializeDecryptUnit(
DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) { DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
Mutex::Autolock _l(mDecryptLock);
return mDrmManagerClientImpl->initializeDecryptUnit( return mDrmManagerClientImpl->initializeDecryptUnit(
mUniqueId, decryptHandle, decryptUnitId, headerInfo); mUniqueId, decryptHandle, decryptUnitId, headerInfo);
} }
@@ -141,16 +134,19 @@ status_t DrmManagerClient::initializeDecryptUnit(
status_t DrmManagerClient::decrypt( status_t DrmManagerClient::decrypt(
DecryptHandle* decryptHandle, int decryptUnitId, DecryptHandle* decryptHandle, int decryptUnitId,
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
Mutex::Autolock _l(mDecryptLock);
return mDrmManagerClientImpl->decrypt( return mDrmManagerClientImpl->decrypt(
mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV); mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
} }
status_t DrmManagerClient::finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId) { status_t DrmManagerClient::finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId) {
Mutex::Autolock _l(mDecryptLock);
return mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, decryptHandle, decryptUnitId); return mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, decryptHandle, decryptUnitId);
} }
ssize_t DrmManagerClient::pread( ssize_t DrmManagerClient::pread(
DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off_t offset) { DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off_t offset) {
Mutex::Autolock _l(mDecryptLock);
return mDrmManagerClientImpl->pread(mUniqueId, decryptHandle, buffer, numBytes, offset); return mDrmManagerClientImpl->pread(mUniqueId, decryptHandle, buffer, numBytes, offset);
} }

View File

@@ -46,14 +46,6 @@ void DrmManagerClientImpl::remove(int uniqueId) {
getDrmManagerService()->removeUniqueId(uniqueId); getDrmManagerService()->removeUniqueId(uniqueId);
} }
DrmManagerClientImpl::DrmManagerClientImpl() {
}
DrmManagerClientImpl::~DrmManagerClientImpl() {
}
const sp<IDrmManagerService>& DrmManagerClientImpl::getDrmManagerService() { const sp<IDrmManagerService>& DrmManagerClientImpl::getDrmManagerService() {
mMutex.lock(); mMutex.lock();
if (NULL == mDrmManagerService.get()) { if (NULL == mDrmManagerService.get()) {
@@ -77,16 +69,12 @@ const sp<IDrmManagerService>& DrmManagerClientImpl::getDrmManagerService() {
return mDrmManagerService; return mDrmManagerService;
} }
status_t DrmManagerClientImpl::loadPlugIns(int uniqueId) { void DrmManagerClientImpl::addClient(int uniqueId) {
return getDrmManagerService()->loadPlugIns(uniqueId); getDrmManagerService()->addClient(uniqueId);
} }
status_t DrmManagerClientImpl::loadPlugIns(int uniqueId, const String8& plugInDirPath) { void DrmManagerClientImpl::removeClient(int uniqueId) {
status_t status = DRM_ERROR_UNKNOWN; getDrmManagerService()->removeClient(uniqueId);
if (EMPTY_STRING != plugInDirPath) {
status = getDrmManagerService()->loadPlugIns(uniqueId, plugInDirPath);
}
return status;
} }
status_t DrmManagerClientImpl::setOnInfoListener( status_t DrmManagerClientImpl::setOnInfoListener(
@@ -96,10 +84,6 @@ status_t DrmManagerClientImpl::setOnInfoListener(
return getDrmManagerService()->setDrmServiceListener(uniqueId, this); return getDrmManagerService()->setDrmServiceListener(uniqueId, this);
} }
status_t DrmManagerClientImpl::unloadPlugIns(int uniqueId) {
return getDrmManagerService()->unloadPlugIns(uniqueId);
}
status_t DrmManagerClientImpl::installDrmEngine(int uniqueId, const String8& drmEngineFile) { status_t DrmManagerClientImpl::installDrmEngine(int uniqueId, const String8& drmEngineFile) {
status_t status = DRM_ERROR_UNKNOWN; status_t status = DRM_ERROR_UNKNOWN;
if (EMPTY_STRING != drmEngineFile) { if (EMPTY_STRING != drmEngineFile) {
@@ -251,6 +235,14 @@ DecryptHandle* DrmManagerClientImpl::openDecryptSession(
return getDrmManagerService()->openDecryptSession(uniqueId, fd, offset, length); return getDrmManagerService()->openDecryptSession(uniqueId, fd, offset, length);
} }
DecryptHandle* DrmManagerClientImpl::openDecryptSession(int uniqueId, const char* uri) {
DecryptHandle* handle = NULL;
if (NULL != uri) {
handle = getDrmManagerService()->openDecryptSession(uniqueId, uri);
}
return handle;
}
status_t DrmManagerClientImpl::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { status_t DrmManagerClientImpl::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
status_t status = DRM_ERROR_UNKNOWN; status_t status = DRM_ERROR_UNKNOWN;
if (NULL != decryptHandle) { if (NULL != decryptHandle) {

View File

@@ -57,15 +57,19 @@ public:
void removeUniqueId(int uniqueId); void removeUniqueId(int uniqueId);
status_t loadPlugIns(int uniqueId); void addClient(int uniqueId);
status_t loadPlugIns(int uniqueId, const String8& plugInDirPath); void removeClient(int uniqueId);
status_t loadPlugIns();
status_t loadPlugIns(const String8& plugInDirPath);
status_t unloadPlugIns();
status_t setDrmServiceListener( status_t setDrmServiceListener(
int uniqueId, const sp<IDrmServiceListener>& drmServiceListener); int uniqueId, const sp<IDrmServiceListener>& drmServiceListener);
status_t unloadPlugIns(int uniqueId);
status_t installDrmEngine(int uniqueId, const String8& drmEngineFile); status_t installDrmEngine(int uniqueId, const String8& drmEngineFile);
DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action); DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action);
@@ -107,6 +111,8 @@ public:
DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length); DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle); status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
@@ -129,12 +135,8 @@ private:
String8 getSupportedPlugInIdFromPath(int uniqueId, const String8& path); String8 getSupportedPlugInIdFromPath(int uniqueId, const String8& path);
void populate(int uniqueId);
bool canHandle(int uniqueId, const String8& path); bool canHandle(int uniqueId, const String8& path);
void initializePlugIns(int uniqueId);
private: private:
static Vector<int> mUniqueIdVector; static Vector<int> mUniqueIdVector;
static const String8 EMPTY_STRING; static const String8 EMPTY_STRING;

View File

@@ -35,36 +35,29 @@ class DrmInfoEvent;
*/ */
class DrmManagerClientImpl : public BnDrmServiceListener { class DrmManagerClientImpl : public BnDrmServiceListener {
private: private:
DrmManagerClientImpl(); DrmManagerClientImpl() { }
public: public:
static DrmManagerClientImpl* create(int* pUniqueId); static DrmManagerClientImpl* create(int* pUniqueId);
static void remove(int uniqueId); static void remove(int uniqueId);
virtual ~DrmManagerClientImpl(); virtual ~DrmManagerClientImpl() { }
public: public:
/** /**
* Initialize DRM Manager * Adds the client respective to given unique id.
* load available plug-ins from default plugInDirPath
* *
* @param[in] uniqueId Unique identifier for a session * @param[in] uniqueId Unique identifier for a session
* @return status_t
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/ */
status_t loadPlugIns(int uniqueId); void addClient(int uniqueId);
/** /**
* Finalize DRM Manager * Removes the client respective to given unique id.
* release resources associated with each plug-in
* unload all plug-ins and etc.
* *
* @param[in] uniqueId Unique identifier for a session * @param[in] uniqueId Unique identifier for a session
* @return status_t
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/ */
status_t unloadPlugIns(int uniqueId); void removeClient(int uniqueId);
/** /**
* Register a callback to be invoked when the caller required to * Register a callback to be invoked when the caller required to
@@ -300,6 +293,16 @@ public:
*/ */
DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length); DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
/**
* Open the decrypt session to decrypt the given protected content
*
* @param[in] uniqueId Unique identifier for a session
* @param[in] uri Path of the protected content to be decrypted
* @return
* Handle for the decryption session
*/
DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
/** /**
* Close the decrypt session for the given handle * Close the decrypt session for the given handle
* *
@@ -378,17 +381,6 @@ public:
status_t notify(const DrmInfoEvent& event); status_t notify(const DrmInfoEvent& event);
private: private:
/**
* Initialize DRM Manager
* load available plug-ins from plugInDirPath
*
* @param[in] uniqueId Unique identifier for a session
* @param[in] plugInDirPath Directory from where to load plug-ins
* @return status_t
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
status_t loadPlugIns(int uniqueId, const String8& plugInDirPath);
/** /**
* Install new DRM Engine Plug-in at the runtime * Install new DRM Engine Plug-in at the runtime
* *

View File

@@ -50,15 +50,13 @@ public:
void removeUniqueId(int uniqueId); void removeUniqueId(int uniqueId);
status_t loadPlugIns(int uniqueId); void addClient(int uniqueId);
status_t loadPlugIns(int uniqueId, const String8& plugInDirPath); void removeClient(int uniqueId);
status_t setDrmServiceListener( status_t setDrmServiceListener(
int uniqueId, const sp<IDrmServiceListener>& drmServiceListener); int uniqueId, const sp<IDrmServiceListener>& drmServiceListener);
status_t unloadPlugIns(int uniqueId);
status_t installDrmEngine(int uniqueId, const String8& drmEngineFile); status_t installDrmEngine(int uniqueId, const String8& drmEngineFile);
DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action); DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action);
@@ -100,6 +98,8 @@ public:
DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length); DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle); status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,

View File

@@ -46,10 +46,9 @@ public:
enum { enum {
ADD_UNIQUEID = IBinder::FIRST_CALL_TRANSACTION, ADD_UNIQUEID = IBinder::FIRST_CALL_TRANSACTION,
REMOVE_UNIQUEID, REMOVE_UNIQUEID,
LOAD_PLUGINS, ADD_CLIENT,
LOAD_PLUGINS_FROM_PATH, REMOVE_CLIENT,
SET_DRM_SERVICE_LISTENER, SET_DRM_SERVICE_LISTENER,
UNLOAD_PLUGINS,
INSTALL_DRM_ENGINE, INSTALL_DRM_ENGINE,
GET_CONSTRAINTS_FROM_CONTENT, GET_CONSTRAINTS_FROM_CONTENT,
CAN_HANDLE, CAN_HANDLE,
@@ -69,6 +68,7 @@ public:
CLOSE_CONVERT_SESSION, CLOSE_CONVERT_SESSION,
GET_ALL_SUPPORT_INFO, GET_ALL_SUPPORT_INFO,
OPEN_DECRYPT_SESSION, OPEN_DECRYPT_SESSION,
OPEN_DECRYPT_SESSION_FROM_URI,
CLOSE_DECRYPT_SESSION, CLOSE_DECRYPT_SESSION,
INITIALIZE_DECRYPT_UNIT, INITIALIZE_DECRYPT_UNIT,
DECRYPT, DECRYPT,
@@ -84,15 +84,13 @@ public:
virtual void removeUniqueId(int uniqueId) = 0; virtual void removeUniqueId(int uniqueId) = 0;
virtual status_t loadPlugIns(int uniqueId) = 0; virtual void addClient(int uniqueId) = 0;
virtual status_t loadPlugIns(int uniqueId, const String8& plugInDirPath) = 0; virtual void removeClient(int uniqueId) = 0;
virtual status_t setDrmServiceListener( virtual status_t setDrmServiceListener(
int uniqueId, const sp<IDrmServiceListener>& infoListener) = 0; int uniqueId, const sp<IDrmServiceListener>& infoListener) = 0;
virtual status_t unloadPlugIns(int uniqueId) = 0;
virtual status_t installDrmEngine(int uniqueId, const String8& drmEngineFile) = 0; virtual status_t installDrmEngine(int uniqueId, const String8& drmEngineFile) = 0;
virtual DrmConstraints* getConstraints( virtual DrmConstraints* getConstraints(
@@ -140,6 +138,8 @@ public:
virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length) = 0; virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length) = 0;
virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri) = 0;
virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0; virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
@@ -168,15 +168,13 @@ public:
virtual void removeUniqueId(int uniqueId); virtual void removeUniqueId(int uniqueId);
virtual status_t loadPlugIns(int uniqueId); virtual void addClient(int uniqueId);
virtual status_t loadPlugIns(int uniqueId, const String8& plugInDirPath); virtual void removeClient(int uniqueId);
virtual status_t setDrmServiceListener( virtual status_t setDrmServiceListener(
int uniqueId, const sp<IDrmServiceListener>& infoListener); int uniqueId, const sp<IDrmServiceListener>& infoListener);
virtual status_t unloadPlugIns(int uniqueId);
virtual status_t installDrmEngine(int uniqueId, const String8& drmEngineFile); virtual status_t installDrmEngine(int uniqueId, const String8& drmEngineFile);
virtual DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action); virtual DrmConstraints* getConstraints(int uniqueId, const String8* path, const int action);
@@ -221,6 +219,8 @@ public:
virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length); virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle); virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,

View File

@@ -80,6 +80,9 @@ public:
status_t openDecryptSession( status_t openDecryptSession(
int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length); int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length);
status_t openDecryptSession(
int uniqueId, DecryptHandle* decryptHandle, const char* uri);
status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle); status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
@@ -354,6 +357,18 @@ protected:
virtual status_t onOpenDecryptSession( virtual status_t onOpenDecryptSession(
int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length) = 0; int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length) = 0;
/**
* Open the decrypt session to decrypt the given protected content
*
* @param[in] uniqueId Unique identifier for a session
* @param[in] decryptHandle Handle for the current decryption session
* @param[in] uri Path of the protected content to be decrypted
* @return
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
*/
virtual status_t onOpenDecryptSession(
int uniqueId, DecryptHandle* decryptHandle, const char* uri) = 0;
/** /**
* Close the decrypt session for the given handle * Close the decrypt session for the given handle
* *

View File

@@ -314,6 +314,18 @@ public:
virtual status_t openDecryptSession( virtual status_t openDecryptSession(
int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length) = 0; int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length) = 0;
/**
* Open the decrypt session to decrypt the given protected content
*
* @param[in] uniqueId Unique identifier for a session
* @param[in] decryptHandle Handle for the current decryption session
* @param[in] uri Path of the protected content to be decrypted
* @return
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
*/
virtual status_t openDecryptSession(
int uniqueId, DecryptHandle* decryptHandle, const char* uri) = 0;
/** /**
* Close the decrypt session for the given handle * Close the decrypt session for the given handle
* *

View File

@@ -74,6 +74,9 @@ protected:
status_t onOpenDecryptSession( status_t onOpenDecryptSession(
int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length); int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length);
status_t onOpenDecryptSession(
int uniqueId, DecryptHandle* decryptHandle, const char* uri);
status_t onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle); status_t onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
status_t onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, status_t onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,

View File

@@ -74,14 +74,14 @@ DrmInfoStatus* DrmPassthruPlugIn::onProcessDrmInfo(int uniqueId, const DrmInfo*
switch (drmInfo->getInfoType()) { switch (drmInfo->getInfoType()) {
case DrmInfoRequest::TYPE_REGISTRATION_INFO: { case DrmInfoRequest::TYPE_REGISTRATION_INFO: {
const DrmBuffer* emptyBuffer = new DrmBuffer(); const DrmBuffer* emptyBuffer = new DrmBuffer();
drmInfoStatus drmInfoStatus = new DrmInfoStatus(DrmInfoStatus::STATUS_OK,
= new DrmInfoStatus(DrmInfoStatus::STATUS_OK, emptyBuffer, drmInfo->getMimeType()); DrmInfoRequest::TYPE_REGISTRATION_INFO, emptyBuffer, drmInfo->getMimeType());
break; break;
} }
case DrmInfoRequest::TYPE_UNREGISTRATION_INFO: { case DrmInfoRequest::TYPE_UNREGISTRATION_INFO: {
const DrmBuffer* emptyBuffer = new DrmBuffer(); const DrmBuffer* emptyBuffer = new DrmBuffer();
drmInfoStatus drmInfoStatus = new DrmInfoStatus(DrmInfoStatus::STATUS_OK,
= new DrmInfoStatus(DrmInfoStatus::STATUS_OK, emptyBuffer, drmInfo->getMimeType()); DrmInfoRequest::TYPE_UNREGISTRATION_INFO, emptyBuffer, drmInfo->getMimeType());
break; break;
} }
case DrmInfoRequest::TYPE_RIGHTS_ACQUISITION_INFO: { case DrmInfoRequest::TYPE_RIGHTS_ACQUISITION_INFO: {
@@ -91,8 +91,8 @@ DrmInfoStatus* DrmPassthruPlugIn::onProcessDrmInfo(int uniqueId, const DrmInfo*
data = new char[bufferSize]; data = new char[bufferSize];
memcpy(data, licenseString.string(), bufferSize); memcpy(data, licenseString.string(), bufferSize);
const DrmBuffer* buffer = new DrmBuffer(data, bufferSize); const DrmBuffer* buffer = new DrmBuffer(data, bufferSize);
drmInfoStatus drmInfoStatus = new DrmInfoStatus(DrmInfoStatus::STATUS_OK,
= new DrmInfoStatus(DrmInfoStatus::STATUS_OK, buffer, drmInfo->getMimeType()); DrmInfoRequest::TYPE_RIGHTS_ACQUISITION_INFO, buffer, drmInfo->getMimeType());
break; break;
} }
} }
@@ -243,6 +243,11 @@ status_t DrmPassthruPlugIn::onOpenDecryptSession(
return DRM_ERROR_CANNOT_HANDLE; return DRM_ERROR_CANNOT_HANDLE;
} }
status_t DrmPassthruPlugIn::onOpenDecryptSession(
int uniqueId, DecryptHandle* decryptHandle, const char* uri) {
return DRM_ERROR_CANNOT_HANDLE;
}
status_t DrmPassthruPlugIn::onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { status_t DrmPassthruPlugIn::onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
LOGD("DrmPassthruPlugIn::onCloseDecryptSession() : %d", uniqueId); LOGD("DrmPassthruPlugIn::onCloseDecryptSession() : %d", uniqueId);
if (NULL != decryptHandle) { if (NULL != decryptHandle) {

View File

@@ -59,8 +59,8 @@ public:
//! TYPE_NO_INTERNET_CONNECTION, when the Internet connection is missing and no attempt //! TYPE_NO_INTERNET_CONNECTION, when the Internet connection is missing and no attempt
//! can be made to renew rights //! can be made to renew rights
static const int TYPE_NO_INTERNET_CONNECTION = 2005; static const int TYPE_NO_INTERNET_CONNECTION = 2005;
//! TYPE_REGISTRATION_FAILED, when registration with server failed. //! TYPE_PROCESS_DRM_INFO_FAILED, when failed to process DrmInfo.
static const int TYPE_REGISTRATION_FAILED = 2006; static const int TYPE_PROCESS_DRM_INFO_FAILED = 2006;
public: public:
/** /**

View File

@@ -41,10 +41,11 @@ public:
* Constructor for DrmInfoStatus * Constructor for DrmInfoStatus
* *
* @param[in] _statusCode Status of the communication * @param[in] _statusCode Status of the communication
* @param[in] _infoType Type of the DRM information processed
* @param[in] _drmBuffer Rights information * @param[in] _drmBuffer Rights information
* @param[in] _mimeType MIME type * @param[in] _mimeType MIME type
*/ */
DrmInfoStatus(int _statusCode, const DrmBuffer* _drmBuffer, const String8& _mimeType); DrmInfoStatus(int _statusCode, int _infoType, const DrmBuffer* _drmBuffer, const String8& _mimeType);
/** /**
* Destructor for DrmInfoStatus * Destructor for DrmInfoStatus
@@ -55,6 +56,7 @@ public:
public: public:
int statusCode; int statusCode;
int infoType;
const DrmBuffer* drmBuffer; const DrmBuffer* drmBuffer;
String8 mimeType; String8 mimeType;
}; };

View File

@@ -17,6 +17,7 @@
#ifndef __DRM_MANAGER_CLIENT_H__ #ifndef __DRM_MANAGER_CLIENT_H__
#define __DRM_MANAGER_CLIENT_H__ #define __DRM_MANAGER_CLIENT_H__
#include <utils/threads.h>
#include <binder/IInterface.h> #include <binder/IInterface.h>
#include "drm_framework_common.h" #include "drm_framework_common.h"
@@ -66,6 +67,15 @@ public:
*/ */
DecryptHandle* openDecryptSession(int fd, int offset, int length); DecryptHandle* openDecryptSession(int fd, int offset, int length);
/**
* Open the decrypt session to decrypt the given protected content
*
* @param[in] uri Path of the protected content to be decrypted
* @return
* Handle for the decryption session
*/
DecryptHandle* openDecryptSession(const char* uri);
/** /**
* Close the decrypt session for the given handle * Close the decrypt session for the given handle
* *
@@ -338,28 +348,9 @@ public:
*/ */
status_t getAllSupportInfo(int* length, DrmSupportInfo** drmSupportInfoArray); status_t getAllSupportInfo(int* length, DrmSupportInfo** drmSupportInfoArray);
private:
/**
* Initialize DRM Manager
* load available plug-ins from default plugInDirPath
*
* @return status_t
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
status_t loadPlugIns();
/**
* Finalize DRM Manager
* release resources associated with each plug-in
* unload all plug-ins and etc.
*
* @return status_t
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
status_t unloadPlugIns();
private: private:
int mUniqueId; int mUniqueId;
Mutex mDecryptLock;
DrmManagerClientImpl* mDrmManagerClientImpl; DrmManagerClientImpl* mDrmManagerClientImpl;
}; };