openDecryptSession() should consistently return sp<DecryptHandle>
Test:run cts-dev --module CtsDrmTestCases -t android.drm.cts.DRMTest
bug:79378662
Change-Id: Id46e63e3e0faf76ec98a77d7d439e5ccbc85e20f
diff --git a/drm/common/include/DrmEngineBase.h b/drm/common/include/DrmEngineBase.h
index 417107f..73f11a4 100644
--- a/drm/common/include/DrmEngineBase.h
+++ b/drm/common/include/DrmEngineBase.h
@@ -59,10 +59,11 @@
int checkRightsStatus(int uniqueId, const String8& path, int action);
- status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
+ status_t consumeRights(int uniqueId, sp<DecryptHandle>& decryptHandle, int action,
+ bool reserve);
status_t setPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position);
+ int uniqueId, sp<DecryptHandle>& decryptHandle, int playbackStatus, int64_t position);
bool validateAction(
int uniqueId, const String8& path, int action, const ActionDescription& description);
@@ -80,27 +81,28 @@
DrmSupportInfo* getSupportInfo(int uniqueId);
status_t openDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle,
+ int uniqueId, sp<DecryptHandle>& decryptHandle,
int fd, off64_t offset, off64_t length, const char* mime);
status_t openDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle,
+ int uniqueId, sp<DecryptHandle>& decryptHandle,
const char* uri, const char* mime);
- status_t openDecryptSession(int uniqueId, DecryptHandle* decryptHandle,
+ status_t openDecryptSession(int uniqueId, sp<DecryptHandle>& decryptHandle,
const DrmBuffer& buf, const String8& mimeType);
- status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
+ status_t closeDecryptSession(int uniqueId, sp<DecryptHandle>& decryptHandle);
- status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+ status_t initializeDecryptUnit(int uniqueId, sp<DecryptHandle>& decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo);
- status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ status_t decrypt(int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId,
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
- status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
+ status_t finalizeDecryptUnit(int uniqueId, sp<DecryptHandle>& decryptHandle,
+ int decryptUnitId);
- ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
+ ssize_t pread(int uniqueId, sp<DecryptHandle>& decryptHandle,
void* buffer, ssize_t numBytes, off64_t offset);
protected:
@@ -265,7 +267,7 @@
* @return status_t
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual status_t onConsumeRights(int uniqueId, DecryptHandle* decryptHandle,
+ virtual status_t onConsumeRights(int uniqueId, sp<DecryptHandle>& decryptHandle,
int action, bool reserve) = 0;
/**
@@ -280,7 +282,8 @@
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
virtual status_t onSetPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) = 0;
+ int uniqueId, sp<DecryptHandle>& decryptHandle, int playbackStatus,
+ int64_t position) = 0;
/**
* Validates whether an action on the DRM content is allowed or not.
@@ -381,7 +384,7 @@
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
*/
virtual status_t onOpenDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle,
+ int uniqueId, sp<DecryptHandle>& decryptHandle,
int fd, off64_t offset, off64_t length) = 0;
/**
@@ -398,7 +401,7 @@
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
*/
virtual status_t onOpenDecryptSession(
- int /* uniqueId */, DecryptHandle* /* decryptHandle */,
+ int /* uniqueId */, sp<DecryptHandle>& /* decryptHandle */,
int /* fd */, off64_t /* offset */, off64_t /* length */,
const char* /* mime */) {
@@ -415,7 +418,7 @@
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
*/
virtual status_t onOpenDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle,
+ int uniqueId, sp<DecryptHandle>& decryptHandle,
const char* uri) = 0;
/**
@@ -430,7 +433,7 @@
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
*/
virtual status_t onOpenDecryptSession(
- int /* uniqueId */, DecryptHandle* /* decryptHandle */,
+ int /* uniqueId */, sp<DecryptHandle>& /* decryptHandle */,
const char* /* uri */, const char* /* mime */) {
return DRM_ERROR_CANNOT_HANDLE;
@@ -447,7 +450,7 @@
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
*/
virtual status_t onOpenDecryptSession(int /* uniqueId */,
- DecryptHandle* /* decryptHandle */,
+ sp<DecryptHandle>& /* decryptHandle */,
const DrmBuffer& /* buf */,
const String8& /* mimeType */) {
return DRM_ERROR_CANNOT_HANDLE;
@@ -461,7 +464,7 @@
* @return status_t
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual status_t onCloseDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
+ virtual status_t onCloseDecryptSession(int uniqueId, sp<DecryptHandle>& decryptHandle) = 0;
/**
* Initialize decryption for the given unit of the protected content
@@ -473,7 +476,7 @@
* @return status_t
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual status_t onInitializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+ virtual status_t onInitializeDecryptUnit(int uniqueId, sp<DecryptHandle>& decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo) = 0;
/**
@@ -493,7 +496,7 @@
* DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED,
* DRM_ERROR_DECRYPT for failure.
*/
- virtual status_t onDecrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ virtual status_t onDecrypt(int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId,
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) = 0;
/**
@@ -506,7 +509,7 @@
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
virtual status_t onFinalizeDecryptUnit(
- int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
+ int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId) = 0;
/**
* Reads the specified number of bytes from an open DRM file.
@@ -519,7 +522,7 @@
*
* @return Number of bytes read. Returns -1 for Failure.
*/
- virtual ssize_t onPread(int uniqueId, DecryptHandle* decryptHandle,
+ virtual ssize_t onPread(int uniqueId, sp<DecryptHandle>& decryptHandle,
void* buffer, ssize_t numBytes, off64_t offset) = 0;
};
diff --git a/drm/common/include/IDrmEngine.h b/drm/common/include/IDrmEngine.h
index acc8ed9..1837a11 100644
--- a/drm/common/include/IDrmEngine.h
+++ b/drm/common/include/IDrmEngine.h
@@ -210,7 +210,7 @@
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
virtual status_t consumeRights(
- int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) = 0;
+ int uniqueId, sp<DecryptHandle>& decryptHandle, int action, bool reserve) = 0;
/**
* Informs the DRM Engine about the playback actions performed on the DRM files.
@@ -223,7 +223,7 @@
* @return status_t
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual status_t setPlaybackStatus(int uniqueId, DecryptHandle* decryptHandle,
+ virtual status_t setPlaybackStatus(int uniqueId, sp<DecryptHandle>& decryptHandle,
int playbackStatus, int64_t position) = 0;
/**
@@ -327,7 +327,7 @@
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
*/
virtual status_t openDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle,
+ int uniqueId, sp<DecryptHandle>& decryptHandle,
int fd, off64_t offset, off64_t length, const char* mime) = 0;
/**
@@ -342,7 +342,7 @@
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
*/
virtual status_t openDecryptSession(
- int uniqueId, DecryptHandle* decryptHandle,
+ int uniqueId, sp<DecryptHandle>& decryptHandle,
const char* uri, const char* mime) = 0;
/**
@@ -355,7 +355,7 @@
* @return
* DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success
*/
- virtual status_t openDecryptSession(int uniqueId, DecryptHandle* decryptHandle,
+ virtual status_t openDecryptSession(int uniqueId, sp<DecryptHandle>& decryptHandle,
const DrmBuffer& buf, const String8& mimeType) = 0;
/**
@@ -366,7 +366,7 @@
* @return status_t
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
+ virtual status_t closeDecryptSession(int uniqueId, sp<DecryptHandle>& decryptHandle) = 0;
/**
* Initialize decryption for the given unit of the protected content
@@ -378,7 +378,7 @@
* @return status_t
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
- virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+ virtual status_t initializeDecryptUnit(int uniqueId, sp<DecryptHandle>& decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo) = 0;
/**
@@ -398,7 +398,7 @@
* DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED,
* DRM_ERROR_DECRYPT for failure.
*/
- virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ virtual status_t decrypt(int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId,
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) = 0;
/**
@@ -411,7 +411,7 @@
* Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure
*/
virtual status_t finalizeDecryptUnit(
- int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
+ int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId) = 0;
/**
* Reads the specified number of bytes from an open DRM file.
@@ -424,7 +424,7 @@
*
* @return Number of bytes read. Returns -1 for Failure.
*/
- virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
+ virtual ssize_t pread(int uniqueId, sp<DecryptHandle>& decryptHandle,
void* buffer, ssize_t numBytes, off64_t offset) = 0;
};
diff --git a/drm/common/include/IDrmManagerService.h b/drm/common/include/IDrmManagerService.h
index 0376b49..836ae0a 100644
--- a/drm/common/include/IDrmManagerService.h
+++ b/drm/common/include/IDrmManagerService.h
@@ -115,10 +115,11 @@
virtual int checkRightsStatus(int uniqueId, const String8& path, int action) = 0;
virtual status_t consumeRights(
- int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) = 0;
+ int uniqueId, sp<DecryptHandle>& decryptHandle, int action, bool reserve) = 0;
virtual status_t setPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) = 0;
+ int uniqueId, sp<DecryptHandle>& decryptHandle, int playbackStatus,
+ int64_t position) = 0;
virtual bool validateAction(
int uniqueId, const String8& path,
@@ -138,28 +139,28 @@
virtual status_t getAllSupportInfo(
int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) = 0;
- virtual DecryptHandle* openDecryptSession(
+ virtual sp<DecryptHandle> openDecryptSession(
int uniqueId, int fd, off64_t offset,
off64_t length, const char* mime) = 0;
- virtual DecryptHandle* openDecryptSession(
+ virtual sp<DecryptHandle> openDecryptSession(
int uniqueId, const char* uri, const char* mime) = 0;
- virtual DecryptHandle* openDecryptSession(
+ virtual sp<DecryptHandle> openDecryptSession(
int uniqueId, const DrmBuffer& buf, const String8& mimeType) = 0;
- virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) = 0;
+ virtual status_t closeDecryptSession(int uniqueId, sp<DecryptHandle>& decryptHandle) = 0;
- virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+ virtual status_t initializeDecryptUnit(int uniqueId, sp<DecryptHandle>& decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo) = 0;
- virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ virtual status_t decrypt(int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId,
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) = 0;
virtual status_t finalizeDecryptUnit(
- int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0;
+ int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId) = 0;
- virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
+ virtual ssize_t pread(int uniqueId, sp<DecryptHandle>& decryptHandle,
void* buffer, ssize_t numBytes,off64_t offset) = 0;
};
@@ -203,10 +204,10 @@
virtual int checkRightsStatus(int uniqueId, const String8& path, int action);
virtual status_t consumeRights(
- int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve);
+ int uniqueId, sp<DecryptHandle>& decryptHandle, int action, bool reserve);
virtual status_t setPlaybackStatus(
- int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position);
+ int uniqueId, sp<DecryptHandle>& decryptHandle, int playbackStatus, int64_t position);
virtual bool validateAction(
int uniqueId, const String8& path, int action, const ActionDescription& description);
@@ -225,28 +226,28 @@
virtual status_t getAllSupportInfo(
int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray);
- virtual DecryptHandle* openDecryptSession(
+ virtual sp<DecryptHandle> openDecryptSession(
int uniqueId, int fd, off64_t offset, off64_t length,
const char* mime);
- virtual DecryptHandle* openDecryptSession(
+ virtual sp<DecryptHandle> openDecryptSession(
int uniqueId, const char* uri, const char* mime);
- virtual DecryptHandle* openDecryptSession(
+ virtual sp<DecryptHandle> openDecryptSession(
int uniqueId, const DrmBuffer& buf, const String8& mimeType);
- virtual status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle);
+ virtual status_t closeDecryptSession(int uniqueId, sp<DecryptHandle>& decryptHandle);
- virtual status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle,
+ virtual status_t initializeDecryptUnit(int uniqueId, sp<DecryptHandle>& decryptHandle,
int decryptUnitId, const DrmBuffer* headerInfo);
- virtual status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId,
+ virtual status_t decrypt(int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId,
const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV);
virtual status_t finalizeDecryptUnit(
- int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId);
+ int uniqueId, sp<DecryptHandle>& decryptHandle, int decryptUnitId);
- virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
+ virtual ssize_t pread(int uniqueId, sp<DecryptHandle>& decryptHandle,
void* buffer, ssize_t numBytes, off64_t offset);
};