blob: 37e001cc6141a7afe28e9894a7de59a38b47d41c [file] [log] [blame]
Remi NGUYEN VANded23152018-12-07 16:52:24 +09001//
2// Copyright (C) 2018 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090017// The network stack can be compiled using system_current (non-finalized) SDK, or finalized system_X
18// SDK. There is also a variant that uses system_current SDK and runs in the system process
19// (InProcessNetworkStack). The following structure is used to create the build rules:
20//
21// NetworkStackAndroidLibraryDefaults <-- common defaults for android libs
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +090022// / \
23// +NetworkStackApiStableShims --> / \ <-- +NetworkStackApiCurrentShims
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +090024// +NetworkStackReleaseApiLevel / \ +NetworkStackDevApiLevel
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +090025// +jarjar apistub.api[latest].* / \ +module src/
26// to apistub.* / \
27// / \
28// NetworkStackApiStableDependencies \
29// / \ android libs w/ all code
30// +module src/ --> / \ (also used in unit tests)
31// / \ |
32// NetworkStackApiStableLib NetworkStackApiCurrentLib <--*
33// | |
34// | <-- +NetworkStackAppDefaults --> |
35// | (APK build params) |
36// | |
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +090037// | <-- +NetworkStackReleaseApiLevel | <-- +NetworkStackDevApiLevel
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +090038// | |
39// | |
40// NetworkStackApiStable NetworkStack, InProcessNetworkStack, <-- APKs
41// TestNetworkStack
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090042
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090043// Common defaults to define SDK level
Remi NGUYEN VAN40369562019-03-20 16:40:54 +090044java_defaults {
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +090045 name: "NetworkStackDevApiLevel",
Remi NGUYEN VAN40369562019-03-20 16:40:54 +090046 sdk_version: "system_current",
Remi NGUYEN VAN40369562019-03-20 16:40:54 +090047}
48
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090049java_defaults {
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +090050 name: "NetworkStackReleaseApiLevel",
Remi NGUYEN VAN38dc8342020-05-18 18:09:28 +090051 sdk_version: "system_30",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +090052 min_sdk_version: "29",
Remi NGUYEN VAN03bcf6c2020-05-07 18:53:35 +090053 target_sdk_version: "30",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090054}
55
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +090056// Filegroups for the API shims
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090057filegroup {
58 name: "NetworkStackApiCurrentShims",
59 srcs: [
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +090060 "apishim/common/**/*.java",
61 "apishim/29/**/*.java",
Remi NGUYEN VANf9c9b712019-11-08 11:37:33 +000062 "apishim/30/**/*.java",
Remi NGUYEN VAN03bcf6c2020-05-07 18:53:35 +090063 "apishim/31/**/*.java",
Remi NGUYEN VAN44e8ebf2020-02-15 04:36:06 +090064 ":networkstack-module-utils-srcs",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090065 ],
66}
67
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +090068// API stable shims only include the compat package, but it is jarjared to replace the non-compat
69// package
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090070filegroup {
71 name: "NetworkStackApiStableShims",
72 srcs: [
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +090073 "apishim/common/**/*.java",
74 "apishim/29/**/*.java",
Remi NGUYEN VAN03bcf6c2020-05-07 18:53:35 +090075 "apishim/30/**/*.java",
Remi NGUYEN VAN44e8ebf2020-02-15 04:36:06 +090076 ":networkstack-module-utils-srcs",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090077 ],
78}
79
80// Common defaults for android libraries containing network stack code, used to compile variants of
81// the network stack in the system process and in the network_stack process
82java_defaults {
83 name: "NetworkStackAndroidLibraryDefaults",
Remi NGUYEN VANded23152018-12-07 16:52:24 +090084 srcs: [
Remi NGUYEN VAN82b4b422019-01-20 09:35:10 +090085 ":framework-networkstack-shared-srcs",
Remi NGUYEN VANded23152018-12-07 16:52:24 +090086 ],
Artur Satayev0eb158a2019-12-10 12:54:01 +000087 libs: ["unsupportedappusage"],
Remi NGUYEN VAN057bf202018-12-04 12:13:09 +090088 static_libs: [
Niklas Lindgren0c904882018-12-07 11:08:04 +010089 "androidx.annotation_annotation",
Lorenzo Colittied700062020-06-10 01:03:55 +090090 "netd_aidl_interface-java",
Remi NGUYEN VAN1fc930c2019-08-09 13:23:47 +090091 "netlink-client",
Remi NGUYEN VANbbb97032019-08-08 15:53:54 +090092 "networkstack-client",
Remi NGUYEN VANc628adc2020-06-08 15:34:22 +090093 "net-utils-framework-common",
Remi NGUYEN VANe7c00c42020-06-22 18:50:20 +090094 // See note on statsprotos when adding/updating proto build rules
Chiachang Wang8b5f84a2019-02-22 11:13:07 +080095 "datastallprotosnano",
lifr1995d8e2020-05-21 20:32:36 +080096 "statsprotos",
paulhu5982eff2019-03-29 19:21:30 +080097 "captiveportal-lib",
Remi NGUYEN VAN0a4df5a2019-03-08 17:20:49 +090098 ],
Kun Niuf3b69042019-07-01 17:03:20 -070099 plugins: ["java_api_finder"],
Remi NGUYEN VAN0a4df5a2019-03-08 17:20:49 +0900100}
101
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900102// The versions of the android library containing network stack code compiled for each SDK variant
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900103// API current uses the sources of the API current shims directly.
104// This allows API current code to be treated identically to code in src/ (it will be moved
105// there eventually), and to use the compat shim as fallback on older devices.
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900106android_library {
107 name: "NetworkStackApiCurrentLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900108 defaults: ["NetworkStackDevApiLevel", "NetworkStackAndroidLibraryDefaults"],
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800109 srcs: [
110 ":NetworkStackApiCurrentShims",
111 "src/**/*.java",
112 ":statslog-networkstack-java-gen"
113 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900114 manifest: "AndroidManifestBase.xml",
115}
116
117// For API stable, first build the dependencies using jarjar compat rules, then build the sources
118// linking with the dependencies.
119java_library {
120 name: "NetworkStackApiStableDependencies",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900121 defaults: ["NetworkStackReleaseApiLevel", "NetworkStackAndroidLibraryDefaults"],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900122 srcs: [":NetworkStackApiStableShims"],
123 jarjar_rules: "apishim/jarjar-rules-compat.txt",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900124}
125
126android_library {
127 name: "NetworkStackApiStableLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900128 defaults: ["NetworkStackReleaseApiLevel"],
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800129 srcs: [
130 "src/**/*.java",
Remi NGUYEN VANfdfd2012020-07-07 15:41:12 +0900131 ":statslog-networkstack-java-gen",
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800132 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900133 // API stable uses a jarjared version of the shims
134 static_libs: [
135 "NetworkStackApiStableDependencies",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900136 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900137 manifest: "AndroidManifestBase.xml",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900138}
139
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900140filegroup {
141 name: "NetworkStackJarJarRules",
142 srcs: ["jarjar-rules-shared.txt"],
143 visibility: [
144 "//packages/modules/NetworkStack/tests/unit",
145 "//packages/modules/NetworkStack/tests/integration",
Paul Huc0312402020-04-10 09:59:48 +0000146 "//frameworks/base/packages/Tethering/tests/integration",
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900147 ]
148}
149
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900150// Common defaults for compiling the actual APK, based on the NetworkStackApiXBase android libraries
151java_defaults {
152 name: "NetworkStackAppDefaults",
153 privileged: true,
154 jni_libs: [
155 "libnativehelper_compat_libc++",
156 "libnetworkstackutilsjni",
157 ],
158 // Resources already included in NetworkStackBase
159 resource_dirs: [],
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900160 jarjar_rules: ":NetworkStackJarJarRules",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900161 use_embedded_native_libs: true,
162 optimize: {
163 proguard_flags_files: ["proguard.flags"],
164 },
165}
166
167// Non-updatable network stack running in the system server process for devices not using the module
168android_app {
169 name: "InProcessNetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900170 defaults: [ "NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900171 static_libs: ["NetworkStackApiCurrentLib"],
172 certificate: "platform",
173 manifest: "AndroidManifest_InProcess.xml",
174 // InProcessNetworkStack is a replacement for NetworkStack
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000175 overrides: ["NetworkStack", "NetworkStackNext"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900176 // The permission configuration *must* be included to ensure security of the device
177 // The InProcessNetworkStack goes together with the PlatformCaptivePortalLogin, which replaces
178 // the default CaptivePortalLogin.
179 required: ["PlatformNetworkPermissionConfig", "PlatformCaptivePortalLogin"],
180}
181
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900182// Pre-merge the AndroidManifest for NetworkStackNext, so that its manifest can be merged on top
183android_library {
184 name: "NetworkStackNextManifestBase",
185 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
186 static_libs: ["NetworkStackApiCurrentLib"],
187 manifest: "AndroidManifest.xml"
188}
189
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900190// NetworkStack build targeting the current API release, for testing on in-development SDK
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900191android_app {
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000192 name: "NetworkStackNext",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900193 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900194 static_libs: ["NetworkStackNextManifestBase"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900195 certificate: "networkstack",
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900196 manifest: "AndroidManifest_Next.xml",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900197 // The permission configuration *must* be included to ensure security of the device
198 required: ["NetworkPermissionConfig"],
199}
200
201// Updatable network stack for finalized API
202android_app {
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000203 name: "NetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900204 defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900205 static_libs: ["NetworkStackApiStableLib"],
206 certificate: "networkstack",
207 manifest: "AndroidManifest.xml",
208 // The permission configuration *must* be included to ensure security of the device
209 required: ["NetworkPermissionConfig"],
Artur Satayev66780a82020-04-09 11:35:52 +0100210 updatable: true,
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900211}
212
213// Android library to derive test APKs for integration tests
214android_library {
215 name: "TestNetworkStackLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900216 defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"],
217 static_libs: ["NetworkStackApiStableLib"],
Remi NGUYEN VANae18aed2019-10-30 18:20:36 +0900218 manifest: "AndroidManifestBase.xml",
Remi NGUYEN VAN252c6f22020-05-25 18:27:59 +0900219 visibility: [
220 "//frameworks/base/tests/net/integration",
221 "//cts/tests/tests/net",
222 ],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900223}
224
paulhue455e2a2019-03-29 17:22:20 +0800225cc_library_shared {
226 name: "libnetworkstackutilsjni",
227 srcs: [
228 "jni/network_stack_utils_jni.cpp"
229 ],
Jooyung Han9b1bf052020-04-29 02:43:03 +0900230 sdk_version: "29",
231 min_sdk_version: "29",
paulhue455e2a2019-03-29 17:22:20 +0800232 shared_libs: [
233 "liblog",
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900234 "libnativehelper_compat_libc++",
paulhue455e2a2019-03-29 17:22:20 +0800235 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900236
237 // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
238 // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
239 // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
240 // build because soong complains of:
241 // module NetworkStack missing dependencies: libc++_shared
242 //
243 // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
244 // we depend on do not dynamically link libc++. This is currently the case, because liblog is
245 // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
246 //
247 // TODO: find a better solution for this in R.
248 stl: "c++_static",
paulhue455e2a2019-03-29 17:22:20 +0800249 cflags: [
250 "-Wall",
251 "-Werror",
252 "-Wno-unused-parameter",
253 ],
254}
255
Chiachang Wang80242272019-04-11 21:24:28 +0800256genrule {
257 name: "statslog-networkstack-java-gen",
258 tools: ["stats-log-api-gen"],
259 cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
Muhammad Qureshi8e0e9bc2019-12-31 11:26:33 -0800260 " --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog" +
261 " --supportQ",
Chiachang Wang80242272019-04-11 21:24:28 +0800262 out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
263}
Kun Niu8e89dd42019-07-16 18:33:45 -0700264
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900265version_code_networkstack_next = "300000000"
266version_code_networkstack_test = "999999999"
267
Kun Niu8e89dd42019-07-16 18:33:45 -0700268genrule {
269 name: "NetworkStackTestAndroidManifest",
270 srcs: ["AndroidManifest.xml"],
271 out: ["TestAndroidManifest.xml"],
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900272 cmd: "sed -E 's/versionCode=\"[0-9]+\"/versionCode=\""
273 + version_code_networkstack_test
274 + "\"/' $(in) > $(out)",
275 visibility: ["//visibility:private"],
276}
277
Kun Niu8e89dd42019-07-16 18:33:45 -0700278android_app {
279 name: "TestNetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900280 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900281 static_libs: ["NetworkStackApiCurrentLib"],
Kun Niu8e89dd42019-07-16 18:33:45 -0700282 certificate: "networkstack",
283 manifest: ":NetworkStackTestAndroidManifest",
Kun Niu8e89dd42019-07-16 18:33:45 -0700284 // The permission configuration *must* be included to ensure security of the device
285 required: ["NetworkPermissionConfig"],
286}
lifr1995d8e2020-05-21 20:32:36 +0800287
Remi NGUYEN VANe7c00c42020-06-22 18:50:20 +0900288// When adding or modifying protos, the jarjar rules and possibly proguard rules need
289// to be updated: proto libraries may pull additional static libraries.
lifr1995d8e2020-05-21 20:32:36 +0800290java_library_static {
291 name: "statsprotos",
292 proto: {
293 type: "lite",
294 },
295 srcs: [
296 "src/com/android/networkstack/metrics/stats.proto",
297 ],
298 static_libs: [
299 "networkstackprotos",
300 ],
301 defaults: ["NetworkStackReleaseApiLevel"],
302}