/*
 * Copyright (C) 2020 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 {
    default_applicable_licenses: ["Android-Apache-2.0"],
}

cc_library_shared {
    name: "liblmkhelper_statsdatom", //TODO(b/163546661): rename back to liblmkhelper.
    srcs: ["jni/alloc_stress_activity.cpp"],
    cflags: [
        "-Wall",
        "-Werror",
    ],
    header_libs: ["jni_headers"],
    shared_libs: ["liblog"],
    stl: "c++_static",
    sdk_version: "current",
}

cc_library_shared {
    name: "libcrashhelper",
    srcs: ["jni/crash_activity.cpp"],
    cflags: [
        "-Wall",
        "-Werror",
    ],
    header_libs: ["jni_headers"],
    stl: "c++_static",
    sdk_version: "current",
}

cc_library_shared {
    name: "libimagedecoderhelper",
    srcs: ["jni/image_decoding.cpp"],
    cflags: [
        "-Wall",
        "-Werror",
    ],
    shared_libs: [
        "libandroid",
        "libjnigraphics",
        "liblog",
    ],
    header_libs: ["jni_headers"],
    stl: "c++_static",
    sdk_version: "current",
}

android_test_helper_app {
    name: "CtsStatsdAtomApp",
    defaults: ["cts_defaults"],
    platform_apis: true,
    min_sdk_version: "28",
    target_sdk_version: "36",
    srcs: [
        "src/**/*.java",
        ":statslog-statsdatom-cts-java-gen",
    ],
    libs: [
        "androidx.annotation_annotation",
        "android.test.runner.stubs.system",
        "junit",
        "org.apache.http.legacy.stubs.system",
    ],
    privileged: true,
    static_libs: [
        "bluetooth-test-util-lib",
        "core-tests-support",
        "ctstestrunner-axt",
        "compatibility-device-util-axt",
        "androidx.legacy_legacy-support-v4",
        "androidx.test.rules",
        "cts-net-utils",
        "collector-device-lib",
        "cts_adpf_atom_common",
        "flag-junit",
    ],
    jni_libs: [
        "liblmkhelper_statsdatom",
        "libcrashhelper",
        "libimagedecoderhelper",
    ],
    compile_multilib: "both",
    v4_signature: true,
}

java_library_static {
    name: "statslog-cts",
    srcs: [
        ":statslog-statsdatom-cts-java-gen",
    ],
    libs: [
        "androidx.annotation_annotation",
    ],
    visibility: [
        "//cts/hostsidetests/statsdapp/apps:__subpackages__",
        "//vendor:__subpackages__",
    ],
}

genrule {
    name: "statslog-statsdatom-cts-java-gen",
    tools: ["stats-log-api-gen"],
    cmd: "$(location stats-log-api-gen) --java $(out) --module cts --javaPackage com.android.server.cts.device.statsdatom --javaClass StatsLogStatsdCts",
    out: ["com/android/server/cts/device/statsdatom/StatsLogStatsdCts.java"],
}
