Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8cf92926 authored by Jayant Chowdhary's avatar Jayant Chowdhary
Browse files

cameraserver: Allow cameraserver HIDL interface to get provider ids with VendorTagSections.



Bug: 110364143

Test: mm -j64
Test: AImageReaderVendorTest (sanity)
Test: GCA (sanity)

Change-Id: Iddcd5c1edb6cbe4b83968f01e46056a30c720219
Signed-off-by: default avatarJayant Chowdhary <jchowdhary@google.com>
parent aee8f295
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -411,6 +411,11 @@ status_t VendorTagDescriptorCache::readFromParcel(const Parcel* parcel) {
    return res;
    return res;
}
}


const std::unordered_map<metadata_vendor_id_t, sp<android::VendorTagDescriptor>> &
            VendorTagDescriptorCache::getVendorIdsAndTagDescriptors() {
    return mVendorMap;
}

int VendorTagDescriptorCache::getTagCount(metadata_vendor_id_t id) const {
int VendorTagDescriptorCache::getTagCount(metadata_vendor_id_t id) const {
    int ret = 0;
    int ret = 0;
    auto desc = mVendorMap.find(id);
    auto desc = mVendorMap.find(id);
+3 −0
Original line number Original line Diff line number Diff line
@@ -211,6 +211,9 @@ class VendorTagDescriptorCache : public Parcelable {
     */
     */
    void dump(int fd, int verbosity, int indentation) const;
    void dump(int fd, int verbosity, int indentation) const;


    const std::unordered_map<metadata_vendor_id_t, sp<android::VendorTagDescriptor>> &
            getVendorIdsAndTagDescriptors();

  protected:
  protected:
    std::unordered_map<metadata_vendor_id_t, sp<android::VendorTagDescriptor>> mVendorMap;
    std::unordered_map<metadata_vendor_id_t, sp<android::VendorTagDescriptor>> mVendorMap;
    struct vendor_tag_cache_ops mVendorCacheOps;
    struct vendor_tag_cache_ops mVendorCacheOps;
+45 −32
Original line number Original line Diff line number Diff line
@@ -40,9 +40,11 @@ using hardware::Void;
using device::V2_0::implementation::H2BCameraDeviceCallbacks;
using device::V2_0::implementation::H2BCameraDeviceCallbacks;
using device::V2_0::implementation::HidlCameraDeviceUser;
using device::V2_0::implementation::HidlCameraDeviceUser;
using service::V2_0::implementation::H2BCameraServiceListener;
using service::V2_0::implementation::H2BCameraServiceListener;
using HCameraMetadataType = android::frameworks::cameraservice::common::V2_0::CameraMetadataType;
using HCameraMetadataType = frameworks::cameraservice::common::V2_0::CameraMetadataType;
using HVendorTag = android::frameworks::cameraservice::common::V2_0::VendorTag;
using HVendorTag = frameworks::cameraservice::common::V2_0::VendorTag;
using HVendorTagSection = android::frameworks::cameraservice::common::V2_0::VendorTagSection;
using HVendorTagSection = frameworks::cameraservice::common::V2_0::VendorTagSection;
using HProviderIdAndVendorTagSections =
        frameworks::cameraservice::common::V2_0::ProviderIdAndVendorTagSections;


sp<HidlCameraService> gHidlCameraService;
sp<HidlCameraService> gHidlCameraService;


@@ -215,19 +217,24 @@ Return<HStatus> HidlCameraService::removeListener(const sp<HCameraServiceListene
}
}


Return<void> HidlCameraService::getCameraVendorTagSections(getCameraVendorTagSections_cb _hidl_cb) {
Return<void> HidlCameraService::getCameraVendorTagSections(getCameraVendorTagSections_cb _hidl_cb) {
    hidl_vec<HVendorTagSection> hVendorTagSections;
    sp<VendorTagDescriptorCache> gCache = VendorTagDescriptorCache::getGlobalVendorTagCache();
    // TODO: Could this be just created on the stack since we don't set it to
    if (gCache == nullptr) {
    //       global cache or anything ?
        _hidl_cb(HStatus::UNKNOWN_ERROR, {});
    HStatus hStatus = HStatus::NO_ERROR;
        return Void();
    sp<VendorTagDescriptor> desc = new VendorTagDescriptor();
    }
    binder::Status serviceRet = mAidlICameraService->getCameraVendorTagDescriptor(desc.get());
    const std::unordered_map<metadata_vendor_id_t, sp<android::VendorTagDescriptor>>

            &vendorIdsAndTagDescs = gCache->getVendorIdsAndTagDescriptors();
    if (!serviceRet.isOk()) {
    if (vendorIdsAndTagDescs.size() == 0) {
        ALOGE("%s: Failed to get VendorTagDescriptor", __FUNCTION__);
        _hidl_cb(HStatus::UNKNOWN_ERROR, {});
        _hidl_cb(B2HStatus(serviceRet), hVendorTagSections);
        return Void();
        return Void();
    }
    }


    hidl_vec<HProviderIdAndVendorTagSections> hTagIdsAndVendorTagSections;
    hTagIdsAndVendorTagSections.resize(vendorIdsAndTagDescs.size());
    size_t j = 0;
    for (auto &vendorIdAndTagDescs : vendorIdsAndTagDescs) {
        hidl_vec<HVendorTagSection> hVendorTagSections;
        sp<VendorTagDescriptor> desc = vendorIdAndTagDescs.second;
        const SortedVector<String8>* sectionNames = desc->getAllSectionNames();
        const SortedVector<String8>* sectionNames = desc->getAllSectionNames();
        size_t numSections = sectionNames->size();
        size_t numSections = sectionNames->size();
        std::vector<std::vector<HVendorTag>> tagsBySection(numSections);
        std::vector<std::vector<HVendorTag>> tagsBySection(numSections);
@@ -247,7 +254,13 @@ Return<void> HidlCameraService::getCameraVendorTagSections(getCameraVendorTagSec
            hVendorTagSections[s].sectionName = (*sectionNames)[s].string();
            hVendorTagSections[s].sectionName = (*sectionNames)[s].string();
            hVendorTagSections[s].tags = tagsBySection[s];
            hVendorTagSections[s].tags = tagsBySection[s];
        }
        }
    _hidl_cb(hStatus, hVendorTagSections);
        HProviderIdAndVendorTagSections &hProviderIdAndVendorTagSections =
                hTagIdsAndVendorTagSections[j];
        hProviderIdAndVendorTagSections.providerId = vendorIdAndTagDescs.first;
        hProviderIdAndVendorTagSections.vendorTagSections = std::move(hVendorTagSections);
        j++;
    }
    _hidl_cb(HStatus::NO_ERROR, hTagIdsAndVendorTagSections);
    return Void();
    return Void();
}
}