diff options
author | Kei Takahashi <KeiA.Takahashi@jp.sony.com> | 2012-01-31 13:18:45 +0900 |
---|---|---|
committer | Kei Takahashi <KeiA.Takahashi@jp.sony.com> | 2012-02-29 12:59:53 +0900 |
commit | 6225df010365d00b1d0f3b1ca13f18cea537c8e3 (patch) | |
tree | f8ec6b625745c57b4a0dbe6aab02072cf10be8d4 /drm/jni | |
parent | d7fa7deef9bc0cf22bf450fdb062327697c087c4 (diff) | |
download | frameworks_base-6225df010365d00b1d0f3b1ca13f18cea537c8e3.zip frameworks_base-6225df010365d00b1d0f3b1ca13f18cea537c8e3.tar.gz frameworks_base-6225df010365d00b1d0f3b1ca13f18cea537c8e3.tar.bz2 |
DRM framwork bug fix: add an API to release resources
When DrmManagerClient object is created and released many times,
the process suddenly crashes.
The case can happen when we make many thumbnails of
DRM-encrypted contents.
The problem is caused by shortage of file descriptors.
DrmManagerClient releases references of file descriptors
only when GC runs. So file descriptors are kept long time
even after the reference of DrmManagerClient are released.
By introducing DrmManagerClient#release() API,
the problem is solved. An application call this API
when we no longer need to use DrmManagerClient object.
Changes are made by SEMC and Sony.
Change-Id: Ie0bbc29cc33872449824285a8d67b1c3cdd8082b
Diffstat (limited to 'drm/jni')
-rw-r--r-- | drm/jni/android_drm_DrmManagerClient.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/drm/jni/android_drm_DrmManagerClient.cpp b/drm/jni/android_drm_DrmManagerClient.cpp index dfc7fb2..cf58177 100644 --- a/drm/jni/android_drm_DrmManagerClient.cpp +++ b/drm/jni/android_drm_DrmManagerClient.cpp @@ -225,25 +225,32 @@ static sp<DrmManagerClientImpl> getDrmManagerClientImpl(JNIEnv* env, jobject thi } static jint android_drm_DrmManagerClient_initialize( - JNIEnv* env, jobject thiz, jobject weak_thiz) { + JNIEnv* env, jobject thiz) { ALOGV("initialize - Enter"); int uniqueId = 0; sp<DrmManagerClientImpl> drmManager = DrmManagerClientImpl::create(&uniqueId, false); drmManager->addClient(uniqueId); - // Set the listener to DrmManager - sp<DrmManagerClient::OnInfoListener> listener = new JNIOnInfoListener(env, thiz, weak_thiz); - drmManager->setOnInfoListener(uniqueId, listener); - setDrmManagerClientImpl(env, thiz, drmManager); ALOGV("initialize - Exit"); - return uniqueId; } -static void android_drm_DrmManagerClient_finalize(JNIEnv* env, jobject thiz, jint uniqueId) { - ALOGV("finalize - Enter"); +static void android_drm_DrmManagerClient_setListeners( + JNIEnv* env, jobject thiz, jint uniqueId, jobject weak_thiz) { + ALOGV("setListeners - Enter"); + + // Set the listener to DrmManager + sp<DrmManagerClient::OnInfoListener> listener = new JNIOnInfoListener(env, thiz, weak_thiz); + getDrmManagerClientImpl(env, thiz)->setOnInfoListener(uniqueId, listener); + + ALOGV("setListeners - Exit"); +} + +static void android_drm_DrmManagerClient_release( + JNIEnv* env, jobject thiz, jint uniqueId) { + ALOGV("release - Enter"); DrmManagerClientImpl::remove(uniqueId); getDrmManagerClientImpl(env, thiz)->setOnInfoListener(uniqueId, NULL); @@ -252,7 +259,7 @@ static void android_drm_DrmManagerClient_finalize(JNIEnv* env, jobject thiz, jin oldClient->setOnInfoListener(uniqueId, NULL); oldClient->removeClient(uniqueId); } - ALOGV("finalize - Exit"); + ALOGV("release - Exit"); } static jobject android_drm_DrmManagerClient_getConstraintsFromContent( @@ -714,11 +721,14 @@ static jobject android_drm_DrmManagerClient_closeConvertSession( static JNINativeMethod nativeMethods[] = { - {"_initialize", "(Ljava/lang/Object;)I", + {"_initialize", "()I", (void*)android_drm_DrmManagerClient_initialize}, - {"_finalize", "(I)V", - (void*)android_drm_DrmManagerClient_finalize}, + {"_setListeners", "(ILjava/lang/Object;)V", + (void*)android_drm_DrmManagerClient_setListeners}, + + {"_release", "(I)V", + (void*)android_drm_DrmManagerClient_release}, {"_getConstraints", "(ILjava/lang/String;I)Landroid/content/ContentValues;", (void*)android_drm_DrmManagerClient_getConstraintsFromContent}, |