summaryrefslogtreecommitdiff
path: root/drm
diff options
context:
space:
mode:
Diffstat (limited to 'drm')
-rw-r--r--drm/common/Android.mk1
-rw-r--r--drm/common/DrmEngineBase.cpp6
-rw-r--r--drm/common/DrmSupportInfo.cpp4
-rw-r--r--drm/common/IDrmIOService.cpp74
-rw-r--r--drm/common/IDrmManagerService.cpp327
-rw-r--r--drm/common/ReadWriteUtils.cpp4
-rw-r--r--drm/drmioserver/Android.mk43
-rw-r--r--drm/drmioserver/DrmIOService.cpp49
-rw-r--r--drm/drmioserver/main_drmioserver.cpp40
-rw-r--r--drm/drmserver/Android.mk3
-rw-r--r--drm/drmserver/DrmManager.cpp49
-rw-r--r--drm/drmserver/DrmManagerService.cpp6
-rw-r--r--drm/drmserver/StringTokenizer.cpp66
-rwxr-xr-x[-rw-r--r--]drm/java/android/drm/DrmConvertedStatus.java23
-rwxr-xr-x[-rw-r--r--]drm/java/android/drm/DrmErrorEvent.java53
-rwxr-xr-x[-rw-r--r--]drm/java/android/drm/DrmEvent.java74
-rwxr-xr-x[-rw-r--r--]drm/java/android/drm/DrmInfo.java70
-rwxr-xr-x[-rw-r--r--]drm/java/android/drm/DrmInfoEvent.java46
-rwxr-xr-x[-rw-r--r--]drm/java/android/drm/DrmInfoRequest.java61
-rwxr-xr-x[-rw-r--r--]drm/java/android/drm/DrmInfoStatus.java34
-rwxr-xr-x[-rw-r--r--]drm/java/android/drm/DrmManagerClient.java389
-rwxr-xr-x[-rw-r--r--]drm/java/android/drm/DrmRights.java92
-rwxr-xr-x[-rw-r--r--]drm/java/android/drm/DrmStore.java82
-rwxr-xr-x[-rw-r--r--]drm/java/android/drm/DrmSupportInfo.java66
-rwxr-xr-x[-rw-r--r--]drm/java/android/drm/DrmUtils.java24
-rwxr-xr-x[-rw-r--r--]drm/java/android/drm/ProcessedData.java34
-rwxr-xr-xdrm/java/android/drm/package.html85
-rw-r--r--drm/libdrmframework/DrmManagerClient.cpp12
-rw-r--r--drm/libdrmframework/DrmManagerClientImpl.cpp38
-rw-r--r--drm/libdrmframework/include/DrmIOService.h46
-rw-r--r--drm/libdrmframework/include/DrmManager.h7
-rw-r--r--drm/libdrmframework/include/DrmManagerClientImpl.h18
-rw-r--r--drm/libdrmframework/include/DrmManagerService.h6
-rw-r--r--drm/libdrmframework/include/IDrmIOService.h86
-rw-r--r--drm/libdrmframework/include/IDrmManagerService.h12
-rw-r--r--drm/libdrmframework/include/PlugInManager.h8
-rw-r--r--drm/libdrmframework/include/StringTokenizer.h87
-rw-r--r--drm/libdrmframework/plugins/common/include/DrmEngineBase.h12
-rw-r--r--drm/libdrmframework/plugins/common/include/IDrmEngine.h6
-rw-r--r--drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk2
-rw-r--r--drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h6
-rw-r--r--drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp6
42 files changed, 918 insertions, 1239 deletions
diff --git a/drm/common/Android.mk b/drm/common/Android.mk
index c79a91a3ec33..f1136c916615 100644
--- a/drm/common/Android.mk
+++ b/drm/common/Android.mk
@@ -26,7 +26,6 @@ LOCAL_SRC_FILES:= \
DrmInfoStatus.cpp \
DrmRights.cpp \
DrmSupportInfo.cpp \
- IDrmIOService.cpp \
IDrmManagerService.cpp \
IDrmServiceListener.cpp \
DrmInfoEvent.cpp \
diff --git a/drm/common/DrmEngineBase.cpp b/drm/common/DrmEngineBase.cpp
index ac360eb8149e..9b16c3685442 100644
--- a/drm/common/DrmEngineBase.cpp
+++ b/drm/common/DrmEngineBase.cpp
@@ -84,7 +84,7 @@ status_t DrmEngineBase::consumeRights(
}
status_t DrmEngineBase::setPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
+ int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) {
return onSetPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
}
@@ -120,7 +120,7 @@ DrmSupportInfo* DrmEngineBase::getSupportInfo(int uniqueId) {
}
status_t DrmEngineBase::openDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length) {
+ int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) {
return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length);
}
@@ -150,7 +150,7 @@ status_t DrmEngineBase::finalizeDecryptUnit(
}
ssize_t DrmEngineBase::pread(
- int uniqueId, DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off_t offset) {
+ int uniqueId, DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off64_t offset) {
return onPread(uniqueId, decryptHandle, buffer, numBytes, offset);
}
diff --git a/drm/common/DrmSupportInfo.cpp b/drm/common/DrmSupportInfo.cpp
index ffc8953fe83e..c0bff0ea7893 100644
--- a/drm/common/DrmSupportInfo.cpp
+++ b/drm/common/DrmSupportInfo.cpp
@@ -45,7 +45,7 @@ bool DrmSupportInfo::isSupportedMimeType(const String8& mimeType) const {
for (unsigned int i = 0; i < mMimeTypeVector.size(); i++) {
const String8 item = mMimeTypeVector.itemAt(i);
- if (String8("") != mimeType && item.find(mimeType) != -1) {
+ if (!strcasecmp(item.string(), mimeType.string())) {
return true;
}
}
@@ -56,7 +56,7 @@ bool DrmSupportInfo::isSupportedFileSuffix(const String8& fileType) const {
for (unsigned int i = 0; i < mFileSuffixVector.size(); i++) {
const String8 item = mFileSuffixVector.itemAt(i);
- if (String8("") != fileType && item.find(fileType) != -1) {
+ if (!strcasecmp(item.string(), fileType.string())) {
return true;
}
}
diff --git a/drm/common/IDrmIOService.cpp b/drm/common/IDrmIOService.cpp
deleted file mode 100644
index e44ca55e5631..000000000000
--- a/drm/common/IDrmIOService.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <stdint.h>
-#include <sys/types.h>
-#include <binder/Parcel.h>
-#include <binder/IPCThreadState.h>
-#include <drm/drm_framework_common.h>
-#include "IDrmIOService.h"
-
-using namespace android;
-
-void BpDrmIOService::writeToFile(const String8& filePath, const String8& dataBuffer) {
- Parcel data, reply;
-
- data.writeInterfaceToken(IDrmIOService::getInterfaceDescriptor());
- data.writeString8(filePath);
- data.writeString8(dataBuffer);
-
- remote()->transact(WRITE_TO_FILE, data, &reply);
-}
-
-String8 BpDrmIOService::readFromFile(const String8& filePath) {
-
- Parcel data, reply;
-
- data.writeInterfaceToken(IDrmIOService::getInterfaceDescriptor());
- data.writeString8(filePath);
-
- remote()->transact(READ_FROM_FILE, data, &reply);
- return reply.readString8();
-}
-
-IMPLEMENT_META_INTERFACE(DrmIOService, "drm.IDrmIOService");
-
-status_t BnDrmIOService::onTransact(
- uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) {
-
- switch (code) {
- case WRITE_TO_FILE:
- {
- CHECK_INTERFACE(IDrmIOService, data, reply);
-
- writeToFile(data.readString8(), data.readString8());
- return DRM_NO_ERROR;
- }
-
- case READ_FROM_FILE:
- {
- CHECK_INTERFACE(IDrmIOService, data, reply);
-
- String8 dataBuffer = readFromFile(data.readString8());
- reply->writeString8(dataBuffer);
- return DRM_NO_ERROR;
- }
-
- default:
- return BBinder::onTransact(code, data, reply, flags);
- }
-}
-
diff --git a/drm/common/IDrmManagerService.cpp b/drm/common/IDrmManagerService.cpp
index 723b50e3e4ce..346934bde87c 100644
--- a/drm/common/IDrmManagerService.cpp
+++ b/drm/common/IDrmManagerService.cpp
@@ -37,6 +37,78 @@
using namespace android;
+static void writeDecrptHandleToParcelData(
+ const DecryptHandle* handle, Parcel* data) {
+ data->writeInt32(handle->decryptId);
+ data->writeString8(handle->mimeType);
+ data->writeInt32(handle->decryptApiType);
+ data->writeInt32(handle->status);
+
+ int size = handle->copyControlVector.size();
+ data->writeInt32(size);
+ for(int i = 0; i < size; i++) {
+ data->writeInt32(handle->copyControlVector.keyAt(i));
+ data->writeInt32(handle->copyControlVector.valueAt(i));
+ }
+
+ size = handle->extendedData.size();
+ data->writeInt32(size);
+ for(int i = 0; i < size; i++) {
+ data->writeString8(handle->extendedData.keyAt(i));
+ data->writeString8(handle->extendedData.valueAt(i));
+ }
+
+ if (NULL != handle->decryptInfo) {
+ data->writeInt32(handle->decryptInfo->decryptBufferLength);
+ } else {
+ data->writeInt32(INVALID_BUFFER_LENGTH);
+ }
+}
+
+static void readDecryptHandleFromParcelData(
+ DecryptHandle* handle, const Parcel& data) {
+ if (0 == data.dataAvail()) {
+ return;
+ }
+
+ handle->decryptId = data.readInt32();
+ handle->mimeType = data.readString8();
+ handle->decryptApiType = data.readInt32();
+ handle->status = data.readInt32();
+
+ int size = data.readInt32();
+ for (int i = 0; i < size; i ++) {
+ DrmCopyControl key = (DrmCopyControl)data.readInt32();
+ int value = data.readInt32();
+ handle->copyControlVector.add(key, value);
+ }
+
+ size = data.readInt32();
+ for (int i = 0; i < size; i ++) {
+ String8 key = data.readString8();
+ String8 value = data.readString8();
+ handle->extendedData.add(key, value);
+ }
+
+ handle->decryptInfo = NULL;
+ const int bufferLen = data.readInt32();
+ if (INVALID_BUFFER_LENGTH != bufferLen) {
+ handle->decryptInfo = new DecryptInfo();
+ handle->decryptInfo->decryptBufferLength = bufferLen;
+ }
+}
+
+static void clearDecryptHandle(DecryptHandle* handle) {
+ if (handle == NULL) {
+ return;
+ }
+ if (handle->decryptInfo) {
+ delete handle->decryptInfo;
+ handle->decryptInfo = NULL;
+ }
+ handle->copyControlVector.clear();
+}
+
int BpDrmManagerService::addUniqueId(int uniqueId) {
LOGV("add uniqueid");
Parcel data, reply;
@@ -344,16 +416,7 @@ status_t BpDrmManagerService::consumeRights(
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
data.writeInt32(uniqueId);
- data.writeInt32(decryptHandle->decryptId);
- data.writeString8(decryptHandle->mimeType);
- data.writeInt32(decryptHandle->decryptApiType);
- data.writeInt32(decryptHandle->status);
-
- if (NULL != decryptHandle->decryptInfo) {
- data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength);
- } else {
- data.writeInt32(INVALID_BUFFER_LENGTH);
- }
+ writeDecrptHandleToParcelData(decryptHandle, &data);
data.writeInt32(action);
data.writeInt32(static_cast< int>(reserve));
@@ -363,26 +426,17 @@ status_t BpDrmManagerService::consumeRights(
}
status_t BpDrmManagerService::setPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
+ int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) {
LOGV("setPlaybackStatus");
Parcel data, reply;
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
data.writeInt32(uniqueId);
- data.writeInt32(decryptHandle->decryptId);
- data.writeString8(decryptHandle->mimeType);
- data.writeInt32(decryptHandle->decryptApiType);
- data.writeInt32(decryptHandle->status);
-
- if (NULL != decryptHandle->decryptInfo) {
- data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength);
- } else {
- data.writeInt32(INVALID_BUFFER_LENGTH);
- }
+ writeDecrptHandleToParcelData(decryptHandle, &data);
data.writeInt32(playbackStatus);
- data.writeInt32(position);
+ data.writeInt64(position);
remote()->transact(SET_PLAYBACK_STATUS, data, &reply);
return reply.readInt32();
@@ -459,7 +513,7 @@ DrmConvertedStatus* BpDrmManagerService::convertData(
if (0 != reply.dataAvail()) {
//Filling DRM Converted Status
const int statusCode = reply.readInt32();
- const int offset = reply.readInt32();
+ const off64_t offset = reply.readInt64();
DrmBuffer* convertedData = NULL;
if (0 != reply.dataAvail()) {
@@ -491,7 +545,7 @@ DrmConvertedStatus* BpDrmManagerService::closeConvertSession(int uniqueId, int c
if (0 != reply.dataAvail()) {
//Filling DRM Converted Status
const int statusCode = reply.readInt32();
- const int offset = reply.readInt32();
+ const off64_t offset = reply.readInt64();
DrmBuffer* convertedData = NULL;
if (0 != reply.dataAvail()) {
@@ -545,32 +599,22 @@ status_t BpDrmManagerService::getAllSupportInfo(
}
DecryptHandle* BpDrmManagerService::openDecryptSession(
- int uniqueId, int fd, int offset, int length) {
+ int uniqueId, int fd, off64_t offset, off64_t length) {
LOGV("Entering BpDrmManagerService::openDecryptSession");
Parcel data, reply;
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
data.writeInt32(uniqueId);
data.writeFileDescriptor(fd);
- data.writeInt32(offset);
- data.writeInt32(length);
+ data.writeInt64(offset);
+ data.writeInt64(length);
remote()->transact(OPEN_DECRYPT_SESSION, 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");
+ readDecryptHandleFromParcelData(handle, reply);
}
return handle;
}
@@ -588,17 +632,9 @@ DecryptHandle* BpDrmManagerService::openDecryptSession(int uniqueId, const char*
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();
- }
+ readDecryptHandleFromParcelData(handle, reply);
} else {
- LOGE("no decryptHandle is generated in service side");
+ LOGV("no decryptHandle is generated in service side");
}
return handle;
}
@@ -610,16 +646,7 @@ status_t BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* d
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
data.writeInt32(uniqueId);
- data.writeInt32(decryptHandle->decryptId);
- data.writeString8(decryptHandle->mimeType);
- data.writeInt32(decryptHandle->decryptApiType);
- data.writeInt32(decryptHandle->status);
-
- if (NULL != decryptHandle->decryptInfo) {
- data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength);
- } else {
- data.writeInt32(INVALID_BUFFER_LENGTH);
- }
+ writeDecrptHandleToParcelData(decryptHandle, &data);
remote()->transact(CLOSE_DECRYPT_SESSION, data, &reply);
@@ -640,16 +667,8 @@ status_t BpDrmManagerService::initializeDecryptUnit(
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
data.writeInt32(uniqueId);
- data.writeInt32(decryptHandle->decryptId);
- data.writeString8(decryptHandle->mimeType);
- data.writeInt32(decryptHandle->decryptApiType);
- data.writeInt32(decryptHandle->status);
+ writeDecrptHandleToParcelData(decryptHandle, &data);
- if (NULL != decryptHandle->decryptInfo) {
- data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength);
- } else {
- data.writeInt32(INVALID_BUFFER_LENGTH);
- }
data.writeInt32(decryptUnitId);
data.writeInt32(headerInfo->length);
@@ -668,16 +687,7 @@ status_t BpDrmManagerService::decrypt(
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
data.writeInt32(uniqueId);
- data.writeInt32(decryptHandle->decryptId);
- data.writeString8(decryptHandle->mimeType);
- data.writeInt32(decryptHandle->decryptApiType);
- data.writeInt32(decryptHandle->status);
-
- if (NULL != decryptHandle->decryptInfo) {
- data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength);
- } else {
- data.writeInt32(INVALID_BUFFER_LENGTH);
- }
+ writeDecrptHandleToParcelData(decryptHandle, &data);
data.writeInt32(decryptUnitId);
data.writeInt32((*decBuffer)->length);
@@ -710,16 +720,7 @@ status_t BpDrmManagerService::finalizeDecryptUnit(
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
data.writeInt32(uniqueId);
- data.writeInt32(decryptHandle->decryptId);
- data.writeString8(decryptHandle->mimeType);
- data.writeInt32(decryptHandle->decryptApiType);
- data.writeInt32(decryptHandle->status);
-
- if (NULL != decryptHandle->decryptInfo) {
- data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength);
- } else {
- data.writeInt32(INVALID_BUFFER_LENGTH);
- }
+ writeDecrptHandleToParcelData(decryptHandle, &data);
data.writeInt32(decryptUnitId);
@@ -729,7 +730,7 @@ status_t BpDrmManagerService::finalizeDecryptUnit(
ssize_t BpDrmManagerService::pread(
int uniqueId, DecryptHandle* decryptHandle, void* buffer,
- ssize_t numBytes, off_t offset) {
+ ssize_t numBytes, off64_t offset) {
LOGV("read");
Parcel data, reply;
int result;
@@ -737,19 +738,10 @@ ssize_t BpDrmManagerService::pread(
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
data.writeInt32(uniqueId);
- data.writeInt32(decryptHandle->decryptId);
- data.writeString8(decryptHandle->mimeType);
- data.writeInt32(decryptHandle->decryptApiType);
- data.writeInt32(decryptHandle->status);
-
- if (NULL != decryptHandle->decryptInfo) {
- data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength);
- } else {
- data.writeInt32(INVALID_BUFFER_LENGTH);
- }
+ writeDecrptHandleToParcelData(decryptHandle, &data);
data.writeInt32(numBytes);
- data.writeInt32(offset);
+ data.writeInt64(offset);
remote()->transact(PREAD, data, &reply);
result = reply.readInt32();
@@ -1071,24 +1063,14 @@ status_t BnDrmManagerService::onTransact(
const int uniqueId = data.readInt32();
DecryptHandle handle;
- handle.decryptId = data.readInt32();
- handle.mimeType = data.readString8();
- handle.decryptApiType = data.readInt32();
- handle.status = data.readInt32();
- handle.decryptInfo = NULL;
-
- const int bufferLength = data.readInt32();
- if (INVALID_BUFFER_LENGTH != bufferLength) {
- handle.decryptInfo = new DecryptInfo();
- handle.decryptInfo->decryptBufferLength = bufferLength;
- }
+ readDecryptHandleFromParcelData(&handle, data);
const status_t status
= consumeRights(uniqueId, &handle, data.readInt32(),
static_cast<bool>(data.readInt32()));
reply->writeInt32(status);
- delete handle.decryptInfo; handle.decryptInfo = NULL;
+ clearDecryptHandle(&handle);
return DRM_NO_ERROR;
}
@@ -1100,23 +1082,13 @@ status_t BnDrmManagerService::onTransact(
const int uniqueId = data.readInt32();
DecryptHandle handle;
- handle.decryptId = data.readInt32();
- handle.mimeType = data.readString8();
- handle.decryptApiType = data.readInt32();
- handle.status = data.readInt32();
- handle.decryptInfo = NULL;
-
- const int bufferLength = data.readInt32();
- if (INVALID_BUFFER_LENGTH != bufferLength) {
- handle.decryptInfo = new DecryptInfo();
- handle.decryptInfo->decryptBufferLength = bufferLength;
- }
+ readDecryptHandleFromParcelData(&handle, data);
const status_t status
- = setPlaybackStatus(uniqueId, &handle, data.readInt32(), data.readInt32());
+ = setPlaybackStatus(uniqueId, &handle, data.readInt32(), data.readInt64());
reply->writeInt32(status);
- delete handle.decryptInfo; handle.decryptInfo = NULL;
+ clearDecryptHandle(&handle);
return DRM_NO_ERROR;
}
@@ -1185,7 +1157,7 @@ status_t BnDrmManagerService::onTransact(
if (NULL != drmConvertedStatus) {
//Filling Drm Converted Ststus
reply->writeInt32(drmConvertedStatus->statusCode);
- reply->writeInt32(drmConvertedStatus->offset);
+ reply->writeInt64(drmConvertedStatus->offset);
if (NULL != drmConvertedStatus->convertedData) {
const DrmBuffer* convertedData = drmConvertedStatus->convertedData;
@@ -1214,7 +1186,7 @@ status_t BnDrmManagerService::onTransact(
if (NULL != drmConvertedStatus) {
//Filling Drm Converted Ststus
reply->writeInt32(drmConvertedStatus->statusCode);
- reply->writeInt32(drmConvertedStatus->offset);
+ reply->writeInt64(drmConvertedStatus->offset);
if (NULL != drmConvertedStatus->convertedData) {
const DrmBuffer* convertedData = drmConvertedStatus->convertedData;
@@ -1274,21 +1246,13 @@ status_t BnDrmManagerService::onTransact(
const int fd = data.readFileDescriptor();
DecryptHandle* handle
- = openDecryptSession(uniqueId, fd, data.readInt32(), data.readInt32());
+ = openDecryptSession(uniqueId, fd, data.readInt64(), data.readInt64());
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");
+ writeDecrptHandleToParcelData(handle, reply);
+ clearDecryptHandle(handle);
+ delete handle; handle = NULL;
}
- delete handle; handle = NULL;
return DRM_NO_ERROR;
}
@@ -1303,18 +1267,13 @@ status_t BnDrmManagerService::onTransact(
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;
- }
+ writeDecrptHandleToParcelData(handle, reply);
+
+ clearDecryptHandle(handle);
+ delete handle; handle = NULL;
} else {
- LOGE("NULL decryptHandle is returned");
+ LOGV("NULL decryptHandle is returned");
}
- delete handle; handle = NULL;
return DRM_NO_ERROR;
}
@@ -1326,17 +1285,7 @@ status_t BnDrmManagerService::onTransact(
const int uniqueId = data.readInt32();
DecryptHandle* handle = new DecryptHandle();
- handle->decryptId = data.readInt32();
- handle->mimeType = data.readString8();
- handle->decryptApiType = data.readInt32();
- handle->status = data.readInt32();
- handle->decryptInfo = NULL;
-
- const int bufferLength = data.readInt32();
- if (INVALID_BUFFER_LENGTH != bufferLength) {
- handle->decryptInfo = new DecryptInfo();
- handle->decryptInfo->decryptBufferLength = bufferLength;
- }
+ readDecryptHandleFromParcelData(handle, data);
const status_t status = closeDecryptSession(uniqueId, handle);
reply->writeInt32(status);
@@ -1351,17 +1300,8 @@ status_t BnDrmManagerService::onTransact(
const int uniqueId = data.readInt32();
DecryptHandle handle;
- handle.decryptId = data.readInt32();
- handle.mimeType = data.readString8();
- handle.decryptApiType = data.readInt32();
- handle.status = data.readInt32();
- handle.decryptInfo = NULL;
-
- const int bufferLength = data.readInt32();
- if (INVALID_BUFFER_LENGTH != bufferLength) {
- handle.decryptInfo = new DecryptInfo();
- handle.decryptInfo->decryptBufferLength = bufferLength;
- }
+ readDecryptHandleFromParcelData(&handle, data);
+
const int decryptUnitId = data.readInt32();
//Filling Header info
@@ -1373,7 +1313,7 @@ status_t BnDrmManagerService::onTransact(
= initializeDecryptUnit(uniqueId, &handle, decryptUnitId, headerInfo);
reply->writeInt32(status);
- delete handle.decryptInfo; handle.decryptInfo = NULL;
+ clearDecryptHandle(&handle);
delete headerInfo; headerInfo = NULL;
return DRM_NO_ERROR;
}
@@ -1386,17 +1326,8 @@ status_t BnDrmManagerService::onTransact(
const int uniqueId = data.readInt32();
DecryptHandle handle;
- handle.decryptId = data.readInt32();
- handle.mimeType = data.readString8();
- handle.decryptApiType = data.readInt32();
- handle.status = data.readInt32();
- handle.decryptInfo = NULL;
-
- const int bufferLength = data.readInt32();
- if (INVALID_BUFFER_LENGTH != bufferLength) {
- handle.decryptInfo = new DecryptInfo();
- handle.decryptInfo->decryptBufferLength = bufferLength;
- }
+ readDecryptHandleFromParcelData(&handle, data);
+
const int decryptUnitId = data.readInt32();
const int decBufferSize = data.readInt32();
@@ -1423,7 +1354,7 @@ status_t BnDrmManagerService::onTransact(
reply->writeInt32(size);
reply->write(decBuffer->data, size);
- delete handle.decryptInfo; handle.decryptInfo = NULL;
+ clearDecryptHandle(&handle);
delete encBuffer; encBuffer = NULL;
delete decBuffer; decBuffer = NULL;
delete [] buffer; buffer = NULL;
@@ -1439,22 +1370,12 @@ status_t BnDrmManagerService::onTransact(
const int uniqueId = data.readInt32();
DecryptHandle handle;
- handle.decryptId = data.readInt32();
- handle.mimeType = data.readString8();
- handle.decryptApiType = data.readInt32();
- handle.status = data.readInt32();
- handle.decryptInfo = NULL;
-
- const int bufferLength = data.readInt32();
- if (INVALID_BUFFER_LENGTH != bufferLength) {
- handle.decryptInfo = new DecryptInfo();
- handle.decryptInfo->decryptBufferLength = bufferLength;
- }
+ readDecryptHandleFromParcelData(&handle, data);
const status_t status = finalizeDecryptUnit(uniqueId, &handle, data.readInt32());
reply->writeInt32(status);
- delete handle.decryptInfo; handle.decryptInfo = NULL;
+ clearDecryptHandle(&handle);
return DRM_NO_ERROR;
}
@@ -1466,22 +1387,12 @@ status_t BnDrmManagerService::onTransact(
const int uniqueId = data.readInt32();
DecryptHandle handle;
- handle.decryptId = data.readInt32();
- handle.mimeType = data.readString8();
- handle.decryptApiType = data.readInt32();
- handle.status = data.readInt32();
- handle.decryptInfo = NULL;
-
- const int bufferLength = data.readInt32();
- if (INVALID_BUFFER_LENGTH != bufferLength) {
- handle.decryptInfo = new DecryptInfo();
- handle.decryptInfo->decryptBufferLength = bufferLength;
- }
+ readDecryptHandleFromParcelData(&handle, data);
const int numBytes = data.readInt32();
char* buffer = new char[numBytes];
- const off_t offset = data.readInt32();
+ const off64_t offset = data.readInt64();
ssize_t result = pread(uniqueId, &handle, buffer, numBytes, offset);
reply->writeInt32(result);
@@ -1489,7 +1400,7 @@ status_t BnDrmManagerService::onTransact(
reply->write(buffer, result);
}
- delete handle.decryptInfo; handle.decryptInfo = NULL;
+ clearDecryptHandle(&handle);
delete [] buffer, buffer = NULL;
return DRM_NO_ERROR;
}
diff --git a/drm/common/ReadWriteUtils.cpp b/drm/common/ReadWriteUtils.cpp
index 7ec4fa2e00fa..c16214e2eaff 100644
--- a/drm/common/ReadWriteUtils.cpp
+++ b/drm/common/ReadWriteUtils.cpp
@@ -42,7 +42,7 @@ String8 ReadWriteUtils::readBytes(const String8& filePath) {
struct stat sb;
if (fstat(fd, &sb) == 0 && sb.st_size > 0) {
- int length = sb.st_size;
+ off64_t length = sb.st_size;
char* bytes = new char[length];
if (length == read(fd, (void*) bytes, length)) {
string.append(bytes, length);
@@ -57,7 +57,7 @@ String8 ReadWriteUtils::readBytes(const String8& filePath) {
int ReadWriteUtils::readBytes(const String8& filePath, char** buffer) {
FILE* file = NULL;
file = fopen(filePath.string(), "r");
- int length = 0;
+ off64_t length = 0;
if (NULL != file) {
int fd = fileno(file);
diff --git a/drm/drmioserver/Android.mk b/drm/drmioserver/Android.mk
deleted file mode 100644
index 11571c7904bc..000000000000
--- a/drm/drmioserver/Android.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- main_drmioserver.cpp \
- DrmIOService.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libutils \
- libbinder
-
-ifeq ($(TARGET_SIMULATOR),true)
- LOCAL_LDLIBS += -ldl
-else
- LOCAL_SHARED_LIBRARIES += libdl
-endif
-
-LOCAL_STATIC_LIBRARIES := libdrmframeworkcommon
-
-LOCAL_C_INCLUDES := \
- $(TOP)/frameworks/base/drm/libdrmframework/include \
- $(TOP)/frameworks/base/include
-
-LOCAL_MODULE:= drmioserver
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_EXECUTABLE)
diff --git a/drm/drmioserver/DrmIOService.cpp b/drm/drmioserver/DrmIOService.cpp
deleted file mode 100644
index 60e6e70daacf..000000000000
--- a/drm/drmioserver/DrmIOService.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define LOG_NDEBUG 0
-#define LOG_TAG "DrmIOService"
-#include <utils/Log.h>
-
-#include <binder/IServiceManager.h>
-#include "DrmIOService.h"
-#include "ReadWriteUtils.h"
-
-using namespace android;
-
-void DrmIOService::instantiate() {
- LOGV("instantiate");
- defaultServiceManager()->addService(String16("drm.drmIOService"), new DrmIOService());
-}
-
-DrmIOService::DrmIOService() {
- LOGV("created");
-}
-
-DrmIOService::~DrmIOService() {
- LOGV("Destroyed");
-}
-
-void DrmIOService::writeToFile(const String8& filePath, const String8& dataBuffer) {
- LOGV("Entering writeToFile");
- ReadWriteUtils::writeToFile(filePath, dataBuffer);
-}
-
-String8 DrmIOService::readFromFile(const String8& filePath) {
- LOGV("Entering readFromFile");
- return ReadWriteUtils::readBytes(filePath);
-}
-
diff --git a/drm/drmioserver/main_drmioserver.cpp b/drm/drmioserver/main_drmioserver.cpp
deleted file mode 100644
index 7ed048d6738a..000000000000
--- a/drm/drmioserver/main_drmioserver.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <sys/types.h>
-#include <unistd.h>
-#include <grp.h>
-
-#include <binder/IPCThreadState.h>
-#include <binder/ProcessState.h>
-#include <binder/IServiceManager.h>
-#include <utils/Log.h>
-#include <private/android_filesystem_config.h>
-
-#include <DrmIOService.h>
-
-using namespace android;
-
-int main(int argc, char** argv)
-{
- sp<ProcessState> proc(ProcessState::self());
- sp<IServiceManager> sm = defaultServiceManager();
- LOGI("ServiceManager: %p", sm.get());
- DrmIOService::instantiate();
- ProcessState::self()->startThreadPool();
- IPCThreadState::self()->joinThreadPool();
-}
-
diff --git a/drm/drmserver/Android.mk b/drm/drmserver/Android.mk
index 5df2ff87c17e..f94f9a37192a 100644
--- a/drm/drmserver/Android.mk
+++ b/drm/drmserver/Android.mk
@@ -19,8 +19,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
main_drmserver.cpp \
DrmManager.cpp \
- DrmManagerService.cpp \
- StringTokenizer.cpp
+ DrmManagerService.cpp
LOCAL_SHARED_LIBRARIES := \
libutils \
diff --git a/drm/drmserver/DrmManager.cpp b/drm/drmserver/DrmManager.cpp
index 49df1c8f4b53..1eee5f216de5 100644
--- a/drm/drmserver/DrmManager.cpp
+++ b/drm/drmserver/DrmManager.cpp
@@ -51,6 +51,7 @@ DrmManager::~DrmManager() {
}
int DrmManager::addUniqueId(int uniqueId) {
+ Mutex::Autolock _l(mLock);
if (0 == uniqueId) {
int temp = 0;
bool foundUniqueId = false;
@@ -78,6 +79,7 @@ int DrmManager::addUniqueId(int uniqueId) {
}
void DrmManager::removeUniqueId(int uniqueId) {
+ Mutex::Autolock _l(mLock);
for (unsigned int i = 0; i < mUniqueIdVector.size(); i++) {
if (uniqueId == mUniqueIdVector.itemAt(i)) {
mUniqueIdVector.removeAt(i);
@@ -87,7 +89,7 @@ void DrmManager::removeUniqueId(int uniqueId) {
}
status_t DrmManager::loadPlugIns() {
- String8 pluginDirPath("/system/lib/drm/plugins/native");
+ String8 pluginDirPath("/system/lib/drm");
return loadPlugIns(pluginDirPath);
}
@@ -107,6 +109,7 @@ status_t DrmManager::loadPlugIns(const String8& plugInDirPath) {
}
status_t DrmManager::unloadPlugIns() {
+ Mutex::Autolock _l(mLock);
mConvertSessionMap.clear();
mDecryptSessionMap.clear();
mPlugInManager.unloadPlugIns();
@@ -116,7 +119,7 @@ status_t DrmManager::unloadPlugIns() {
status_t DrmManager::setDrmServiceListener(
int uniqueId, const sp<IDrmServiceListener>& drmServiceListener) {
- Mutex::Autolock _l(mLock);
+ Mutex::Autolock _l(mListenerLock);
if (NULL != drmServiceListener.get()) {
mServiceListeners.add(uniqueId, drmServiceListener);
} else {
@@ -126,6 +129,7 @@ status_t DrmManager::setDrmServiceListener(
}
void DrmManager::addClient(int uniqueId) {
+ Mutex::Autolock _l(mLock);
if (!mSupportInfoToPlugInIdMap.isEmpty()) {
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
for (unsigned int index = 0; index < plugInIdList.size(); index++) {
@@ -137,6 +141,7 @@ void DrmManager::addClient(int uniqueId) {
}
void DrmManager::removeClient(int uniqueId) {
+ Mutex::Autolock _l(mLock);
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
for (unsigned int index = 0; index < plugInIdList.size(); index++) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInIdList.itemAt(index));
@@ -145,6 +150,7 @@ void DrmManager::removeClient(int uniqueId) {
}
DrmConstraints* DrmManager::getConstraints(int uniqueId, const String8* path, const int action) {
+ Mutex::Autolock _l(mLock);
const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, *path);
if (EMPTY_STRING != plugInId) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
@@ -154,6 +160,7 @@ DrmConstraints* DrmManager::getConstraints(int uniqueId, const String8* path, co
}
DrmMetadata* DrmManager::getMetadata(int uniqueId, const String8* path) {
+ Mutex::Autolock _l(mLock);
const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, *path);
if (EMPTY_STRING != plugInId) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
@@ -163,6 +170,7 @@ DrmMetadata* DrmManager::getMetadata(int uniqueId, const String8* path) {
}
status_t DrmManager::installDrmEngine(int uniqueId, const String8& absolutePath) {
+ Mutex::Autolock _l(mLock);
mPlugInManager.loadPlugIn(absolutePath);
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(absolutePath);
@@ -176,6 +184,7 @@ status_t DrmManager::installDrmEngine(int uniqueId, const String8& absolutePath)
}
bool DrmManager::canHandle(int uniqueId, const String8& path, const String8& mimeType) {
+ Mutex::Autolock _l(mLock);
const String8 plugInId = getSupportedPlugInId(mimeType);
bool result = (EMPTY_STRING != plugInId) ? true : false;
@@ -184,13 +193,17 @@ bool DrmManager::canHandle(int uniqueId, const String8& path, const String8& mim
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
result = rDrmEngine.canHandle(uniqueId, path);
} else {
- result = canHandle(uniqueId, path);
+ String8 extension = path.getPathExtension();
+ if (String8("") != extension) {
+ result = canHandle(uniqueId, path);
+ }
}
}
return result;
}
DrmInfoStatus* DrmManager::processDrmInfo(int uniqueId, const DrmInfo* drmInfo) {
+ Mutex::Autolock _l(mLock);
const String8 plugInId = getSupportedPlugInId(drmInfo->getMimeType());
if (EMPTY_STRING != plugInId) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
@@ -215,6 +228,7 @@ bool DrmManager::canHandle(int uniqueId, const String8& path) {
}
DrmInfo* DrmManager::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) {
+ Mutex::Autolock _l(mLock);
const String8 plugInId = getSupportedPlugInId(drmInfoRequest->getMimeType());
if (EMPTY_STRING != plugInId) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
@@ -225,6 +239,7 @@ DrmInfo* DrmManager::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoR
status_t DrmManager::saveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath) {
+ Mutex::Autolock _l(mLock);
const String8 plugInId = getSupportedPlugInId(drmRights.getMimeType());
status_t result = DRM_ERROR_UNKNOWN;
if (EMPTY_STRING != plugInId) {
@@ -235,6 +250,7 @@ status_t DrmManager::saveRights(int uniqueId, const DrmRights& drmRights,
}
String8 DrmManager::getOriginalMimeType(int uniqueId, const String8& path) {
+ Mutex::Autolock _l(mLock);
const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, path);
if (EMPTY_STRING != plugInId) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
@@ -244,6 +260,7 @@ String8 DrmManager::getOriginalMimeType(int uniqueId, const String8& path) {
}
int DrmManager::getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType) {
+ Mutex::Autolock _l(mLock);
const String8 plugInId = getSupportedPlugInId(uniqueId, path, mimeType);
if (EMPTY_STRING != plugInId) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
@@ -253,6 +270,7 @@ int DrmManager::getDrmObjectType(int uniqueId, const String8& path, const String
}
int DrmManager::checkRightsStatus(int uniqueId, const String8& path, int action) {
+ Mutex::Autolock _l(mLock);
const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, path);
if (EMPTY_STRING != plugInId) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
@@ -264,6 +282,7 @@ int DrmManager::checkRightsStatus(int uniqueId, const String8& path, int action)
status_t DrmManager::consumeRights(
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) {
status_t result = DRM_ERROR_UNKNOWN;
+ Mutex::Autolock _l(mDecryptLock);
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
result = drmEngine->consumeRights(uniqueId, decryptHandle, action, reserve);
@@ -272,8 +291,9 @@ status_t DrmManager::consumeRights(
}
status_t DrmManager::setPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
+ int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) {
status_t result = DRM_ERROR_UNKNOWN;
+ Mutex::Autolock _l(mDecryptLock);
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
result = drmEngine->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
@@ -283,6 +303,7 @@ status_t DrmManager::setPlaybackStatus(
bool DrmManager::validateAction(
int uniqueId, const String8& path, int action, const ActionDescription& description) {
+ Mutex::Autolock _l(mLock);
const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, path);
if (EMPTY_STRING != plugInId) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
@@ -292,6 +313,7 @@ bool DrmManager::validateAction(
}
status_t DrmManager::removeRights(int uniqueId, const String8& path) {
+ Mutex::Autolock _l(mLock);
const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, path);
status_t result = DRM_ERROR_UNKNOWN;
if (EMPTY_STRING != plugInId) {
@@ -315,6 +337,7 @@ status_t DrmManager::removeAllRights(int uniqueId) {
}
int DrmManager::openConvertSession(int uniqueId, const String8& mimeType) {
+ Mutex::Autolock _l(mConvertLock);
int convertId = -1;
const String8 plugInId = getSupportedPlugInId(mimeType);
@@ -322,7 +345,6 @@ int DrmManager::openConvertSession(int uniqueId, const String8& mimeType) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
if (DRM_NO_ERROR == rDrmEngine.openConvertSession(uniqueId, mConvertId + 1)) {
- Mutex::Autolock _l(mConvertLock);
++mConvertId;
convertId = mConvertId;
mConvertSessionMap.add(convertId, &rDrmEngine);
@@ -335,6 +357,7 @@ DrmConvertedStatus* DrmManager::convertData(
int uniqueId, int convertId, const DrmBuffer* inputData) {
DrmConvertedStatus *drmConvertedStatus = NULL;
+ Mutex::Autolock _l(mConvertLock);
if (mConvertSessionMap.indexOfKey(convertId) != NAME_NOT_FOUND) {
IDrmEngine* drmEngine = mConvertSessionMap.valueFor(convertId);
drmConvertedStatus = drmEngine->convertData(uniqueId, convertId, inputData);
@@ -343,6 +366,7 @@ DrmConvertedStatus* DrmManager::convertData(
}
DrmConvertedStatus* DrmManager::closeConvertSession(int uniqueId, int convertId) {
+ Mutex::Autolock _l(mConvertLock);
DrmConvertedStatus *drmConvertedStatus = NULL;
if (mConvertSessionMap.indexOfKey(convertId) != NAME_NOT_FOUND) {
@@ -355,6 +379,7 @@ DrmConvertedStatus* DrmManager::closeConvertSession(int uniqueId, int convertId)
status_t DrmManager::getAllSupportInfo(
int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) {
+ Mutex::Autolock _l(mLock);
Vector<String8> plugInPathList = mPlugInManager.getPlugInIdList();
int size = plugInPathList.size();
int validPlugins = 0;
@@ -384,7 +409,7 @@ status_t DrmManager::getAllSupportInfo(
return DRM_NO_ERROR;
}
-DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, int offset, int length) {
+DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length) {
Mutex::Autolock _l(mDecryptLock);
status_t result = DRM_ERROR_CANNOT_HANDLE;
Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
@@ -407,7 +432,6 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, int offset,
}
if (DRM_NO_ERROR != result) {
delete handle; handle = NULL;
- LOGE("DrmManager::openDecryptSession: no capable plug-in found");
}
return handle;
}
@@ -435,7 +459,7 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, const char* uri) {
}
if (DRM_NO_ERROR != result) {
delete handle; handle = NULL;
- LOGE("DrmManager::openDecryptSession: no capable plug-in found");
+ LOGV("DrmManager::openDecryptSession: no capable plug-in found");
}
return handle;
}
@@ -456,6 +480,7 @@ status_t DrmManager::closeDecryptSession(int uniqueId, DecryptHandle* decryptHan
status_t DrmManager::initializeDecryptUnit(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
status_t result = DRM_ERROR_UNKNOWN;
+ Mutex::Autolock _l(mDecryptLock);
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
result = drmEngine->initializeDecryptUnit(uniqueId, decryptHandle, decryptUnitId, headerInfo);
@@ -466,6 +491,8 @@ status_t DrmManager::initializeDecryptUnit(
status_t DrmManager::decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
status_t result = DRM_ERROR_UNKNOWN;
+
+ Mutex::Autolock _l(mDecryptLock);
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
result = drmEngine->decrypt(
@@ -477,6 +504,7 @@ status_t DrmManager::decrypt(int uniqueId, DecryptHandle* decryptHandle, int dec
status_t DrmManager::finalizeDecryptUnit(
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) {
status_t result = DRM_ERROR_UNKNOWN;
+ Mutex::Autolock _l(mDecryptLock);
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
result = drmEngine->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId);
@@ -485,9 +513,10 @@ status_t DrmManager::finalizeDecryptUnit(
}
ssize_t DrmManager::pread(int uniqueId, DecryptHandle* decryptHandle,
- void* buffer, ssize_t numBytes, off_t offset) {
+ void* buffer, ssize_t numBytes, off64_t offset) {
ssize_t result = DECRYPT_FILE_ERROR;
+ Mutex::Autolock _l(mDecryptLock);
if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) {
IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId);
result = drmEngine->pread(uniqueId, decryptHandle, buffer, numBytes, offset);
@@ -544,7 +573,7 @@ String8 DrmManager::getSupportedPlugInIdFromPath(int uniqueId, const String8& pa
}
void DrmManager::onInfo(const DrmInfoEvent& event) {
- Mutex::Autolock _l(mLock);
+ Mutex::Autolock _l(mListenerLock);
for (unsigned int index = 0; index < mServiceListeners.size(); index++) {
int uniqueId = mServiceListeners.keyAt(index);
diff --git a/drm/drmserver/DrmManagerService.cpp b/drm/drmserver/DrmManagerService.cpp
index 4dcfa720f095..0901a44f0129 100644
--- a/drm/drmserver/DrmManagerService.cpp
+++ b/drm/drmserver/DrmManagerService.cpp
@@ -162,7 +162,7 @@ status_t DrmManagerService::consumeRights(
}
status_t DrmManagerService::setPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
+ int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) {
LOGV("Entering setPlaybackStatus");
return mDrmManager->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position);
}
@@ -207,7 +207,7 @@ status_t DrmManagerService::getAllSupportInfo(
}
DecryptHandle* DrmManagerService::openDecryptSession(
- int uniqueId, int fd, int offset, int length) {
+ int uniqueId, int fd, off64_t offset, off64_t length) {
LOGV("Entering DrmManagerService::openDecryptSession");
if (isProtectedCallAllowed()) {
return mDrmManager->openDecryptSession(uniqueId, fd, offset, length);
@@ -251,7 +251,7 @@ status_t DrmManagerService::finalizeDecryptUnit(
}
ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle,
- void* buffer, ssize_t numBytes, off_t offset) {
+ void* buffer, ssize_t numBytes, off64_t offset) {
LOGV("Entering pread");
return mDrmManager->pread(uniqueId, decryptHandle, buffer, numBytes, offset);
}
diff --git a/drm/drmserver/StringTokenizer.cpp b/drm/drmserver/StringTokenizer.cpp
deleted file mode 100644
index 2130a0090f47..000000000000
--- a/drm/drmserver/StringTokenizer.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "StringTokenizer.h"
-
-using namespace android;
-
-StringTokenizer::StringTokenizer(const String8& string, const String8& delimiter) {
- splitString(string, delimiter);
-}
-
-void StringTokenizer::splitString(const String8& string, const String8& delimiter) {
- for (unsigned int i = 0; i < string.length(); i++) {
- unsigned int position = string.find(delimiter.string(), i);
- if (string.length() != position) {
- String8 token(string.string()+i, position-i);
- if (token.length()) {
- mStringTokenizerVector.push(token);
- i = position + delimiter.length() - 1;
- }
- } else {
- mStringTokenizerVector.push(String8(string.string()+i, string.length()-i));
- break;
- }
- }
-}
-
-StringTokenizer::Iterator StringTokenizer::iterator() {
- return Iterator(this);
-}
-
-StringTokenizer::Iterator::Iterator(const StringTokenizer::Iterator& iterator) :
- mStringTokenizer(iterator.mStringTokenizer),
- mIndex(iterator.mIndex) {
-}
-
-StringTokenizer::Iterator& StringTokenizer::Iterator::operator=(
- const StringTokenizer::Iterator& iterator) {
- mStringTokenizer = iterator.mStringTokenizer;
- mIndex = iterator.mIndex;
- return *this;
-}
-
-bool StringTokenizer::Iterator::hasNext() {
- return mIndex < mStringTokenizer->mStringTokenizerVector.size();
-}
-
-String8& StringTokenizer::Iterator::next() {
- String8& value = mStringTokenizer->mStringTokenizerVector.editItemAt(mIndex);
- mIndex++;
- return value;
-}
-
diff --git a/drm/java/android/drm/DrmConvertedStatus.java b/drm/java/android/drm/DrmConvertedStatus.java
index f2005527da1d..cecb135e6855 100644..100755
--- a/drm/java/android/drm/DrmConvertedStatus.java
+++ b/drm/java/android/drm/DrmConvertedStatus.java
@@ -17,13 +17,11 @@
package android.drm;
/**
- * This is an entity class which wraps the status of the conversion, the converted
- * data/checksum data and the offset. Offset is going to be used in the case of close
- * session where the agent will inform where the header and body signature should be added
- *
- * As a result of {@link DrmManagerClient#convertData(int, byte [])} and
- * {@link DrmManagerClient#closeConvertSession(int)} an instance of DrmConvertedStatus
- * would be returned.
+ * An entity class that wraps converted data, conversion status, and the
+ * offset for appending the header and body signature to the converted data. An instance of this
+ * class is returned by the {@link DrmManagerClient#convertData convertData()} and
+ * {@link DrmManagerClient#closeConvertSession closeConvertSession()} methods. The offset is provided only when a
+ * conversion session is closed by calling {@link DrmManagerClient#closeConvertSession closeConvertSession()}.
*
*/
public class DrmConvertedStatus {
@@ -32,16 +30,19 @@ public class DrmConvertedStatus {
public static final int STATUS_INPUTDATA_ERROR = 2;
public static final int STATUS_ERROR = 3;
+ /** Status code for the conversion.*/
public final int statusCode;
+ /** Converted data.*/
public final byte[] convertedData;
+ /** Offset value for the body and header signature.*/
public final int offset;
/**
- * constructor to create DrmConvertedStatus object with given parameters
+ * Creates a <code>DrmConvertedStatus</code> object with the specified parameters.
*
- * @param _statusCode Status of the conversion
- * @param _convertedData Converted data/checksum data
- * @param _offset Offset value
+ * @param _statusCode Conversion status.
+ * @param _convertedData Converted data.
+ * @param _offset Offset value for appending the header and body signature.
*/
public DrmConvertedStatus(int _statusCode, byte[] _convertedData, int _offset) {
statusCode = _statusCode;
diff --git a/drm/java/android/drm/DrmErrorEvent.java b/drm/java/android/drm/DrmErrorEvent.java
index 20fd8aa080f8..2cb82e67e14b 100644..100755
--- a/drm/java/android/drm/DrmErrorEvent.java
+++ b/drm/java/android/drm/DrmErrorEvent.java
@@ -16,53 +16,72 @@
package android.drm;
+import java.util.HashMap;
+
/**
- * This is an entity class which would be passed to caller in
- * {@link DrmManagerClient.OnErrorListener#onError(DrmManagerClient, DrmErrorEvent)}
+ * An entity class that is passed to the
+ * {@link DrmManagerClient.OnErrorListener#onError onError()} callback.
*
*/
public class DrmErrorEvent extends DrmEvent {
/**
- * TYPE_RIGHTS_NOT_INSTALLED, when something went wrong installing the rights.
+ * Something went wrong installing the rights.
*/
public static final int TYPE_RIGHTS_NOT_INSTALLED = 2001;
/**
- * TYPE_RIGHTS_RENEWAL_NOT_ALLOWED, when the server rejects renewal of rights.
+ * The server rejected the renewal of rights.
*/
public static final int TYPE_RIGHTS_RENEWAL_NOT_ALLOWED = 2002;
/**
- * TYPE_NOT_SUPPORTED, when answer from server can not be handled by the native agent.
+ * Response from the server cannot be handled by the DRM plug-in (agent).
*/
public static final int TYPE_NOT_SUPPORTED = 2003;
/**
- * TYPE_OUT_OF_MEMORY, when memory allocation fail during renewal.
- * Can in the future perhaps be used to trigger garbage collector.
+ * Memory allocation failed during renewal. Can in the future perhaps be used to trigger
+ * garbage collector.
*/
public static final int TYPE_OUT_OF_MEMORY = 2004;
/**
- * TYPE_NO_INTERNET_CONNECTION, when the Internet connection is missing and no attempt
- * can be made to renew rights.
+ * An Internet connection is not available and no attempt can be made to renew rights.
*/
public static final int TYPE_NO_INTERNET_CONNECTION = 2005;
/**
- * TYPE_PROCESS_DRM_INFO_FAILED, when failed to process DrmInfo.
+ * Failed to process {@link DrmInfo}. This error event is sent when a
+ * {@link DrmManagerClient#processDrmInfo processDrmInfo()} call fails.
*/
public static final int TYPE_PROCESS_DRM_INFO_FAILED = 2006;
/**
- * TYPE_REMOVE_ALL_RIGHTS_FAILED, when failed to remove all the rights objects
- * associated with all DRM schemes.
+ * Failed to remove all the rights objects associated with all DRM schemes.
*/
public static final int TYPE_REMOVE_ALL_RIGHTS_FAILED = 2007;
+ /**
+ * Failed to acquire {@link DrmInfo}. This error event is sent when an
+ * {@link DrmManagerClient#acquireDrmInfo acquireDrmInfo()} call fails.
+ */
+ public static final int TYPE_ACQUIRE_DRM_INFO_FAILED = 2008;
/**
- * constructor to create DrmErrorEvent object with given parameters
+ * Creates a <code>DrmErrorEvent</code> object with the specified parameters.
*
- * @param uniqueId Unique session identifier
- * @param type Type of information
- * @param message Message description
+ * @param uniqueId Unique session identifier.
+ * @param type Type of the event. Could be any of the event types defined above.
+ * @param message Message description.
*/
public DrmErrorEvent(int uniqueId, int type, String message) {
super(uniqueId, type, message);
}
-}
+ /**
+ * Creates a <code>DrmErrorEvent</code> object with the specified parameters.
+ *
+ * @param uniqueId Unique session identifier.
+ * @param type Type of the event. Could be any of the event types defined above.
+ * @param message Message description.
+ * @param attributes Attributes for extensible information. Could be any
+ * information provided by the plug-in.
+ */
+ public DrmErrorEvent(int uniqueId, int type, String message,
+ HashMap<String, Object> attributes) {
+ super(uniqueId, type, message, attributes);
+ }
+}
diff --git a/drm/java/android/drm/DrmEvent.java b/drm/java/android/drm/DrmEvent.java
index f7bc5cd11884..4053eb39e799 100644..100755
--- a/drm/java/android/drm/DrmEvent.java
+++ b/drm/java/android/drm/DrmEvent.java
@@ -16,34 +16,65 @@
package android.drm;
+import java.util.HashMap;
+
/**
- * This is the base class which would be used to notify the caller
- * about any event occurred in DRM framework.
+ * A base class that is used to send asynchronous event information from the DRM framework.
*
*/
public class DrmEvent {
/**
- * Constant field signifies that all the rights information associated with
- * all DRM schemes are removed successfully
+ * All of the rights information associated with all DRM schemes have been successfully removed.
*/
public static final int TYPE_ALL_RIGHTS_REMOVED = 1001;
/**
- * Constant field signifies that given information is processed successfully
+ * The given DRM information has been successfully processed.
*/
public static final int TYPE_DRM_INFO_PROCESSED = 1002;
-
+ /**
+ * The key that is used in the <code>attributes</code> HashMap to pass the return status.
+ */
public static final String DRM_INFO_STATUS_OBJECT = "drm_info_status_object";
+ /**
+ * The key that is used in the <code>attributes</code> HashMap to pass the
+ * {@link DrmInfo} object.
+ */
+ public static final String DRM_INFO_OBJECT = "drm_info_object";
private final int mUniqueId;
private final int mType;
private String mMessage = "";
+ private HashMap<String, Object> mAttributes = new HashMap<String, Object>();
+
+ /**
+ * Creates a <code>DrmEvent</code> object with the specified parameters.
+ *
+ * @param uniqueId Unique session identifier.
+ * @param type Type of information.
+ * @param message Message description.
+ * @param attributes Attributes for extensible information.
+ */
+ protected DrmEvent(int uniqueId, int type, String message,
+ HashMap<String, Object> attributes) {
+ mUniqueId = uniqueId;
+ mType = type;
+
+ if (null != message) {
+ mMessage = message;
+ }
+
+ if (null != attributes) {
+ mAttributes = attributes;
+ }
+ }
+
/**
- * constructor for DrmEvent class
+ * Creates a <code>DrmEvent</code> object with the specified parameters.
*
- * @param uniqueId Unique session identifier
- * @param type Type of information
- * @param message Message description
+ * @param uniqueId Unique session identifier.
+ * @param type Type of information.
+ * @param message Message description.
*/
protected DrmEvent(int uniqueId, int type, String message) {
mUniqueId = uniqueId;
@@ -55,30 +86,39 @@ public class DrmEvent {
}
/**
- * Returns the Unique Id associated with this object
+ * Retrieves the unique session identifier associated with this object.
*
- * @return Unique Id
+ * @return The unique session identifier.
*/
public int getUniqueId() {
return mUniqueId;
}
/**
- * Returns the Type of information associated with this object
+ * Retrieves the type of information that is associated with this object.
*
- * @return Type of information
+ * @return The type of information.
*/
public int getType() {
return mType;
}
/**
- * Returns the message description associated with this object
+ * Retrieves the message description associated with this object.
*
- * @return message description
+ * @return The message description.
*/
public String getMessage() {
return mMessage;
}
-}
+ /**
+ * Retrieves the attribute associated with the specified key.
+ *
+ * @return One of the attributes or null if no mapping for
+ * the key is found.
+ */
+ public Object getAttribute(String key) {
+ return mAttributes.get(key);
+ }
+}
diff --git a/drm/java/android/drm/DrmInfo.java b/drm/java/android/drm/DrmInfo.java
index 7d3fbf1fd848..8812bfe5a11e 100644..100755
--- a/drm/java/android/drm/DrmInfo.java
+++ b/drm/java/android/drm/DrmInfo.java
@@ -21,14 +21,13 @@ import java.util.HashMap;
import java.util.Iterator;
/**
- * This is an entity class in which necessary information required to transact
- * between device and online DRM server is described. DRM Framework achieves
- * server registration, license acquisition and any other server related transaction
- * by passing an instance of this class to {@link DrmManagerClient#processDrmInfo(DrmInfo)}.
- *
- * Caller can retrieve the {@link DrmInfo} instance by using
- * {@link DrmManagerClient#acquireDrmInfo(DrmInfoRequest)}
- * by passing {@link DrmInfoRequest} instance.
+ * An entity class that describes the information required to send transactions
+ * between a device and an online DRM server. The DRM framework achieves
+ * server registration, license acquisition, and any other server-related transactions
+ * by passing an instance of this class to {@link DrmManagerClient#processDrmInfo}.
+ *<p>
+ * The caller can retrieve the {@link DrmInfo} instance by passing a {@link DrmInfoRequest}
+ * instance to {@link DrmManagerClient#acquireDrmInfo}.
*
*/
public class DrmInfo {
@@ -40,11 +39,11 @@ public class DrmInfo {
private final HashMap<String, Object> mAttributes = new HashMap<String, Object>();
/**
- * constructor to create DrmInfo object with given parameters
+ * Creates a <code>DrmInfo</code> object with the given parameters.
*
- * @param infoType Type of information
- * @param data Trigger data
- * @param mimeType MIME type
+ * @param infoType The type of information.
+ * @param data The trigger data.
+ * @param mimeType The MIME type.
*/
public DrmInfo(int infoType, byte[] data, String mimeType) {
mInfoType = infoType;
@@ -53,11 +52,11 @@ public class DrmInfo {
}
/**
- * constructor to create DrmInfo object with given parameters
+ * Creates a <code>DrmInfo</code> object with the given parameters.
*
- * @param infoType Type of information
- * @param path Trigger data
- * @param mimeType MIME type
+ * @param infoType The type of information.
+ * @param path The trigger data.
+ * @param mimeType The MIME type.
*/
public DrmInfo(int infoType, String path, String mimeType) {
mInfoType = infoType;
@@ -73,67 +72,70 @@ public class DrmInfo {
}
/**
- * Adds optional information as <key, value> pair to this object
+ * Adds optional information as key-value pairs to this object. To add a custom object
+ * to the <code>DrmInfo</code> object, you must override the {@link #toString} implementation.
+ *
+ * @param key Key to add.
+ * @param value Value to add.
*
- * @param key Key to add
- * @param value Value to add
- * To put custom object into DrmInfo, custom object has to
- * override toString() implementation.
*/
public void put(String key, Object value) {
mAttributes.put(key, value);
}
/**
- * Retrieves the value of given key, if not found returns null
+ * Retrieves the value of a given key.
+ *
+ * @param key The key whose value is being retrieved.
*
- * @param key Key whose value to be retrieved
- * @return The value or null
+ * @return The value of the key being retrieved. Returns null if the key cannot be found.
*/
public Object get(String key) {
return mAttributes.get(key);
}
/**
- * Returns Iterator object to walk through the keys associated with this instance
+ * Retrieves an iterator object that you can use to iterate over the keys associated with
+ * this <code>DrmInfo</code> object.
*
- * @return Iterator object
+ * @return The iterator object.
*/
public Iterator<String> keyIterator() {
return mAttributes.keySet().iterator();
}
/**
- * Returns Iterator object to walk through the values associated with this instance
+ * Retrieves an iterator object that you can use to iterate over the values associated with
+ * this <code>DrmInfo</code> object.
*
- * @return Iterator object
+ * @return The iterator object.
*/
public Iterator<Object> iterator() {
return mAttributes.values().iterator();
}
/**
- * Returns the trigger data associated with this object
+ * Retrieves the trigger data associated with this object.
*
- * @return Trigger data
+ * @return The trigger data.
*/
public byte[] getData() {
return mData;
}
/**
- * Returns the mimetype associated with this object
+ * Retrieves the MIME type associated with this object.
*
- * @return MIME type
+ * @return The MIME type.
*/
public String getMimeType() {
return mMimeType;
}
/**
- * Returns information type associated with this instance
+ * Retrieves the information type associated with this object.
*
- * @return Information type
+ * @return The information type.
*/
public int getInfoType() {
return mInfoType;
diff --git a/drm/java/android/drm/DrmInfoEvent.java b/drm/java/android/drm/DrmInfoEvent.java
index a778e06f8461..67aa0a96b636 100644..100755
--- a/drm/java/android/drm/DrmInfoEvent.java
+++ b/drm/java/android/drm/DrmInfoEvent.java
@@ -16,45 +16,63 @@
package android.drm;
+import java.util.HashMap;
+
/**
- * This is an entity class which would be passed to caller in
- * {@link DrmManagerClient.OnInfoListener#onInfo(DrmManagerClient, DrmInfoEvent)}
+ * An entity class that is passed to the
+ * {@link DrmManagerClient.OnInfoListener#onInfo onInfo()} callback.
*
*/
public class DrmInfoEvent extends DrmEvent {
/**
- * TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT, when registration has been already done
- * by another account ID.
+ * The registration has already been done by another account ID.
*/
public static final int TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT = 1;
/**
- * TYPE_REMOVE_RIGHTS, when the rights needs to be removed completely.
+ * The rights need to be removed completely.
*/
public static final int TYPE_REMOVE_RIGHTS = 2;
/**
- * TYPE_RIGHTS_INSTALLED, when the rights are downloaded and installed ok.
+ * The rights have been successfully downloaded and installed.
*/
public static final int TYPE_RIGHTS_INSTALLED = 3;
/**
- * TYPE_WAIT_FOR_RIGHTS, rights object is on it's way to phone,
- * wait before calling checkRights again.
+ * The rights object is being delivered to the device. You must wait before
+ * calling {@link DrmManagerClient#acquireRights acquireRights()} again.
*/
public static final int TYPE_WAIT_FOR_RIGHTS = 4;
/**
- * TYPE_ACCOUNT_ALREADY_REGISTERED, when registration has been
- * already done for the given account.
+ * The registration has already been done for the given account.
*/
public static final int TYPE_ACCOUNT_ALREADY_REGISTERED = 5;
+ /**
+ * The rights have been removed.
+ */
+ public static final int TYPE_RIGHTS_REMOVED = 6;
/**
- * constructor to create DrmInfoEvent object with given parameters
+ * Creates a <code>DrmInfoEvent</code> object with the specified parameters.
*
- * @param uniqueId Unique session identifier
- * @param type Type of information
- * @param message Message description
+ * @param uniqueId Unique session identifier.
+ * @param type Type of the event. Could be any of the event types defined above.
+ * @param message Message description.
*/
public DrmInfoEvent(int uniqueId, int type, String message) {
super(uniqueId, type, message);
}
+
+ /**
+ * Creates a <code>DrmInfoEvent</code> object with the specified parameters.
+ *
+ * @param uniqueId Unique session identifier.
+ * @param type Type of the event. Could be any of the event types defined above.
+ * @param message Message description.
+ * @param attributes Attributes for extensible information. Could be any
+ * information provided by the plug-in.
+ */
+ public DrmInfoEvent(int uniqueId, int type, String message,
+ HashMap<String, Object> attributes) {
+ super(uniqueId, type, message, attributes);
+ }
}
diff --git a/drm/java/android/drm/DrmInfoRequest.java b/drm/java/android/drm/DrmInfoRequest.java
index a5a799c438c2..9f86f5f5a7c3 100644..100755
--- a/drm/java/android/drm/DrmInfoRequest.java
+++ b/drm/java/android/drm/DrmInfoRequest.java
@@ -20,30 +20,37 @@ import java.util.HashMap;
import java.util.Iterator;
/**
- * This is an entity class used to pass required parameters to get
- * the necessary information to communicate with online DRM server
- *
- * An instance of this class is passed to {@link DrmManagerClient#acquireDrmInfo(DrmInfoRequest)}
- * to get the instance of {@link DrmInfo}
+ * An entity class that is used to pass information to an online DRM server. An instance of this
+ * class is passed to the {@link DrmManagerClient#acquireDrmInfo acquireDrmInfo()} method to get an
+ * instance of a {@link DrmInfo}.
*
*/
public class DrmInfoRequest {
// Changes in following constants should be in sync with DrmInfoRequest.cpp
/**
- * Constants defines the type of {@link DrmInfoRequest}
+ * Acquires DRM server registration information.
*/
public static final int TYPE_REGISTRATION_INFO = 1;
+ /**
+ * Acquires information for unregistering the DRM server.
+ */
public static final int TYPE_UNREGISTRATION_INFO = 2;
+ /**
+ * Acquires rights information.
+ */
public static final int TYPE_RIGHTS_ACQUISITION_INFO = 3;
+ /**
+ * Acquires the progress of the rights acquisition.
+ */
public static final int TYPE_RIGHTS_ACQUISITION_PROGRESS_INFO = 4;
/**
- * Key to pass the unique id for the account or the user
+ * Key that is used to pass the unique session ID for the account or the user.
*/
public static final String ACCOUNT_ID = "account_id";
/**
- * Key to pass the unique id used for subscription
+ * Key that is used to pass the unique session ID for the subscription.
*/
public static final String SUBSCRIPTION_ID = "subscription_id";
@@ -52,10 +59,10 @@ public class DrmInfoRequest {
private final HashMap<String, Object> mRequestInformation = new HashMap<String, Object>();
/**
- * constructor to create DrmInfoRequest object with type and mimetype
+ * Creates a <code>DrmInfoRequest</code> object with type and MIME type.
*
- * @param infoType Type of information
- * @param mimeType MIME type
+ * @param infoType Type of information.
+ * @param mimeType MIME type.
*/
public DrmInfoRequest(int infoType, String mimeType) {
mInfoType = infoType;
@@ -63,56 +70,60 @@ public class DrmInfoRequest {
}
/**
- * Returns the mimetype associated with this object
+ * Retrieves the MIME type associated with this object.
*
- * @return MIME type
+ * @return The MIME type.
*/
public String getMimeType() {
return mMimeType;
}
/**
- * Returns Information type associated with this instance
+ * Retrieves the information type associated with this object.
*
- * @return Information type
+ * @return The information type.
*/
public int getInfoType() {
return mInfoType;
}
/**
- * Adds optional information as <key, value> pair to this object.
+ * Adds optional information as key-value pairs to this object.
*
- * @param key Key to add
- * @param value Value to add
+ * @param key The key to add.
+ * @param value The value to add.
*/
public void put(String key, Object value) {
mRequestInformation.put(key, value);
}
/**
- * Retrieves the value of given key, if not found returns null
+ * Retrieves the value of a given key.
+ *
+ * @param key The key whose value is being retrieved.
*
- * @param key Key whose value to be retrieved
- * @return The value or null
+ * @return The value of the key that is being retrieved. Returns null if the key cannot be
+ * found.
*/
public Object get(String key) {
return mRequestInformation.get(key);
}
/**
- * Returns Iterator object to walk through the keys associated with this instance
+ * Retrieves an iterator object that you can use to iterate over the keys associated with
+ * this <code>DrmInfoRequest</code> object.
*
- * @return Iterator object
+ * @return The iterator object.
*/
public Iterator<String> keyIterator() {
return mRequestInformation.keySet().iterator();
}
/**
- * Returns Iterator object to walk through the values associated with this instance
+ * Retrieves an iterator object that you can use to iterate over the values associated with
+ * this <code>DrmInfoRequest</code> object.
*
- * @return Iterator object
+ * @return The iterator object.
*/
public Iterator<Object> iterator() {
return mRequestInformation.values().iterator();
diff --git a/drm/java/android/drm/DrmInfoStatus.java b/drm/java/android/drm/DrmInfoStatus.java
index b37ea5180ac8..b04694bb79fb 100644..100755
--- a/drm/java/android/drm/DrmInfoStatus.java
+++ b/drm/java/android/drm/DrmInfoStatus.java
@@ -17,12 +17,12 @@
package android.drm;
/**
- * This is an entity class which wraps the result of communication between device
- * and online DRM server.
- *
- * As a result of {@link DrmManagerClient#processDrmInfo(DrmInfo)} an instance of DrmInfoStatus
- * would be returned. This class holds {@link ProcessedData}, which could be used to instantiate
- * {@link DrmRights#DrmRights(ProcessedData, String)} in license acquisition.
+ * An entity class that wraps the result of communication between a device and an online DRM
+ * server. Specifically, when the {@link DrmManagerClient#processDrmInfo processDrmInfo()} method
+ * is called, an instance of <code>DrmInfoStatus</code> is returned.
+ *<p>
+ * This class contains the {@link ProcessedData} object, which can be used to instantiate a
+ * {@link DrmRights} object during license acquisition.
*
*/
public class DrmInfoStatus {
@@ -30,18 +30,30 @@ public class DrmInfoStatus {
public static final int STATUS_OK = 1;
public static final int STATUS_ERROR = 2;
+ /**
+ * The status of the communication.
+ */
public final int statusCode;
+ /**
+ * The type of DRM information processed.
+ */
public final int infoType;
+ /**
+ * The MIME type of the content.
+ */
public final String mimeType;
+ /**
+ * The processed data.
+ */
public final ProcessedData data;
/**
- * constructor to create DrmInfoStatus object with given parameters
+ * Creates a <code>DrmInfoStatus</code> object with the specified parameters.
*
- * @param _statusCode Status of the communication
- * @param _infoType Type of the DRM information processed
- * @param _data The processed data
- * @param _mimeType MIME type
+ * @param _statusCode The status of the communication.
+ * @param _infoType The type of the DRM information processed.
+ * @param _data The processed data.
+ * @param _mimeType The MIME type.
*/
public DrmInfoStatus(int _statusCode, int _infoType, ProcessedData _data, String _mimeType) {
statusCode = _statusCode;
diff --git a/drm/java/android/drm/DrmManagerClient.java b/drm/java/android/drm/DrmManagerClient.java
index 6caf678d8558..f3a034307ad9 100644..100755
--- a/drm/java/android/drm/DrmManagerClient.java
+++ b/drm/java/android/drm/DrmManagerClient.java
@@ -35,18 +35,17 @@ import java.util.ArrayList;
import java.util.HashMap;
/**
- * Interface of DRM Framework.
- * Java application will instantiate this class
- * to access DRM agent through DRM Framework.
+ * The main programming interface for the DRM framework. An application must instantiate this class
+ * to access DRM agents through the DRM framework.
*
*/
public class DrmManagerClient {
/**
- * Constant field signifies the success or no error occurred
+ * Indicates that a request was successful or that no error occurred.
*/
public static final int ERROR_NONE = 0;
/**
- * Constant field signifies that error occurred and the reason is not known
+ * Indicates that an error occurred and the reason is not known.
*/
public static final int ERROR_UNKNOWN = -2000;
@@ -58,45 +57,45 @@ public class DrmManagerClient {
}
/**
- * Interface definition of a callback to be invoked to communicate
- * some info and/or warning about DrmManagerClient.
+ * Interface definition for a callback that receives status messages and warnings
+ * during registration and rights acquisition.
*/
public interface OnInfoListener {
/**
- * Called to indicate an info or a warning.
+ * Called when the DRM framework sends status or warning information during registration
+ * and rights acquisition.
*
- * @param client DrmManagerClient instance
- * @param event instance which wraps reason and necessary information
+ * @param client The <code>DrmManagerClient</code> instance.
+ * @param event The {@link DrmInfoEvent} instance that wraps the status information or
+ * warnings.
*/
public void onInfo(DrmManagerClient client, DrmInfoEvent event);
}
/**
- * Interface definition of a callback to be invoked to communicate
- * the result of time consuming APIs asynchronously
+ * Interface definition for a callback that receives information
+ * about DRM processing events.
*/
public interface OnEventListener {
/**
- * Called to indicate the result of asynchronous APIs.
+ * Called when the DRM framework sends information about a DRM processing request.
*
- * @param client DrmManagerClient instance
- * @param event instance which wraps type and message
- * @param attributes resultant values in key and value pair.
+ * @param client The <code>DrmManagerClient</code> instance.
+ * @param event The {@link DrmEvent} instance that wraps the information being
+ * conveyed, such as the information type and message.
*/
- public void onEvent(DrmManagerClient client, DrmEvent event,
- HashMap<String, Object> attributes);
+ public void onEvent(DrmManagerClient client, DrmEvent event);
}
/**
- * Interface definition of a callback to be invoked to communicate
- * the error occurred
+ * Interface definition for a callback that receives information about DRM framework errors.
*/
public interface OnErrorListener {
/**
- * Called to indicate the error occurred.
+ * Called when the DRM framework sends error information.
*
- * @param client DrmManagerClient instance
- * @param event instance which wraps error type and message
+ * @param client The <code>DrmManagerClient</code> instance.
+ * @param event The {@link DrmErrorEvent} instance that wraps the error type and message.
*/
public void onError(DrmManagerClient client, DrmErrorEvent event);
}
@@ -128,12 +127,17 @@ public class DrmManagerClient {
case ACTION_PROCESS_DRM_INFO: {
final DrmInfo drmInfo = (DrmInfo) msg.obj;
DrmInfoStatus status = _processDrmInfo(mUniqueId, drmInfo);
+
+ attributes.put(DrmEvent.DRM_INFO_STATUS_OBJECT, status);
+ attributes.put(DrmEvent.DRM_INFO_OBJECT, drmInfo);
+
if (null != status && DrmInfoStatus.STATUS_OK == status.statusCode) {
- attributes.put(DrmEvent.DRM_INFO_STATUS_OBJECT, status);
- event = new DrmEvent(mUniqueId, getEventType(status.infoType), null);
+ event = new DrmEvent(mUniqueId,
+ getEventType(status.infoType), null, attributes);
} else {
int infoType = (null != status) ? status.infoType : drmInfo.getInfoType();
- error = new DrmErrorEvent(mUniqueId, getErrorType(infoType), null);
+ error = new DrmErrorEvent(mUniqueId,
+ getErrorType(infoType), null, attributes);
}
break;
}
@@ -151,7 +155,7 @@ public class DrmManagerClient {
return;
}
if (null != mOnEventListener && null != event) {
- mOnEventListener.onEvent(DrmManagerClient.this, event, attributes);
+ mOnEventListener.onEvent(DrmManagerClient.this, event);
}
if (null != mOnErrorListener && null != error) {
mOnErrorListener.onError(DrmManagerClient.this, error);
@@ -181,7 +185,7 @@ public class DrmManagerClient {
}
public void handleMessage(Message msg) {
- DrmInfoEvent event = null;
+ DrmInfoEvent info = null;
DrmErrorEvent error = null;
switch (msg.what) {
@@ -197,11 +201,15 @@ public class DrmManagerClient {
} catch (IOException e) {
e.printStackTrace();
}
- event = new DrmInfoEvent(uniqueId, infoType, message);
+ info = new DrmInfoEvent(uniqueId, infoType, message);
break;
}
- case DrmInfoEvent.TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT: {
- event = new DrmInfoEvent(uniqueId, infoType, message);
+ case DrmInfoEvent.TYPE_ALREADY_REGISTERED_BY_ANOTHER_ACCOUNT:
+ case DrmInfoEvent.TYPE_RIGHTS_INSTALLED:
+ case DrmInfoEvent.TYPE_WAIT_FOR_RIGHTS:
+ case DrmInfoEvent.TYPE_ACCOUNT_ALREADY_REGISTERED:
+ case DrmInfoEvent.TYPE_RIGHTS_REMOVED: {
+ info = new DrmInfoEvent(uniqueId, infoType, message);
break;
}
default:
@@ -209,8 +217,8 @@ public class DrmManagerClient {
break;
}
- if (null != mOnInfoListener && null != event) {
- mOnInfoListener.onInfo(DrmManagerClient.this, event);
+ if (null != mOnInfoListener && null != info) {
+ mOnInfoListener.onInfo(DrmManagerClient.this, info);
}
if (null != mOnErrorListener && null != error) {
mOnErrorListener.onError(DrmManagerClient.this, error);
@@ -224,9 +232,9 @@ public class DrmManagerClient {
}
/**
- * To instantiate DrmManagerClient
+ * Creates a <code>DrmManagerClient</code>.
*
- * @param context context of the caller
+ * @param context Context of the caller.
*/
public DrmManagerClient(Context context) {
mContext = context;
@@ -250,10 +258,10 @@ public class DrmManagerClient {
}
/**
- * Register a callback to be invoked when the caller required to receive
- * supplementary information.
+ * Registers an {@link DrmManagerClient.OnInfoListener} callback, which is invoked when the
+ * DRM framework sends status or warning information during registration or rights acquisition.
*
- * @param infoListener
+ * @param infoListener Interface definition for the callback.
*/
public synchronized void setOnInfoListener(OnInfoListener infoListener) {
if (null != infoListener) {
@@ -262,10 +270,10 @@ public class DrmManagerClient {
}
/**
- * Register a callback to be invoked when the caller required to receive
- * the result of asynchronous APIs.
+ * Registers an {@link DrmManagerClient.OnEventListener} callback, which is invoked when the
+ * DRM framework sends information about DRM processing.
*
- * @param eventListener
+ * @param eventListener Interface definition for the callback.
*/
public synchronized void setOnEventListener(OnEventListener eventListener) {
if (null != eventListener) {
@@ -274,10 +282,10 @@ public class DrmManagerClient {
}
/**
- * Register a callback to be invoked when the caller required to receive
- * error result of asynchronous APIs.
+ * Registers an {@link DrmManagerClient.OnErrorListener} callback, which is invoked when
+ * the DRM framework sends error information.
*
- * @param errorListener
+ * @param errorListener Interface definition for the callback.
*/
public synchronized void setOnErrorListener(OnErrorListener errorListener) {
if (null != errorListener) {
@@ -286,9 +294,10 @@ public class DrmManagerClient {
}
/**
- * Retrieves informations about all the plug-ins registered with DrmFramework.
+ * Retrieves information about all the DRM plug-ins (agents) that are registered with
+ * the DRM framework.
*
- * @return Array of DrmEngine plug-in strings
+ * @return A <code>String</code> array of DRM plug-in descriptions.
*/
public String[] getAvailableDrmEngines() {
DrmSupportInfo[] supportInfos = _getAllSupportInfo(mUniqueId);
@@ -303,12 +312,13 @@ public class DrmManagerClient {
}
/**
- * Get constraints information evaluated from DRM content
+ * Retrieves constraint information for rights-protected content.
+ *
+ * @param path Path to the content from which you are retrieving DRM constraints.
+ * @param action Action defined in {@link DrmStore.Action}.
*
- * @param path Content path from where DRM constraints would be retrieved.
- * @param action Actions defined in {@link DrmStore.Action}
- * @return ContentValues instance in which constraints key-value pairs are embedded
- * or null in case of failure
+ * @return A {@link android.content.ContentValues} instance that contains
+ * key-value pairs representing the constraints. Null in case of failure.
*/
public ContentValues getConstraints(String path, int action) {
if (null == path || path.equals("") || !DrmStore.Action.isValid(action)) {
@@ -318,11 +328,12 @@ public class DrmManagerClient {
}
/**
- * Get metadata information from DRM content
+ * Retrieves metadata information for rights-protected content.
*
- * @param path Content path from where DRM metadata would be retrieved.
- * @return ContentValues instance in which metadata key-value pairs are embedded
- * or null in case of failure
+ * @param path Path to the content from which you are retrieving metadata information.
+ *
+ * @return A {@link android.content.ContentValues} instance that contains
+ * key-value pairs representing the metadata. Null in case of failure.
*/
public ContentValues getMetadata(String path) {
if (null == path || path.equals("")) {
@@ -332,12 +343,13 @@ public class DrmManagerClient {
}
/**
- * Get constraints information evaluated from DRM content
+ * Retrieves constraint information for rights-protected content.
+ *
+ * @param uri URI for the content from which you are retrieving DRM constraints.
+ * @param action Action defined in {@link DrmStore.Action}.
*
- * @param uri Content URI from where DRM constraints would be retrieved.
- * @param action Actions defined in {@link DrmStore.Action}
- * @return ContentValues instance in which constraints key-value pairs are embedded
- * or null in case of failure
+ * @return A {@link android.content.ContentValues} instance that contains
+ * key-value pairs representing the constraints. Null in case of failure.
*/
public ContentValues getConstraints(Uri uri, int action) {
if (null == uri || Uri.EMPTY == uri) {
@@ -347,11 +359,12 @@ public class DrmManagerClient {
}
/**
- * Get metadata information from DRM content
+ * Retrieves metadata information for rights-protected content.
+ *
+ * @param uri URI for the content from which you are retrieving metadata information.
*
- * @param uri Content URI from where DRM metadata would be retrieved.
- * @return ContentValues instance in which metadata key-value pairs are embedded
- * or null in case of failure
+ * @return A {@link android.content.ContentValues} instance that contains
+ * key-value pairs representing the constraints. Null in case of failure.
*/
public ContentValues getMetadata(Uri uri) {
if (null == uri || Uri.EMPTY == uri) {
@@ -361,18 +374,19 @@ public class DrmManagerClient {
}
/**
- * Save DRM rights to specified rights path
- * and make association with content path.
+ * Saves rights to a specified path and associates that path with the content path.
+ *
+ * <p class="note"><strong>Note:</strong> For OMA or WM-DRM, <code>rightsPath</code> and
+ * <code>contentPath</code> can be null.</p>
*
- * <p class="note">In case of OMA or WM-DRM, rightsPath and contentPath could be null.</p>
+ * @param drmRights The {@link DrmRights} to be saved.
+ * @param rightsPath File path where rights will be saved.
+ * @param contentPath File path where content is saved.
*
- * @param drmRights DrmRights to be saved
- * @param rightsPath File path where rights to be saved
- * @param contentPath File path where content was saved
- * @return
- * ERROR_NONE for success
- * ERROR_UNKNOWN for failure
- * @throws IOException if failed to save rights information in the given path
+ * @return ERROR_NONE for success; ERROR_UNKNOWN for failure.
+ *
+ * @throws IOException If the call failed to save rights information at the given
+ * <code>rightsPath</code>.
*/
public int saveRights(
DrmRights drmRights, String rightsPath, String contentPath) throws IOException {
@@ -386,9 +400,10 @@ public class DrmManagerClient {
}
/**
- * Install new DRM Engine Plug-in at the runtime
+ * Installs a new DRM plug-in (agent) at runtime.
+ *
+ * @param engineFilePath File path to the plug-in file to be installed.
*
- * @param engineFilePath Path of the plug-in file to be installed
* {@hide}
*/
public void installDrmEngine(String engineFilePath) {
@@ -400,13 +415,12 @@ public class DrmManagerClient {
}
/**
- * Check whether the given mimetype or path can be handled.
+ * Checks whether the given MIME type or path can be handled.
+ *
+ * @param path Path of the content to be handled.
+ * @param mimeType MIME type of the object to be handled.
*
- * @param path Path of the content to be handled
- * @param mimeType Mimetype of the object to be handled
- * @return
- * true - if the given mimeType or path can be handled
- * false - cannot be handled.
+ * @return True if the given MIME type or path can be handled; false if they cannot be handled.
*/
public boolean canHandle(String path, String mimeType) {
if ((null == path || path.equals("")) && (null == mimeType || mimeType.equals(""))) {
@@ -416,13 +430,12 @@ public class DrmManagerClient {
}
/**
- * Check whether the given mimetype or uri can be handled.
+ * Checks whether the given MIME type or URI can be handled.
*
- * @param uri Content URI of the data to be handled.
- * @param mimeType Mimetype of the object to be handled
- * @return
- * true - if the given mimeType or path can be handled
- * false - cannot be handled.
+ * @param uri URI for the content to be handled.
+ * @param mimeType MIME type of the object to be handled
+ *
+ * @return True if the given MIME type or URI can be handled; false if they cannot be handled.
*/
public boolean canHandle(Uri uri, String mimeType) {
if ((null == uri || Uri.EMPTY == uri) && (null == mimeType || mimeType.equals(""))) {
@@ -432,12 +445,10 @@ public class DrmManagerClient {
}
/**
- * Executes given drm information based on its type
+ * Processes the given DRM information based on the information type.
*
- * @param drmInfo Information needs to be processed
- * @return
- * ERROR_NONE for success
- * ERROR_UNKNOWN for failure
+ * @param drmInfo The {@link DrmInfo} to be processed.
+ * @return ERROR_NONE for success; ERROR_UNKNOWN for failure.
*/
public int processDrmInfo(DrmInfo drmInfo) {
if (null == drmInfo || !drmInfo.isValid()) {
@@ -452,10 +463,12 @@ public class DrmManagerClient {
}
/**
- * Retrieves necessary information for register, unregister or rights acquisition.
+ * Retrieves information for registering, unregistering, or acquiring rights.
+ *
+ * @param drmInfoRequest The {@link DrmInfoRequest} that specifies the type of DRM
+ * information being retrieved.
*
- * @param drmInfoRequest Request information to retrieve drmInfo
- * @return DrmInfo Instance as a result of processing given input
+ * @return A {@link DrmInfo} instance.
*/
public DrmInfo acquireDrmInfo(DrmInfoRequest drmInfoRequest) {
if (null == drmInfoRequest || !drmInfoRequest.isValid()) {
@@ -465,32 +478,36 @@ public class DrmManagerClient {
}
/**
- * Executes given DrmInfoRequest and returns the rights information asynchronously.
- * This is a utility API which consists of {@link #acquireDrmInfo(DrmInfoRequest)}
- * and {@link #processDrmInfo(DrmInfo)}.
- * It can be used if selected DRM agent can work with this combined sequences.
- * In case of some DRM schemes, such as OMA DRM, application needs to invoke
- * {@link #acquireDrmInfo(DrmInfoRequest)} and {@link #processDrmInfo(DrmInfo)}, separately.
+ * Processes a given {@link DrmInfoRequest} and returns the rights information asynchronously.
+ *<p>
+ * This is a utility method that consists of an
+ * {@link #acquireDrmInfo(DrmInfoRequest) acquireDrmInfo()} and a
+ * {@link #processDrmInfo(DrmInfo) processDrmInfo()} method call. This utility method can be
+ * used only if the selected DRM plug-in (agent) supports this sequence of calls. Some DRM
+ * agents, such as OMA, do not support this utility method, in which case an application must
+ * invoke {@link #acquireDrmInfo(DrmInfoRequest) acquireDrmInfo()} and
+ * {@link #processDrmInfo(DrmInfo) processDrmInfo()} separately.
*
- * @param drmInfoRequest Request information to retrieve drmInfo
- * @return
- * ERROR_NONE for success
- * ERROR_UNKNOWN for failure
+ * @param drmInfoRequest The {@link DrmInfoRequest} used to acquire the rights.
+ * @return ERROR_NONE for success; ERROR_UNKNOWN for failure.
*/
public int acquireRights(DrmInfoRequest drmInfoRequest) {
DrmInfo drmInfo = acquireDrmInfo(drmInfoRequest);
+ if (null == drmInfo) {
+ return ERROR_UNKNOWN;
+ }
return processDrmInfo(drmInfo);
}
/**
- * Retrieves the type of the protected object (content, rights, etc..)
- * using specified path or mimetype. At least one parameter should be non null
- * to retrieve DRM object type
+ * Retrieves the type of rights-protected object (for example, content object, rights
+ * object, and so on) using the specified path or MIME type. At least one parameter must
+ * be specified to retrieve the DRM object type.
*
- * @param path Path of the content or null.
- * @param mimeType Mimetype of the content or null.
- * @return Type of the DRM content.
- * @see DrmStore.DrmObjectType
+ * @param path Path to the content or null.
+ * @param mimeType MIME type of the content or null.
+ *
+ * @return An <code>int</code> that corresponds to a {@link DrmStore.DrmObjectType}.
*/
public int getDrmObjectType(String path, String mimeType) {
if ((null == path || path.equals("")) && (null == mimeType || mimeType.equals(""))) {
@@ -500,14 +517,14 @@ public class DrmManagerClient {
}
/**
- * Retrieves the type of the protected object (content, rights, etc..)
- * using specified uri or mimetype. At least one parameter should be non null
- * to retrieve DRM object type
+ * Retrieves the type of rights-protected object (for example, content object, rights
+ * object, and so on) using the specified URI or MIME type. At least one parameter must
+ * be specified to retrieve the DRM object type.
*
- * @param uri The content URI of the data
- * @param mimeType Mimetype of the content or null.
- * @return Type of the DRM content.
- * @see DrmStore.DrmObjectType
+ * @param uri URI for the content or null.
+ * @param mimeType MIME type of the content or null.
+ *
+ * @return An <code>int</code> that corresponds to a {@link DrmStore.DrmObjectType}.
*/
public int getDrmObjectType(Uri uri, String mimeType) {
if ((null == uri || Uri.EMPTY == uri) && (null == mimeType || mimeType.equals(""))) {
@@ -524,10 +541,11 @@ public class DrmManagerClient {
}
/**
- * Retrieves the mime type embedded inside the original content
+ * Retrieves the MIME type embedded in the original content.
*
- * @param path Path of the protected content
- * @return Mimetype of the original content, such as "video/mpeg"
+ * @param path Path to the rights-protected content.
+ *
+ * @return The MIME type of the original content, such as <code>video/mpeg</code>.
*/
public String getOriginalMimeType(String path) {
if (null == path || path.equals("")) {
@@ -537,10 +555,11 @@ public class DrmManagerClient {
}
/**
- * Retrieves the mime type embedded inside the original content
+ * Retrieves the MIME type embedded in the original content.
+ *
+ * @param uri URI of the rights-protected content.
*
- * @param uri The content URI of the data
- * @return Mimetype of the original content, such as "video/mpeg"
+ * @return MIME type of the original content, such as <code>video/mpeg</code>.
*/
public String getOriginalMimeType(Uri uri) {
if (null == uri || Uri.EMPTY == uri) {
@@ -550,22 +569,22 @@ public class DrmManagerClient {
}
/**
- * Check whether the given content has valid rights or not
+ * Checks whether the given content has valid rights.
*
- * @param path Path of the protected content
- * @return Status of the rights for the protected content
- * @see DrmStore.RightsStatus
+ * @param path Path to the rights-protected content.
+ *
+ * @return An <code>int</code> representing the {@link DrmStore.RightsStatus} of the content.
*/
public int checkRightsStatus(String path) {
return checkRightsStatus(path, DrmStore.Action.DEFAULT);
}
/**
- * Check whether the given content has valid rights or not
+ * Check whether the given content has valid rights.
+ *
+ * @param uri URI of the rights-protected content.
*
- * @param uri The content URI of the data
- * @return Status of the rights for the protected content
- * @see DrmStore.RightsStatus
+ * @return An <code>int</code> representing the {@link DrmStore.RightsStatus} of the content.
*/
public int checkRightsStatus(Uri uri) {
if (null == uri || Uri.EMPTY == uri) {
@@ -575,12 +594,13 @@ public class DrmManagerClient {
}
/**
- * Check whether the given content has valid rights or not for specified action.
+ * Checks whether the given rights-protected content has valid rights for the specified
+ * {@link DrmStore.Action}.
*
- * @param path Path of the protected content
- * @param action Action to perform
- * @return Status of the rights for the protected content
- * @see DrmStore.RightsStatus
+ * @param path Path to the rights-protected content.
+ * @param action The {@link DrmStore.Action} to perform.
+ *
+ * @return An <code>int</code> representing the {@link DrmStore.RightsStatus} of the content.
*/
public int checkRightsStatus(String path, int action) {
if (null == path || path.equals("") || !DrmStore.Action.isValid(action)) {
@@ -590,12 +610,13 @@ public class DrmManagerClient {
}
/**
- * Check whether the given content has valid rights or not for specified action.
+ * Checks whether the given rights-protected content has valid rights for the specified
+ * {@link DrmStore.Action}.
+ *
+ * @param uri URI for the rights-protected content.
+ * @param action The {@link DrmStore.Action} to perform.
*
- * @param uri The content URI of the data
- * @param action Action to perform
- * @return Status of the rights for the protected content
- * @see DrmStore.RightsStatus
+ * @return An <code>int</code> representing the {@link DrmStore.RightsStatus} of the content.
*/
public int checkRightsStatus(Uri uri, int action) {
if (null == uri || Uri.EMPTY == uri) {
@@ -605,12 +626,11 @@ public class DrmManagerClient {
}
/**
- * Removes the rights associated with the given protected content
+ * Removes the rights associated with the given rights-protected content.
+ *
+ * @param path Path to the rights-protected content.
*
- * @param path Path of the protected content
- * @return
- * ERROR_NONE for success
- * ERROR_UNKNOWN for failure
+ * @return ERROR_NONE for success; ERROR_UNKNOWN for failure.
*/
public int removeRights(String path) {
if (null == path || path.equals("")) {
@@ -620,12 +640,11 @@ public class DrmManagerClient {
}
/**
- * Removes the rights associated with the given protected content
+ * Removes the rights associated with the given rights-protected content.
*
- * @param uri The content URI of the data
- * @return
- * ERROR_NONE for success
- * ERROR_UNKNOWN for failure
+ * @param uri URI for the rights-protected content.
+ *
+ * @return ERROR_NONE for success; ERROR_UNKNOWN for failure.
*/
public int removeRights(Uri uri) {
if (null == uri || Uri.EMPTY == uri) {
@@ -635,12 +654,10 @@ public class DrmManagerClient {
}
/**
- * Removes all the rights information of every plug-in associated with
- * DRM framework. Will be used in master reset
+ * Removes all the rights information of every DRM plug-in (agent) associated with
+ * the DRM framework. Will be used during a master reset.
*
- * @return
- * ERROR_NONE for success
- * ERROR_UNKNOWN for failure
+ * @return ERROR_NONE for success; ERROR_UNKNOWN for failure.
*/
public int removeAllRights() {
int result = ERROR_UNKNOWN;
@@ -652,13 +669,14 @@ public class DrmManagerClient {
}
/**
- * This API is for Forward Lock based DRM scheme.
- * Each time the application tries to download a new DRM file
- * which needs to be converted, then the application has to
- * begin with calling this API.
+ * Initiates a new conversion session. An application must initiate a conversion session
+ * with this method each time it downloads a rights-protected file that needs to be converted.
+ *<p>
+ * This method applies only to forward-locking (copy protection) DRM schemes.
+ *
+ * @param mimeType MIME type of the input data packet.
*
- * @param mimeType Description/MIME type of the input data packet
- * @return convert ID which will be used for maintaining convert session.
+ * @return A convert ID that is used used to maintain the conversion session.
*/
public int openConvertSession(String mimeType) {
if (null == mimeType || mimeType.equals("")) {
@@ -668,16 +686,17 @@ public class DrmManagerClient {
}
/**
- * Accepts and converts the input data which is part of DRM file.
- * The resultant converted data and the status is returned in the DrmConvertedInfo
- * object. This method will be called each time there are new block
- * of data received by the application.
+ * Converts the input data (content) that is part of a rights-protected file. The converted
+ * data and status is returned in a {@link DrmConvertedStatus} object. This method should be
+ * called each time there is a new block of data received by the application.
+ *
+ * @param convertId Handle for the conversion session.
+ * @param inputData Input data that needs to be converted.
*
- * @param convertId Handle for the convert session
- * @param inputData Input Data which need to be converted
- * @return Return object contains the status of the data conversion,
- * the output converted data and offset. In this case the
- * application will ignore the offset information.
+ * @return A {@link DrmConvertedStatus} object that contains the status of the data conversion,
+ * the converted data, and offset for the header and body signature. An application can
+ * ignore the offset because it is only relevant to the
+ * {@link #closeConvertSession closeConvertSession()} method.
*/
public DrmConvertedStatus convertData(int convertId, byte[] inputData) {
if (null == inputData || 0 >= inputData.length) {
@@ -687,16 +706,15 @@ public class DrmManagerClient {
}
/**
- * Informs the Drm Agent when there is no more data which need to be converted
- * or when an error occurs. Upon successful conversion of the complete data,
- * the agent will inform that where the header and body signature
- * should be added. This signature appending is needed to integrity
- * protect the converted file.
+ * Informs the DRM plug-in (agent) that there is no more data to convert or that an error
+ * has occurred. Upon successful conversion of the data, the DRM agent will provide an offset
+ * value indicating where the header and body signature should be added. Appending the
+ * signature is necessary to protect the integrity of the converted file.
*
- * @param convertId Handle for the convert session
- * @return Return object contains the status of the data conversion,
- * the header and body signature data. It also informs
- * the application on which offset these signature data should be appended.
+ * @param convertId Handle for the conversion session.
+ *
+ * @return A {@link DrmConvertedStatus} object that contains the status of the data conversion,
+ * the converted data, and the offset for the header and body signature.
*/
public DrmConvertedStatus closeConvertSession(int convertId) {
return _closeConvertSession(mUniqueId, convertId);
@@ -732,6 +750,7 @@ public class DrmManagerClient {
* This method expects uri in the following format
* content://media/<table_name>/<row_index> (or)
* file://sdcard/test.mp4
+ * http://test.com/test.mp4
*
* Here <table_name> shall be "video" or "audio" or "images"
* <row_index> the index of the content in given table
@@ -743,6 +762,10 @@ public class DrmManagerClient {
if (null == scheme || scheme.equals("") ||
scheme.equals(ContentResolver.SCHEME_FILE)) {
path = uri.getPath();
+
+ } else if (scheme.equals("http")) {
+ path = uri.toString();
+
} else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
String[] projection = new String[] {MediaStore.MediaColumns.DATA};
Cursor cursor = null;
diff --git a/drm/java/android/drm/DrmRights.java b/drm/java/android/drm/DrmRights.java
index 103af0742f95..59079562b07d 100644..100755
--- a/drm/java/android/drm/DrmRights.java
+++ b/drm/java/android/drm/DrmRights.java
@@ -20,14 +20,16 @@ import java.io.File;
import java.io.IOException;
/**
- * This is an entity class which wraps the license information which was
- * retrieved from the online DRM server.
- *
- * Caller can instantiate {@link DrmRights} by
- * invoking {@link DrmRights#DrmRights(ProcessedData, String)}
- * constructor by using the result of {@link DrmManagerClient#processDrmInfo(DrmInfo)} interface.
- * Caller can also instantiate {@link DrmRights} using the file path
- * which contains rights information.
+ * An entity class that wraps the license information retrieved from the online DRM server.
+ *<p>
+ * A caller can instantiate a {@link DrmRights} object by first invoking the
+ * {@link DrmManagerClient#processDrmInfo(DrmInfo)} method and then using the resulting
+ * {@link ProcessedData} object to invoke the {@link DrmRights#DrmRights(ProcessedData, String)}
+ * constructor.
+ *<p>
+ * A caller can also instantiate a {@link DrmRights} object by using the
+ * {@link DrmRights#DrmRights(String, String)} constructor, which takes a path to a file
+ * containing rights information instead of a <code>ProcessedData</code>.
*
*/
public class DrmRights {
@@ -37,10 +39,10 @@ public class DrmRights {
private String mSubscriptionId = "";
/**
- * constructor to create DrmRights object with given parameters
+ * Creates a <code>DrmRights</code> object with the given parameters.
*
- * @param rightsFilePath Path of the file containing rights data
- * @param mimeType MIME type
+ * @param rightsFilePath Path to the file containing rights information.
+ * @param mimeType MIME type.
*/
public DrmRights(String rightsFilePath, String mimeType) {
File file = new File(rightsFilePath);
@@ -48,11 +50,11 @@ public class DrmRights {
}
/**
- * constructor to create DrmRights object with given parameters
+ * Creates a <code>DrmRights</code> object with the given parameters.
*
- * @param rightsFilePath Path of the file containing rights data
- * @param mimeType MIME type
- * @param accountId Account Id of the user
+ * @param rightsFilePath Path to the file containing rights information.
+ * @param mimeType MIME type.
+ * @param accountId Account ID of the user.
*/
public DrmRights(String rightsFilePath, String mimeType, String accountId) {
this(rightsFilePath, mimeType);
@@ -63,12 +65,12 @@ public class DrmRights {
}
/**
- * constructor to create DrmRights object with given parameters
+ * Creates a <code>DrmRights</code> object with the given parameters.
*
- * @param rightsFilePath Path of the file containing rights data
- * @param mimeType MIME type
- * @param accountId Account Id of the user
- * @param subscriptionId Subscription Id of the user
+ * @param rightsFilePath Path to the file containing rights information.
+ * @param mimeType MIME type.
+ * @param accountId Account ID of the user.
+ * @param subscriptionId Subscription ID of the user.
*/
public DrmRights(
String rightsFilePath, String mimeType, String accountId, String subscriptionId) {
@@ -84,10 +86,10 @@ public class DrmRights {
}
/**
- * constructor to create DrmRights object with given parameters
+ * Creates a <code>DrmRights</code> object with the given parameters.
*
- * @param rightsFile File containing rights data
- * @param mimeType MIME type
+ * @param rightsFile File containing rights information.
+ * @param mimeType MIME type.
*/
public DrmRights(File rightsFile, String mimeType) {
instantiate(rightsFile, mimeType);
@@ -104,16 +106,20 @@ public class DrmRights {
}
/**
- * constructor to create DrmRights object with given parameters
- * The user can pass String or binary data<p>
- * Usage:<p>
- * i) String(e.g. data is instance of String):<br>
- * - new DrmRights(data.getBytes(), mimeType)<p>
- * ii) Binary data<br>
- * - new DrmRights(binaryData[], mimeType)<br>
+ * Creates a <code>DrmRights</code> object with the given parameters.
+ *<p>
+ * The application can pass the processed data as a <code>String</code> or as binary data.
+ *<p>
+ * The following code snippet shows how to pass the processed data as a <code>String</code>:
+ *<p>
+ * new DrmRights(data.getBytes(), mimeType)
+ *<p>
+ * The following code snippet shows how to pass the processed data as binary data:
+ *<p>
+ * new DrmRights(binaryData[], mimeType)
*
- * @param data Processed data
- * @param mimeType MIME type
+ * @param data A {@link ProcessedData} object.
+ * @param mimeType The MIME type.
*/
public DrmRights(ProcessedData data, String mimeType) {
mData = data.getData();
@@ -132,47 +138,45 @@ public class DrmRights {
}
/**
- * Returns the rights data associated with this object
+ * Retrieves the rights data associated with this <code>DrmRights</code> object.
*
- * @return Rights data
+ * @return A <code>byte</code> array representing the rights data.
*/
public byte[] getData() {
return mData;
}
/**
- * Returns the mimetype associated with this object
+ * Retrieves the MIME type associated with this <code>DrmRights</code> object.
*
- * @return MIME type
+ * @return The MIME type.
*/
public String getMimeType() {
return mMimeType;
}
/**
- * Returns the account-id associated with this object
+ * Retrieves the account ID associated with this <code>DrmRights</code> object.
*
- * @return Account Id
+ * @return The account ID.
*/
public String getAccountId() {
return mAccountId;
}
/**
- * Returns the subscription-id associated with this object
+ * Retrieves the subscription ID associated with this <code>DrmRights</code> object.
*
- * @return Subscription Id
+ * @return The subscription ID.
*/
public String getSubscriptionId() {
return mSubscriptionId;
}
/**
- * Returns whether this instance is valid or not
+ * Determines whether this instance is valid or not.
*
- * @return
- * true if valid
- * false if invalid
+ * @return True if valid; false if invalid.
*/
/*package*/ boolean isValid() {
return (null != mMimeType && !mMimeType.equals("")
diff --git a/drm/java/android/drm/DrmStore.java b/drm/java/android/drm/DrmStore.java
index 44df90c6687c..ae311de73861 100644..100755
--- a/drm/java/android/drm/DrmStore.java
+++ b/drm/java/android/drm/DrmStore.java
@@ -17,91 +17,97 @@
package android.drm;
/**
- * This class defines all the constants used by DRM framework
+ * Defines constants that are used by the DRM framework.
*
*/
public class DrmStore {
/**
- * Columns representing drm constraints
+ * Interface definition for the columns that represent DRM constraints.
*/
public interface ConstraintsColumns {
/**
- * The max repeat count
- * <P>Type: INTEGER</P>
+ * The maximum repeat count.
+ * <p>
+ * Type: INTEGER
*/
public static final String MAX_REPEAT_COUNT = "max_repeat_count";
/**
- * The remaining repeat count
- * <P>Type: INTEGER</P>
+ * The remaining repeat count.
+ * <p>
+ * Type: INTEGER
*/
public static final String REMAINING_REPEAT_COUNT = "remaining_repeat_count";
/**
- * The time before which the protected file can not be played/viewed
- * <P>Type: TEXT</P>
+ * The time before which the rights-protected file cannot be played/viewed.
+ * <p>
+ * Type: TEXT
*/
public static final String LICENSE_START_TIME = "license_start_time";
/**
- * The time after which the protected file can not be played/viewed
- * <P>Type: TEXT</P>
+ * The time after which the rights-protected file cannot be played/viewed.
+ * <p>
+ * Type: TEXT
*/
public static final String LICENSE_EXPIRY_TIME = "license_expiry_time";
/**
- * The available time for license
- * <P>Type: TEXT</P>
+ * The available time left before the license expires.
+ * <p>
+ * Type: TEXT
*/
public static final String LICENSE_AVAILABLE_TIME = "license_available_time";
/**
- * The data stream for extended metadata
- * <P>Type: TEXT</P>
+ * The data stream for extended metadata.
+ * <p>
+ * Type: TEXT
*/
public static final String EXTENDED_METADATA = "extended_metadata";
}
/**
- * Defines constants related to DRM types
+ * Defines DRM object types.
*/
public static class DrmObjectType {
/**
- * Field specifies the unknown type
+ * An unknown object type.
*/
public static final int UNKNOWN = 0x00;
/**
- * Field specifies the protected content type
+ * A rights-protected file object type.
*/
public static final int CONTENT = 0x01;
/**
- * Field specifies the rights information
+ * A rights information object type.
*/
public static final int RIGHTS_OBJECT = 0x02;
/**
- * Field specifies the trigger information
+ * A trigger information object type.
*/
public static final int TRIGGER_OBJECT = 0x03;
}
/**
- * Defines constants related to playback
+ * Defines playback states for content.
*/
public static class Playback {
/**
- * Constant field signifies playback start
+ * Playback started.
*/
public static final int START = 0x00;
/**
- * Constant field signifies playback stop
+ * Playback stopped.
*/
public static final int STOP = 0x01;
/**
- * Constant field signifies playback paused
+ * Playback paused.
*/
public static final int PAUSE = 0x02;
/**
- * Constant field signifies playback resumed
+ * Playback resumed.
*/
public static final int RESUME = 0x03;
@@ -120,39 +126,39 @@ public class DrmStore {
}
/**
- * Defines actions that can be performed on protected content
+ * Defines actions that can be performed on rights-protected content.
*/
public static class Action {
/**
- * Constant field signifies that the default action
+ * The default action.
*/
public static final int DEFAULT = 0x00;
/**
- * Constant field signifies that the content can be played
+ * The rights-protected content can be played.
*/
public static final int PLAY = 0x01;
/**
- * Constant field signifies that the content can be set as ring tone
+ * The rights-protected content can be set as a ringtone.
*/
public static final int RINGTONE = 0x02;
/**
- * Constant field signifies that the content can be transfered
+ * The rights-protected content can be transferred.
*/
public static final int TRANSFER = 0x03;
/**
- * Constant field signifies that the content can be set as output
+ * The rights-protected content can be set as output.
*/
public static final int OUTPUT = 0x04;
/**
- * Constant field signifies that preview is allowed
+ * The rights-protected content can be previewed.
*/
public static final int PREVIEW = 0x05;
/**
- * Constant field signifies that the content can be executed
+ * The rights-protected content can be executed.
*/
public static final int EXECUTE = 0x06;
/**
- * Constant field signifies that the content can displayed
+ * The rights-protected content can be displayed.
*/
public static final int DISPLAY = 0x07;
@@ -175,23 +181,23 @@ public class DrmStore {
}
/**
- * Defines constants related to status of the rights
+ * Defines status notifications for digital rights.
*/
public static class RightsStatus {
/**
- * Constant field signifies that the rights are valid
+ * The digital rights are valid.
*/
public static final int RIGHTS_VALID = 0x00;
/**
- * Constant field signifies that the rights are invalid
+ * The digital rights are invalid.
*/
public static final int RIGHTS_INVALID = 0x01;
/**
- * Constant field signifies that the rights are expired for the content
+ * The digital rights have expired.
*/
public static final int RIGHTS_EXPIRED = 0x02;
/**
- * Constant field signifies that the rights are not acquired for the content
+ * The digital rights have not been acquired for the rights-protected content.
*/
public static final int RIGHTS_NOT_ACQUIRED = 0x03;
}
diff --git a/drm/java/android/drm/DrmSupportInfo.java b/drm/java/android/drm/DrmSupportInfo.java
index 0886af8e8da0..720c545282a9 100644..100755
--- a/drm/java/android/drm/DrmSupportInfo.java
+++ b/drm/java/android/drm/DrmSupportInfo.java
@@ -20,11 +20,11 @@ import java.util.ArrayList;
import java.util.Iterator;
/**
- * This is an entity class which wraps the capability of each plug-in,
- * such as mimetype's and file suffixes it could handle.
- *
- * Plug-in developer could return the capability of the plugin by passing
- * {@link DrmSupportInfo} instance.
+ * An entity class that wraps the capability of each DRM plug-in (agent),
+ * such as the MIME type and file suffix the DRM plug-in can handle.
+ *<p>
+ * Plug-in developers can expose the capability of their plug-in by passing an instance of this
+ * class to an application.
*
*/
public class DrmSupportInfo {
@@ -33,47 +33,47 @@ public class DrmSupportInfo {
private String mDescription = "";
/**
- * Add the mime-type to the support info such that respective plug-in is
- * capable of handling the given mime-type.
+ * Adds the specified MIME type to the list of MIME types this DRM plug-in supports.
*
- * @param mimeType MIME type
+ * @param mimeType MIME type that can be handles by this DRM plug-in.
*/
public void addMimeType(String mimeType) {
mMimeTypeList.add(mimeType);
}
/**
- * Add the file suffix to the support info such that respective plug-in is
- * capable of handling the given file suffix.
+ * Adds the specified file suffix to the list of file suffixes this DRM plug-in supports.
*
- * @param fileSuffix File suffix which can be handled
+ * @param fileSuffix File suffix that can be handled by this DRM plug-in.
*/
public void addFileSuffix(String fileSuffix) {
mFileSuffixList.add(fileSuffix);
}
/**
- * Returns the iterator to walk to through mime types of this object
+ * Retrieves an iterator object that you can use to iterate over the MIME types that
+ * this DRM plug-in supports.
*
- * @return Iterator object
+ * @return The iterator object
*/
public Iterator<String> getMimeTypeIterator() {
return mMimeTypeList.iterator();
}
/**
- * Returns the iterator to walk to through file suffixes of this object
+ * Retrieves an iterator object that you can use to iterate over the file suffixes that
+ * this DRM plug-in supports.
*
- * @return Iterator object
+ * @return The iterator object.
*/
public Iterator<String> getFileSuffixIterator() {
return mFileSuffixList.iterator();
}
/**
- * Set the unique description about the plugin
+ * Sets a description for the DRM plug-in (agent).
*
- * @param description Unique description
+ * @param description Unique description of plug-in.
*/
public void setDescription(String description) {
if (null != description) {
@@ -82,30 +82,28 @@ public class DrmSupportInfo {
}
/**
- * Returns the unique description associated with the plugin
+ * Retrieves the DRM plug-in (agent) description.
*
- * @return Unique description
+ * @return The plug-in description.
*/
public String getDescriprition() {
return mDescription;
}
/**
- * Overridden hash code implementation
+ * Overridden hash code implementation.
*
- * @return Hash code value
+ * @return The hash code value.
*/
public int hashCode() {
return mFileSuffixList.hashCode() + mMimeTypeList.hashCode() + mDescription.hashCode();
}
/**
- * Overridden equals implementation
+ * Overridden <code>equals</code> implementation.
*
- * @param object The object to be compared
- * @return
- * true if equal
- * false if not equal
+ * @param object The object to be compared.
+ * @return True if equal; false if not equal.
*/
public boolean equals(Object object) {
boolean result = false;
@@ -119,12 +117,10 @@ public class DrmSupportInfo {
}
/**
- * Returns whether given mime-type is supported or not
+ * Determines whether a given MIME type is supported.
*
- * @param mimeType MIME type
- * @return
- * true if mime type is supported
- * false if mime type is not supported
+ * @param mimeType MIME type.
+ * @return True if Mime type is supported; false if MIME type is not supported.
*/
/* package */ boolean isSupportedMimeType(String mimeType) {
if (null != mimeType && !mimeType.equals("")) {
@@ -139,12 +135,10 @@ public class DrmSupportInfo {
}
/**
- * Returns whether given file suffix is supported or not
+ * Determines whether a given file suffix is supported.
*
- * @param fileSuffix File suffix
- * @return
- * true - if file suffix is supported
- * false - if file suffix is not supported
+ * @param fileSuffix File suffix.
+ * @return True if file suffix is supported; false if file suffix is not supported.
*/
/* package */ boolean isSupportedFileSuffix(String fileSuffix) {
return mFileSuffixList.contains(fileSuffix);
diff --git a/drm/java/android/drm/DrmUtils.java b/drm/java/android/drm/DrmUtils.java
index 8903485aeead..dc5f1fa3d087 100644..100755
--- a/drm/java/android/drm/DrmUtils.java
+++ b/drm/java/android/drm/DrmUtils.java
@@ -28,9 +28,11 @@ import java.util.HashMap;
import java.util.Iterator;
/**
- * The utility class used in the DRM Framework. This inclueds APIs for file operations
- * and ExtendedMetadataParser for parsing extended metadata BLOB in DRM constraints.
- *
+ * A utility class that provides operations for parsing extended metadata embedded in
+ * DRM constraint information. If a DRM scheme has specific constraints beyond the standard
+ * constraints, the constraints will show up in the
+ * {@link DrmStore.ConstraintsColumns#EXTENDED_METADATA} key. You can use
+ * {@link DrmUtils.ExtendedMetadataParser} to iterate over those values.
*/
public class DrmUtils {
/* Should be used when we need to read from local file */
@@ -99,13 +101,10 @@ public class DrmUtils {
}
/**
- * Get an instance of ExtendedMetadataParser to be used for parsing
- * extended metadata BLOB in DRM constraints. <br>
- *
- * extendedMetadata BLOB is retrieved by specifing
- * key DrmStore.ConstraintsColumns.EXTENDED_METADATA.
+ * Gets an instance of {@link DrmUtils.ExtendedMetadataParser}, which can be used to parse
+ * extended metadata embedded in DRM constraint information.
*
- * @param extendedMetadata BLOB in which key-value pairs of extended metadata are embedded.
+ * @param extendedMetadata Object in which key-value pairs of extended metadata are embedded.
*
*/
public static ExtendedMetadataParser getExtendedMetadataParser(byte[] extendedMetadata) {
@@ -113,9 +112,10 @@ public class DrmUtils {
}
/**
- * Utility parser to parse the extended meta-data embedded inside DRM constraints<br><br>
- *
- * Usage example<br>
+ * Utility that parses extended metadata embedded in DRM constraint information.
+ *<p>
+ * Usage example:
+ *<p>
* byte[] extendedMetadata<br>
* &nbsp;&nbsp;&nbsp;&nbsp; =
* constraints.getAsByteArray(DrmStore.ConstraintsColumns.EXTENDED_METADATA);<br>
diff --git a/drm/java/android/drm/ProcessedData.java b/drm/java/android/drm/ProcessedData.java
index 579264f00ba2..06e03e73be91 100644..100755
--- a/drm/java/android/drm/ProcessedData.java
+++ b/drm/java/android/drm/ProcessedData.java
@@ -17,11 +17,11 @@
package android.drm;
/**
- * This is an entity class which wraps the result of transaction between
- * device and online DRM server by using {@link DrmManagerClient#processDrmInfo(DrmInfo)}
+ * An entity class that wraps the result of a
+ * {@link DrmManagerClient#processDrmInfo(DrmInfo) processDrmInfo()}
+ * transaction between a device and a DRM server.
*
- * In license acquisition scenario this class would hold the binary data
- * of rights information.
+ * In a license acquisition scenario this class holds the rights information in binary form.
*
*/
public class ProcessedData {
@@ -30,10 +30,10 @@ public class ProcessedData {
private String mSubscriptionId = "";
/**
- * constructor to create ProcessedData object with given parameters
+ * Creates a <code>ProcessedData</code> object with the given parameters.
*
- * @param data Rights data
- * @param accountId Account Id of the user
+ * @param data Rights data.
+ * @param accountId Account ID of the user.
*/
/* package */ ProcessedData(byte[] data, String accountId) {
mData = data;
@@ -41,11 +41,11 @@ public class ProcessedData {
}
/**
- * constructor to create ProcessedData object with given parameters
+ * Creates a <code>ProcessedData</code> object with the given parameters.
*
- * @param data Rights data
- * @param accountId Account Id of the user
- * @param subscriptionId Subscription Id of the user
+ * @param data Rights data.
+ * @param accountId Account ID of the user.
+ * @param subscriptionId Subscription ID of the user.
*/
/* package */ ProcessedData(byte[] data, String accountId, String subscriptionId) {
mData = data;
@@ -54,27 +54,27 @@ public class ProcessedData {
}
/**
- * Returns the processed data as a result.
+ * Retrieves the processed data.
*
- * @return Rights data associated
+ * @return The rights data.
*/
public byte[] getData() {
return mData;
}
/**
- * Returns the account-id associated with this object
+ * Retrieves the account ID associated with this object.
*
- * @return Account Id associated
+ * @return The account ID of the user.
*/
public String getAccountId() {
return mAccountId;
}
/**
- * Returns the subscription-id associated with this object
+ * Returns the subscription ID associated with this object.
*
- * @return Subscription Id associated
+ * @return The subscription ID of the user.
*/
public String getSubscriptionId() {
return mSubscriptionId;
diff --git a/drm/java/android/drm/package.html b/drm/java/android/drm/package.html
new file mode 100755
index 000000000000..161d6e0bd1bf
--- /dev/null
+++ b/drm/java/android/drm/package.html
@@ -0,0 +1,85 @@
+<HTML>
+<BODY>
+<p>Provides classes for managing DRM content and determining the capabilities of DRM plugins
+(agents). Common uses of the DRM API include:</p>
+<ul>
+ <li>Determining which DRM plug-ins (agents) are installed on a device.</li>
+ <li>Retrieving information about specific plug-ins, such as the MIME types and file suffixes
+ they support.</li>
+ <li>Registering a user or a device with an online DRM service.</li>
+ <li>Retrieving license constraints for rights-protected content.</li>
+ <li>Checking whether a user has the proper rights to play or use rights-protected
+ content.</li>
+ <li>Associating rights-protected content with its license so you can use the
+ {@link android.media.MediaPlayer} API to play the content.</li>
+</ul>
+
+<h2>DRM Overview</h2>
+
+<p>The Android platform provides an extensible DRM framework that lets applications manage
+rights-protected content according to the license constraints that are associated with the
+content. The DRM framework supports many DRM schemes; which DRM schemes a device supports
+is up to the device manufacturer.</p>
+
+<p>The Android DRM framework is implemented in two architectural layers (see figure below):</p>
+<ul>
+ <li>A DRM framework API, which is exposed to applications through the Android
+application framework and runs through the Dalvik VM for standard applications.</li>
+ <li>A native code DRM manager, which implements the DRM framework and exposes an
+interface for DRM plug-ins (agents) to handle rights management and decryption for various
+DRM schemes.</li>
+</ul>
+
+<img src="../../../images/drm_arch.png" alt="DRM architecture diagram" border="0"/>
+
+<p>For application developers, the DRM framework offers an abstract, unified API that
+simplifies the management of rights-protected content. The API hides the complexity of DRM
+operations and allows a consistent operation mode for both rights-protected and unprotected content
+across a variety of DRM schemes. For device manufacturers, content owners, and Internet digital
+media providers the DRM framework’s plugin architecture provides a means of adding support for a
+specific DRM scheme to the Android system.</p>
+
+<h2>Using the DRM API</h2>
+
+<p>In a typical DRM session, an Android application uses the DRM framework API to
+instantiate a {@link android.drm.DrmManagerClient}. The application calls various methods
+on the DRM client to query rights and perform other DRM-related tasks. Each
+{@link android.drm.DrmManagerClient} instance has its own unique ID, so the DRM manager is able to
+differentiate callers.</p>
+
+<p>Although each DRM plug-in may require a different sequence
+of API calls, the general call sequence for an application is as follows:</p>
+
+<ul>
+ <li>Register the device with an online DRM service.
+ <p>You can do this by first using the {@link android.drm.DrmManagerClient#acquireDrmInfo
+acquireDrmInfo()} method to acquire the registration information, and then using the {@link
+android.drm.DrmManagerClient#processDrmInfo processDrmInfo()} method to process the
+registration information.</p>
+ </li>
+ <li>Acquire the license that's associated with the rights-protected content.
+ <p>You can do this by first using the {@link android.drm.DrmManagerClient#acquireDrmInfo
+acquireDrmInfo()} method to acquire the license information, and then using the {@link
+android.drm.DrmManagerClient#processDrmInfo processDrmInfo()} method to process the
+license information. You can also use the {@link
+android.drm.DrmManagerClient#acquireRights acquireRights()} method.</p>
+ </li>
+ <li>Extract constraint information from the license.
+ <p>You can use the {@link android.drm.DrmManagerClient#getConstraints getConstraints()}
+ method to do this.</p>
+ </li>
+ <li>Associate the rights-protected content with its license.
+ <p>You can use the {@link android.drm.DrmManagerClient#saveRights saveRights()} method
+ to do this.</p>
+ </li>
+</ul>
+
+<p>After you make an association between the rights-protected content and its license,
+the DRM manager automatically handles rights management for that content. Specifically, the
+DRM manager will handle all further licensing checks when you attempt to play the content using
+the {@link android.media.MediaPlayer} API.</p>
+
+<p>To learn how to use the DRM API with a specific DRM plug-in, see the documentation provided
+by the plug-in developer.</p>
+</BODY>
+</HTML>
diff --git a/drm/libdrmframework/DrmManagerClient.cpp b/drm/libdrmframework/DrmManagerClient.cpp
index 8bb00c3a32cc..c1f382aa3420 100644
--- a/drm/libdrmframework/DrmManagerClient.cpp
+++ b/drm/libdrmframework/DrmManagerClient.cpp
@@ -32,7 +32,6 @@ DrmManagerClient::~DrmManagerClient() {
DrmManagerClientImpl::remove(mUniqueId);
mDrmManagerClientImpl->removeClient(mUniqueId);
mDrmManagerClientImpl->setOnInfoListener(mUniqueId, NULL);
- delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL;
}
status_t DrmManagerClient::setOnInfoListener(
@@ -78,12 +77,11 @@ int DrmManagerClient::checkRightsStatus(const String8& path, int action) {
}
status_t DrmManagerClient::consumeRights(DecryptHandle* decryptHandle, int action, bool reserve) {
- Mutex::Autolock _l(mDecryptLock);
return mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve);
}
status_t DrmManagerClient::setPlaybackStatus(
- DecryptHandle* decryptHandle, int playbackStatus, int position) {
+ DecryptHandle* decryptHandle, int playbackStatus, int64_t position) {
return mDrmManagerClientImpl
->setPlaybackStatus(mUniqueId, decryptHandle, playbackStatus, position);
}
@@ -117,7 +115,7 @@ status_t DrmManagerClient::getAllSupportInfo(int* length, DrmSupportInfo** drmSu
return mDrmManagerClientImpl->getAllSupportInfo(mUniqueId, length, drmSupportInfoArray);
}
-DecryptHandle* DrmManagerClient::openDecryptSession(int fd, int offset, int length) {
+DecryptHandle* DrmManagerClient::openDecryptSession(int fd, off64_t offset, off64_t length) {
return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length);
}
@@ -131,7 +129,6 @@ status_t DrmManagerClient::closeDecryptSession(DecryptHandle* decryptHandle) {
status_t DrmManagerClient::initializeDecryptUnit(
DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) {
- Mutex::Autolock _l(mDecryptLock);
return mDrmManagerClientImpl->initializeDecryptUnit(
mUniqueId, decryptHandle, decryptUnitId, headerInfo);
}
@@ -139,19 +136,16 @@ status_t DrmManagerClient::initializeDecryptUnit(
status_t DrmManagerClient::decrypt(
DecryptHandle* decryptHandle, int decryptUnitId,
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) {
- Mutex::Autolock _l(mDecryptLock);
return mDrmManagerClientImpl->decrypt(
mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV);
}
status_t DrmManagerClient::finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId) {
- Mutex::Autolock _l(mDecryptLock);
return mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, decryptHandle, decryptUnitId);
}
ssize_t DrmManagerClient::pread(
- DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off_t offset) {
- Mutex::Autolock _l(mDecryptLock);
+ DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off64_t offset) {
return mDrmManagerClientImpl->pread(mUniqueId, decryptHandle, buffer, numBytes, offset);
}
diff --git a/drm/libdrmframework/DrmManagerClientImpl.cpp b/drm/libdrmframework/DrmManagerClientImpl.cpp
index eea312b5edb3..9c7fed398fb6 100644
--- a/drm/libdrmframework/DrmManagerClientImpl.cpp
+++ b/drm/libdrmframework/DrmManagerClientImpl.cpp
@@ -28,8 +28,9 @@ using namespace android;
#define INVALID_VALUE -1
-Mutex DrmManagerClientImpl::mMutex;
-sp<IDrmManagerService> DrmManagerClientImpl::mDrmManagerService;
+Mutex DrmManagerClientImpl::sMutex;
+sp<IDrmManagerService> DrmManagerClientImpl::sDrmManagerService;
+sp<DrmManagerClientImpl::DeathNotifier> DrmManagerClientImpl::sDeathNotifier;
const String8 DrmManagerClientImpl::EMPTY_STRING("");
DrmManagerClientImpl* DrmManagerClientImpl::create(int* pUniqueId) {
@@ -47,8 +48,8 @@ void DrmManagerClientImpl::remove(int uniqueId) {
}
const sp<IDrmManagerService>& DrmManagerClientImpl::getDrmManagerService() {
- mMutex.lock();
- if (NULL == mDrmManagerService.get()) {
+ Mutex::Autolock lock(sMutex);
+ if (NULL == sDrmManagerService.get()) {
sp<IServiceManager> sm = defaultServiceManager();
sp<IBinder> binder;
do {
@@ -62,11 +63,13 @@ const sp<IDrmManagerService>& DrmManagerClientImpl::getDrmManagerService() {
reqt.tv_nsec = 500000000; //0.5 sec
nanosleep(&reqt, NULL);
} while (true);
-
- mDrmManagerService = interface_cast<IDrmManagerService>(binder);
+ if (NULL == sDeathNotifier.get()) {
+ sDeathNotifier = new DeathNotifier();
+ }
+ binder->linkToDeath(sDeathNotifier);
+ sDrmManagerService = interface_cast<IDrmManagerService>(binder);
}
- mMutex.unlock();
- return mDrmManagerService;
+ return sDrmManagerService;
}
void DrmManagerClientImpl::addClient(int uniqueId) {
@@ -179,7 +182,7 @@ status_t DrmManagerClientImpl::consumeRights(
}
status_t DrmManagerClientImpl::setPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) {
+ int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) {
status_t status = DRM_ERROR_UNKNOWN;
if (NULL != decryptHandle) {
status = getDrmManagerService()->setPlaybackStatus(
@@ -240,7 +243,7 @@ status_t DrmManagerClientImpl::getAllSupportInfo(
}
DecryptHandle* DrmManagerClientImpl::openDecryptSession(
- int uniqueId, int fd, int offset, int length) {
+ int uniqueId, int fd, off64_t offset, off64_t length) {
return getDrmManagerService()->openDecryptSession(uniqueId, fd, offset, length);
}
@@ -292,7 +295,7 @@ status_t DrmManagerClientImpl::finalizeDecryptUnit(
}
ssize_t DrmManagerClientImpl::pread(int uniqueId, DecryptHandle* decryptHandle,
- void* buffer, ssize_t numBytes, off_t offset) {
+ void* buffer, ssize_t numBytes, off64_t offset) {
ssize_t retCode = INVALID_VALUE;
if ((NULL != decryptHandle) && (NULL != buffer) && (0 < numBytes)) {
retCode = getDrmManagerService()->pread(uniqueId, decryptHandle, buffer, numBytes, offset);
@@ -309,3 +312,16 @@ status_t DrmManagerClientImpl::notify(const DrmInfoEvent& event) {
return DRM_NO_ERROR;
}
+DrmManagerClientImpl::DeathNotifier::~DeathNotifier() {
+ Mutex::Autolock lock(sMutex);
+ if (NULL != sDrmManagerService.get()) {
+ sDrmManagerService->asBinder()->unlinkToDeath(this);
+ }
+}
+
+void DrmManagerClientImpl::DeathNotifier::binderDied(const wp<IBinder>& who) {
+ Mutex::Autolock lock(sMutex);
+ DrmManagerClientImpl::sDrmManagerService.clear();
+ LOGW("DrmManager server died!");
+}
+
diff --git a/drm/libdrmframework/include/DrmIOService.h b/drm/libdrmframework/include/DrmIOService.h
deleted file mode 100644
index 244124e79124..000000000000
--- a/drm/libdrmframework/include/DrmIOService.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __DRM_IO_SERVICE_H__
-#define __DRM_IO_SERVICE_H__
-
-#include "IDrmIOService.h"
-
-namespace android {
-
-/**
- * This is the implementation class for DRM IO service.
- *
- * The instance of this class is created while starting the DRM IO service.
- *
- */
-class DrmIOService : public BnDrmIOService {
-public:
- static void instantiate();
-
-private:
- DrmIOService();
- virtual ~DrmIOService();
-
-public:
- void writeToFile(const String8& filePath, const String8& dataBuffer);
- String8 readFromFile(const String8& filePath);
-};
-
-};
-
-#endif /* __DRM_IO_SERVICE_H__ */
-
diff --git a/drm/libdrmframework/include/DrmManager.h b/drm/libdrmframework/include/DrmManager.h
index bc462c2b5050..c7276f988a20 100644
--- a/drm/libdrmframework/include/DrmManager.h
+++ b/drm/libdrmframework/include/DrmManager.h
@@ -95,7 +95,7 @@ public:
status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
status_t setPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
+ int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position);
bool validateAction(
int uniqueId, const String8& path, int action, const ActionDescription& description);
@@ -112,7 +112,7 @@ public:
status_t getAllSupportInfo(int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
- DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
+ DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
@@ -127,7 +127,7 @@ public:
status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
- void* buffer, ssize_t numBytes, off_t offset);
+ void* buffer, ssize_t numBytes, off64_t offset);
void onInfo(const DrmInfoEvent& event);
@@ -147,6 +147,7 @@ private:
int mDecryptSessionId;
int mConvertId;
Mutex mLock;
+ Mutex mListenerLock;
Mutex mDecryptLock;
Mutex mConvertLock;
TPlugInManager<IDrmEngine> mPlugInManager;
diff --git a/drm/libdrmframework/include/DrmManagerClientImpl.h b/drm/libdrmframework/include/DrmManagerClientImpl.h
index ff84fc733e53..429e4c3f55b7 100644
--- a/drm/libdrmframework/include/DrmManagerClientImpl.h
+++ b/drm/libdrmframework/include/DrmManagerClientImpl.h
@@ -203,7 +203,7 @@ public:
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
status_t setPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
+ int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position);
/**
* Validates whether an action on the DRM content is allowed or not.
@@ -303,7 +303,7 @@ public:
* @return
* Handle for the decryption session
*/
- DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
+ DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
/**
* Open the decrypt session to decrypt the given protected content
@@ -381,7 +381,7 @@ public:
* @return Number of bytes read. Returns -1 for Failure.
*/
ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
- void* buffer, ssize_t numBytes, off_t offset);
+ void* buffer, ssize_t numBytes, off64_t offset);
/**
* Notify the event to the registered listener
@@ -407,9 +407,17 @@ private:
Mutex mLock;
sp<DrmManagerClient::OnInfoListener> mOnInfoListener;
+ class DeathNotifier: public IBinder::DeathRecipient {
+ public:
+ DeathNotifier() {}
+ virtual ~DeathNotifier();
+ virtual void binderDied(const wp<IBinder>& who);
+ };
+
private:
- static Mutex mMutex;
- static sp<IDrmManagerService> mDrmManagerService;
+ static Mutex sMutex;
+ static sp<DeathNotifier> sDeathNotifier;
+ static sp<IDrmManagerService> sDrmManagerService;
static const sp<IDrmManagerService>& getDrmManagerService();
static const String8 EMPTY_STRING;
};
diff --git a/drm/libdrmframework/include/DrmManagerService.h b/drm/libdrmframework/include/DrmManagerService.h
index f346356ae094..d0a0db74f1ba 100644
--- a/drm/libdrmframework/include/DrmManagerService.h
+++ b/drm/libdrmframework/include/DrmManagerService.h
@@ -81,7 +81,7 @@ public:
status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
status_t setPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
+ int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position);
bool validateAction(int uniqueId, const String8& path,
int action, const ActionDescription& description);
@@ -98,7 +98,7 @@ public:
status_t getAllSupportInfo(int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
- DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
+ DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
@@ -113,7 +113,7 @@ public:
status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
- void* buffer, ssize_t numBytes, off_t offset);
+ void* buffer, ssize_t numBytes, off64_t offset);
private:
DrmManager* mDrmManager;
diff --git a/drm/libdrmframework/include/IDrmIOService.h b/drm/libdrmframework/include/IDrmIOService.h
deleted file mode 100644
index 5e0d907e6794..000000000000
--- a/drm/libdrmframework/include/IDrmIOService.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __IDRM_IO_SERVICE_H__
-#define __IDRM_IO_SERVICE_H__
-
-#include <utils/RefBase.h>
-#include <binder/IInterface.h>
-#include <binder/Parcel.h>
-
-namespace android {
-
-/**
- * This is the interface class for DRM IO service.
- *
- */
-class IDrmIOService : public IInterface
-{
-public:
- enum {
- WRITE_TO_FILE = IBinder::FIRST_CALL_TRANSACTION,
- READ_FROM_FILE
- };
-
-public:
- DECLARE_META_INTERFACE(DrmIOService);
-
-public:
- /**
- * Writes the data into the file path provided
- *
- * @param[in] filePath Path of the file
- * @param[in] dataBuffer Data to write
- */
- virtual void writeToFile(const String8& filePath, const String8& dataBuffer) = 0;
-
- /**
- * Reads the data from the file path provided
- *
- * @param[in] filePath Path of the file
- * @return Data read from the file
- */
- virtual String8 readFromFile(const String8& filePath) = 0;
-};
-
-/**
- * This is the Binder implementation class for DRM IO service.
- */
-class BpDrmIOService: public BpInterface<IDrmIOService>
-{
-public:
- BpDrmIOService(const sp<IBinder>& impl)
- : BpInterface<IDrmIOService>(impl) {}
-
- virtual void writeToFile(const String8& filePath, const String8& dataBuffer);
-
- virtual String8 readFromFile(const String8& filePath);
-};
-
-/**
- * This is the Binder implementation class for DRM IO service.
- */
-class BnDrmIOService: public BnInterface<IDrmIOService>
-{
-public:
- virtual status_t onTransact(
- uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0);
-};
-
-};
-
-#endif /* __IDRM_IO_SERVICE_H__ */
-
diff --git a/drm/libdrmframework/include/IDrmManagerService.h b/drm/libdrmframework/include/IDrmManagerService.h
index f1dabd399a19..2424ea5fc228 100644
--- a/drm/libdrmframework/include/IDrmManagerService.h
+++ b/drm/libdrmframework/include/IDrmManagerService.h
@@ -120,7 +120,7 @@ public:
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) = 0;
virtual status_t setPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) = 0;
+ int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) = 0;
virtual bool validateAction(
int uniqueId, const String8& path,
@@ -140,7 +140,7 @@ public:
virtual status_t getAllSupportInfo(
int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) = 0;
- virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length) = 0;
+ virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length) = 0;
virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri) = 0;
@@ -156,7 +156,7 @@ public:
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
- void* buffer, ssize_t numBytes,off_t offset) = 0;
+ void* buffer, ssize_t numBytes,off64_t offset) = 0;
};
/**
@@ -204,7 +204,7 @@ public:
int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
virtual status_t setPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
+ int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position);
virtual bool validateAction(
int uniqueId, const String8& path, int action, const ActionDescription& description);
@@ -223,7 +223,7 @@ public:
virtual status_t getAllSupportInfo(
int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
- virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length);
+ virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length);
virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri);
@@ -239,7 +239,7 @@ public:
int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
- void* buffer, ssize_t numBytes, off_t offset);
+ void* buffer, ssize_t numBytes, off64_t offset);
};
/**
diff --git a/drm/libdrmframework/include/PlugInManager.h b/drm/libdrmframework/include/PlugInManager.h
index 9ad195fd80b0..8029138d50f9 100644
--- a/drm/libdrmframework/include/PlugInManager.h
+++ b/drm/libdrmframework/include/PlugInManager.h
@@ -230,11 +230,9 @@ private:
*/
bool isPlugIn(const struct dirent* pEntry) const {
String8 sName(pEntry->d_name);
- int extentionPos = sName.size() - String8(PLUGIN_EXTENSION).size();
- if (extentionPos < 0) {
- return false;
- }
- return extentionPos == (int)sName.find(PLUGIN_EXTENSION);
+ String8 extension(sName.getPathExtension());
+ // Note that the plug-in extension must exactly match case
+ return extension == String8(PLUGIN_EXTENSION);
}
/**
diff --git a/drm/libdrmframework/include/StringTokenizer.h b/drm/libdrmframework/include/StringTokenizer.h
deleted file mode 100644
index 70e755822403..000000000000
--- a/drm/libdrmframework/include/StringTokenizer.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __STRING_TOKENIZER_H__
-#define __STRING_TOKENIZER_H__
-
-#include <drm/drm_framework_common.h>
-
-namespace android {
-
-/**
- * This is an utility class for String manipulation.
- *
- */
-class StringTokenizer {
-public:
- /**
- * Iterator for string tokens
- */
- class Iterator {
- friend class StringTokenizer;
- private:
- Iterator(StringTokenizer* StringTokenizer)
- : mStringTokenizer(StringTokenizer), mIndex(0) {}
-
- public:
- Iterator(const Iterator& iterator);
- Iterator& operator=(const Iterator& iterator);
- virtual ~Iterator() {}
-
- public:
- bool hasNext();
- String8& next();
-
- private:
- StringTokenizer* mStringTokenizer;
- unsigned int mIndex;
- };
-
-public:
- /**
- * Constructor for StringTokenizer
- *
- * @param[in] string Complete string data
- * @param[in] delimeter Delimeter used to split the string
- */
- StringTokenizer(const String8& string, const String8& delimeter);
-
- /**
- * Destructor for StringTokenizer
- */
- ~StringTokenizer() {}
-
-private:
- /**
- * Splits the string according to the delimeter
- */
- void splitString(const String8& string, const String8& delimeter);
-
-public:
- /**
- * Returns Iterator object to walk through the split string values
- *
- * @return Iterator object
- */
- Iterator iterator();
-
-private:
- Vector<String8> mStringTokenizerVector;
-};
-
-};
-#endif /* __STRING_TOKENIZER_H__ */
-
diff --git a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
index 67b635522334..b61e3d353a27 100644
--- a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
+++ b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
@@ -62,7 +62,7 @@ public:
status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
status_t setPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
+ int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position);
bool validateAction(
int uniqueId, const String8& path, int action, const ActionDescription& description);
@@ -80,7 +80,7 @@ public:
DrmSupportInfo* getSupportInfo(int uniqueId);
status_t openDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length);
+ int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length);
status_t openDecryptSession(
int uniqueId, DecryptHandle* decryptHandle, const char* uri);
@@ -96,7 +96,7 @@ public:
status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
- void* buffer, ssize_t numBytes, off_t offset);
+ void* buffer, ssize_t numBytes, off64_t offset);
protected:
/////////////////////////////////////////////////////
@@ -268,7 +268,7 @@ protected:
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
virtual status_t onSetPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) = 0;
+ int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) = 0;
/**
* Validates whether an action on the DRM content is allowed or not.
@@ -369,7 +369,7 @@ protected:
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
*/
virtual status_t onOpenDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length) = 0;
+ int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) = 0;
/**
* Open the decrypt session to decrypt the given protected content
@@ -450,7 +450,7 @@ protected:
* @return Number of bytes read. Returns -1 for Failure.
*/
virtual ssize_t onPread(int uniqueId, DecryptHandle* decryptHandle,
- void* buffer, ssize_t numBytes, off_t offset) = 0;
+ void* buffer, ssize_t numBytes, off64_t offset) = 0;
};
};
diff --git a/drm/libdrmframework/plugins/common/include/IDrmEngine.h b/drm/libdrmframework/plugins/common/include/IDrmEngine.h
index f839070649eb..d05c24ff6101 100644
--- a/drm/libdrmframework/plugins/common/include/IDrmEngine.h
+++ b/drm/libdrmframework/plugins/common/include/IDrmEngine.h
@@ -224,7 +224,7 @@ public:
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
virtual status_t setPlaybackStatus(int uniqueId, DecryptHandle* decryptHandle,
- int playbackStatus, int position) = 0;
+ int playbackStatus, int64_t position) = 0;
/**
* Validates whether an action on the DRM content is allowed or not.
@@ -325,7 +325,7 @@ public:
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
*/
virtual status_t openDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length) = 0;
+ int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) = 0;
/**
* Open the decrypt session to decrypt the given protected content
@@ -406,7 +406,7 @@ public:
* @return Number of bytes read. Returns -1 for Failure.
*/
virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
- void* buffer, ssize_t numBytes, off_t offset) = 0;
+ void* buffer, ssize_t numBytes, off64_t offset) = 0;
};
};
diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk
index 21de4eafa9ff..35fa7340589a 100644
--- a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk
+++ b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk
@@ -63,7 +63,7 @@ LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/include \
external/openssl/include
-LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/drm/plugins/native
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/drm
LOCAL_MODULE_TAGS := optional
diff --git a/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h b/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h
index bbcd9ed384d2..f941f7007dc8 100644
--- a/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h
+++ b/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h
@@ -56,7 +56,7 @@ protected:
status_t onConsumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
status_t onSetPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position);
+ int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position);
bool onValidateAction(
int uniqueId, const String8& path, int action, const ActionDescription& description);
@@ -74,7 +74,7 @@ protected:
DrmSupportInfo* onGetSupportInfo(int uniqueId);
status_t onOpenDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length);
+ int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length);
status_t onOpenDecryptSession(
int uniqueId, DecryptHandle* decryptHandle, const char* uri);
@@ -90,7 +90,7 @@ protected:
status_t onFinalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
ssize_t onPread(int uniqueId, DecryptHandle* decryptHandle,
- void* buffer, ssize_t numBytes, off_t offset);
+ void* buffer, ssize_t numBytes, off64_t offset);
private:
DecryptHandle* openDecryptSessionImpl();
diff --git a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
index dee1fdb29c3d..976978fb385e 100644
--- a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
+++ b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
@@ -187,7 +187,7 @@ status_t DrmPassthruPlugIn::onConsumeRights(int uniqueId, DecryptHandle* decrypt
}
status_t DrmPassthruPlugIn::onSetPlaybackStatus(int uniqueId, DecryptHandle* decryptHandle,
- int playbackStatus, int position) {
+ int playbackStatus, int64_t position) {
LOGD("DrmPassthruPlugIn::onSetPlaybackStatus() : %d", uniqueId);
return DRM_NO_ERROR;
}
@@ -234,7 +234,7 @@ DrmConvertedStatus* DrmPassthruPlugIn::onCloseConvertSession(int uniqueId, int c
}
status_t DrmPassthruPlugIn::onOpenDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length) {
+ int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) {
LOGD("DrmPassthruPlugIn::onOpenDecryptSession() : %d", uniqueId);
#ifdef ENABLE_PASSTHRU_DECRYPTION
@@ -292,7 +292,7 @@ status_t DrmPassthruPlugIn::onFinalizeDecryptUnit(
}
ssize_t DrmPassthruPlugIn::onPread(int uniqueId, DecryptHandle* decryptHandle,
- void* buffer, ssize_t numBytes, off_t offset) {
+ void* buffer, ssize_t numBytes, off64_t offset) {
LOGD("DrmPassthruPlugIn::onPread() : %d", uniqueId);
return 0;
}