diff --git a/frameworks/native/capi/screencapture/native_avscreen_capture.cpp b/frameworks/native/capi/screencapture/native_avscreen_capture.cpp index c23e2fe12acc9d29fee40628d84d07a8835be97f..666ae2bac8b0fc961150246b39f70a5b7f5524dd 100644 --- a/frameworks/native/capi/screencapture/native_avscreen_capture.cpp +++ b/frameworks/native/capi/screencapture/native_avscreen_capture.cpp @@ -747,6 +747,7 @@ OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetStateCallback(struct OH_AVScre OH_AVScreenCapture_OnStateChange callback, void *userData) { CHECK_AND_RETURN_RET_LOG(capture != nullptr, AV_SCREEN_CAPTURE_ERR_INVALID_VAL, "input capture is nullptr!"); + CHECK_AND_RETURN_RET_LOG(callback != nullptr, AV_SCREEN_CAPTURE_ERR_INVALID_VAL, "input stateCallback is nullptr!"); struct ScreenCaptureObject *screenCaptureObj = reinterpret_cast(capture); CHECK_AND_RETURN_RET_LOG(screenCaptureObj->screenCapture_ != nullptr, AV_SCREEN_CAPTURE_ERR_INVALID_VAL, "screenCapture_ is null"); @@ -765,6 +766,7 @@ OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetErrorCallback(struct OH_AVScre OH_AVScreenCapture_OnError callback, void *userData) { CHECK_AND_RETURN_RET_LOG(capture != nullptr, AV_SCREEN_CAPTURE_ERR_INVALID_VAL, "input capture is nullptr!"); + CHECK_AND_RETURN_RET_LOG(callback != nullptr, AV_SCREEN_CAPTURE_ERR_INVALID_VAL, "input errorCallback is nullptr!"); struct ScreenCaptureObject *screenCaptureObj = reinterpret_cast(capture); CHECK_AND_RETURN_RET_LOG(screenCaptureObj->screenCapture_ != nullptr, AV_SCREEN_CAPTURE_ERR_INVALID_VAL, "screenCapture_ is null"); @@ -782,6 +784,7 @@ OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SetDataCallback(struct OH_AVScree OH_AVScreenCapture_OnBufferAvailable callback, void *userData) { CHECK_AND_RETURN_RET_LOG(capture != nullptr, AV_SCREEN_CAPTURE_ERR_INVALID_VAL, "input capture is nullptr!"); + CHECK_AND_RETURN_RET_LOG(callback != nullptr, AV_SCREEN_CAPTURE_ERR_INVALID_VAL, "input dataCallback is nullptr!"); struct ScreenCaptureObject *screenCaptureObj = reinterpret_cast(capture); CHECK_AND_RETURN_RET_LOG(screenCaptureObj->screenCapture_ != nullptr, AV_SCREEN_CAPTURE_ERR_INVALID_VAL, "screenCapture_ is null"); diff --git a/frameworks/native/screen_capture/screen_capture_impl.cpp b/frameworks/native/screen_capture/screen_capture_impl.cpp index facc593f3af6f8144863b33567ce00bf281b18bf..c25f8316f1798f5350477044a2581977e74d6969 100644 --- a/frameworks/native/screen_capture/screen_capture_impl.cpp +++ b/frameworks/native/screen_capture/screen_capture_impl.cpp @@ -69,7 +69,7 @@ ScreenCaptureImpl::~ScreenCaptureImpl() int32_t ScreenCaptureImpl::Release() { - MEDIA_LOGD("ScreenCaptureImpl:0x%{public}06" PRIXPTR " CheckScreenCapturePermssion in", FAKE_POINTER(this)); + MEDIA_LOGD("ScreenCaptureImpl:0x%{public}06" PRIXPTR " Release in", FAKE_POINTER(this)); CHECK_AND_RETURN_RET_LOG(screenCaptureService_ != nullptr, MSERR_NO_MEMORY, "screen capture service does not exist.."); screenCaptureService_->Release(); diff --git a/test/unittest/screen_capture_test/capi/src/screen_capture_capi_mock.cpp b/test/unittest/screen_capture_test/capi/src/screen_capture_capi_mock.cpp index fb6ce9d01a4221c519e84b9ebe87f4b18eafdf8f..0f61445799d5fdf3f18e8469568c648a3b62eef6 100644 --- a/test/unittest/screen_capture_test/capi/src/screen_capture_capi_mock.cpp +++ b/test/unittest/screen_capture_test/capi/src/screen_capture_capi_mock.cpp @@ -191,7 +191,9 @@ int32_t ScreenCaptureCapiMock::Release() { UNITTEST_CHECK_AND_RETURN_RET_LOG(screenCapture_ != nullptr, MSERR_INVALID_OPERATION, "screenCapture_ == nullptr"); DelCallback(screenCapture_); - return OH_AVScreenCapture_Release(screenCapture_); + int32_t ret = OH_AVScreenCapture_Release(screenCapture_); + screenCapture_ = nullptr; + return ret; } int32_t ScreenCaptureCapiMock::SetMicrophoneEnabled(bool isMicrophone)