// 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"],
}

android_app_certificate {
    name: "com.android.appsearch.apk.certificate",
    certificate: "com.android.appsearch.apk",
}

java_defaults {
    name: "appsearch-apk-defaults",
    sdk_version: "module_current",
    min_sdk_version: "Tiramisu",
    srcs: ["src/**/*.java"],
    static_libs: [
        "androidx.appcompat_appcompat",
        "com.android.appsearch.isolated_storage_service.aidl-java",
        "com.android.isolated_storage_service.aidl-java",
        "statslog-appsearch-lib",
    ],
    libs: [
        "androidx.annotation_annotation",
        "framework-virtualization.stubs.module_lib",
    ],
    jni_uses_platform_apis: true,
    use_embedded_native_libs: true,
    apex_available: ["com.android.appsearch"],

    // - this library is mounted via the APEX
    // jni_libs: ["libicing_anywhere"],
    optimize: {
        // TODO: more aggressive proguarding?
        // proguard_compatibility: false,
        // proguard_flags_files: ["proguard.flags"],

        enabled: true,
        optimize: true,
        shrink_resources: true,
        shrink: true,
    },
}

android_app {
    name: "com.android.appsearch.apk",
    sdk_version: "module_current",
    min_sdk_version: "Tiramisu",
    privileged: true,
    updatable: true,
    certificate: ":com.android.appsearch.apk.certificate",
    defaults: [
        "appsearch-apk-defaults",
    ],
    compile_multilib: "first",
    apex_available: ["com.android.appsearch"],
}

// A special library created strictly for use by the tests as they need the implementation library
// but that is not available when building from prebuilts. Using a library with a different name to
// what is used by the prebuilts ensures that this will never depend on the prebuilt.
java_library {
    name: "appsearch-apk-for-tests",
    defaults: ["appsearch-apk-defaults"],
}
