/*
 * Copyright (C) 2021 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_libmediaplayerservice_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: [
        "frameworks_av_media_libmediaplayerservice_license",
    ],
}

cc_defaults {
    name: "libmediaplayerserviceFuzzer_defaults",
    static_libs: [
        "libmediaplayerservice",
        "liblog",
    ],
    shared_libs: [
        "camera_platform_flags_c_lib",
        "framework-permission-aidl-cpp",
        "libbinder",
        "libbinder_ndk",
        "libcutils",
        "libmedia",
        "libstagefright",
        "libutils",
        "libstagefright_foundation",
    ],
    fuzz_config: {
        cc: [
            "android-media-playback+bugs@google.com",
        ],
        componentid: 155276,
        hotlists: [
            "4593311",
        ],
        description: "The fuzzer targets the APIs of libmediaplayerservice",
        vector: "remote",
        service_privilege: "privileged",
        users: "multi_user",
        fuzzed_code_usage: "shipped",
    },
}

cc_fuzz {
    name: "mediarecorder_fuzzer",
    srcs: [
        "mediarecorder_fuzzer.cpp",
    ],
    defaults: [
        "libaudioflinger_dependencies",
        "libmediaplayerserviceFuzzer_defaults",
    ],
    static_libs: [
        "libstagefright_rtsp",
        "libbase",
        "libstagefright_nuplayer",
        "libplayerservice_datasource",
        "libstagefright_timedtext",
        "libaudioprocessing_base",
    ],
    shared_libs: [
        "android.hardware.media.omx@1.0",
        "media_permission-aidl-cpp",
        "libactivitymanager_aidl",
        "libandroid_net",
        "libaudioflinger",
        "libaudiofoundation",
        "libcamera_client",
        "libcodec2_client",
        "libcrypto",
        "libdatasource",
        "libdrmframework",
        "libgui",
        "libhidlbase",
        "libmedia_codeclist",
        "libmedia_omx",
        "libmediadrm",
        "libnetd_client",
        "libstagefright_httplive",
        "packagemanager_aidl-cpp",
        "libfakeservicemanager",
        "libresourcemanagerservice",
        "libmediametricsservice",
        "mediametricsservice-aidl-cpp",
        "libcameraservice",
        "android.hardware.camera.common@1.0",
        "android.hardware.camera.provider@2.4",
        "android.hardware.camera.provider@2.5",
        "android.hardware.camera.provider@2.6",
        "android.hardware.camera.provider@2.7",
        "android.hardware.camera.provider-V3-ndk",
        "android.hardware.camera.device@1.0",
        "android.hardware.camera.device@3.2",
        "android.hardware.camera.device@3.4",
        "libaudiohal@7.0",
    ],
}

cc_fuzz {
    name: "metadataretriever_fuzzer",
    srcs: [
        "metadataretriever_fuzzer.cpp",
    ],
    defaults: [
        "libmediaplayerserviceFuzzer_defaults",
        "libmediaplayerservice_defaults",
    ],
    static_libs: [
        "libplayerservice_datasource",
    ],
    shared_libs: [
        "libdatasource",
        "libdrmframework",
        "libstagefright_httplive",
        "libmediaextractorservice",
    ],
    include_dirs: ["frameworks/av/services/mediaextractor"],
}

cc_fuzz {
    name: "mediaplayer_fuzzer",
    srcs: [
        "mediaplayer_fuzzer.cpp",
    ],
    defaults: [
        "libmediaplayerserviceFuzzer_defaults",
    ],
    static_libs: [
        "libgmock",
        "libgtest_ndk_c++",
        "libplayerservice_datasource",
        "libstagefright_nuplayer",
        "libstagefright_rtsp",
        "libstagefright_timedtext",
        "libbinder_random_parcel",
    ],
    shared_libs: [
        "android.hardware.media.c2@1.0",
        "android.hardware.media.omx@1.0",
        "av-types-aidl-cpp",
        "libaudioclient_aidl_conversion",
        "libbase",
        "libactivitymanager_aidl",
        "libandroid_net",
        "libaudioclient",
        "libaudiofoundation",
        "libcamera_client",
        "libcodec2_client",
        "libcrypto",
        "libdatasource",
        "libdrmframework",
        "libgui",
        "libhidlbase",
        "liblog",
        "libmedia_codeclist",
        "libmedia_omx",
        "libmediadrm",
        "libmediametrics",
        "libmediautils",
        "libmemunreachable",
        "libnetd_client",
        "libpowermanager",
        "libstagefright_httplive",
        "libaudiohal@7.0",
        "libmediaextractorservice",
    ],
    corpus: ["corpus/*"],
    include_dirs: ["frameworks/av/services/mediaextractor"],
}

cc_fuzz {
    name: "media_player_service_fuzzer",
    defaults: [
        "service_fuzzer_defaults",
        "libmediaplayerservice_defaults",
        "fuzzer_disable_leaks",
    ],
    srcs: [
        "media_player_service_fuzzer.cpp",
    ],
    fuzz_config: {
        cc: [
            "kyslov@google.com",
            "ibaker@google.com",
        ],
        triage_assignee: "waghpawan@google.com",
    },
    cflags: [
        "-DFUZZ_MODE_MEDIA_PLAYER_SERVICE",
    ],
    include_dirs: ["frameworks/av/media/libmediaplayerservice/"],
}
