diff --git a/drm/drmserver/DrmManager.cpp b/drm/drmserver/DrmManager.cpp index 537791c95e..49df1c8f4b 100644 --- a/drm/drmserver/DrmManager.cpp +++ b/drm/drmserver/DrmManager.cpp @@ -117,7 +117,11 @@ status_t DrmManager::unloadPlugIns() { status_t DrmManager::setDrmServiceListener( int uniqueId, const sp& drmServiceListener) { Mutex::Autolock _l(mLock); - mServiceListeners.add(uniqueId, drmServiceListener); + if (NULL != drmServiceListener.get()) { + mServiceListeners.add(uniqueId, drmServiceListener); + } else { + mServiceListeners.removeItem(uniqueId); + } return DRM_NO_ERROR; } diff --git a/drm/libdrmframework/DrmManagerClient.cpp b/drm/libdrmframework/DrmManagerClient.cpp index fa3d52ad1a..8bb00c3a32 100644 --- a/drm/libdrmframework/DrmManagerClient.cpp +++ b/drm/libdrmframework/DrmManagerClient.cpp @@ -31,6 +31,7 @@ DrmManagerClient::DrmManagerClient(): DrmManagerClient::~DrmManagerClient() { DrmManagerClientImpl::remove(mUniqueId); mDrmManagerClientImpl->removeClient(mUniqueId); + mDrmManagerClientImpl->setOnInfoListener(mUniqueId, NULL); delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL; } diff --git a/drm/libdrmframework/DrmManagerClientImpl.cpp b/drm/libdrmframework/DrmManagerClientImpl.cpp index 32fa4919e9..eea312b5ed 100644 --- a/drm/libdrmframework/DrmManagerClientImpl.cpp +++ b/drm/libdrmframework/DrmManagerClientImpl.cpp @@ -81,7 +81,8 @@ status_t DrmManagerClientImpl::setOnInfoListener( int uniqueId, const sp& infoListener) { Mutex::Autolock _l(mLock); mOnInfoListener = infoListener; - return getDrmManagerService()->setDrmServiceListener(uniqueId, this); + return getDrmManagerService()->setDrmServiceListener(uniqueId, + (NULL != infoListener.get()) ? this : NULL); } status_t DrmManagerClientImpl::installDrmEngine(int uniqueId, const String8& drmEngineFile) { diff --git a/include/drm/DrmManagerClient.h b/include/drm/DrmManagerClient.h index 3dbfbe204d..004556f1d2 100644 --- a/include/drm/DrmManagerClient.h +++ b/include/drm/DrmManagerClient.h @@ -48,6 +48,9 @@ public: public: class OnInfoListener: virtual public RefBase { + public: + virtual ~OnInfoListener() {} + public: virtual void onInfo(const DrmInfoEvent& event) = 0; };