summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvichal Rakesh <arakesh@google.com>2022-05-23 22:57:56 +0000
committerAvichal Rakesh <arakesh@google.com>2022-05-24 21:09:47 +0000
commit3b83dc695125192b07ca0b79bd91830f9859484a (patch)
treebfdd634186ff447590753d858a7201808e1901d7
parent5e6dbb8cf19d17fe7f67fe90024ae8726fa9df36 (diff)
downloadcamera-3b83dc695125192b07ca0b79bd91830f9859484a.tar.gz
Return Status::ILLEGAL_ARGUMENT if callback is nullptr
AIDL documentation states that ICameraProvider::setCallback should return Status::ILLEGAL_ARGUMENT if the callback passed is a null pointer. The current implementation incorrectly returns OK even if the callback is null. This CL adds a null checks and returns Status::ILLEGAL_ARGUMENT if required. Bug: 233221359 Test: atest VtsAidlHalCameraProvider_TargetTest Change-Id: I2d705262df0f7acd403cd1eeae1bdc09a18565d2
-rw-r--r--common/hal/aidl_service/aidl_camera_provider.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/common/hal/aidl_service/aidl_camera_provider.cc b/common/hal/aidl_service/aidl_camera_provider.cc
index 91bc2c4..7eac3f2 100644
--- a/common/hal/aidl_service/aidl_camera_provider.cc
+++ b/common/hal/aidl_service/aidl_camera_provider.cc
@@ -181,6 +181,12 @@ status_t AidlCameraProvider::Initialize() {
ScopedAStatus AidlCameraProvider::setCallback(
const std::shared_ptr<ICameraProviderCallback>& callback) {
+ if (callback == nullptr) {
+ ALOGE("AidlCameraProvider::setCallback() called with nullptr");
+ return ScopedAStatus::fromServiceSpecificError(
+ static_cast<int32_t>(Status::ILLEGAL_ARGUMENT));
+ }
+
bool first_time = false;
{
std::unique_lock<std::mutex> lock(callbacks_lock_);