diff --git a/camera/provider/2.4/default/ExternalCameraProviderImpl_2_4.cpp b/camera/provider/2.4/default/ExternalCameraProviderImpl_2_4.cpp index 04db7f33ee..2d919cccff 100644 --- a/camera/provider/2.4/default/ExternalCameraProviderImpl_2_4.cpp +++ b/camera/provider/2.4/default/ExternalCameraProviderImpl_2_4.cpp @@ -95,13 +95,14 @@ ExternalCameraProviderImpl_2_4::~ExternalCameraProviderImpl_2_4() { Return ExternalCameraProviderImpl_2_4::setCallback( const sp& callback) { + if (callback == nullptr) { + return Status::ILLEGAL_ARGUMENT; + } + { Mutex::Autolock _l(mLock); mCallbacks = callback; } - if (mCallbacks == nullptr) { - return Status::OK; - } // Send a callback for all devices to initialize { for (const auto& pair : mCameraStatusMap) { diff --git a/camera/provider/2.4/default/LegacyCameraProviderImpl_2_4.cpp b/camera/provider/2.4/default/LegacyCameraProviderImpl_2_4.cpp index 69318c7368..07ed689c98 100644 --- a/camera/provider/2.4/default/LegacyCameraProviderImpl_2_4.cpp +++ b/camera/provider/2.4/default/LegacyCameraProviderImpl_2_4.cpp @@ -448,11 +448,11 @@ bool LegacyCameraProviderImpl_2_4::setUpVendorTags() { // Methods from ::android::hardware::camera::provider::V2_4::ICameraProvider follow. Return LegacyCameraProviderImpl_2_4::setCallback( const sp& callback) { + if (callback == nullptr) { + return Status::ILLEGAL_ARGUMENT; + } Mutex::Autolock _l(mCbLock); mCallbacks = callback; - if (mCallbacks == nullptr) { - return Status::OK; - } // Add and report all presenting external cameras. for (auto const& statusPair : mCameraStatusMap) { int id = std::stoi(statusPair.first); diff --git a/camera/provider/2.7/default/ExternalCameraProviderImpl_2_7.cpp b/camera/provider/2.7/default/ExternalCameraProviderImpl_2_7.cpp index 62ce074404..eba49a5649 100644 --- a/camera/provider/2.7/default/ExternalCameraProviderImpl_2_7.cpp +++ b/camera/provider/2.7/default/ExternalCameraProviderImpl_2_7.cpp @@ -91,11 +91,11 @@ ExternalCameraProviderImpl_2_7::~ExternalCameraProviderImpl_2_7() { Return ExternalCameraProviderImpl_2_7::setCallback( const sp& callback) { + if (callback == nullptr) { + return Status::ILLEGAL_ARGUMENT; + } Mutex::Autolock _l(mLock); mCallbacks = callback; - if (mCallbacks == nullptr) { - return Status::OK; - } // Send a callback for all devices to initialize { for (const auto& pair : mCameraStatusMap) { diff --git a/camera/provider/default/ExternalCameraProvider.cpp b/camera/provider/default/ExternalCameraProvider.cpp index 4d2c847255..54875abb20 100644 --- a/camera/provider/default/ExternalCameraProvider.cpp +++ b/camera/provider/default/ExternalCameraProvider.cpp @@ -75,15 +75,15 @@ ExternalCameraProvider::~ExternalCameraProvider() { ndk::ScopedAStatus ExternalCameraProvider::setCallback( const std::shared_ptr& in_callback) { + if (in_callback == nullptr) { + return fromStatus(Status::ILLEGAL_ARGUMENT); + } + { Mutex::Autolock _l(mLock); mCallback = in_callback; } - if (mCallback == nullptr) { - return fromStatus(Status::OK); - } - for (const auto& pair : mCameraStatusMap) { mCallback->cameraDeviceStatusChange(pair.first, pair.second); }