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

Commit 62d45f11 authored by Avichal Rakesh's avatar Avichal Rakesh
Browse files

cameraservice: handle Surfaces coming from vendor clients

Vendor client interface has been updated to use Surface instead
of NativeHandle for parceling ImageReader surface.

This CL updates the cameraservice to handle both windowHandles
and surfaces coming from the vendor client.

Bug: 283283111
Test: 'atest ACameraNdkVendorTest' passes
      FaceHAL works OK!
Change-Id: I2e5515cfedd5d37c5addcf40aa56b0ecfa42b53f
parent 91ccc1b5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@

    <hal format="aidl">
        <name>android.frameworks.cameraservice.service</name>
        <version>1</version>
        <version>2</version>
        <interface>
            <name>ICameraService</name>
            <instance>default</instance>
+3 −2
Original line number Diff line number Diff line
@@ -66,6 +66,7 @@ cc_defaults {
        "libmedia_codeclist",
        "libmedia_omx",
        "libmemunreachable",
        "libnativewindow",
        "libprocessgroup",
        "libprocinfo",
        "libsensorprivacy",
@@ -95,8 +96,8 @@ cc_defaults {
        "android.frameworks.cameraservice.device@2.0",
        "android.frameworks.cameraservice.device@2.1",
        "android.frameworks.cameraservice.common-V1-ndk",
        "android.frameworks.cameraservice.service-V1-ndk",
        "android.frameworks.cameraservice.device-V1-ndk",
        "android.frameworks.cameraservice.service-V2-ndk",
        "android.frameworks.cameraservice.device-V2-ndk",
        "android.hardware.camera.common-V1-ndk",
        "android.hardware.camera.device-V2-ndk",
        "android.hardware.camera.metadata-V2-ndk",
+38 −13
Original line number Diff line number Diff line
@@ -73,7 +73,29 @@ int32_t convertFromAidl(SStreamConfigurationMode streamConfigurationMode) {

UOutputConfiguration convertFromAidl(const SOutputConfiguration &src) {
    std::vector<sp<IGraphicBufferProducer>> iGBPs;
    if (!src.surfaces.empty()) {
        auto& surfaces = src.surfaces;
        iGBPs.reserve(surfaces.size());

        for (auto& sSurface : surfaces) {
            sp<IGraphicBufferProducer> igbp =
                    Surface::getIGraphicBufferProducer(sSurface.get());
            if (igbp == nullptr) {
                ALOGE("%s: ANativeWindow (%p) not backed by a Surface.",
                      __FUNCTION__, sSurface.get());
                continue;
            }
            iGBPs.push_back(igbp);
        }
    } else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
        // HIDL token manager (and consequently 'windowHandles') is deprecated and will be removed
        // in the future. However, cameraservice must still support old NativeHandle pathway until
        // all vendors have moved away from using NativeHandles
        auto &windowHandles = src.windowHandles;
#pragma clang diagnostic pop

        iGBPs.reserve(windowHandles.size());

        for (auto &handle : windowHandles) {
@@ -84,13 +106,16 @@ UOutputConfiguration convertFromAidl(const SOutputConfiguration &src) {
                        __FUNCTION__, handle.toString().c_str());
                continue;
            }

            iGBPs.push_back(new H2BGraphicBufferProducer(igbp));
            native_handle_delete(nh);
        }
    }

    UOutputConfiguration outputConfiguration(
        iGBPs, convertFromAidl(src.rotation), src.physicalCameraId,
        src.windowGroupId, OutputConfiguration::SURFACE_TYPE_UNKNOWN, 0, 0,
        (windowHandles.size() > 1));
        (iGBPs.size() > 1));
    return outputConfiguration;
}