1//########################################################################
2// Build FrameworksNetTests package
3//########################################################################
4package {
5    default_team: "trendy_team_fwk_core_networking",
6    // See: http://go/android-license-faq
7    // A large-scale-change added 'default_applicable_licenses' to import
8    // all of the 'license_kinds' from "Android-Apache-2.0"
9    // to get the below license kinds:
10    //   SPDX-license-identifier-Apache-2.0
11    default_applicable_licenses: ["Android-Apache-2.0"],
12}
13
14// Whether to enable the FrameworksNetTests. Set to false in the branches that might have older
15// frameworks/base since FrameworksNetTests includes the test for classes that are not in
16// connectivity module.
17enable_frameworks_net_tests = true
18// Placeholder
19// This is a placeholder comment to minimize merge conflicts, as enable_frameworks_net_tests
20// may have different values depending on the branch
21// Placeholder
22
23java_defaults {
24    name: "FrameworksNetTests-jni-defaults",
25    jni_libs: [
26        "ld-android",
27        "libandroid_net_frameworktests_util_jni",
28        "libbase",
29        "libbinder",
30        "libc++",
31        "libcrypto",
32        "libcutils",
33        "libdl_android",
34        "libhidl-gen-utils",
35        "libhidlbase",
36        "libjsoncpp",
37        "liblog",
38        "liblzma",
39        "libnativehelper",
40        "libnetdutils",
41        "libnetworkstats",
42        "libnetworkstatsfactorytestjni",
43        "libpackagelistparser",
44        "libpcre2",
45        "libselinux",
46        "libtinyxml2",
47        "libui",
48        "libunwindstack",
49        "libutils",
50        "libutilscallstack",
51        "libvndksupport",
52        "libziparchive",
53        "libz",
54        "netd_aidl_interface-V5-cpp",
55    ],
56}
57
58filegroup {
59    name: "non-connectivity-module-test",
60    srcs: [
61        "java/android/net/IpMemoryStoreTest.java",
62        "java/android/net/TelephonyNetworkSpecifierTest.java",
63        "java/android/net/ipmemorystore/*.java",
64        "java/android/net/netstats/NetworkStatsDataMigrationUtilsTest.kt",
65        "java/com/android/internal/net/NetworkUtilsInternalTest.java",
66        "java/com/android/server/connectivity/IpConnectivityEventBuilderTest.java",
67        "java/com/android/server/connectivity/IpConnectivityMetricsTest.java",
68        "java/com/android/server/connectivity/MetricsTestUtil.java",
69        "java/com/android/server/connectivity/MultipathPolicyTrackerTest.java",
70        "java/com/android/server/connectivity/NetdEventListenerServiceTest.java",
71        "java/com/android/server/net/ipmemorystore/*.java",
72    ],
73}
74
75java_defaults {
76    name: "FrameworksNetTestsDefaults",
77    min_sdk_version: "30",
78    defaults: [
79        "framework-connectivity-internal-test-defaults",
80    ],
81    srcs: [
82        "java/**/*.java",
83        "java/**/*.kt",
84    ],
85    static_libs: [
86        "androidx.test.rules",
87        "androidx.test.uiautomator_uiautomator",
88        "bouncycastle-repackaged-unbundled",
89        "core-tests-support",
90        "FrameworksNetCommonTests",
91        "frameworks-base-testutils",
92        "frameworks-net-integration-testutils",
93        "framework-protos",
94        "mockito-target-minus-junit4",
95        "net-tests-utils",
96        "net-utils-services-common",
97        "platform-compat-test-rules",
98        "platform-test-annotations",
99        "service-connectivity-pre-jarjar",
100        "service-connectivity-tiramisu-pre-jarjar",
101        "testables",
102        "cts-net-utils",
103    ],
104    libs: [
105        "android.net.ipsec.ike.stubs.module_lib",
106        "android.test.runner",
107        "android.test.base",
108        "android.test.mock",
109        "ServiceConnectivityResources",
110    ],
111    exclude_kotlinc_generated_files: false,
112}
113
114android_library {
115    name: "FrameworksNetTestsLib",
116    defaults: [
117        "FrameworksNetTestsDefaults",
118    ],
119    exclude_srcs: [":non-connectivity-module-test"],
120    visibility: ["//packages/modules/Connectivity/tests:__subpackages__"],
121}
122
123genrule {
124    name: "frameworks-net-tests-jarjar-rules",
125    defaults: ["jarjar-rules-combine-defaults"],
126    srcs: [
127        ":frameworks-net-tests-lib-jarjar-gen",
128        // This is necessary because the tests use framework-connectivity-internal-test-defaults,
129        // which require the user to use connectivity jarjar rules.
130        ":connectivity-jarjar-rules",
131    ],
132    out: ["frameworks-net-tests-jarjar-rules.txt"],
133    visibility: ["//packages/modules/Connectivity/tests:__subpackages__"],
134}
135
136java_genrule {
137    name: "frameworks-net-tests-lib-jarjar-gen",
138    tool_files: [
139        ":FrameworksNetTestsLib{.jar}",
140        "jarjar-excludes.txt",
141    ],
142    tools: [
143        "jarjar-rules-generator",
144    ],
145    out: ["frameworks-net-tests-lib-jarjar-rules.txt"],
146    cmd: "$(location jarjar-rules-generator) " +
147        "$(location :FrameworksNetTestsLib{.jar}) " +
148        "--prefix android.net.connectivity " +
149        "--excludes $(location jarjar-excludes.txt) " +
150        "--output $(out)",
151    visibility: ["//visibility:private"],
152}
153
154android_test {
155    name: "FrameworksNetTests",
156    enabled: enable_frameworks_net_tests,
157    defaults: [
158        "FrameworksNetTestsDefaults",
159        "FrameworksNetTests-jni-defaults",
160    ],
161    jarjar_rules: ":frameworks-net-tests-jarjar-rules",
162    test_suites: ["device-tests"],
163    static_libs: [
164        "services.core",
165        "services.net",
166    ],
167    jni_libs: [
168        "libandroid_net_connectivity_com_android_net_module_util_jni",
169        "libservice-connectivity",
170    ],
171}
172