Skip to content

Commit dc91865

Browse files
author
Takeshi Aimi
committed
Update of DRM Framework.
-Access permission handling Introduce an internal function which allows the desired process to access decryption flow. This new function is just for reference and each OEM manufacturer should implement/replace with their solutions. -New API, getMetadata() This API is for retrieving media metadata from container-based DRM, such as OMA forward-lock content. This API asks DRM agent to retrieve media metadata hiddein inside of DRM special container. -New API, acquireRights() This API wraps acquireDrmInfo() and processDrmInfo(). If DRM agent has valid implementation of both APIs, Application can acquire DrmRights only by calling this API. -Bug fix in event loop of OnInfoListener. Separate OnInfo event loop from mail thread loop so as to avoid the issue that message is not dispatched when mail thread is busy. Changes are made by SEMC and Sony. Change-Id: I04ee3e0988152a71e221f2256d83253749a29da0
1 parent 14ac954 commit dc91865

23 files changed

+573
-83
lines changed

api/current.xml

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -55702,17 +55702,6 @@
5570255702
<parameter name="message" type="java.lang.String">
5570355703
</parameter>
5570455704
</constructor>
55705-
<field name="TYPE_DRM_INFO_ACQUISITION_FAILED"
55706-
type="int"
55707-
transient="false"
55708-
volatile="false"
55709-
value="2008"
55710-
static="true"
55711-
final="true"
55712-
deprecated="not deprecated"
55713-
visibility="public"
55714-
>
55715-
</field>
5571655705
<field name="TYPE_NOT_SUPPORTED"
5571755706
type="int"
5571855707
transient="false"
@@ -55846,17 +55835,6 @@
5584655835
visibility="public"
5584755836
>
5584855837
</method>
55849-
<field name="DRM_INFO_OBJECT"
55850-
type="java.lang.String"
55851-
transient="false"
55852-
volatile="false"
55853-
value="&quot;drm_info_object&quot;"
55854-
static="true"
55855-
final="true"
55856-
deprecated="not deprecated"
55857-
visibility="public"
55858-
>
55859-
</field>
5586055838
<field name="DRM_INFO_STATUS_OBJECT"
5586155839
type="java.lang.String"
5586255840
transient="false"
@@ -55879,17 +55857,6 @@
5587955857
visibility="public"
5588055858
>
5588155859
</field>
55882-
<field name="TYPE_DRM_INFO_ACQUIRED"
55883-
type="int"
55884-
transient="false"
55885-
volatile="false"
55886-
value="1003"
55887-
static="true"
55888-
final="true"
55889-
deprecated="not deprecated"
55890-
visibility="public"
55891-
>
55892-
</field>
5589355860
<field name="TYPE_DRM_INFO_PROCESSED"
5589455861
type="int"
5589555862
transient="false"
@@ -56365,6 +56332,19 @@
5636556332
</parameter>
5636656333
</constructor>
5636756334
<method name="acquireDrmInfo"
56335+
return="android.drm.DrmInfo"
56336+
abstract="false"
56337+
native="false"
56338+
synchronized="false"
56339+
static="false"
56340+
final="false"
56341+
deprecated="not deprecated"
56342+
visibility="public"
56343+
>
56344+
<parameter name="drmInfoRequest" type="android.drm.DrmInfoRequest">
56345+
</parameter>
56346+
</method>
56347+
<method name="acquireRights"
5636856348
return="int"
5636956349
abstract="false"
5637056350
native="false"
@@ -56562,6 +56542,32 @@
5656256542
<parameter name="mimeType" type="java.lang.String">
5656356543
</parameter>
5656456544
</method>
56545+
<method name="getMetadata"
56546+
return="android.content.ContentValues"
56547+
abstract="false"
56548+
native="false"
56549+
synchronized="false"
56550+
static="false"
56551+
final="false"
56552+
deprecated="not deprecated"
56553+
visibility="public"
56554+
>
56555+
<parameter name="path" type="java.lang.String">
56556+
</parameter>
56557+
</method>
56558+
<method name="getMetadata"
56559+
return="android.content.ContentValues"
56560+
abstract="false"
56561+
native="false"
56562+
synchronized="false"
56563+
static="false"
56564+
final="false"
56565+
deprecated="not deprecated"
56566+
visibility="public"
56567+
>
56568+
<parameter name="uri" type="android.net.Uri">
56569+
</parameter>
56570+
</method>
5656556571
<method name="getOriginalMimeType"
5656656572
return="java.lang.String"
5656756573
abstract="false"

