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

Commit 5fd7c315 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6035658 from 0a37a2c5 to rvc-release

Change-Id: I73ade977ab5c9abd9522a812e1120654e2083d81
parents ce201c11 0a37a2c5
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -31,8 +31,8 @@
#include <utils/RefBase.h>
#include <utils/Timers.h>
#include <utils/Vector.h>

#include <limits>
#include <queue>

/*
 * Additional private constants not defined in ndk/ui/input.h.
@@ -709,8 +709,8 @@ public:
    PreallocatedInputEventFactory() { }
    virtual ~PreallocatedInputEventFactory() { }

    virtual KeyEvent* createKeyEvent() { return & mKeyEvent; }
    virtual MotionEvent* createMotionEvent() { return & mMotionEvent; }
    virtual KeyEvent* createKeyEvent() override { return &mKeyEvent; }
    virtual MotionEvent* createMotionEvent() override { return &mMotionEvent; }

private:
    KeyEvent mKeyEvent;
@@ -725,16 +725,16 @@ public:
    explicit PooledInputEventFactory(size_t maxPoolSize = 20);
    virtual ~PooledInputEventFactory();

    virtual KeyEvent* createKeyEvent();
    virtual MotionEvent* createMotionEvent();
    virtual KeyEvent* createKeyEvent() override;
    virtual MotionEvent* createMotionEvent() override;

    void recycle(InputEvent* event);

private:
    const size_t mMaxPoolSize;

    Vector<KeyEvent*> mKeyEventPool;
    Vector<MotionEvent*> mMotionEventPool;
    std::queue<std::unique_ptr<KeyEvent>> mKeyEventPool;
    std::queue<std::unique_ptr<MotionEvent>> mMotionEventPool;
};

} // namespace android
+20 −0
Original line number Diff line number Diff line
@@ -38,12 +38,32 @@ protected:

// ----------------------------------------------------------------------

/**
 * If this is a local object and the descriptor matches, this will return the
 * actual local object which is implementing the interface. Otherwise, this will
 * return a proxy to the interface without checking the interface descriptor.
 * This means that subsequent calls may fail with BAD_TYPE.
 */
template<typename INTERFACE>
inline sp<INTERFACE> interface_cast(const sp<IBinder>& obj)
{
    return INTERFACE::asInterface(obj);
}

/**
 * This is the same as interface_cast, except that it always checks to make sure
 * the descriptor matches, and if it doesn't match, it will return nullptr.
 */
template<typename INTERFACE>
inline sp<INTERFACE> checked_interface_cast(const sp<IBinder>& obj)
{
    if (obj->getInterfaceDescriptor() != INTERFACE::descriptor) {
        return nullptr;
    }

    return interface_cast<INTERFACE>(obj);
}

// ----------------------------------------------------------------------

template<typename INTERFACE>
+292 −233

File changed.

Preview size limit exceeded, changes collapsed.

+32 −0
Original line number Diff line number Diff line
cc_fuzz {
    name: "libgralloctypes_fuzzer",
    defaults: ["libbinder_ndk_host_user"],
    host_supported: true,

    fuzz_config: {
        cc: ["marissaw@google.com"],
    },

    srcs: [
        "gralloctypes.cpp",
        "main.cpp",
        "util.cpp",
    ],
    static_libs: [
        "libbase",
        "libcgrouprc",
        "libcgrouprc_format",
        "libcutils",
        "libgralloctypes",
        "libhidlbase",
        "liblog",
        "libprocessgroup",
        "libjsoncpp",
        "libutils",
    ],

    // This flag enables verbose output in the fuzz target, and is very useful
    // for debugging a failure. If you are trying to diagnose how a crash was
    // produced, you may find uncommenting the below line very useful.
    // cflags: ["-DENABLE_LOG_FUZZ"],
}
+64 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#define FUZZ_LOG_TAG "gralloctypes"

#include <cstdint>

#include <aidl/android/hardware/graphics/common/BlendMode.h>
#include <aidl/android/hardware/graphics/common/Dataspace.h>
#include <aidl/android/hardware/graphics/common/ExtendableType.h>
#include <aidl/android/hardware/graphics/common/PlaneLayout.h>
#include <android/hardware/graphics/common/1.2/types.h>
#include <gralloctypes/Gralloc4.h>
#include <hidl/HidlSupport.h>
#include <utils/Errors.h>

#include "gralloctypes.h"
#include "util.h"

using ::android::status_t;

#define GRALLOCTYPES_DECODE(T, FUNC) \
    [] (const ::android::hardware::hidl_vec<uint8_t>& vec, uint8_t /*data*/) {\
        FUZZ_LOG() << "about to read " #T " using " #FUNC;\
        T t;\
        status_t err = FUNC(vec, &t);\
        (void) err;\
        FUZZ_LOG() << #T " done " /* << "err: " << err*/;\
    }


// clang-format off
std::vector<GrallocTypesDecode> GRALLOCTYPES_DECODE_FUNCTIONS {
    GRALLOCTYPES_DECODE(uint64_t, ::android::gralloc4::decodeBufferId),
    GRALLOCTYPES_DECODE(std::string, ::android::gralloc4::decodeName),
    GRALLOCTYPES_DECODE(uint64_t, ::android::gralloc4::decodeWidth),
    GRALLOCTYPES_DECODE(uint64_t, ::android::gralloc4::decodeHeight),
    GRALLOCTYPES_DECODE(uint64_t, ::android::gralloc4::decodeLayerCount),
    GRALLOCTYPES_DECODE(::android::hardware::graphics::common::V1_2::PixelFormat, ::android::gralloc4::decodePixelFormatRequested),
    GRALLOCTYPES_DECODE(uint32_t, ::android::gralloc4::decodePixelFormatFourCC),
    GRALLOCTYPES_DECODE(uint64_t, ::android::gralloc4::decodePixelFormatModifier),
    GRALLOCTYPES_DECODE(uint64_t, ::android::gralloc4::decodeUsage),
    GRALLOCTYPES_DECODE(uint64_t, ::android::gralloc4::decodeAllocationSize),
    GRALLOCTYPES_DECODE(uint64_t, ::android::gralloc4::decodeProtectedContent),
    GRALLOCTYPES_DECODE(aidl::android::hardware::graphics::common::ExtendableType, ::android::gralloc4::decodeCompression),
    GRALLOCTYPES_DECODE(aidl::android::hardware::graphics::common::ExtendableType, ::android::gralloc4::decodeInterlaced),
    GRALLOCTYPES_DECODE(aidl::android::hardware::graphics::common::ExtendableType, ::android::gralloc4::decodeChromaSiting),
    GRALLOCTYPES_DECODE(std::vector<aidl::android::hardware::graphics::common::PlaneLayout>, ::android::gralloc4::decodePlaneLayouts),
    GRALLOCTYPES_DECODE(aidl::android::hardware::graphics::common::Dataspace, ::android::gralloc4::decodeDataspace),
    GRALLOCTYPES_DECODE(aidl::android::hardware::graphics::common::BlendMode, ::android::gralloc4::decodeBlendMode),
};
// clang-format on
Loading