/*
 * Copyright (C) 2022 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.
 */

package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "frameworks_av_media_ndk_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["frameworks_av_media_ndk_license"],
}

cc_defaults {
     name: "libmediandk_fuzzer_defaults",
     shared_libs: [
        "libandroid_runtime_lazy",
        "libbase",
        "libdatasource",
        "libmedia",
        "libmediadrm",
        "libmedia_omx",
        "libmedia_jni_utils",
        "libstagefright",
        "libstagefright_foundation",
        "liblog",
        "libutils",
        "libcutils",
        "libnativewindow",
        "libhidlbase",
        "libgui",
        "libui",
        "libmediandk",
     ],
     static_libs: [
        "libmediandk_utils",
        "libnativehelper_lazy",
     ],
     header_libs: [
         "media_ndk_headers",
     ],
     fuzz_config: {
        cc: [
            "android-media-fuzzing-reports@google.com",
        ],
        componentid: 155276,
        hotlists: [
            "4593311",
        ],
        description: "The fuzzer targets the APIs of libmediandk library",
        vector: "local_no_privileges_required",
        service_privilege: "privileged",
        users: "multi_user",
        fuzzed_code_usage: "shipped",
    },
}

cc_fuzz {
    name: "ndk_crypto_fuzzer",
    srcs: ["ndk_crypto_fuzzer.cpp"],
    defaults: ["libmediandk_fuzzer_defaults"],
    fuzz_config: {
        libfuzzer_options: [
            "max_len=10000",
        ],
    },
}

cc_fuzz {
     name: "ndk_image_reader_fuzzer",
     srcs: [
        "ndk_image_reader_fuzzer.cpp",
     ],
     shared_libs: [
        "android.hidl.token@1.0-utils",
        "android.hardware.graphics.bufferqueue@1.0",
     ],
     cflags: [
        "-D__ANDROID_VNDK__",
     ],
     defaults: ["libmediandk_fuzzer_defaults"],
}

cc_fuzz {
    name: "ndk_extractor_fuzzer",
    srcs: ["ndk_extractor_fuzzer.cpp"],
    defaults: ["libmediandk_fuzzer_defaults"],
    shared_libs: ["libbinder_ndk",],
    corpus: ["corpus/*"],
}

cc_fuzz {
    name: "ndk_mediaformat_fuzzer",
    srcs: ["ndk_mediaformat_fuzzer.cpp"],
    defaults: ["libmediandk_fuzzer_defaults",],
}

cc_fuzz {
    name: "ndk_drm_fuzzer",
    srcs: ["ndk_drm_fuzzer.cpp"],
    defaults: ["libmediandk_fuzzer_defaults",],
}

cc_fuzz {
    name: "ndk_mediamuxer_fuzzer",
    srcs: ["ndk_mediamuxer_fuzzer.cpp"],
    defaults: ["libmediandk_fuzzer_defaults"],
    shared_libs: ["libbinder_ndk",],
}

cc_fuzz {
    name: "ndk_sync_codec_fuzzer",
    srcs: [
            "ndk_sync_codec_fuzzer.cpp",
             "NdkMediaCodecFuzzerBase.cpp",
          ],
    header_libs: ["libnativewindow_headers",],
    defaults: ["libmediandk_fuzzer_defaults",],
}

cc_fuzz {
    name: "ndk_async_codec_fuzzer",
    srcs: [
           "ndk_async_codec_fuzzer.cpp",
           "NdkMediaCodecFuzzerBase.cpp",
          ],
    header_libs: [
           "libnativewindow_headers",
           "libutils_headers",
          ],
    defaults: ["libmediandk_fuzzer_defaults",],
}
