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

Commit 5b8987e7 authored by Andreas Huber's avatar Andreas Huber
Browse files

Allow propagation of error information and description from the CryptoPlugin to

the higher layers.

Change-Id: I9f434ad55cdf575803c208bedf47b607baff2330
related-to-bug: 6365261
parent fd9e14bc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/ALooper.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/foundation/AString.h>
#include <media/stagefright/DataSource.h>
#include <media/stagefright/MediaCodec.h>
#include <media/stagefright/MediaCodecList.h>
+4 −1
Original line number Diff line number Diff line
@@ -24,6 +24,8 @@

namespace android {

struct AString;

struct ICrypto : public IInterface {
    DECLARE_META_INTERFACE(Crypto);

@@ -46,7 +48,8 @@ struct ICrypto : public IInterface {
            CryptoPlugin::Mode mode,
            const void *srcPtr,
            const CryptoPlugin::SubSample *subSamples, size_t numSubSamples,
            void *dstPtr) = 0;
            void *dstPtr,
            AString *errorDetailMsg) = 0;

private:
    DISALLOW_EVIL_CONSTRUCTORS(ICrypto);
+5 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ namespace android {
struct ABuffer;
struct ACodec;
struct AMessage;
struct AString;
struct ICrypto;
struct SoftwareRenderer;
struct SurfaceTextureClient;
@@ -72,7 +73,8 @@ struct MediaCodec : public AHandler {
            size_t offset,
            size_t size,
            int64_t presentationTimeUs,
            uint32_t flags);
            uint32_t flags,
            AString *errorDetailMsg = NULL);

    status_t queueSecureInputBuffer(
            size_t index,
@@ -83,7 +85,8 @@ struct MediaCodec : public AHandler {
            const uint8_t iv[16],
            CryptoPlugin::Mode mode,
            int64_t presentationTimeUs,
            uint32_t flags);
            uint32_t flags,
            AString *errorDetailMsg = NULL);

    status_t dequeueInputBuffer(size_t *index, int64_t timeoutUs = 0ll);

+6 −2
Original line number Diff line number Diff line
@@ -55,8 +55,12 @@ enum {
    ERROR_DRM_CANNOT_HANDLE                 = DRM_ERROR_BASE - 6,
    ERROR_DRM_TAMPER_DETECTED               = DRM_ERROR_BASE - 7,

    ERROR_DRM_WV_VENDOR_MAX                 = DRM_ERROR_BASE - 500,
    ERROR_DRM_WV_VENDOR_MIN                 = DRM_ERROR_BASE - 999,
    ERROR_DRM_VENDOR_MAX                    = DRM_ERROR_BASE - 500,
    ERROR_DRM_VENDOR_MIN                    = DRM_ERROR_BASE - 999,

    // Deprecated
    ERROR_DRM_WV_VENDOR_MAX                 = ERROR_DRM_VENDOR_MAX,
    ERROR_DRM_WV_VENDOR_MIN                 = ERROR_DRM_VENDOR_MIN,

    // Heartbeat Error Codes
    HEARTBEAT_ERROR_BASE = -3000,
+17 −2
Original line number Diff line number Diff line
@@ -20,7 +20,9 @@

#include <binder/Parcel.h>
#include <media/ICrypto.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AString.h>

namespace android {

@@ -96,7 +98,8 @@ struct BpCrypto : public BpInterface<ICrypto> {
            CryptoPlugin::Mode mode,
            const void *srcPtr,
            const CryptoPlugin::SubSample *subSamples, size_t numSubSamples,
            void *dstPtr) {
            void *dstPtr,
            AString *errorDetailMsg) {
        Parcel data, reply;
        data.writeInterfaceToken(ICrypto::getInterfaceDescriptor());
        data.writeInt32(secure);
@@ -135,6 +138,10 @@ struct BpCrypto : public BpInterface<ICrypto> {

        status_t result = reply.readInt32();

        if (result >= ERROR_DRM_VENDOR_MIN && result <= ERROR_DRM_VENDOR_MAX) {
            errorDetailMsg->setTo(reply.readCString());
        }

        if (result != OK) {
            return result;
        }
@@ -251,6 +258,8 @@ status_t BnCrypto::onTransact(
                dstPtr = malloc(totalSize);
            }

            AString errorDetailMsg;

            status_t err = decrypt(
                    secure,
                    key,
@@ -258,10 +267,16 @@ status_t BnCrypto::onTransact(
                    mode,
                    srcData,
                    subSamples, numSubSamples,
                    dstPtr);
                    dstPtr,
                    &errorDetailMsg);

            reply->writeInt32(err);

            if (err >= ERROR_DRM_VENDOR_MIN
                    && err <= ERROR_DRM_VENDOR_MAX) {
                reply->writeCString(errorDetailMsg.c_str());
            }

            if (!secure) {
                if (err == OK) {
                    reply->write(dstPtr, totalSize);
Loading