Merge "Update of DRM framework"
This commit is contained in:
132
api/current.xml
132
api/current.xml
@ -55656,29 +55656,7 @@
|
|||||||
type="int"
|
type="int"
|
||||||
transient="false"
|
transient="false"
|
||||||
volatile="false"
|
volatile="false"
|
||||||
value="2012"
|
value="2008"
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="TYPE_FINALIZE_FAILED"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="2010"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="TYPE_INITIALIZE_FAILED"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="2009"
|
|
||||||
static="true"
|
static="true"
|
||||||
final="true"
|
final="true"
|
||||||
deprecated="not deprecated"
|
deprecated="not deprecated"
|
||||||
@ -55718,7 +55696,7 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
<field name="TYPE_REGISTRATION_FAILED"
|
<field name="TYPE_PROCESS_DRM_INFO_FAILED"
|
||||||
type="int"
|
type="int"
|
||||||
transient="false"
|
transient="false"
|
||||||
volatile="false"
|
volatile="false"
|
||||||
@ -55733,18 +55711,7 @@
|
|||||||
type="int"
|
type="int"
|
||||||
transient="false"
|
transient="false"
|
||||||
volatile="false"
|
volatile="false"
|
||||||
value="2011"
|
value="2007"
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="TYPE_RIGHTS_ACQUISITION_FAILED"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="2008"
|
|
||||||
static="true"
|
static="true"
|
||||||
final="true"
|
final="true"
|
||||||
deprecated="not deprecated"
|
deprecated="not deprecated"
|
||||||
@ -55773,17 +55740,6 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
<field name="TYPE_UNREGISTRATION_FAILED"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="2007"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
</class>
|
</class>
|
||||||
<class name="DrmEvent"
|
<class name="DrmEvent"
|
||||||
extends="java.lang.Object"
|
extends="java.lang.Object"
|
||||||
@ -55866,7 +55822,7 @@
|
|||||||
type="int"
|
type="int"
|
||||||
transient="false"
|
transient="false"
|
||||||
volatile="false"
|
volatile="false"
|
||||||
value="1006"
|
value="1001"
|
||||||
static="true"
|
static="true"
|
||||||
final="true"
|
final="true"
|
||||||
deprecated="not deprecated"
|
deprecated="not deprecated"
|
||||||
@ -55874,28 +55830,6 @@
|
|||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
<field name="TYPE_DRM_INFO_ACQUIRED"
|
<field name="TYPE_DRM_INFO_ACQUIRED"
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="1007"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="TYPE_FINALIZED"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="1001"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="TYPE_INITIALIZED"
|
|
||||||
type="int"
|
type="int"
|
||||||
transient="false"
|
transient="false"
|
||||||
volatile="false"
|
volatile="false"
|
||||||
@ -55906,7 +55840,7 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
<field name="TYPE_REGISTERED"
|
<field name="TYPE_DRM_INFO_PROCESSED"
|
||||||
type="int"
|
type="int"
|
||||||
transient="false"
|
transient="false"
|
||||||
volatile="false"
|
volatile="false"
|
||||||
@ -55917,28 +55851,6 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
<field name="TYPE_RIGHTS_ACQUIRED"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="1005"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
<field name="TYPE_UNREGISTERED"
|
|
||||||
type="int"
|
|
||||||
transient="false"
|
|
||||||
volatile="false"
|
|
||||||
value="1004"
|
|
||||||
static="true"
|
|
||||||
final="true"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</field>
|
|
||||||
</class>
|
</class>
|
||||||
<class name="DrmInfo"
|
<class name="DrmInfo"
|
||||||
extends="java.lang.Object"
|
extends="java.lang.Object"
|
||||||
@ -56314,6 +56226,8 @@
|
|||||||
>
|
>
|
||||||
<parameter name="_statusCode" type="int">
|
<parameter name="_statusCode" type="int">
|
||||||
</parameter>
|
</parameter>
|
||||||
|
<parameter name="_infoType" type="int">
|
||||||
|
</parameter>
|
||||||
<parameter name="_data" type="android.drm.ProcessedData">
|
<parameter name="_data" type="android.drm.ProcessedData">
|
||||||
</parameter>
|
</parameter>
|
||||||
<parameter name="_mimeType" type="java.lang.String">
|
<parameter name="_mimeType" type="java.lang.String">
|
||||||
@ -56351,6 +56265,16 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
|
<field name="infoType"
|
||||||
|
type="int"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
static="false"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
<field name="mimeType"
|
<field name="mimeType"
|
||||||
type="java.lang.String"
|
type="java.lang.String"
|
||||||
transient="false"
|
transient="false"
|
||||||
@ -56614,17 +56538,6 @@
|
|||||||
<parameter name="uri" type="android.net.Uri">
|
<parameter name="uri" type="android.net.Uri">
|
||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
<method name="loadPlugIns"
|
|
||||||
return="int"
|
|
||||||
abstract="false"
|
|
||||||
native="false"
|
|
||||||
synchronized="false"
|
|
||||||
static="false"
|
|
||||||
final="false"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</method>
|
|
||||||
<method name="openConvertSession"
|
<method name="openConvertSession"
|
||||||
return="int"
|
return="int"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
@ -56746,17 +56659,6 @@
|
|||||||
<parameter name="infoListener" type="android.drm.DrmManagerClient.OnInfoListener">
|
<parameter name="infoListener" type="android.drm.DrmManagerClient.OnInfoListener">
|
||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
<method name="unloadPlugIns"
|
|
||||||
return="int"
|
|
||||||
abstract="false"
|
|
||||||
native="false"
|
|
||||||
synchronized="false"
|
|
||||||
static="false"
|
|
||||||
final="false"
|
|
||||||
deprecated="not deprecated"
|
|
||||||
visibility="public"
|
|
||||||
>
|
|
||||||
</method>
|
|
||||||
<field name="ERROR_NONE"
|
<field name="ERROR_NONE"
|
||||||
type="int"
|
type="int"
|
||||||
transient="false"
|
transient="false"
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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) {
|
||||||
|
|
||||||
|
@ -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);
|
||||||
@ -565,6 +545,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;
|
||||||
@ -746,25 +754,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -783,18 +785,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");
|
||||||
@ -881,6 +871,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) {
|
||||||
@ -1239,6 +1230,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");
|
||||||
|
@ -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,16 +391,43 @@ 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;
|
||||||
LOGE("DrmManager::openDecryptSession: no capable plug-in found");
|
LOGE("DrmManager::openDecryptSession: no capable plug-in found");
|
||||||
}
|
}
|
||||||
|
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);
|
||||||
@ -443,28 +481,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("");
|
||||||
|
@ -27,36 +27,21 @@
|
|||||||
|
|
||||||
using namespace android;
|
using namespace android;
|
||||||
|
|
||||||
#define SUCCESS 0
|
|
||||||
#define DRM_DIRECTORY_PERMISSION 0700
|
|
||||||
#define DRM_PLUGINS_ROOT "/data/drm/plugins"
|
|
||||||
#define DRM_PLUGINS_NATIVE "/data/drm/plugins/native"
|
|
||||||
#define DRM_PLUGINS_NATIVE_DATABASES "/data/drm/plugins/native/databases"
|
|
||||||
|
|
||||||
void DrmManagerService::instantiate() {
|
void DrmManagerService::instantiate() {
|
||||||
LOGV("instantiate");
|
LOGV("instantiate");
|
||||||
|
defaultServiceManager()->addService(String16("drm.drmManager"), new DrmManagerService());
|
||||||
int res = mkdir(DRM_PLUGINS_ROOT, DRM_DIRECTORY_PERMISSION);
|
|
||||||
if (SUCCESS == res || EEXIST == errno) {
|
|
||||||
res = mkdir(DRM_PLUGINS_NATIVE, DRM_DIRECTORY_PERMISSION);
|
|
||||||
if (SUCCESS == res || EEXIST == errno) {
|
|
||||||
res = mkdir(DRM_PLUGINS_NATIVE_DATABASES, DRM_DIRECTORY_PERMISSION);
|
|
||||||
if (SUCCESS == res || EEXIST == errno) {
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,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(
|
||||||
@ -85,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);
|
||||||
@ -197,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);
|
||||||
|
@ -45,35 +45,19 @@ public class DrmErrorEvent extends DrmEvent {
|
|||||||
*/
|
*/
|
||||||
public static final int TYPE_NO_INTERNET_CONNECTION = 2005;
|
public static final int TYPE_NO_INTERNET_CONNECTION = 2005;
|
||||||
/**
|
/**
|
||||||
* TYPE_REGISTRATION_FAILED, when failed to register with the service.
|
* TYPE_PROCESS_DRM_INFO_FAILED, when failed to process DrmInfo.
|
||||||
*/
|
*/
|
||||||
public static final int TYPE_REGISTRATION_FAILED = 2006;
|
public static final int TYPE_PROCESS_DRM_INFO_FAILED = 2006;
|
||||||
/**
|
|
||||||
* TYPE_UNREGISTRATION_FAILED, when failed to unregister with the service.
|
|
||||||
*/
|
|
||||||
public static final int TYPE_UNREGISTRATION_FAILED = 2007;
|
|
||||||
/**
|
|
||||||
* TYPE_RIGHTS_ACQUISITION_FAILED, when failed to acquire the rights information required.
|
|
||||||
*/
|
|
||||||
public static final int TYPE_RIGHTS_ACQUISITION_FAILED = 2008;
|
|
||||||
/**
|
|
||||||
* TYPE_INITIALIZE_FAILED, when failed to load and initialize the available plugins.
|
|
||||||
*/
|
|
||||||
public static final int TYPE_INITIALIZE_FAILED = 2009;
|
|
||||||
/**
|
|
||||||
* TYPE_FINALIZE_FAILED, when failed to unload and finalize the loaded plugins.
|
|
||||||
*/
|
|
||||||
public static final int TYPE_FINALIZE_FAILED = 2010;
|
|
||||||
/**
|
/**
|
||||||
* TYPE_REMOVE_ALL_RIGHTS_FAILED, when failed to remove all the rights objects
|
* TYPE_REMOVE_ALL_RIGHTS_FAILED, when failed to remove all the rights objects
|
||||||
* associated with all DRM schemes.
|
* associated with all DRM schemes.
|
||||||
*/
|
*/
|
||||||
public static final int TYPE_REMOVE_ALL_RIGHTS_FAILED = 2011;
|
public static final int TYPE_REMOVE_ALL_RIGHTS_FAILED = 2007;
|
||||||
/**
|
/**
|
||||||
* TYPE_DRM_INFO_ACQUISITION_FAILED, when failed to get the required information to
|
* TYPE_DRM_INFO_ACQUISITION_FAILED, when failed to get the required information to
|
||||||
* communicate with the service.
|
* communicate with the service.
|
||||||
*/
|
*/
|
||||||
public static final int TYPE_DRM_INFO_ACQUISITION_FAILED = 2012;
|
public static final int TYPE_DRM_INFO_ACQUISITION_FAILED = 2008;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor to create DrmErrorEvent object with given parameters
|
* constructor to create DrmErrorEvent object with given parameters
|
||||||
|
@ -22,36 +22,20 @@ package android.drm;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DrmEvent {
|
public class DrmEvent {
|
||||||
/**
|
|
||||||
* Constant field signifies that unload and finalize the loaded plugins successfully
|
|
||||||
*/
|
|
||||||
public static final int TYPE_FINALIZED = 1001;
|
|
||||||
/**
|
|
||||||
* Constant field signifies that register with the service successfully
|
|
||||||
*/
|
|
||||||
public static final int TYPE_REGISTERED = 1002;
|
|
||||||
/**
|
|
||||||
* Constant field signifies that load and initialized the available plugins successfully
|
|
||||||
*/
|
|
||||||
public static final int TYPE_INITIALIZED = 1003;
|
|
||||||
/**
|
|
||||||
* Constant field signifies that unregister with the service successfully
|
|
||||||
*/
|
|
||||||
public static final int TYPE_UNREGISTERED = 1004;
|
|
||||||
/**
|
|
||||||
* Constant field signifies that rights information is acquired successfully
|
|
||||||
*/
|
|
||||||
public static final int TYPE_RIGHTS_ACQUIRED = 1005;
|
|
||||||
/**
|
/**
|
||||||
* Constant field signifies that all the rights information associated with
|
* Constant field signifies that all the rights information associated with
|
||||||
* all DRM schemes are removed successfully
|
* all DRM schemes are removed successfully
|
||||||
*/
|
*/
|
||||||
public static final int TYPE_ALL_RIGHTS_REMOVED = 1006;
|
public static final int TYPE_ALL_RIGHTS_REMOVED = 1001;
|
||||||
|
/**
|
||||||
|
* Constant field signifies that given information is processed successfully
|
||||||
|
*/
|
||||||
|
public static final int TYPE_DRM_INFO_PROCESSED = 1002;
|
||||||
/**
|
/**
|
||||||
* Constant field signifies that the required information to communicate with
|
* Constant field signifies that the required information to communicate with
|
||||||
* the service is acquired sucessfully
|
* the service is acquired sucessfully
|
||||||
*/
|
*/
|
||||||
public static final int TYPE_DRM_INFO_ACQUIRED = 1007;
|
public static final int TYPE_DRM_INFO_ACQUIRED = 1003;
|
||||||
|
|
||||||
public static final String DRM_INFO_STATUS_OBJECT = "drm_info_status_object";
|
public static final String DRM_INFO_STATUS_OBJECT = "drm_info_status_object";
|
||||||
public static final String DRM_INFO_OBJECT = "drm_info_object";
|
public static final String DRM_INFO_OBJECT = "drm_info_object";
|
||||||
|
@ -31,6 +31,7 @@ public class DrmInfoStatus {
|
|||||||
public static final int STATUS_ERROR = 2;
|
public static final int STATUS_ERROR = 2;
|
||||||
|
|
||||||
public final int statusCode;
|
public final int statusCode;
|
||||||
|
public final int infoType;
|
||||||
public final String mimeType;
|
public final String mimeType;
|
||||||
public final ProcessedData data;
|
public final ProcessedData data;
|
||||||
|
|
||||||
@ -38,11 +39,13 @@ public class DrmInfoStatus {
|
|||||||
* constructor to create DrmInfoStatus object with given parameters
|
* constructor to create DrmInfoStatus object with given parameters
|
||||||
*
|
*
|
||||||
* @param _statusCode Status of the communication
|
* @param _statusCode Status of the communication
|
||||||
|
* @param _infoType Type of the DRM information processed
|
||||||
* @param _data The processed data
|
* @param _data The processed data
|
||||||
* @param _mimeType MIME type
|
* @param _mimeType MIME type
|
||||||
*/
|
*/
|
||||||
public DrmInfoStatus(int _statusCode, ProcessedData _data, String _mimeType) {
|
public DrmInfoStatus(int _statusCode, int _infoType, ProcessedData _data, String _mimeType) {
|
||||||
statusCode = _statusCode;
|
statusCode = _statusCode;
|
||||||
|
infoType = _infoType;
|
||||||
data = _data;
|
data = _data;
|
||||||
mimeType = _mimeType;
|
mimeType = _mimeType;
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,11 @@
|
|||||||
|
|
||||||
package android.drm;
|
package android.drm;
|
||||||
|
|
||||||
|
import android.content.ContentResolver;
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
|
import android.database.sqlite.SQLiteException;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
@ -99,14 +101,9 @@ public class DrmManagerClient {
|
|||||||
public void onError(DrmManagerClient client, DrmErrorEvent event);
|
public void onError(DrmManagerClient client, DrmErrorEvent event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int STATE_UNINITIALIZED = 0;
|
private static final int ACTION_REMOVE_ALL_RIGHTS = 1001;
|
||||||
private static final int STATE_INITIALIZED = 1;
|
private static final int ACTION_ACQUIRE_DRM_INFO = 1002;
|
||||||
|
private static final int ACTION_PROCESS_DRM_INFO = 1003;
|
||||||
private static final int ACTION_INITIALIZE = 1000;
|
|
||||||
private static final int ACTION_FINALIZE = 1001;
|
|
||||||
private static final int ACTION_REMOVE_ALL_RIGHTS = 1002;
|
|
||||||
private static final int ACTION_ACQUIRE_DRM_INFO = 1003;
|
|
||||||
private static final int ACTION_PROCESS_DRM_INFO = 1004;
|
|
||||||
|
|
||||||
private int mUniqueId;
|
private int mUniqueId;
|
||||||
private int mNativeContext;
|
private int mNativeContext;
|
||||||
@ -116,7 +113,6 @@ public class DrmManagerClient {
|
|||||||
private OnInfoListener mOnInfoListener;
|
private OnInfoListener mOnInfoListener;
|
||||||
private OnEventListener mOnEventListener;
|
private OnEventListener mOnEventListener;
|
||||||
private OnErrorListener mOnErrorListener;
|
private OnErrorListener mOnErrorListener;
|
||||||
private int mCurrentState = STATE_UNINITIALIZED;
|
|
||||||
|
|
||||||
private class EventHandler extends Handler {
|
private class EventHandler extends Handler {
|
||||||
|
|
||||||
@ -130,16 +126,6 @@ public class DrmManagerClient {
|
|||||||
HashMap<String, Object> attributes = new HashMap<String, Object>();
|
HashMap<String, Object> attributes = new HashMap<String, Object>();
|
||||||
|
|
||||||
switch(msg.what) {
|
switch(msg.what) {
|
||||||
case ACTION_INITIALIZE: {
|
|
||||||
if (ERROR_NONE == _loadPlugIns(mUniqueId, msg.obj)) {
|
|
||||||
mCurrentState = STATE_INITIALIZED;
|
|
||||||
event = new DrmEvent(mUniqueId, DrmEvent.TYPE_INITIALIZED, null);
|
|
||||||
} else {
|
|
||||||
error = new DrmErrorEvent(mUniqueId,
|
|
||||||
DrmErrorEvent.TYPE_INITIALIZE_FAILED, null);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ACTION_ACQUIRE_DRM_INFO: {
|
case ACTION_ACQUIRE_DRM_INFO: {
|
||||||
final DrmInfoRequest request = (DrmInfoRequest) msg.obj;
|
final DrmInfoRequest request = (DrmInfoRequest) msg.obj;
|
||||||
DrmInfo drmInfo = _acquireDrmInfo(mUniqueId, request);
|
DrmInfo drmInfo = _acquireDrmInfo(mUniqueId, request);
|
||||||
@ -157,10 +143,10 @@ public class DrmManagerClient {
|
|||||||
DrmInfoStatus status = _processDrmInfo(mUniqueId, drmInfo);
|
DrmInfoStatus status = _processDrmInfo(mUniqueId, drmInfo);
|
||||||
if (null != status && DrmInfoStatus.STATUS_OK == status.statusCode) {
|
if (null != status && DrmInfoStatus.STATUS_OK == status.statusCode) {
|
||||||
attributes.put(DrmEvent.DRM_INFO_STATUS_OBJECT, status);
|
attributes.put(DrmEvent.DRM_INFO_STATUS_OBJECT, status);
|
||||||
event = new DrmEvent(mUniqueId, getEventType(drmInfo.getInfoType()), null);
|
event = new DrmEvent(mUniqueId, getEventType(status.infoType), null);
|
||||||
} else {
|
} else {
|
||||||
error = new DrmErrorEvent(mUniqueId,
|
int infoType = (null != status) ? status.infoType : drmInfo.getInfoType();
|
||||||
getErrorType(drmInfo.getInfoType()), null);
|
error = new DrmErrorEvent(mUniqueId, getErrorType(infoType), null);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -173,16 +159,6 @@ public class DrmManagerClient {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ACTION_FINALIZE: {
|
|
||||||
if (ERROR_NONE == _unloadPlugIns(mUniqueId)) {
|
|
||||||
mCurrentState = STATE_UNINITIALIZED;
|
|
||||||
event = new DrmEvent(mUniqueId, DrmEvent.TYPE_FINALIZED, null);
|
|
||||||
} else {
|
|
||||||
error = new DrmErrorEvent(mUniqueId,
|
|
||||||
DrmErrorEvent.TYPE_FINALIZE_FAILED, null);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
Log.e(TAG, "Unknown message type " + msg.what);
|
Log.e(TAG, "Unknown message type " + msg.what);
|
||||||
return;
|
return;
|
||||||
@ -283,6 +259,12 @@ public class DrmManagerClient {
|
|||||||
|
|
||||||
// save the unique id
|
// save the unique id
|
||||||
mUniqueId = hashCode();
|
mUniqueId = hashCode();
|
||||||
|
|
||||||
|
_initialize(mUniqueId, new WeakReference<DrmManagerClient>(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void finalize() {
|
||||||
|
_finalize(mUniqueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -321,59 +303,12 @@ public class DrmManagerClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes DrmFramework, which loads all available plug-ins
|
|
||||||
* in the default plug-in directory path
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* ERROR_NONE for success
|
|
||||||
* ERROR_UNKNOWN for failure
|
|
||||||
*/
|
|
||||||
public int loadPlugIns() {
|
|
||||||
int result = ERROR_UNKNOWN;
|
|
||||||
if (STATE_UNINITIALIZED == getState()) {
|
|
||||||
if (null != mEventHandler) {
|
|
||||||
Message msg = mEventHandler.obtainMessage(
|
|
||||||
ACTION_INITIALIZE, new WeakReference<DrmManagerClient>(this));
|
|
||||||
result = (mEventHandler.sendMessage(msg)) ? ERROR_NONE : result;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result = ERROR_NONE;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finalize DrmFramework, which release resources associated with each plug-in
|
|
||||||
* and unload all plug-ins.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* ERROR_NONE for success
|
|
||||||
* ERROR_UNKNOWN for failure
|
|
||||||
*/
|
|
||||||
public int unloadPlugIns() {
|
|
||||||
int result = ERROR_UNKNOWN;
|
|
||||||
if (STATE_INITIALIZED == getState()) {
|
|
||||||
if (null != mEventHandler) {
|
|
||||||
Message msg = mEventHandler.obtainMessage(ACTION_FINALIZE);
|
|
||||||
result = (mEventHandler.sendMessage(msg)) ? ERROR_NONE : result;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result = ERROR_NONE;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves informations about all the plug-ins registered with DrmFramework.
|
* Retrieves informations about all the plug-ins registered with DrmFramework.
|
||||||
*
|
*
|
||||||
* @return Array of DrmEngine plug-in strings
|
* @return Array of DrmEngine plug-in strings
|
||||||
*/
|
*/
|
||||||
public String[] getAvailableDrmEngines() {
|
public String[] getAvailableDrmEngines() {
|
||||||
if (STATE_UNINITIALIZED == getState()) {
|
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
|
||||||
}
|
|
||||||
|
|
||||||
DrmSupportInfo[] supportInfos = _getAllSupportInfo(mUniqueId);
|
DrmSupportInfo[] supportInfos = _getAllSupportInfo(mUniqueId);
|
||||||
ArrayList<String> descriptions = new ArrayList<String>();
|
ArrayList<String> descriptions = new ArrayList<String>();
|
||||||
|
|
||||||
@ -396,8 +331,6 @@ public class DrmManagerClient {
|
|||||||
public ContentValues getConstraints(String path, int action) {
|
public ContentValues getConstraints(String path, int action) {
|
||||||
if (null == path || path.equals("") || !DrmStore.Action.isValid(action)) {
|
if (null == path || path.equals("") || !DrmStore.Action.isValid(action)) {
|
||||||
throw new IllegalArgumentException("Given usage or path is invalid/null");
|
throw new IllegalArgumentException("Given usage or path is invalid/null");
|
||||||
} else if (STATE_UNINITIALIZED == getState()) {
|
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
|
||||||
}
|
}
|
||||||
return _getConstraints(mUniqueId, path, action);
|
return _getConstraints(mUniqueId, path, action);
|
||||||
}
|
}
|
||||||
@ -411,6 +344,9 @@ public class DrmManagerClient {
|
|||||||
* or null in case of failure
|
* or null in case of failure
|
||||||
*/
|
*/
|
||||||
public ContentValues getConstraints(Uri uri, int action) {
|
public ContentValues getConstraints(Uri uri, int action) {
|
||||||
|
if (null == uri || Uri.EMPTY == uri) {
|
||||||
|
throw new IllegalArgumentException("Uri should be non null");
|
||||||
|
}
|
||||||
return getConstraints(convertUriToPath(uri), action);
|
return getConstraints(convertUriToPath(uri), action);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,8 +368,6 @@ public class DrmManagerClient {
|
|||||||
DrmRights drmRights, String rightsPath, String contentPath) throws IOException {
|
DrmRights drmRights, String rightsPath, String contentPath) throws IOException {
|
||||||
if (null == drmRights || !drmRights.isValid()) {
|
if (null == drmRights || !drmRights.isValid()) {
|
||||||
throw new IllegalArgumentException("Given drmRights or contentPath is not valid");
|
throw new IllegalArgumentException("Given drmRights or contentPath is not valid");
|
||||||
} else if (STATE_UNINITIALIZED == getState()) {
|
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
|
||||||
}
|
}
|
||||||
if (null != rightsPath && !rightsPath.equals("")) {
|
if (null != rightsPath && !rightsPath.equals("")) {
|
||||||
DrmUtils.writeToFile(rightsPath, drmRights.getData());
|
DrmUtils.writeToFile(rightsPath, drmRights.getData());
|
||||||
@ -451,8 +385,6 @@ public class DrmManagerClient {
|
|||||||
if (null == engineFilePath || engineFilePath.equals("")) {
|
if (null == engineFilePath || engineFilePath.equals("")) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Given engineFilePath: "+ engineFilePath + "is not valid");
|
"Given engineFilePath: "+ engineFilePath + "is not valid");
|
||||||
} else if (STATE_UNINITIALIZED == getState()) {
|
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
|
||||||
}
|
}
|
||||||
_installDrmEngine(mUniqueId, engineFilePath);
|
_installDrmEngine(mUniqueId, engineFilePath);
|
||||||
}
|
}
|
||||||
@ -464,14 +396,11 @@ public class DrmManagerClient {
|
|||||||
* @param mimeType Mimetype of the object to be handled
|
* @param mimeType Mimetype of the object to be handled
|
||||||
* @return
|
* @return
|
||||||
* true - if the given mimeType or path can be handled
|
* true - if the given mimeType or path can be handled
|
||||||
* false - cannot be handled. false will be return in case
|
* false - cannot be handled.
|
||||||
* the state is uninitialized
|
|
||||||
*/
|
*/
|
||||||
public boolean canHandle(String path, String mimeType) {
|
public boolean canHandle(String path, String mimeType) {
|
||||||
if ((null == path || path.equals("")) && (null == mimeType || mimeType.equals(""))) {
|
if ((null == path || path.equals("")) && (null == mimeType || mimeType.equals(""))) {
|
||||||
throw new IllegalArgumentException("Path or the mimetype should be non null");
|
throw new IllegalArgumentException("Path or the mimetype should be non null");
|
||||||
} else if (STATE_UNINITIALIZED == getState()) {
|
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
|
||||||
}
|
}
|
||||||
return _canHandle(mUniqueId, path, mimeType);
|
return _canHandle(mUniqueId, path, mimeType);
|
||||||
}
|
}
|
||||||
@ -483,8 +412,7 @@ public class DrmManagerClient {
|
|||||||
* @param mimeType Mimetype of the object to be handled
|
* @param mimeType Mimetype of the object to be handled
|
||||||
* @return
|
* @return
|
||||||
* true - if the given mimeType or path can be handled
|
* true - if the given mimeType or path can be handled
|
||||||
* false - cannot be handled. false will be return in case
|
* false - cannot be handled.
|
||||||
* the state is uninitialized
|
|
||||||
*/
|
*/
|
||||||
public boolean canHandle(Uri uri, String mimeType) {
|
public boolean canHandle(Uri uri, String mimeType) {
|
||||||
if ((null == uri || Uri.EMPTY == uri) && (null == mimeType || mimeType.equals(""))) {
|
if ((null == uri || Uri.EMPTY == uri) && (null == mimeType || mimeType.equals(""))) {
|
||||||
@ -504,8 +432,6 @@ public class DrmManagerClient {
|
|||||||
public int processDrmInfo(DrmInfo drmInfo) {
|
public int processDrmInfo(DrmInfo drmInfo) {
|
||||||
if (null == drmInfo || !drmInfo.isValid()) {
|
if (null == drmInfo || !drmInfo.isValid()) {
|
||||||
throw new IllegalArgumentException("Given drmInfo is invalid/null");
|
throw new IllegalArgumentException("Given drmInfo is invalid/null");
|
||||||
} else if (STATE_UNINITIALIZED == getState()) {
|
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
|
||||||
}
|
}
|
||||||
int result = ERROR_UNKNOWN;
|
int result = ERROR_UNKNOWN;
|
||||||
if (null != mEventHandler) {
|
if (null != mEventHandler) {
|
||||||
@ -526,8 +452,6 @@ public class DrmManagerClient {
|
|||||||
public int acquireDrmInfo(DrmInfoRequest drmInfoRequest) {
|
public int acquireDrmInfo(DrmInfoRequest drmInfoRequest) {
|
||||||
if (null == drmInfoRequest || !drmInfoRequest.isValid()) {
|
if (null == drmInfoRequest || !drmInfoRequest.isValid()) {
|
||||||
throw new IllegalArgumentException("Given drmInfoRequest is invalid/null");
|
throw new IllegalArgumentException("Given drmInfoRequest is invalid/null");
|
||||||
} else if (STATE_UNINITIALIZED == getState()) {
|
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
|
||||||
}
|
}
|
||||||
int result = ERROR_UNKNOWN;
|
int result = ERROR_UNKNOWN;
|
||||||
if (null != mEventHandler) {
|
if (null != mEventHandler) {
|
||||||
@ -550,8 +474,6 @@ public class DrmManagerClient {
|
|||||||
public int getDrmObjectType(String path, String mimeType) {
|
public int getDrmObjectType(String path, String mimeType) {
|
||||||
if ((null == path || path.equals("")) && (null == mimeType || mimeType.equals(""))) {
|
if ((null == path || path.equals("")) && (null == mimeType || mimeType.equals(""))) {
|
||||||
throw new IllegalArgumentException("Path or the mimetype should be non null");
|
throw new IllegalArgumentException("Path or the mimetype should be non null");
|
||||||
} else if (STATE_UNINITIALIZED == getState()) {
|
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
|
||||||
}
|
}
|
||||||
return _getDrmObjectType(mUniqueId, path, mimeType);
|
return _getDrmObjectType(mUniqueId, path, mimeType);
|
||||||
}
|
}
|
||||||
@ -589,8 +511,6 @@ public class DrmManagerClient {
|
|||||||
public String getOriginalMimeType(String path) {
|
public String getOriginalMimeType(String path) {
|
||||||
if (null == path || path.equals("")) {
|
if (null == path || path.equals("")) {
|
||||||
throw new IllegalArgumentException("Given path should be non null");
|
throw new IllegalArgumentException("Given path should be non null");
|
||||||
} else if (STATE_UNINITIALIZED == getState()) {
|
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
|
||||||
}
|
}
|
||||||
return _getOriginalMimeType(mUniqueId, path);
|
return _getOriginalMimeType(mUniqueId, path);
|
||||||
}
|
}
|
||||||
@ -644,8 +564,6 @@ public class DrmManagerClient {
|
|||||||
public int checkRightsStatus(String path, int action) {
|
public int checkRightsStatus(String path, int action) {
|
||||||
if (null == path || path.equals("") || !DrmStore.Action.isValid(action)) {
|
if (null == path || path.equals("") || !DrmStore.Action.isValid(action)) {
|
||||||
throw new IllegalArgumentException("Given path or action is not valid");
|
throw new IllegalArgumentException("Given path or action is not valid");
|
||||||
} else if (STATE_UNINITIALIZED == getState()) {
|
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
|
||||||
}
|
}
|
||||||
return _checkRightsStatus(mUniqueId, path, action);
|
return _checkRightsStatus(mUniqueId, path, action);
|
||||||
}
|
}
|
||||||
@ -676,8 +594,6 @@ public class DrmManagerClient {
|
|||||||
public int removeRights(String path) {
|
public int removeRights(String path) {
|
||||||
if (null == path || path.equals("")) {
|
if (null == path || path.equals("")) {
|
||||||
throw new IllegalArgumentException("Given path should be non null");
|
throw new IllegalArgumentException("Given path should be non null");
|
||||||
} else if (STATE_UNINITIALIZED == getState()) {
|
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
|
||||||
}
|
}
|
||||||
return _removeRights(mUniqueId, path);
|
return _removeRights(mUniqueId, path);
|
||||||
}
|
}
|
||||||
@ -706,9 +622,6 @@ public class DrmManagerClient {
|
|||||||
* ERROR_UNKNOWN for failure
|
* ERROR_UNKNOWN for failure
|
||||||
*/
|
*/
|
||||||
public int removeAllRights() {
|
public int removeAllRights() {
|
||||||
if (STATE_UNINITIALIZED == getState()) {
|
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
|
||||||
}
|
|
||||||
int result = ERROR_UNKNOWN;
|
int result = ERROR_UNKNOWN;
|
||||||
if (null != mEventHandler) {
|
if (null != mEventHandler) {
|
||||||
Message msg = mEventHandler.obtainMessage(ACTION_REMOVE_ALL_RIGHTS);
|
Message msg = mEventHandler.obtainMessage(ACTION_REMOVE_ALL_RIGHTS);
|
||||||
@ -729,8 +642,6 @@ public class DrmManagerClient {
|
|||||||
public int openConvertSession(String mimeType) {
|
public int openConvertSession(String mimeType) {
|
||||||
if (null == mimeType || mimeType.equals("")) {
|
if (null == mimeType || mimeType.equals("")) {
|
||||||
throw new IllegalArgumentException("Path or the mimeType should be non null");
|
throw new IllegalArgumentException("Path or the mimeType should be non null");
|
||||||
} else if (STATE_UNINITIALIZED == getState()) {
|
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
|
||||||
}
|
}
|
||||||
return _openConvertSession(mUniqueId, mimeType);
|
return _openConvertSession(mUniqueId, mimeType);
|
||||||
}
|
}
|
||||||
@ -750,8 +661,6 @@ public class DrmManagerClient {
|
|||||||
public DrmConvertedStatus convertData(int convertId, byte[] inputData) {
|
public DrmConvertedStatus convertData(int convertId, byte[] inputData) {
|
||||||
if (null == inputData || 0 >= inputData.length) {
|
if (null == inputData || 0 >= inputData.length) {
|
||||||
throw new IllegalArgumentException("Given inputData should be non null");
|
throw new IllegalArgumentException("Given inputData should be non null");
|
||||||
} else if (STATE_UNINITIALIZED == getState()) {
|
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
|
||||||
}
|
}
|
||||||
return _convertData(mUniqueId, convertId, inputData);
|
return _convertData(mUniqueId, convertId, inputData);
|
||||||
}
|
}
|
||||||
@ -769,28 +678,17 @@ public class DrmManagerClient {
|
|||||||
* the application on which offset these signature data should be appended.
|
* the application on which offset these signature data should be appended.
|
||||||
*/
|
*/
|
||||||
public DrmConvertedStatus closeConvertSession(int convertId) {
|
public DrmConvertedStatus closeConvertSession(int convertId) {
|
||||||
if (STATE_UNINITIALIZED == getState()) {
|
|
||||||
throw new IllegalStateException("Not Initialized yet");
|
|
||||||
}
|
|
||||||
return _closeConvertSession(mUniqueId, convertId);
|
return _closeConvertSession(mUniqueId, convertId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getState() {
|
|
||||||
return mCurrentState;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getEventType(int infoType) {
|
private int getEventType(int infoType) {
|
||||||
int eventType = -1;
|
int eventType = -1;
|
||||||
|
|
||||||
switch (infoType) {
|
switch (infoType) {
|
||||||
case DrmInfoRequest.TYPE_REGISTRATION_INFO:
|
case DrmInfoRequest.TYPE_REGISTRATION_INFO:
|
||||||
eventType = DrmEvent.TYPE_REGISTERED;
|
|
||||||
break;
|
|
||||||
case DrmInfoRequest.TYPE_UNREGISTRATION_INFO:
|
case DrmInfoRequest.TYPE_UNREGISTRATION_INFO:
|
||||||
eventType = DrmEvent.TYPE_UNREGISTERED;
|
|
||||||
break;
|
|
||||||
case DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO:
|
case DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO:
|
||||||
eventType = DrmEvent.TYPE_RIGHTS_ACQUIRED;
|
eventType = DrmEvent.TYPE_DRM_INFO_PROCESSED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return eventType;
|
return eventType;
|
||||||
@ -801,13 +699,9 @@ public class DrmManagerClient {
|
|||||||
|
|
||||||
switch (infoType) {
|
switch (infoType) {
|
||||||
case DrmInfoRequest.TYPE_REGISTRATION_INFO:
|
case DrmInfoRequest.TYPE_REGISTRATION_INFO:
|
||||||
error = DrmErrorEvent.TYPE_REGISTRATION_FAILED;
|
|
||||||
break;
|
|
||||||
case DrmInfoRequest.TYPE_UNREGISTRATION_INFO:
|
case DrmInfoRequest.TYPE_UNREGISTRATION_INFO:
|
||||||
error = DrmErrorEvent.TYPE_UNREGISTRATION_FAILED;
|
|
||||||
break;
|
|
||||||
case DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO:
|
case DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO:
|
||||||
error = DrmErrorEvent.TYPE_RIGHTS_ACQUISITION_FAILED;
|
error = DrmErrorEvent.TYPE_PROCESS_DRM_INFO_FAILED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
@ -822,25 +716,35 @@ public class DrmManagerClient {
|
|||||||
* <row_index> the index of the content in given table
|
* <row_index> the index of the content in given table
|
||||||
*/
|
*/
|
||||||
private String convertUriToPath(Uri uri) {
|
private String convertUriToPath(Uri uri) {
|
||||||
|
String path = null;
|
||||||
String scheme = uri.getScheme();
|
String scheme = uri.getScheme();
|
||||||
if (null == scheme || scheme.equals("file")) {
|
if (null == scheme || scheme.equals("") || scheme.equals(ContentResolver.SCHEME_FILE)) {
|
||||||
return uri.getPath();
|
path = uri.getPath();
|
||||||
|
} else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
|
||||||
|
String[] projection = new String[] {MediaStore.MediaColumns.DATA};
|
||||||
|
Cursor cursor = null;
|
||||||
|
try {
|
||||||
|
cursor = mContext.getContentResolver().query(uri, projection, null, null, null);
|
||||||
|
} catch (SQLiteException e) {
|
||||||
|
throw new IllegalArgumentException("Given Uri is not formatted in a way " +
|
||||||
|
"so that it can be found in media store.");
|
||||||
|
}
|
||||||
|
if (null == cursor || 0 == cursor.getCount() || !cursor.moveToFirst()) {
|
||||||
|
throw new IllegalArgumentException("Given Uri could not be found in media store");
|
||||||
|
}
|
||||||
|
int pathIndex = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
|
||||||
|
path = cursor.getString(pathIndex);
|
||||||
|
cursor.close();
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Given Uri scheme is not supported");
|
||||||
}
|
}
|
||||||
String[] projection = new String[] {MediaStore.MediaColumns.DATA};
|
|
||||||
Cursor cursor = mContext.getContentResolver().query(uri, projection, null, null, null);
|
|
||||||
if (null == cursor || 0 == cursor.getCount() || !cursor.moveToFirst()) {
|
|
||||||
throw new IllegalArgumentException("Given Uri could not be found in media store");
|
|
||||||
}
|
|
||||||
int pathIndex = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA);
|
|
||||||
String path = cursor.getString(pathIndex);
|
|
||||||
cursor.close();
|
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private native interfaces
|
// private native interfaces
|
||||||
private native int _loadPlugIns(int uniqueId, Object weak_this);
|
private native void _initialize(int uniqueId, Object weak_this);
|
||||||
|
|
||||||
private native int _unloadPlugIns(int uniqueId);
|
private native void _finalize(int uniqueId);
|
||||||
|
|
||||||
private native void _installDrmEngine(int uniqueId, String engineFilepath);
|
private native void _installDrmEngine(int uniqueId, String engineFilepath);
|
||||||
|
|
||||||
|
@ -167,6 +167,9 @@ public class DrmUtils {
|
|||||||
|
|
||||||
//Fetch Value
|
//Fetch Value
|
||||||
String strValue = readMultipleBytes(constraintData, valueLength, index);
|
String strValue = readMultipleBytes(constraintData, valueLength, index);
|
||||||
|
if (strValue.equals(" ")) {
|
||||||
|
strValue = "";
|
||||||
|
}
|
||||||
index += valueLength;
|
index += valueLength;
|
||||||
mMap.put(strKey, strValue);
|
mMap.put(strKey, strValue);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//#define LOG_NDEBUG 0
|
//#define LOG_NDEBUG 0
|
||||||
#define LOG_TAG "DrmManager-JNI"
|
#define LOG_TAG "android_drm_DrmManagerClient"
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
@ -223,38 +223,32 @@ static sp<DrmManagerClientImpl> getDrmManagerClientImpl(JNIEnv* env, jobject thi
|
|||||||
return sp<DrmManagerClientImpl>(client);
|
return sp<DrmManagerClientImpl>(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint android_drm_DrmManagerClient_loadPlugIns(
|
static void android_drm_DrmManagerClient_initialize(
|
||||||
JNIEnv* env, jobject thiz, jint uniqueId, jobject weak_thiz) {
|
JNIEnv* env, jobject thiz, jint uniqueId, jobject weak_thiz) {
|
||||||
LOGV("load plugins - Enter");
|
LOGV("initialize - Enter");
|
||||||
|
|
||||||
sp<DrmManagerClientImpl> drmManager = DrmManagerClientImpl::create(&uniqueId);
|
sp<DrmManagerClientImpl> drmManager = DrmManagerClientImpl::create(&uniqueId);
|
||||||
|
drmManager->addClient(uniqueId);
|
||||||
|
|
||||||
// Set the listener to DrmManager
|
// Set the listener to DrmManager
|
||||||
sp<DrmManagerClient::OnInfoListener> listener = new JNIOnInfoListener(env, thiz, weak_thiz);
|
sp<DrmManagerClient::OnInfoListener> listener = new JNIOnInfoListener(env, thiz, weak_thiz);
|
||||||
drmManager->setOnInfoListener(uniqueId, listener);
|
drmManager->setOnInfoListener(uniqueId, listener);
|
||||||
|
|
||||||
setDrmManagerClientImpl(env, thiz, drmManager);
|
setDrmManagerClientImpl(env, thiz, drmManager);
|
||||||
|
LOGV("initialize - Exit");
|
||||||
LOGV("load plugins - Exit");
|
|
||||||
return getDrmManagerClientImpl(env, thiz)->loadPlugIns(uniqueId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint android_drm_DrmManagerClient_unloadPlugIns(JNIEnv* env, jobject thiz, jint uniqueId) {
|
static void android_drm_DrmManagerClient_finalize(JNIEnv* env, jobject thiz, jint uniqueId) {
|
||||||
LOGV("unload plugins - Enter");
|
LOGV("finalize - Enter");
|
||||||
sp<DrmManagerClientImpl> client = getDrmManagerClientImpl(env, thiz);
|
|
||||||
|
|
||||||
DrmManagerClientImpl::remove(uniqueId);
|
DrmManagerClientImpl::remove(uniqueId);
|
||||||
int result = client->unloadPlugIns(uniqueId);
|
getDrmManagerClientImpl(env, thiz)->setOnInfoListener(uniqueId, NULL);
|
||||||
if (DRM_NO_ERROR == result) {
|
|
||||||
client->setOnInfoListener(uniqueId, NULL);
|
|
||||||
|
|
||||||
sp<DrmManagerClientImpl> oldClient = setDrmManagerClientImpl(env, thiz, NULL);
|
sp<DrmManagerClientImpl> oldClient = setDrmManagerClientImpl(env, thiz, NULL);
|
||||||
if (oldClient != NULL) {
|
if (oldClient != NULL) {
|
||||||
oldClient->setOnInfoListener(uniqueId, NULL);
|
oldClient->setOnInfoListener(uniqueId, NULL);
|
||||||
}
|
oldClient->removeClient(uniqueId);
|
||||||
}
|
}
|
||||||
LOGV("unload plugins - Exit");
|
LOGV("finalize - Exit");
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static jobject android_drm_DrmManagerClient_getConstraintsFromContent(
|
static jobject android_drm_DrmManagerClient_getConstraintsFromContent(
|
||||||
@ -441,6 +435,7 @@ static jobject android_drm_DrmManagerClient_processDrmInfo(
|
|||||||
|
|
||||||
if (NULL != localRef && NULL != pDrmInfoStatus) {
|
if (NULL != localRef && NULL != pDrmInfoStatus) {
|
||||||
int statusCode = pDrmInfoStatus->statusCode;
|
int statusCode = pDrmInfoStatus->statusCode;
|
||||||
|
int infoType = pDrmInfoStatus->infoType;
|
||||||
|
|
||||||
jbyteArray dataArray = NULL;
|
jbyteArray dataArray = NULL;
|
||||||
if (NULL != pDrmInfoStatus->drmBuffer) {
|
if (NULL != pDrmInfoStatus->drmBuffer) {
|
||||||
@ -461,10 +456,10 @@ static jobject android_drm_DrmManagerClient_processDrmInfo(
|
|||||||
|
|
||||||
constructorId
|
constructorId
|
||||||
= env->GetMethodID(localRef,
|
= env->GetMethodID(localRef,
|
||||||
"<init>", "(ILandroid/drm/ProcessedData;Ljava/lang/String;)V");
|
"<init>", "(IILandroid/drm/ProcessedData;Ljava/lang/String;)V");
|
||||||
|
|
||||||
drmInfoStatus = env->NewObject(localRef, constructorId, statusCode, processedData,
|
drmInfoStatus = env->NewObject(localRef, constructorId, statusCode, infoType,
|
||||||
env->NewStringUTF(pDrmInfoStatus->mimeType.string()));
|
processedData, env->NewStringUTF(pDrmInfoStatus->mimeType.string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
delete mData; mData = NULL;
|
delete mData; mData = NULL;
|
||||||
@ -678,11 +673,11 @@ static jobject android_drm_DrmManagerClient_closeConvertSession(
|
|||||||
|
|
||||||
static JNINativeMethod nativeMethods[] = {
|
static JNINativeMethod nativeMethods[] = {
|
||||||
|
|
||||||
{"_loadPlugIns", "(ILjava/lang/Object;)I",
|
{"_initialize", "(ILjava/lang/Object;)V",
|
||||||
(void*)android_drm_DrmManagerClient_loadPlugIns},
|
(void*)android_drm_DrmManagerClient_initialize},
|
||||||
|
|
||||||
{"_unloadPlugIns", "(I)I",
|
{"_finalize", "(I)V",
|
||||||
(void*)android_drm_DrmManagerClient_unloadPlugIns},
|
(void*)android_drm_DrmManagerClient_finalize},
|
||||||
|
|
||||||
{"_getConstraints", "(ILjava/lang/String;I)Landroid/content/ContentValues;",
|
{"_getConstraints", "(ILjava/lang/String;I)Landroid/content/ContentValues;",
|
||||||
(void*)android_drm_DrmManagerClient_getConstraintsFromContent},
|
(void*)android_drm_DrmManagerClient_getConstraintsFromContent},
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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) {
|
||||||
|
@ -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;
|
||||||
|
@ -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
|
||||||
*
|
*
|
||||||
|
@ -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,
|
||||||
|
@ -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,
|
||||||
|
@ -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
|
||||||
*
|
*
|
||||||
|
@ -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
|
||||||
*
|
*
|
||||||
|
@ -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,
|
||||||
|
@ -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) {
|
||||||
|
@ -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:
|
||||||
/**
|
/**
|
||||||
|
@ -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;
|
||||||
};
|
};
|
||||||
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user