diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp index a82f0f76e3..ceca0f8ac9 100644 --- a/services/camera/libcameraservice/common/CameraProviderManager.cpp +++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp @@ -254,37 +254,7 @@ status_t CameraProviderManager::setUpVendorTags() { sp tagCache = new VendorTagDescriptorCache(); for (auto& provider : mProviders) { - hardware::hidl_vec vts; - Status status; - hardware::Return ret; - ret = provider->mInterface->getVendorTags( - [&](auto s, const auto& vendorTagSecs) { - status = s; - if (s == Status::OK) { - vts = vendorTagSecs; - } - }); - if (!ret.isOk()) { - ALOGE("%s: Transaction error getting vendor tags from provider '%s': %s", - __FUNCTION__, provider->mProviderName.c_str(), ret.description().c_str()); - return DEAD_OBJECT; - } - if (status != Status::OK) { - return mapToStatusT(status); - } - - // Read all vendor tag definitions into a descriptor - sp desc; - status_t res; - if ((res = HidlVendorTagDescriptor::createDescriptorFromHidl(vts, /*out*/desc)) - != OK) { - ALOGE("%s: Could not generate descriptor from vendor tag operations," - "received error %s (%d). Camera clients will not be able to use" - "vendor tags", __FUNCTION__, strerror(res), res); - return res; - } - - tagCache->addVendorDescriptor(provider->mProviderTagid, desc); + tagCache->addVendorDescriptor(provider->mProviderTagid, provider->mVendorTagDescriptor); } VendorTagDescriptorCache::setAsGlobalVendorTagCache(tagCache); @@ -750,6 +720,13 @@ status_t CameraProviderManager::ProviderInfo::initialize() { } } + res = setUpVendorTags(); + if (res != OK) { + ALOGE("%s: Unable to set up vendor tags from provider '%s'", + __FUNCTION__, mProviderName.c_str()); + return res; + } + ALOGI("Camera provider %s ready with %zu camera devices", mProviderName.c_str(), mDevices.size()); @@ -994,6 +971,42 @@ void CameraProviderManager::ProviderInfo::serviceDied(uint64_t cookie, mManager->removeProvider(mProviderName); } +status_t CameraProviderManager::ProviderInfo::setUpVendorTags() { + if (mVendorTagDescriptor != nullptr) + return OK; + + hardware::hidl_vec vts; + Status status; + hardware::Return ret; + ret = mInterface->getVendorTags( + [&](auto s, const auto& vendorTagSecs) { + status = s; + if (s == Status::OK) { + vts = vendorTagSecs; + } + }); + if (!ret.isOk()) { + ALOGE("%s: Transaction error getting vendor tags from provider '%s': %s", + __FUNCTION__, mProviderName.c_str(), ret.description().c_str()); + return DEAD_OBJECT; + } + if (status != Status::OK) { + return mapToStatusT(status); + } + + // Read all vendor tag definitions into a descriptor + status_t res; + if ((res = HidlVendorTagDescriptor::createDescriptorFromHidl(vts, /*out*/mVendorTagDescriptor)) + != OK) { + ALOGE("%s: Could not generate descriptor from vendor tag operations," + "received error %s (%d). Camera clients will not be able to use" + "vendor tags", __FUNCTION__, strerror(res), res); + return res; + } + + return OK; +} + template std::unique_ptr CameraProviderManager::ProviderInfo::initializeDeviceInfo( diff --git a/services/camera/libcameraservice/common/CameraProviderManager.h b/services/camera/libcameraservice/common/CameraProviderManager.h index 99b87fbc0c..1473b8fbe7 100644 --- a/services/camera/libcameraservice/common/CameraProviderManager.h +++ b/services/camera/libcameraservice/common/CameraProviderManager.h @@ -266,6 +266,7 @@ private: const std::string mProviderName; const sp mInterface; const metadata_vendor_id_t mProviderTagid; + sp mVendorTagDescriptor; ProviderInfo(const std::string &providerName, sp& interface, @@ -294,6 +295,11 @@ private: // hidl_death_recipient interface - this locks the parent mInterfaceMutex virtual void serviceDied(uint64_t cookie, const wp& who) override; + /** + * Setup vendor tags for this provider + */ + status_t setUpVendorTags(); + // Basic device information, common to all camera devices struct DeviceInfo { const std::string mName; // Full instance name