diff --git a/frameworks/native/drm/key_session_impl.cpp b/frameworks/native/drm/key_session_impl.cpp index 83fb8a35..b8e3a5ac 100644 --- a/frameworks/native/drm/key_session_impl.cpp +++ b/frameworks/native/drm/key_session_impl.cpp @@ -39,24 +39,6 @@ MediaKeySessionImpl::MediaKeySessionImpl(sptr &keySessi DRM_ERR_LOG("failed to add deathRecipient"); return; } - - CreateListenerObject(); -} - -int32_t MediaKeySessionImpl::CreateListenerObject() -{ - DRM_INFO_LOG("CreateListenerObject"); - std::lock_guard lock(mutex_); - listenerStub_ = new(std::nothrow) DrmListenerStub(); - DRM_CHECK_AND_RETURN_RET_LOG(listenerStub_ != nullptr, DRM_MEMORY_ERROR, - "failed to new DrmListenerStub object"); - DRM_CHECK_AND_RETURN_RET_LOG(keySessionServiceProxy_ != nullptr, DRM_MEMORY_ERROR, - "Drm service does not exist."); - - sptr object = listenerStub_->AsObject(); - DRM_CHECK_AND_RETURN_RET_LOG(object != nullptr, DRM_MEMORY_ERROR, "listener object is nullptr."); - - return keySessionServiceProxy_->SetListenerObject(object); } MediaKeySessionImpl::~MediaKeySessionImpl() @@ -78,7 +60,6 @@ void MediaKeySessionImpl::MediaKeySessionServerDied(pid_t pid) (void)keySessionServiceProxy_->AsObject()->RemoveDeathRecipient(deathRecipient_); keySessionServiceProxy_ = nullptr; } - listenerStub_ = nullptr; deathRecipient_ = nullptr; } diff --git a/frameworks/native/drm/media_key_system_impl.cpp b/frameworks/native/drm/media_key_system_impl.cpp index 490c494b..b66df794 100644 --- a/frameworks/native/drm/media_key_system_impl.cpp +++ b/frameworks/native/drm/media_key_system_impl.cpp @@ -39,8 +39,6 @@ MediaKeySystemImpl::MediaKeySystemImpl(sptr &mediaKeysys DRM_ERR_LOG("failed to add deathRecipient"); return; } - - CreateListenerObject(); } MediaKeySystemImpl::~MediaKeySystemImpl() @@ -58,23 +56,6 @@ void MediaKeySystemImpl::MediaKeySystemServerDied(pid_t pid) serviceProxy_ = nullptr; deathRecipient_ = nullptr; } - listenerStub_ = nullptr; -} - -int32_t MediaKeySystemImpl::CreateListenerObject() -{ - DRM_INFO_LOG("CreateListenerObject"); - std::lock_guard lock(mutex_); - listenerStub_ = new(std::nothrow) DrmListenerStub(); - DRM_CHECK_AND_RETURN_RET_LOG(listenerStub_ != nullptr, DRM_MEMORY_ERROR, - "failed to new DrmListenerStub object"); - DRM_CHECK_AND_RETURN_RET_LOG(serviceProxy_ != nullptr, DRM_MEMORY_ERROR, - "Drm service does not exist."); - - sptr object = listenerStub_->AsObject(); - DRM_CHECK_AND_RETURN_RET_LOG(object != nullptr, DRM_MEMORY_ERROR, "listener object is nullptr."); - - return serviceProxy_->SetListenerObject(object); } int32_t MediaKeySystemImpl::Release() diff --git a/interfaces/inner_api/native/drm/key_session_impl.h b/interfaces/inner_api/native/drm/key_session_impl.h index ed5b3258..b131e57b 100644 --- a/interfaces/inner_api/native/drm/key_session_impl.h +++ b/interfaces/inner_api/native/drm/key_session_impl.h @@ -72,14 +72,12 @@ public: int32_t RequireSecureDecoderModule(std::string &mimeType, bool *status); private: - int32_t CreateListenerObject(); void MediaKeySessionServerDied(pid_t pid); sptr keySessionApplicationCallback_; sptr keySessionServiceCallback_; sptr keySessionServiceProxy_; std::recursive_mutex mutex_; sptr deathRecipient_ = nullptr; - sptr listenerStub_ = nullptr; }; class MediaKeySessionServiceCallback : public MediaKeySessionServiceCallbackStub { diff --git a/interfaces/inner_api/native/drm/media_key_system_impl.h b/interfaces/inner_api/native/drm/media_key_system_impl.h index 926e5b62..8cb4731b 100644 --- a/interfaces/inner_api/native/drm/media_key_system_impl.h +++ b/interfaces/inner_api/native/drm/media_key_system_impl.h @@ -68,13 +68,11 @@ public: private: void MediaKeySystemServerDied(pid_t pid); - int32_t CreateListenerObject(); std::recursive_mutex mutex_; sptr serviceProxy_; sptr mediaKeySystemApplicationCallback_; sptr serviceCallback_; sptr deathRecipient_ = nullptr; - sptr listenerStub_ = nullptr; }; class MediaKeySystemCallback : public MediaKeySystemServiceCallbackStub { diff --git a/services/drm_service/client/include/media_decrypt_module_service_proxy.h b/services/drm_service/client/include/media_decrypt_module_service_proxy.h index 65d63b24..9cd3b400 100644 --- a/services/drm_service/client/include/media_decrypt_module_service_proxy.h +++ b/services/drm_service/client/include/media_decrypt_module_service_proxy.h @@ -28,7 +28,6 @@ public: explicit MediaDecryptModuleServiceProxy(const sptr &impl); virtual ~MediaDecryptModuleServiceProxy() = default; int32_t Release() override; - int32_t SetListenerObject(const sptr &object) override; int32_t DecryptMediaData(bool secureDecodrtState, IMediaDecryptModuleService::CryptInfo &cryptInfo, IMediaDecryptModuleService::DrmBuffer &srcBuffer, IMediaDecryptModuleService::DrmBuffer &dstBuffer) override; diff --git a/services/drm_service/client/src/media_decrypt_module_service_proxy.cpp b/services/drm_service/client/src/media_decrypt_module_service_proxy.cpp index e065558c..66701ceb 100644 --- a/services/drm_service/client/src/media_decrypt_module_service_proxy.cpp +++ b/services/drm_service/client/src/media_decrypt_module_service_proxy.cpp @@ -44,23 +44,6 @@ int32_t MediaDecryptModuleServiceProxy::Release() return ret; } -int32_t MediaDecryptModuleServiceProxy::SetListenerObject(const sptr &object) -{ - DRM_INFO_LOG("SetListenerObject enter."); - MessageParcel data; - MessageParcel reply; - MessageOption option; - - data.WriteInterfaceToken(GetDescriptor()); - (void)data.WriteRemoteObject(object); - int ret = Remote()->SendRequest(DECRYPT_MODULE_SET_LISTENER_OBJ, data, reply, option); - if (ret != DRM_OK) { - DRM_ERR_LOG("Set listener obj failed, errcode: %{public}d", ret); - return IPC_PROXY_ERR; - } - return reply.ReadInt32(); -} - int32_t MediaDecryptModuleServiceProxy::ProcessDrmBuffer(MessageParcel &data, IMediaDecryptModuleService::DrmBuffer &srcBuffer, IMediaDecryptModuleService::DrmBuffer &dstBuffer) { diff --git a/services/drm_service/ipc/i_mediadecryptmodule_service.h b/services/drm_service/ipc/i_mediadecryptmodule_service.h index 40a5e194..ab9aad03 100644 --- a/services/drm_service/ipc/i_mediadecryptmodule_service.h +++ b/services/drm_service/ipc/i_mediadecryptmodule_service.h @@ -64,7 +64,6 @@ public: virtual ~IMediaDecryptModuleService() = default; virtual int32_t Release() = 0; - virtual int32_t SetListenerObject(const sptr &object) = 0; virtual int32_t DecryptMediaData(bool secureDecodrtState, IMediaDecryptModuleService::CryptInfo &cryptInfo, DrmBuffer &srcBuffer, DrmBuffer &dstBuffer) = 0; DECLARE_INTERFACE_DESCRIPTOR(u"IMediaDecryptModuleService"); diff --git a/services/drm_service/ipc/remote_request_code.h b/services/drm_service/ipc/remote_request_code.h index d8c360df..48533438 100644 --- a/services/drm_service/ipc/remote_request_code.h +++ b/services/drm_service/ipc/remote_request_code.h @@ -63,8 +63,7 @@ enum MediaKeySessionServiceRequestCode { enum MediaDecryptModuleServiceRequestCode { DECRYPT_MODULE_DECRYPT_DATA = 0, - DECRYPT_MODULE_SET_LISTENER_OBJ = 1, - DECRYPT_MODULE_RELEASE = 2, + DECRYPT_MODULE_RELEASE = 1, }; enum MediaKeySessionServiceCallbackRequestCode { diff --git a/services/drm_service/server/include/media_decrypt_module_service_stub.h b/services/drm_service/server/include/media_decrypt_module_service_stub.h index 2c998bf0..ff52bc47 100644 --- a/services/drm_service/server/include/media_decrypt_module_service_stub.h +++ b/services/drm_service/server/include/media_decrypt_module_service_stub.h @@ -35,8 +35,6 @@ public: virtual int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; - int32_t SetListenerObject(const sptr &object) override; - private: void MediaDecryptModuleClientDied(pid_t pid); std::recursive_mutex decryptModuleStubMutex_; diff --git a/services/drm_service/server/src/drm_host_manager.cpp b/services/drm_service/server/src/drm_host_manager.cpp index bdd0aa26..e3ae4855 100644 --- a/services/drm_service/server/src/drm_host_manager.cpp +++ b/services/drm_service/server/src/drm_host_manager.cpp @@ -462,6 +462,7 @@ void DrmHostManager::ReleaseSevices(sptr drmHostServiePr remote->RemoveDeathRecipient(drmHostDeathRecipientMap[drmHostServieProxy]); drmHostDeathRecipientMap[drmHostServieProxy] = nullptr; } + drmHostDeathRecipientMap.erase(drmHostServieProxy); std::string name = hdiMediaKeySystemFactoryAndPluginNameMap[drmHostServieProxy]; /* No need to release non lazy loading */ if (lazyLoadPluginInfoMap.count(name) <= 0) { diff --git a/services/drm_service/server/src/media_decrypt_module_service_stub.cpp b/services/drm_service/server/src/media_decrypt_module_service_stub.cpp index 143edcb1..4f5d7109 100644 --- a/services/drm_service/server/src/media_decrypt_module_service_stub.cpp +++ b/services/drm_service/server/src/media_decrypt_module_service_stub.cpp @@ -44,33 +44,6 @@ void MediaDecryptModuleServiceStub::MediaDecryptModuleClientDied(pid_t pid) } } -int32_t MediaDecryptModuleServiceStub::SetListenerObject(const sptr &object) -{ - pid_t pid = IPCSkeleton::GetCallingPid(); - std::lock_guard lock(decryptModuleStubMutex_); - if (clientListener_ != nullptr && clientListener_->AsObject() != nullptr && deathRecipient_ != nullptr) { - DRM_DEBUG_LOG("This MediaDecryptModuleServiceStub has already set listener!"); - (void)clientListener_->AsObject()->RemoveDeathRecipient(deathRecipient_); - deathRecipient_ = nullptr; - clientListener_ = nullptr; - } - - DRM_CHECK_AND_RETURN_RET_LOG(object != nullptr, DRM_MEMORY_ERROR, "set listener object is nullptr"); - sptr clientListener_ = iface_cast(object); - DRM_CHECK_AND_RETURN_RET_LOG( - clientListener_ != nullptr, DRM_MEMORY_ERROR, "failed to convert IDrmListener"); - deathRecipient_ = new (std::nothrow) DrmDeathRecipient(pid); - DRM_CHECK_AND_RETURN_RET_LOG(deathRecipient_ != nullptr, DRM_MEMORY_ERROR, "failed to new DrmDeathRecipient"); - deathRecipient_->SetNotifyCb([this] (pid_t pid) { - this->MediaDecryptModuleClientDied(pid); - }); - if (clientListener_->AsObject() != nullptr) { - (void)clientListener_->AsObject()->AddDeathRecipient(deathRecipient_); - } - DRM_DEBUG_LOG("MediaDecryptModule client pid:%{public}d", pid); - return DRM_OK; -} - int32_t MediaDecryptModuleServiceStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { @@ -139,12 +112,6 @@ int32_t MediaDecryptModuleServiceStub::OnRemoteRequest(uint32_t code, MessagePar } return ret; } - case DECRYPT_MODULE_SET_LISTENER_OBJ: { - DRM_INFO_LOG("DECRYPT_MODULE_SET_LISTENER_OBJ enter."); - sptr object = data.ReadRemoteObject(); - int32_t ret = SetListenerObject(object); - return ret; - } case DECRYPT_MODULE_RELEASE: { DRM_INFO_LOG("MediaDecryptModuleServiceStub DECRYPT_MODULE_RELEASE enter."); int32_t ret = Release();