Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9334934 authored by Gloria Wang's avatar Gloria Wang Committed by Android Code Review
Browse files

Merge "Update of DRM Framework."

parents e4ae7fc3 dc918656
Loading
Loading
Loading
Loading
+39 −33
Original line number Diff line number Diff line
@@ -55702,17 +55702,6 @@
<parameter name="message" type="java.lang.String">
</parameter>
</constructor>
<field name="TYPE_DRM_INFO_ACQUISITION_FAILED"
 type="int"
 transient="false"
 volatile="false"
 value="2008"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="TYPE_NOT_SUPPORTED"
 type="int"
 transient="false"
@@ -55846,17 +55835,6 @@
 visibility="public"
>
</method>
<field name="DRM_INFO_OBJECT"
 type="java.lang.String"
 transient="false"
 volatile="false"
 value="&quot;drm_info_object&quot;"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="DRM_INFO_STATUS_OBJECT"
 type="java.lang.String"
 transient="false"
@@ -55879,17 +55857,6 @@
 visibility="public"
>
</field>
<field name="TYPE_DRM_INFO_ACQUIRED"
 type="int"
 transient="false"
 volatile="false"
 value="1003"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="TYPE_DRM_INFO_PROCESSED"
 type="int"
 transient="false"
@@ -56365,6 +56332,19 @@
</parameter>
</constructor>
<method name="acquireDrmInfo"
 return="android.drm.DrmInfo"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="drmInfoRequest" type="android.drm.DrmInfoRequest">
</parameter>
</method>
<method name="acquireRights"
 return="int"
 abstract="false"
 native="false"
@@ -56562,6 +56542,32 @@
<parameter name="mimeType" type="java.lang.String">
</parameter>
</method>
<method name="getMetadata"
 return="android.content.ContentValues"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="path" type="java.lang.String">
</parameter>
</method>
<method name="getMetadata"
 return="android.content.ContentValues"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="uri" type="android.net.Uri">
</parameter>
</method>
<method name="getOriginalMimeType"
 return="java.lang.String"
 abstract="false"
+1 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ include $(CLEAR_VARS)

LOCAL_SRC_FILES:= \
    DrmConstraints.cpp \
    DrmMetadata.cpp \
    DrmConvertedStatus.cpp \
    DrmEngineBase.cpp \
    DrmInfo.cpp \
+4 −0
Original line number Diff line number Diff line
@@ -31,6 +31,10 @@ DrmConstraints* DrmEngineBase::getConstraints(
    return onGetConstraints(uniqueId, path, action);
}

DrmMetadata* DrmEngineBase::getMetadata(int uniqueId, const String8* path) {
    return onGetMetadata(uniqueId, path);
}