drm/common/Android.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ include $(CLEAR_VARS)
1818

1919
LOCAL_SRC_FILES:= \
2020
DrmConstraints.cpp \
21+
DrmMetadata.cpp \
2122
DrmConvertedStatus.cpp \
2223
DrmEngineBase.cpp \
2324
DrmInfo.cpp \

drm/common/DrmEngineBase.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ DrmConstraints* DrmEngineBase::getConstraints(
3131
return onGetConstraints(uniqueId, path, action);
3232
}
3333

34+
DrmMetadata* DrmEngineBase::getMetadata(int uniqueId, const String8* path) {
35+
return onGetMetadata(uniqueId, path);
36+
}
37+
3438
status_t DrmEngineBase::initialize(int uniqueId) {
3539
return onInitialize(uniqueId);
3640
}

drm/common/DrmMetadata.cpp

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Copyright (C) 2010 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include <drm/DrmMetadata.h>
18+
19+
using namespace android;
20+
21+
int DrmMetadata::getCount(void) const {
22+
return mMetadataMap.size();
23+
}
24+
25+
status_t DrmMetadata::put(const String8* key,
26+
const char* value) {
27+
if((value != NULL) && (key != NULL)) {
28+
int length = strlen(value);
29+
char* charValue = new char[length + 1];
30+
31+
memcpy(charValue, value, length);
32+
charValue[length] = '\0';
33+
mMetadataMap.add(*key, charValue);
34+
}
35+
return NO_ERROR;
36+
}
37+
38+
String8 DrmMetadata::get(const String8& key) const {
39+
if (NULL != getValue(&key)) {
40+
return String8(getValue(&key));
41+
}
42+
else {
43+
return String8("");
44+
}
45+
}
46+
47+
const char* DrmMetadata::getValue(const String8* key) const {
48+
if(key != NULL) {
49+
if (NAME_NOT_FOUND != mMetadataMap.indexOfKey(*key)) {
50+
return mMetadataMap.valueFor(*key);
51+
}
52+
else {
53+
return NULL;
54+
}
55+
} else {
56+
return NULL;
57+
}
58+
}
59+
60+
const char* DrmMetadata::getAsByteArray(const String8* key) const {
61+
return getValue(key);
62+
}
63+
64+
bool DrmMetadata::KeyIterator::hasNext() {
65+
return mIndex < mDrmMetadata->mMetadataMap.size();
66+
}
67+
68+
const String8& DrmMetadata::KeyIterator::next() {
69+
const String8& key = mDrmMetadata->mMetadataMap.keyAt(mIndex);
70+
mIndex++;
71+
return key;
72+
}
73+
74+
DrmMetadata::KeyIterator DrmMetadata::keyIterator() {
75+
return KeyIterator(this);
76+
}
77+
78+
DrmMetadata::KeyIterator::KeyIterator(const DrmMetadata::KeyIterator& keyIterator) :
79+
mDrmMetadata(keyIterator.mDrmMetadata),
80+
mIndex(keyIterator.mIndex) {
81+
LOGV("DrmMetadata::KeyIterator::KeyIterator");
82+
}
83+
84+
DrmMetadata::KeyIterator& DrmMetadata::KeyIterator::operator=(const DrmMetadata::KeyIterator& keyIterator) {
85+
LOGV("DrmMetadata::KeyIterator::operator=");
86+
mDrmMetadata = keyIterator.mDrmMetadata;
87+
mIndex = keyIterator.mIndex;
88+
return *this;
89+
}
90+
91+
92+
DrmMetadata::Iterator DrmMetadata::iterator() {
93+
return Iterator(this);
94+
}
95+
96+
DrmMetadata::Iterator::Iterator(const DrmMetadata::Iterator& iterator) :
97+
mDrmMetadata(iterator.mDrmMetadata),
98+
mIndex(iterator.mIndex) {
99+
LOGV("DrmMetadata::Iterator::Iterator");
100+
}
101+
102+
DrmMetadata::Iterator& DrmMetadata::Iterator::operator=(const DrmMetadata::Iterator& iterator) {
103+
LOGV("DrmMetadata::Iterator::operator=");
104+
mDrmMetadata = iterator.mDrmMetadata;
105+
mIndex = iterator.mIndex;
106+
return *this;
107+
}
108+
109+
bool DrmMetadata::Iterator::hasNext() {
110+
return mIndex < mDrmMetadata->mMetadataMap.size();
111+
}
112+
113+
String8 DrmMetadata::Iterator::next() {
114+
String8 value = String8(mDrmMetadata->mMetadataMap.editValueAt(mIndex));
115+
mIndex++;
116+
return value;
117+
}

