Add missing 'offset' parameter to decrypt.
Required for functionality
Test: gtests passing
Change-Id: I9e368c146092512dfa42230be0e05848044d2df5
related-to-bug: 32815560
diff --git a/drm/crypto/1.0/ICryptoPlugin.hal b/drm/crypto/1.0/ICryptoPlugin.hal
index 2f7fd87..52c1d02 100644
--- a/drm/crypto/1.0/ICryptoPlugin.hal
+++ b/drm/crypto/1.0/ICryptoPlugin.hal
@@ -73,6 +73,8 @@
* of clear and encrypted bytes to process. This allows the decrypt
* call to operate on a range of subsamples in a single call
* @param source the input buffer for the decryption
+ * @param offset the offset of the first byte of encrypted data from
+ * the base of the source buffer
* @param destination the output buffer for the decryption
* @return status the status of the call. The status must be OK or one of
* the following errors: ERROR_DRM_NO_LICENSE if no license keys have been
@@ -89,6 +91,6 @@
*/
decrypt(bool secure, uint8_t[16] keyId, uint8_t[16] iv, Mode mode,
Pattern pattern, vec<SubSample> subSamples,
- memory source, DestinationBuffer destination)
+ memory source, uint32_t offset, DestinationBuffer destination)
generates(Status status, uint32_t bytesWritten, string detailedError);
};
diff --git a/drm/crypto/1.0/default/CryptoPlugin.cpp b/drm/crypto/1.0/default/CryptoPlugin.cpp
index 6056f81..81365c8 100644
--- a/drm/crypto/1.0/default/CryptoPlugin.cpp
+++ b/drm/crypto/1.0/default/CryptoPlugin.cpp
@@ -54,7 +54,8 @@
const hidl_array<uint8_t, 16>& keyId,
const hidl_array<uint8_t, 16>& iv, Mode mode,
const Pattern& pattern, const hidl_vec<SubSample>& subSamples,
- const hidl_memory& source, const DestinationBuffer& destination,
+ const hidl_memory& source, uint32_t offset,
+ const DestinationBuffer& destination,
decrypt_cb _hidl_cb) {
android::CryptoPlugin::Mode legacyMode;
@@ -88,9 +89,14 @@
AString detailMessage;
- void *destPtr = NULL;
sp<IMemory> sharedSourceMemory = mapMemory(source);
+
+ void *srcPtr = static_cast<void *>(sharedSourceMemory->getPointer());
+ uint8_t *offsetSrc = static_cast<uint8_t *>(srcPtr) + offset;
+ srcPtr = static_cast<void *>(offsetSrc);
+
sp<IMemory> sharedDestinationMemory;
+ void *destPtr = NULL;
if (destination.type == BufferType::SHARED_MEMORY) {
sharedDestinationMemory = mapMemory(destination.nonsecureMemory);
@@ -102,8 +108,8 @@
destPtr = static_cast<void *>(handle);
}
ssize_t result = mLegacyPlugin->decrypt(secure, keyId.data(), iv.data(),
- legacyMode, legacyPattern, sharedSourceMemory->getPointer(),
- legacySubSamples, subSamples.size(), destPtr, &detailMessage);
+ legacyMode, legacyPattern, srcPtr, legacySubSamples,
+ subSamples.size(), destPtr, &detailMessage);
if (destination.type == BufferType::SHARED_MEMORY) {
sharedDestinationMemory->commit();
diff --git a/drm/crypto/1.0/default/CryptoPlugin.h b/drm/crypto/1.0/default/CryptoPlugin.h
index 2c3032b..b1473f1 100644
--- a/drm/crypto/1.0/default/CryptoPlugin.h
+++ b/drm/crypto/1.0/default/CryptoPlugin.h
@@ -59,7 +59,8 @@
Return<void> decrypt(bool secure, const hidl_array<uint8_t, 16>& keyId,
const hidl_array<uint8_t, 16>& iv, Mode mode, const Pattern& pattern,
const hidl_vec<SubSample>& subSamples, const hidl_memory& source,
- const DestinationBuffer& destination, decrypt_cb _hidl_cb) override;
+ uint32_t offset, const DestinationBuffer& destination,
+ decrypt_cb _hidl_cb) override;
private:
android::CryptoPlugin *mLegacyPlugin;