//
// 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.
//

package {
    default_team: "trendy_team_fwk_core_networking",
    default_applicable_licenses: ["Android-Apache-2.0"],
}

java_defaults {
    name: "CaptivePortalLoginDefaults",
    sdk_version: "module_current",
    min_sdk_version: "31",
    target_sdk_version: "36", // Keep in sync with CaptivePortalLoginTests
    lint: {
        strict_updatability_linting: true,
    },
    optimize: {
        ignore_warnings: false,
    },
}

android_library {
    name: "CaptivePortalLoginLib",
    defaults: ["CaptivePortalLoginDefaults"],
    srcs: [
        "src/**/*.java",
        ":statslog-captiveportallogin-java-gen",
    ],
    static_libs: [
        "androidx.annotation_annotation",
        "androidx.browser_browser",
        "androidx.legacy_legacy-support-core-ui",
        "captiveportal-lib",
        "metrics-constants-protos",
        "modules-utils-build",
        "net-utils-connectivity-apks",
    ],
    libs: [
        "framework-configinfrastructure.stubs.module_lib",
        "framework-connectivity.stubs.module_lib",
        "framework-mediaprovider.stubs.module_lib",
        "framework-statsd.stubs.module_lib",
        "framework-wifi.stubs.module_lib",
    ],
    manifest: "AndroidManifest.xml",
}

java_genrule {
    name: "CaptivePortalLoginJarJarRules",
    tool_files: [
        ":CaptivePortalLoginLib{.jar}",
        "jarjar-excludes.txt",
    ],
    tools: [
        "jarjar-rules-generator",
    ],
    out: ["CaptivePortalLoginJarJarRules.txt"],
    cmd: "$(location jarjar-rules-generator) " +
        "$(location :CaptivePortalLoginLib{.jar}) " +
        "--excludes $(location jarjar-excludes.txt) " +
        "--prefix com.android.captiveportallogin " +
        "--output $(out)",
    visibility: [
        "//packages/modules/CaptivePortalLogin:__subpackages__",
    ],
}

android_app {
    name: "CaptivePortalLogin",
    defaults: ["CaptivePortalLoginDefaults"],
    static_libs: ["CaptivePortalLoginLib"],
    jarjar_rules: ":CaptivePortalLoginJarJarRules",
    certificate: "networkstack",
    updatable: true,
    licenses: [
        "Android-Apache-2.0",
        "opensourcerequest",
    ],
}

android_library {
    name: "CaptivePortalLoginTestLib",
    defaults: ["CaptivePortalLoginDefaults"],
    static_libs: [
        "CaptivePortalLoginLib",
        "net-tests-utils",
    ],
    lint: {
        strict_updatability_linting: true,
    },
}

genrule {
    name: "statslog-captiveportallogin-java-gen",
    tools: ["stats-log-api-gen"],
    cmd: "$(location stats-log-api-gen) --java $(out) --module captive_portal_login" +
        " --javaPackage com.android.os.corenetworking.captiveportallogin --javaClass CaptivePortalLoginStatsLog" +
        " --minApiLevel 30",
    out: ["com/android/os/corenetworking/captiveportallogin/CaptivePortalLoginStatsLog.java"],
}
