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

Commit da0a7910 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 7829765 from b35e2ee9 to tm-release

Change-Id: Iaff222ab4bf4220d4c5fca43e6ed008b00ce2598
parents 2c4bd1bf b35e2ee9
Loading
Loading
Loading
Loading
+25 −17
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
 * limitations under the License.
 */

#include <fuzzer/FuzzedDataProvider.h>
#include <cmath>
#include <cstdlib>
#include <cstring>
@@ -21,36 +22,43 @@
#include "FormatConvert.h"

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, std::size_t size) {
    if (size < 256) {
    // 1 random value (4bytes) + min imagesize = 16*2 times bytes per pixel (worse case 2)
    if (size < (4 + 16 * 2 * 2)) {
        return 0;
    }
    FuzzedDataProvider fdp(data, size);
    std::size_t image_pixel_size = size - 4;
    image_pixel_size = (image_pixel_size & INT_MAX) / 2;

    std::srand(std::time(nullptr));  // use current time as seed for random generator
    int random_variable = std::rand() % 10;
    int width = (int)sqrt(size);
    int height = width * ((float)random_variable / 10.0);
    // API have a requirement that width must be divied by 16 except yuyvtorgb
    int min_height = 2;
    int max_height = (image_pixel_size / 16) & ~(1);  // must be even number
    int height = fdp.ConsumeIntegralInRange<uint32_t>(min_height, max_height);
    int width = (image_pixel_size / height) & ~(16);  // must be divisible by 16

    uint8_t* src = (uint8_t*)malloc(sizeof(uint8_t) * size);
    memcpy(src, data, sizeof(uint8_t) * (size));
    uint32_t* tgt = (uint32_t*)malloc(sizeof(uint32_t) * size);
    uint8_t* src = (uint8_t*)(data + 4);
    uint32_t* tgt = (uint32_t*)malloc(sizeof(uint32_t) * image_pixel_size);

#ifdef COPY_NV21_TO_RGB32
    android::hardware::automotive::evs::common::Utils::copyNV21toRGB32(width, height, src, tgt, 0);
    android::hardware::automotive::evs::common::Utils::copyNV21toRGB32(width, height, src, tgt,
                                                                       width);
#elif COPY_NV21_TO_BGR32
    android::hardware::automotive::evs::common::Utils::copyNV21toBGR32(width, height, src, tgt, 0);
    android::hardware::automotive::evs::common::Utils::copyNV21toBGR32(width, height, src, tgt,
                                                                       width);
#elif COPY_YV12_TO_RGB32
    android::hardware::automotive::evs::common::Utils::copyYV12toRGB32(width, height, src, tgt, 0);
    android::hardware::automotive::evs::common::Utils::copyYV12toRGB32(width, height, src, tgt,
                                                                       width);
#elif COPY_YV12_TO_BGR32
    android::hardware::automotive::evs::common::Utils::copyYV12toBGR32(width, height, src, tgt, 0);
    android::hardware::automotive::evs::common::Utils::copyYV12toBGR32(width, height, src, tgt,
                                                                       width);
#elif COPY_YUYV_TO_RGB32
    android::hardware::automotive::evs::common::Utils::copyYUYVtoRGB32(width, height, src, 0, tgt,
                                                                       0);
    android::hardware::automotive::evs::common::Utils::copyYUYVtoRGB32(width, height, src, width,
                                                                       tgt, width);
#elif COPY_YUYV_TO_BGR32
    android::hardware::automotive::evs::common::Utils::copyYUYVtoBGR32(width, height, src, 0, tgt,
                                                                       0);
    android::hardware::automotive::evs::common::Utils::copyYUYVtoBGR32(width, height, src, width,
                                                                       tgt, width);
#endif

    free(src);
    free(tgt);

    return 0;
+7 −7
Original line number Diff line number Diff line
@@ -61,18 +61,18 @@ void TestRenderEngine::initGraphicBuffer(uint32_t width, uint32_t height, uint32
void TestRenderEngine::drawLayers() {
    base::unique_fd bufferFence;

    std::vector<const renderengine::LayerSettings*> compositionLayerPointers;
    compositionLayerPointers.reserve(mCompositionLayers.size());
    std::vector<renderengine::LayerSettings> compositionLayers;
    compositionLayers.reserve(mCompositionLayers.size());
    std::transform(mCompositionLayers.begin(), mCompositionLayers.end(),
                   std::back_insert_iterator(compositionLayerPointers),
                   [](renderengine::LayerSettings& settings) -> renderengine::LayerSettings* {
                       return &settings;
                   std::back_insert_iterator(compositionLayers),
                   [](renderengine::LayerSettings& settings) -> renderengine::LayerSettings {
                       return settings;
                   });
    auto texture = std::make_shared<renderengine::ExternalTexture>(
            mGraphicBuffer, *mRenderEngine, renderengine::ExternalTexture::Usage::WRITEABLE);
    auto [status, readyFence] = mRenderEngine
                                        ->drawLayers(mDisplaySettings, compositionLayerPointers,
                                                     texture, true, std::move(bufferFence))
                                        ->drawLayers(mDisplaySettings, compositionLayers, texture,
                                                     true, std::move(bufferFence))
                                        .get();
    int fd = readyFence.release();
    if (fd != -1) {
+1 −4
Original line number Diff line number Diff line
@@ -2,11 +2,8 @@
butlermichael@google.com
dgross@google.com
jeanluc@google.com
levp@google.com
miaowang@google.com
mikie@google.com
mks@google.com
pszczepaniak@google.com
slavash@google.com
vddang@google.com
xusongw@google.com
ianhua@google.com
+2 −0
Original line number Diff line number Diff line
@@ -107,8 +107,10 @@ cc_test {
    static_libs: [
        "VtsHalWifiV1_0TargetTestUtil",
        "android.hardware.wifi@1.0",
        "android.hardware.wifi.hostapd@1.0",
        "libwifi-system-iface",
    ],
    disable_framework: true,
    test_suites: [
        "general-tests",
        "vts",
+6 −1
Original line number Diff line number Diff line
@@ -15,9 +15,9 @@
 */

#include <android-base/logging.h>

#include <android/hardware/wifi/1.0/IWifi.h>
#include <android/hardware/wifi/1.0/IWifiApIface.h>
#include <android/hardware/wifi/hostapd/1.0/IHostapd.h>
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <hidl/ServiceManagement.h>
@@ -26,6 +26,7 @@
#include "wifi_hidl_test_utils.h"

using ::android::sp;
using ::android::hardware::wifi::hostapd::V1_0::IHostapd;
using ::android::hardware::wifi::V1_0::IfaceType;
using ::android::hardware::wifi::V1_0::IWifi;
using ::android::hardware::wifi::V1_0::IWifiApIface;
@@ -38,6 +39,10 @@ using ::android::hardware::wifi::V1_0::WifiStatusCode;
class WifiApIfaceHidlTest : public ::testing::TestWithParam<std::string> {
   public:
    virtual void SetUp() override {
        if (android::hardware::getAllHalInstanceNames(IHostapd::descriptor)
                .empty()) {
            GTEST_SKIP() << "Device does not support AP";
        }
        // Make sure test starts with a clean state
        stopWifi(GetInstanceName());

Loading