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

Commit 2349feca authored by Carlos Martinez Romero's avatar Carlos Martinez Romero
Browse files

Update the fuzzers to use the flag SurfaceTypes

We are currently limitig the use of IGBPs outside of libgui to allow for
further development of bufferqueues without external breakages. More
information at go/warren-buffers.

BYPASS_IGBP_IGBC_API_REASON: this CL is part of the migration.
Bug: 342197851
Test: atest camera_client_test
Flag: com.android.graphics.libgui.flags.wb_libcameraservice

Change-Id: I4e7f57a11f536baf0902b83480f4191dad775368
parent ea0a0849
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -548,10 +548,9 @@ TEST_F(CameraClientBinderTest, CheckBinderCameraDeviceUser) {
                  opaqueConsumer->setDefaultBufferFormat(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED));

        sp<Surface> surface = opaqueConsumer->getSurface();

        sp<IGraphicBufferProducer> producer = surface->getIGraphicBufferProducer();
        ParcelableSurfaceType pSurface = flagtools::surfaceToParcelableSurfaceType(surface);
        std::string noPhysicalId;
        OutputConfiguration output(producer, /*rotation*/ 0, noPhysicalId);
        OutputConfiguration output(pSurface, /*rotation*/ 0, noPhysicalId);
#else
        sp<IGraphicBufferProducer> gbProducer;
        sp<IGraphicBufferConsumer> gbConsumer;
+13 −5
Original line number Diff line number Diff line
@@ -70,8 +70,10 @@ unique_ptr<OutputConfiguration> C2OutputConfigurationFuzzer::getC2OutputConfig()
                        int32_t surfaceSetID = mFDP->ConsumeIntegral<int32_t>();
                        bool isShared = mFDP->ConsumeBool();
                        sp<SurfaceType> surface = createSurface();
                        ParcelableSurfaceType pSurface =
                            flagtools::convertSurfaceTypeToParcelable(surface);
                        outputConfiguration = make_unique<OutputConfiguration>(
                                surface, rotation, physicalCameraId, surfaceSetID, isShared);
                                pSurface, rotation, physicalCameraId, surfaceSetID, isShared);
                    },

                    [&]() {
@@ -81,10 +83,12 @@ unique_ptr<OutputConfiguration> C2OutputConfigurationFuzzer::getC2OutputConfig()
                        bool isShared = mFDP->ConsumeBool();
                        size_t surfaceSize =
                                mFDP->ConsumeIntegralInRange<size_t>(kSizeMin, kSizeMax);
                        vector<sp<SurfaceType>> surfaces;
                        vector<ParcelableSurfaceType> surfaces;
                        for (size_t idx = 0; idx < surfaceSize; ++idx) {
                            sp<SurfaceType> surface = createSurface();
                            surfaces.push_back(surface);
                            ParcelableSurfaceType pSurface =
                                flagtools::convertSurfaceTypeToParcelable(surface);
                            surfaces.push_back(pSurface);
                        }
                        outputConfiguration = make_unique<OutputConfiguration>(
                                surfaces, rotation, physicalCameraId, surfaceSetID, isShared);
@@ -115,7 +119,9 @@ void C2OutputConfigurationFuzzer::invokeC2OutputConfigFuzzer() {
                [&]() { outputConfiguration->getSurfaces(); },
                [&]() {
                    sp<SurfaceType> surface = createSurface();
                    outputConfiguration->addSurface(surface);
                    ParcelableSurfaceType pSurface =
                        flagtools::convertSurfaceTypeToParcelable(surface);
                    outputConfiguration->addSurface(pSurface);
                },
                [&]() { outputConfiguration->isMultiResolution(); },
                [&]() { outputConfiguration->getColorSpace(); },
@@ -123,7 +129,9 @@ void C2OutputConfigurationFuzzer::invokeC2OutputConfigFuzzer() {
                [&]() { outputConfiguration->getTimestampBase(); },
                [&]() {
                    sp<SurfaceType> surface = createSurface();
                    outputConfiguration->getMirrorMode(surface);
                    ParcelableSurfaceType pSurface =
                        flagtools::convertSurfaceTypeToParcelable(surface);
                    outputConfiguration->getMirrorMode(pSurface);
                },
                [&]() { outputConfiguration->useReadoutTimestamp(); },
        });
+8 −3
Original line number Diff line number Diff line
@@ -17,7 +17,12 @@
#include <camera2/OutputConfiguration.h>
#include <camera2/SessionConfiguration.h>
#include <fuzzer/FuzzedDataProvider.h>
#include <gui/Flags.h> // remove with WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
#if WB_LIBCAMERASERVICE_WITH_DEPENDENCIES
#include <gui/Surface.h>
#else
#include <gui/IGraphicBufferProducer.h>
#endif
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
#include "camera2common.h"
@@ -53,7 +58,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
        outputConfiguration = new OutputConfiguration();
        sessionConfiguration->addOutputConfiguration(*outputConfiguration);
    } else {
        sp<IGraphicBufferProducer> iGBP = nullptr;
        ParcelableSurfaceType pSurface;
        sp<SurfaceComposerClient> composerClient = new SurfaceComposerClient;
        sp<SurfaceControl> surfaceControl = composerClient->createSurface(
                static_cast<String8>(fdp.ConsumeRandomLengthString().c_str()),
@@ -61,7 +66,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
                fdp.ConsumeIntegral<int32_t>(), fdp.ConsumeIntegral<int32_t>());
        if (surfaceControl) {
            sp<Surface> surface = surfaceControl->getSurface();
            iGBP = surface->getIGraphicBufferProducer();
            pSurface = flagtools::surfaceToParcelableSurfaceType(surface);
            surface.clear();
        }
        int32_t rotation = fdp.ConsumeIntegral<int32_t>();
@@ -69,7 +74,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
        int32_t surfaceSetID = fdp.ConsumeIntegral<int32_t>();
        bool isShared = fdp.ConsumeBool();
        outputConfiguration =
                new OutputConfiguration(iGBP, rotation, physicalCameraId, surfaceSetID, isShared);
            new OutputConfiguration(pSurface, rotation, physicalCameraId, surfaceSetID, isShared);
        sessionConfiguration->addOutputConfiguration(*outputConfiguration);
    }