/*
 * Copyright (C) 2024 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"],
}

filegroup {
    name: "service-profiling-sources",
    srcs: [
        "java/**/*.java",
        ":statslog-profiling-java-gen",
    ],
}

java_library {
    name: "service-profiling",
    defaults: ["standalone-system-server-module-optimize-defaults"],
    srcs: [":service-profiling-sources"],
    sdk_version: "system_server_current",
    libs: [
        "framework-annotations-lib",
        "framework-profiling.impl",
        "framework-configinfrastructure.stubs.module_lib",
        "framework-statsd.stubs.module_lib",
    ],
    static_libs: [
        "modules-utils-build",
        "profiling_flags_not_exported_lib",
        "service-profiling-proto",
        "perfetto_config_java_protos_system_server_current",
    ],
    lint: {
        strict_updatability_linting: true,
    },
    apex_available: [
        "com.android.profiling",
    ],
    min_sdk_version: "35",
    installable: true,
}

java_library {
    name: "service-profiling-proto",
    proto: {
        type: "lite",
        canonical_path_from_root: false,
        include_dirs: [
            "external/protobuf/src",
            "external/protobuf/java",
        ],
    },
    srcs: [
        "proto/**/*.proto",
    ],
    visibility: [
        "//packages/modules/Profiling/tests:__subpackages__",
    ],
    installable: false,
    min_sdk_version: "35",
    sdk_version: "system_server_current",
    apex_available: [
        "com.android.profiling",
    ],
}

genrule {
    name: "statslog-profiling-java-gen",
    tools: ["stats-log-api-gen"],
    cmd: "$(location stats-log-api-gen) --java $(out) --module profiling " +
        "--javaPackage android.os.profiling --javaClass ProfilingStatsLog " +
        "--minApiLevel 35",
    out: ["android/os/profiling/ProfilingStatsLog.java"],
}
