blob: 08b60d0dda011f0fecd2c0cbbe552ae3563b2e1f [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",
Luke Huang02ea10d2020-04-07 15:45:02 +000090 "netd_aidl_interface-V3-java",
Remi NGUYEN VAN1fc930c2019-08-09 13:23:47 +090091 "netlink-client",
Remi NGUYEN VANbbb97032019-08-08 15:53:54 +090092 "networkstack-client",
Chiachang Wang8b5f84a2019-02-22 11:13:07 +080093 "datastallprotosnano",
lifr1995d8e2020-05-21 20:32:36 +080094 "statsprotos",
paulhu5982eff2019-03-29 19:21:30 +080095 "captiveportal-lib",
Remi NGUYEN VAN0a4df5a2019-03-08 17:20:49 +090096 ],
Kun Niuf3b69042019-07-01 17:03:20 -070097 plugins: ["java_api_finder"],
Remi NGUYEN VAN0a4df5a2019-03-08 17:20:49 +090098}
99
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900100// The versions of the android library containing network stack code compiled for each SDK variant
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900101// API current uses the sources of the API current shims directly.
102// This allows API current code to be treated identically to code in src/ (it will be moved
103// there eventually), and to use the compat shim as fallback on older devices.
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900104android_library {
105 name: "NetworkStackApiCurrentLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900106 defaults: ["NetworkStackDevApiLevel", "NetworkStackAndroidLibraryDefaults"],
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800107 srcs: [
108 ":NetworkStackApiCurrentShims",
109 "src/**/*.java",
110 ":statslog-networkstack-java-gen"
111 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900112 manifest: "AndroidManifestBase.xml",
113}
114
115// For API stable, first build the dependencies using jarjar compat rules, then build the sources
116// linking with the dependencies.
117java_library {
118 name: "NetworkStackApiStableDependencies",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900119 defaults: ["NetworkStackReleaseApiLevel", "NetworkStackAndroidLibraryDefaults"],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900120 srcs: [":NetworkStackApiStableShims"],
121 jarjar_rules: "apishim/jarjar-rules-compat.txt",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900122}
123
124android_library {
125 name: "NetworkStackApiStableLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900126 defaults: ["NetworkStackReleaseApiLevel"],
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800127 srcs: [
128 "src/**/*.java",
129 ":statslog-networkstack-java-gen-q",
130 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900131 // API stable uses a jarjared version of the shims
132 static_libs: [
133 "NetworkStackApiStableDependencies",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900134 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900135 manifest: "AndroidManifestBase.xml",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900136}
137
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900138filegroup {
139 name: "NetworkStackJarJarRules",
140 srcs: ["jarjar-rules-shared.txt"],
141 visibility: [
142 "//packages/modules/NetworkStack/tests/unit",
143 "//packages/modules/NetworkStack/tests/integration",
Paul Huc0312402020-04-10 09:59:48 +0000144 "//frameworks/base/packages/Tethering/tests/integration",
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900145 ]
146}
147
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900148// Common defaults for compiling the actual APK, based on the NetworkStackApiXBase android libraries
149java_defaults {
150 name: "NetworkStackAppDefaults",
151 privileged: true,
152 jni_libs: [
153 "libnativehelper_compat_libc++",
154 "libnetworkstackutilsjni",
155 ],
156 // Resources already included in NetworkStackBase
157 resource_dirs: [],
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900158 jarjar_rules: ":NetworkStackJarJarRules",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900159 use_embedded_native_libs: true,
160 optimize: {
161 proguard_flags_files: ["proguard.flags"],
162 },
163}
164
165// Non-updatable network stack running in the system server process for devices not using the module
166android_app {
167 name: "InProcessNetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900168 defaults: [ "NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900169 static_libs: ["NetworkStackApiCurrentLib"],
170 certificate: "platform",
171 manifest: "AndroidManifest_InProcess.xml",
172 // InProcessNetworkStack is a replacement for NetworkStack
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000173 overrides: ["NetworkStack", "NetworkStackNext"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900174 // The permission configuration *must* be included to ensure security of the device
175 // The InProcessNetworkStack goes together with the PlatformCaptivePortalLogin, which replaces
176 // the default CaptivePortalLogin.
177 required: ["PlatformNetworkPermissionConfig", "PlatformCaptivePortalLogin"],
178}
179
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900180// Pre-merge the AndroidManifest for NetworkStackNext, so that its manifest can be merged on top
181android_library {
182 name: "NetworkStackNextManifestBase",
183 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
184 static_libs: ["NetworkStackApiCurrentLib"],
185 manifest: "AndroidManifest.xml"
186}
187
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900188// NetworkStack build targeting the current API release, for testing on in-development SDK
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900189android_app {
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000190 name: "NetworkStackNext",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900191 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900192 static_libs: ["NetworkStackNextManifestBase"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900193 certificate: "networkstack",
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900194 manifest: "AndroidManifest_Next.xml",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900195 // The permission configuration *must* be included to ensure security of the device
196 required: ["NetworkPermissionConfig"],
197}
198
199// Updatable network stack for finalized API
200android_app {
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000201 name: "NetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900202 defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900203 static_libs: ["NetworkStackApiStableLib"],
204 certificate: "networkstack",
205 manifest: "AndroidManifest.xml",
206 // The permission configuration *must* be included to ensure security of the device
207 required: ["NetworkPermissionConfig"],
Artur Satayev66780a82020-04-09 11:35:52 +0100208 updatable: true,
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900209}
210
211// Android library to derive test APKs for integration tests
212android_library {
213 name: "TestNetworkStackLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900214 defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"],
215 static_libs: ["NetworkStackApiStableLib"],
Remi NGUYEN VANae18aed2019-10-30 18:20:36 +0900216 manifest: "AndroidManifestBase.xml",
Remi NGUYEN VAN252c6f22020-05-25 18:27:59 +0900217 visibility: [
218 "//frameworks/base/tests/net/integration",
219 "//cts/tests/tests/net",
220 ],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900221}
222
paulhue455e2a2019-03-29 17:22:20 +0800223cc_library_shared {
224 name: "libnetworkstackutilsjni",
225 srcs: [
226 "jni/network_stack_utils_jni.cpp"
227 ],
Jooyung Han9b1bf052020-04-29 02:43:03 +0900228 sdk_version: "29",
229 min_sdk_version: "29",
paulhue455e2a2019-03-29 17:22:20 +0800230 shared_libs: [
231 "liblog",
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900232 "libnativehelper_compat_libc++",
paulhue455e2a2019-03-29 17:22:20 +0800233 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900234
235 // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
236 // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
237 // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
238 // build because soong complains of:
239 // module NetworkStack missing dependencies: libc++_shared
240 //
241 // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
242 // we depend on do not dynamically link libc++. This is currently the case, because liblog is
243 // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
244 //
245 // TODO: find a better solution for this in R.
246 stl: "c++_static",
paulhue455e2a2019-03-29 17:22:20 +0800247 cflags: [
248 "-Wall",
249 "-Werror",
250 "-Wno-unused-parameter",
251 ],
252}
253
Chiachang Wang80242272019-04-11 21:24:28 +0800254genrule {
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800255 name: "statslog-networkstack-java-gen-q",
256 tools: ["stats-log-api-gen"],
257 cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
258 " --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog" +
259 " --compileQ",
260 out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
261}
262
263genrule {
Chiachang Wang80242272019-04-11 21:24:28 +0800264 name: "statslog-networkstack-java-gen",
265 tools: ["stats-log-api-gen"],
266 cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
Muhammad Qureshi8e0e9bc2019-12-31 11:26:33 -0800267 " --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog" +
268 " --supportQ",
Chiachang Wang80242272019-04-11 21:24:28 +0800269 out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
270}
Kun Niu8e89dd42019-07-16 18:33:45 -0700271
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900272version_code_networkstack_next = "300000000"
273version_code_networkstack_test = "999999999"
274
Kun Niu8e89dd42019-07-16 18:33:45 -0700275genrule {
276 name: "NetworkStackTestAndroidManifest",
277 srcs: ["AndroidManifest.xml"],
278 out: ["TestAndroidManifest.xml"],
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900279 cmd: "sed -E 's/versionCode=\"[0-9]+\"/versionCode=\""
280 + version_code_networkstack_test
281 + "\"/' $(in) > $(out)",
282 visibility: ["//visibility:private"],
283}
284
Kun Niu8e89dd42019-07-16 18:33:45 -0700285android_app {
286 name: "TestNetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900287 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900288 static_libs: ["NetworkStackApiCurrentLib"],
Kun Niu8e89dd42019-07-16 18:33:45 -0700289 certificate: "networkstack",
290 manifest: ":NetworkStackTestAndroidManifest",
Kun Niu8e89dd42019-07-16 18:33:45 -0700291 // The permission configuration *must* be included to ensure security of the device
292 required: ["NetworkPermissionConfig"],
293}
lifr1995d8e2020-05-21 20:32:36 +0800294
295java_library_static {
296 name: "statsprotos",
297 proto: {
298 type: "lite",
299 },
300 srcs: [
301 "src/com/android/networkstack/metrics/stats.proto",
302 ],
303 static_libs: [
304 "networkstackprotos",
305 ],
306 defaults: ["NetworkStackReleaseApiLevel"],
307}