drm/common/IDrmManagerService.cpp

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include <drm/DrmInfo.h>
2626
#include <drm/DrmConstraints.h>
27+
#include <drm/DrmMetadata.h>
2728
#include <drm/DrmRights.h>
2829
#include <drm/DrmInfoStatus.h>
2930
#include <drm/DrmConvertedStatus.h>
@@ -123,6 +124,35 @@ DrmConstraints* BpDrmManagerService::getConstraints(
123124
return drmConstraints;
124125
}
125126

127+
DrmMetadata* BpDrmManagerService::getMetadata(int uniqueId, const String8* path) {
128+
LOGV("Get Metadata");
129+
Parcel data, reply;
130+
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
131+
data.writeInt32(uniqueId);
132+
133+
DrmMetadata* drmMetadata = NULL;
134+
data.writeString8(*path);
135+
remote()->transact(GET_METADATA_FROM_CONTENT, data, &reply);
136+
137+
if (0 != reply.dataAvail()) {
138+
//Filling Drm Metadata
139+
drmMetadata = new DrmMetadata();
140+
141+
const int size = reply.readInt32();
142+
for (int index = 0; index < size; ++index) {
143+
const String8 key(reply.readString8());
144+
const int bufferSize = reply.readInt32();
145+
char* data = NULL;
146+
if (0 < bufferSize) {
147+
data = new char[bufferSize];
148+
reply.read(data, bufferSize);
149+
}
150+
drmMetadata->put(&key, data);
151+
}
152+
}
153+
return drmMetadata;
154+
}
155+
126156
bool BpDrmManagerService::canHandle(int uniqueId, const String8& path, const String8& mimeType) {
127157
LOGV("Can Handle");
128158
Parcel data, reply;
@@ -827,6 +857,38 @@ status_t BnDrmManagerService::onTransact(
827857
return DRM_NO_ERROR;
828858
}
829859

860+
case GET_METADATA_FROM_CONTENT:
861+
{
862+
LOGV("BnDrmManagerService::onTransact :GET_METADATA_FROM_CONTENT");
863+
CHECK_INTERFACE(IDrmManagerService, data, reply);
864+
865+
const int uniqueId = data.readInt32();
866+
const String8 path = data.readString8();
867+
868+
DrmMetadata* drmMetadata = getMetadata(uniqueId, &path);
869+
if (NULL != drmMetadata) {
870+
//Filling DRM Metadata contents
871+
reply->writeInt32(drmMetadata->getCount());
872+
873+
DrmMetadata::KeyIterator keyIt = drmMetadata->keyIterator();
874+
while (keyIt.hasNext()) {
875+
const String8 key = keyIt.next();
876+
reply->writeString8(key);
877+
const char* value = drmMetadata->getAsByteArray(&key);
878+
int bufferSize = 0;
879+
if (NULL != value) {
880+
bufferSize = strlen(value);
881+
reply->writeInt32(bufferSize + 1);
882+
reply->write(value, bufferSize + 1);
883+
} else {
884+
reply->writeInt32(0);
885+
}
886+
}
887+
}
888+
delete drmMetadata; drmMetadata = NULL;
889+
return NO_ERROR;
890+
}
891+
830892
case CAN_HANDLE:
831893
{
832894
LOGV("BnDrmManagerService::onTransact :CAN_HANDLE");

drm/drmserver/DrmManager.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <drm/DrmInfoEvent.h>
2424
#include <drm/DrmRights.h>
2525
#include <drm/DrmConstraints.h>
26+
#include <drm/DrmMetadata.h>
2627
#include <drm/DrmInfoStatus.h>
2728
#include <drm/DrmInfoRequest.h>
2829
#include <drm/DrmSupportInfo.h>
@@ -148,6 +149,15 @@ DrmConstraints* DrmManager::getConstraints(int uniqueId, const String8* path, co
148149
return NULL;
149150
}
150151

152+
DrmMetadata* DrmManager::getMetadata(int uniqueId, const String8* path) {
153+
const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, *path);
154+
if (EMPTY_STRING != plugInId) {
155+
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
156+
return rDrmEngine.getMetadata(uniqueId, path);
157+
}
158+
return NULL;
159+
}
160+
151161
status_t DrmManager::installDrmEngine(int uniqueId, const String8& absolutePath) {
152162
mPlugInManager.loadPlugIn(absolutePath);
153163

0 commit comments

Comments
 (0)