Merge "Return ILLEGAL_ARGUMENT for setting null callback" into main

This commit is contained in:
Tang Lee 2023-10-03 03:14:52 +00:00 committed by Android (Google) Code Review
commit cc29bdd2d3
4 changed files with 14 additions and 13 deletions

View file

@ -95,13 +95,14 @@ ExternalCameraProviderImpl_2_4::~ExternalCameraProviderImpl_2_4() {
Return<Status> ExternalCameraProviderImpl_2_4::setCallback(
const sp<ICameraProviderCallback>& 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) {

View file

@ -448,11 +448,11 @@ bool LegacyCameraProviderImpl_2_4::setUpVendorTags() {
// Methods from ::android::hardware::camera::provider::V2_4::ICameraProvider follow.
Return<Status> LegacyCameraProviderImpl_2_4::setCallback(
const sp<ICameraProviderCallback>& 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);

View file

@ -91,11 +91,11 @@ ExternalCameraProviderImpl_2_7::~ExternalCameraProviderImpl_2_7() {
Return<Status> ExternalCameraProviderImpl_2_7::setCallback(
const sp<ICameraProviderCallback>& 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) {

View file

@ -75,15 +75,15 @@ ExternalCameraProvider::~ExternalCameraProvider() {
ndk::ScopedAStatus ExternalCameraProvider::setCallback(
const std::shared_ptr<ICameraProviderCallback>& 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);
}