diff --git a/frameworks/native/camera/base/src/input/camera_manager.cpp b/frameworks/native/camera/base/src/input/camera_manager.cpp index c21a399e9f7d27aee91ec53b8e5009999e3965a5..5d34628ead33b43ae1df195ef9e6bda27b90d6c1 100644 --- a/frameworks/native/camera/base/src/input/camera_manager.cpp +++ b/frameworks/native/camera/base/src/input/camera_manager.cpp @@ -173,6 +173,15 @@ CameraManager::~CameraManager() MEDIA_INFO_LOG("CameraManager::~CameraManager() called"); RemoveServiceProxyDeathRecipient(); UnSubscribeSystemAbility(); + auto serviceProxy = GetServiceProxy(); + if (serviceProxy) { + serviceProxy->UnSetListenerObject(); + UnSetCameraServiceCallback(); + UnSetCameraMuteServiceCallback(); + UnSetTorchServiceCallback(); + UnSetFoldServiceCallback(); + UnSetControlCenterStatusCallback(); + } } int32_t CameraManager::CreateListenerObject() diff --git a/services/camera_service/idls/ICameraService.idl b/services/camera_service/idls/ICameraService.idl index 3e6db524f71f85d13bf692682235f1cb7fe5ddb1..5c0aa4d0b8a34b5d555beecac5a0af6b04228010 100644 --- a/services/camera_service/idls/ICameraService.idl +++ b/services/camera_service/idls/ICameraService.idl @@ -95,6 +95,7 @@ interface ICameraService{ [ipccode 53] void GetControlCenterStatus([out] boolean status); [ipccode 54] void CheckControlCenterPermission(); [ipccode 57] void SetUsePhysicalCameraOrientation([in] boolean isUsed); + [ipccode 58] void UnSetListenerObject(); [ipccode 101] void AllowOpenByOHSide([in] String cameraId, [in] int state, [inout] boolean canOpenCamera); [ipccode 102, oneway] void NotifyCameraState([in] String cameraId, [in] int state); [ipccode 104] void SetPeerCallback([in] ICameraBroker callbackFunc); diff --git a/services/camera_service/include/hcamera_service.h b/services/camera_service/include/hcamera_service.h index 642a7b1819375bda0e046ba301baa64ee53a9e17..9a169bf3c12c6cfda829b24a8212b90f7afac79d 100644 --- a/services/camera_service/include/hcamera_service.h +++ b/services/camera_service/include/hcamera_service.h @@ -181,6 +181,7 @@ public: int32_t Dump(int fd, const vector& args) override; int DestroyStubObj() override; int SetListenerObject(const sptr& object) override; + int UnSetListenerObject() override; CameraServiceStatus GetServiceStatus(); void SetServiceStatus(CameraServiceStatus); diff --git a/services/camera_service/src/hcamera_service.cpp b/services/camera_service/src/hcamera_service.cpp index 74e62cb5d0a7ec572a5e619dfbf170c16048f3da..2d46383481f602c7025de4995d77e07fd9d097a3 100644 --- a/services/camera_service/src/hcamera_service.cpp +++ b/services/camera_service/src/hcamera_service.cpp @@ -2468,6 +2468,13 @@ int HCameraService::SetListenerObject(const sptr& object) return CAMERA_OK; } +int HCameraService::UnSetListenerObject() +{ + pid_t pid = IPCSkeleton::GetCallingPid(); + ClearCameraListenerByPid(pid); // Ensure cleanup before starting the listener if this is the second call + return CAMERA_OK; +} + int32_t HCameraService::SaveCurrentParamForRestore(std::string cameraId, RestoreParamTypeOhos restoreParamType, int activeTime, EffectParam effectParam, sptr captureSession) {