1// Copyright (C) 2019 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package {
16    default_applicable_licenses: ["Android-Apache-2.0"],
17}
18
19apex_test {
20    name: "test_com.android.sdkext",
21    defaults: ["com.android.sdkext-defaults"],
22    bootclasspath_fragments: ["test_com.android.sdkext-bootclasspath-fragment"],
23    manifest: "test_manifest.json",
24    prebuilts: [
25        "sdkinfo_45",
26        "test_extensions_db",
27    ],
28    file_contexts: ":com.android.sdkext-file_contexts",
29    installable: false, // Should never be installed on the systemimage
30    multilib: {
31        prefer32: {
32            binaries: [
33                "derive_classpath_prefer32",
34                "derive_sdk_prefer32",
35            ],
36        },
37    },
38    // The automated test infra ends up building this apex for 64+32-bit and
39    // then installs it on a 32-bit-only device. Work around this weirdness
40    // by preferring 32-bit.
41    compile_multilib: "prefer32",
42}
43
44// Encapsulate the contributions made by the test_com.android.sdkext to the
45// bootclasspath.
46bootclasspath_fragment {
47    name: "test_com.android.sdkext-bootclasspath-fragment",
48    contents: [
49        "framework-sdkextensions",
50        "test_framework-sdkextensions",
51    ],
52    apex_available: ["test_com.android.sdkext"],
53
54    // The bootclasspath_fragments that provide APIs on which this depends.
55    fragments: [
56        {
57            apex: "com.android.art",
58            module: "art-bootclasspath-fragment",
59        },
60    ],
61}
62
63genrule {
64    name: "sdkinfo_45_src",
65    out: ["sdkinfo.pb"],
66    tools: ["gen_sdkinfo"],
67    cmd: "$(location) -v 45 -o $(out)",
68}
69
70prebuilt_etc {
71    name: "sdkinfo_45",
72    src: ":sdkinfo_45_src",
73    filename: "sdkinfo.pb",
74    installable: false,
75    visibility: [
76        ":__pkg__",
77        "//frameworks/av/apex/testing",
78    ],
79}
80
81genrule {
82    name: "test_extensions_db.pb",
83    srcs: ["test_extensions_db.textpb"],
84    out: ["test_extensions_db.pb"],
85    tools: ["gen_sdk"],
86    cmd: "$(location gen_sdk) --action print_binary --database $(location test_extensions_db.textpb) > $(out)",
87    visibility: ["//visibility:private"],
88}
89
90prebuilt_etc {
91    name: "test_extensions_db",
92    src: ":test_extensions_db.pb",
93    filename: "extensions_db.pb",
94    installable: false,
95    visibility: ["//visibility:private"],
96}
97
98filegroup {
99    name: "test_framework-sdkextensions-sources",
100    srcs: ["impl-src/android/os/ext/test/Test.java"],
101    path: "impl-src",
102    visibility: [
103        "//packages/modules/SdkExtensions:__subpackages__",
104    ],
105}
106
107java_sdk_library {
108    name: "test_framework-sdkextensions",
109    defaults: ["framework-module-defaults"],
110    srcs: [":test_framework-sdkextensions-sources"],
111    permitted_packages: ["android.os.ext.test"],
112    min_sdk_version: "30",
113    apex_available: [
114        "test_com.android.sdkext",
115    ],
116    impl_library_visibility: [
117        "//packages/modules/SdkExtensions/tests/e2e:__subpackages__",
118    ],
119    lint: {
120        strict_updatability_linting: true,
121    },
122
123    // Test only SDK, don't check against released APIs.
124    unsafe_ignore_missing_latest_api: true,
125
126    // Output the api files to a special directory that won't trigger an API
127    // review as it is a test only API.
128    api_dir: "apis_for_tests",
129
130    // Testing only.
131    no_dist: true,
132}
133