Allow propagation of error information and description from the CryptoPlugin to

the higher layers.

Change-Id: I9f434ad55cdf575803c208bedf47b607baff2330
related-to-bug: 6365261
diff --git a/media/libmedia/ICrypto.cpp b/media/libmedia/ICrypto.cpp
index d51fe01..3452e5c 100644
--- a/media/libmedia/ICrypto.cpp
+++ b/media/libmedia/ICrypto.cpp
@@ -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 @@
             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 @@
 
         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 @@
                 dstPtr = malloc(totalSize);
             }
 
+            AString errorDetailMsg;
+
             status_t err = decrypt(
                     secure,
                     key,
@@ -258,10 +267,16 @@
                     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);