status_t DrmEngineBase::initialize(int uniqueId) {
    return onInitialize(uniqueId);
}
+117 −0
Original line number Diff line number Diff line
/*
 * 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 <drm/DrmMetadata.h>

using namespace android;

int DrmMetadata::getCount(void) const {
	return mMetadataMap.size();
}

status_t DrmMetadata::put(const String8* key,
                          const char* value) {
    if((value != NULL) && (key != NULL)) {
        int length = strlen(value);
        char* charValue = new char[length + 1];

        memcpy(charValue, value, length);
        charValue[length] = '\0';
        mMetadataMap.add(*key, charValue);
    }
    return NO_ERROR;
}

String8 DrmMetadata::get(const String8& key) const {
    if (NULL != getValue(&key)) {
        return String8(getValue(&key));
    }
    else {
        return String8("");
    }
}

const char* DrmMetadata::getValue(const String8* key) const {
    if(key != NULL) {
        if (NAME_NOT_FOUND != mMetadataMap.indexOfKey(*key)) {
            return mMetadataMap.valueFor(*key);
        }
        else {
            return NULL;
        }
    } else {
        return NULL;
    }
}

const char* DrmMetadata::getAsByteArray(const String8* key) const {
    return getValue(key);
}

bool DrmMetadata::KeyIterator::hasNext() {
    return mIndex < mDrmMetadata->mMetadataMap.size();
}

const String8& DrmMetadata::KeyIterator::next() {
    const String8& key = mDrmMetadata->mMetadataMap.keyAt(mIndex);
    mIndex++;
    return key;
}

DrmMetadata::KeyIterator DrmMetadata::keyIterator() {
    return KeyIterator(this);
}

DrmMetadata::KeyIterator::KeyIterator(const DrmMetadata::KeyIterator& keyIterator) :
    mDrmMetadata(keyIterator.mDrmMetadata),
    mIndex(keyIterator.mIndex) {
    LOGV("DrmMetadata::KeyIterator::KeyIterator");
}

DrmMetadata::KeyIterator& DrmMetadata::KeyIterator::operator=(const DrmMetadata::KeyIterator& keyIterator) {
    LOGV("DrmMetadata::KeyIterator::operator=");
    mDrmMetadata = keyIterator.mDrmMetadata;
    mIndex = keyIterator.mIndex;
    return *this;
}


DrmMetadata::Iterator DrmMetadata::iterator() {
    return Iterator(this);
}

DrmMetadata::Iterator::Iterator(const DrmMetadata::Iterator& iterator) :
    mDrmMetadata(iterator.mDrmMetadata),
    mIndex(iterator.mIndex) {
    LOGV("DrmMetadata::Iterator::Iterator");
}

DrmMetadata::Iterator& DrmMetadata::Iterator::operator=(const DrmMetadata::Iterator& iterator) {
    LOGV("DrmMetadata::Iterator::operator=");
    mDrmMetadata = iterator.mDrmMetadata;
    mIndex = iterator.mIndex;
    return *this;
}

bool DrmMetadata::Iterator::hasNext() {
    return mIndex < mDrmMetadata->mMetadataMap.size();
}

String8 DrmMetadata::Iterator::next() {
    String8 value = String8(mDrmMetadata->mMetadataMap.editValueAt(mIndex));
    mIndex++;
    return value;
}
+62 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@

#include <drm/DrmInfo.h>
#include <drm/DrmConstraints.h>
#include <drm/DrmMetadata.h>
#include <drm/DrmRights.h>
#include <drm/DrmInfoStatus.h>
#include <drm/DrmConvertedStatus.h>
@@ -123,6 +124,35 @@ DrmConstraints* BpDrmManagerService::getConstraints(
    return drmConstraints;
}

DrmMetadata* BpDrmManagerService::getMetadata(int uniqueId, const String8* path) {
    LOGV("Get Metadata");
    Parcel data, reply;
    data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
    data.writeInt32(uniqueId);

    DrmMetadata* drmMetadata = NULL;
    data.writeString8(*path);
    remote()->transact(GET_METADATA_FROM_CONTENT, data, &reply);

    if (0 != reply.dataAvail()) {
        //Filling Drm Metadata
        drmMetadata = new DrmMetadata();

        const int size = reply.readInt32();
        for (int index = 0; index < size; ++index) {
            const String8 key(reply.readString8());
            const int bufferSize = reply.readInt32();
            char* data = NULL;
            if (0 < bufferSize) {
                data = new char[bufferSize];
                reply.read(data, bufferSize);
            }
            drmMetadata->put(&key, data);
        }
    }
    return drmMetadata;
}

bool BpDrmManagerService::canHandle(int uniqueId, const String8& path, const String8& mimeType) {
    LOGV("Can Handle");
    Parcel data, reply;
@@ -827,6 +857,38 @@ status_t BnDrmManagerService::onTransact(
        return DRM_NO_ERROR;
    }

    case GET_METADATA_FROM_CONTENT:
    {
        LOGV("BnDrmManagerService::onTransact :GET_METADATA_FROM_CONTENT");
        CHECK_INTERFACE(IDrmManagerService, data, reply);

        const int uniqueId = data.readInt32();
        const String8 path = data.readString8();

        DrmMetadata* drmMetadata = getMetadata(uniqueId, &path);
        if (NULL != drmMetadata) {
            //Filling DRM Metadata contents
            reply->writeInt32(drmMetadata->getCount());

            DrmMetadata::KeyIterator keyIt = drmMetadata->keyIterator();
            while (keyIt.hasNext()) {
                const String8 key = keyIt.next();
                reply->writeString8(key);
                const char* value = drmMetadata->getAsByteArray(&key);
                int bufferSize = 0;
                if (NULL != value) {
                    bufferSize = strlen(value);
                    reply->writeInt32(bufferSize + 1);
                    reply->write(value, bufferSize + 1);
                } else {
                    reply->writeInt32(0);
                }
            }
        }
        delete drmMetadata; drmMetadata = NULL;
        return NO_ERROR;
    }

    case CAN_HANDLE:
    {
        LOGV("BnDrmManagerService::onTransact :CAN_HANDLE");
Loading