blob: cdda32a5cff77444f98201daa3afa278f5769dec [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 VAN67933142020-05-07 18:53:35 +090051 // TODO: use system_30 once a prebuilt SDK is available for R
52 sdk_version: "system_current",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +090053 min_sdk_version: "29",
Remi NGUYEN VAN67933142020-05-07 18:53:35 +090054 target_sdk_version: "30",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090055}
56
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +090057// Filegroups for the API shims
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090058filegroup {
59 name: "NetworkStackApiCurrentShims",
60 srcs: [
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +090061 "apishim/common/**/*.java",
62 "apishim/29/**/*.java",
Remi NGUYEN VANf9c9b712019-11-08 11:37:33 +000063 "apishim/30/**/*.java",
Remi NGUYEN VAN67933142020-05-07 18:53:35 +090064 "apishim/31/**/*.java",
Remi NGUYEN VAN44e8ebf2020-02-15 04:36:06 +090065 ":networkstack-module-utils-srcs",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090066 ],
67}
68
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +090069// API stable shims only include the compat package, but it is jarjared to replace the non-compat
70// package
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090071filegroup {
72 name: "NetworkStackApiStableShims",
73 srcs: [
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +090074 "apishim/common/**/*.java",
75 "apishim/29/**/*.java",
Remi NGUYEN VAN67933142020-05-07 18:53:35 +090076 "apishim/30/**/*.java",
Remi NGUYEN VAN44e8ebf2020-02-15 04:36:06 +090077 ":networkstack-module-utils-srcs",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090078 ],
79}
80
81// Common defaults for android libraries containing network stack code, used to compile variants of
82// the network stack in the system process and in the network_stack process
83java_defaults {
84 name: "NetworkStackAndroidLibraryDefaults",
Remi NGUYEN VANded23152018-12-07 16:52:24 +090085 srcs: [
Remi NGUYEN VAN82b4b422019-01-20 09:35:10 +090086 ":framework-networkstack-shared-srcs",
Remi NGUYEN VANded23152018-12-07 16:52:24 +090087 ],
Artur Satayev0eb158a2019-12-10 12:54:01 +000088 libs: ["unsupportedappusage"],
Remi NGUYEN VAN057bf202018-12-04 12:13:09 +090089 static_libs: [
Niklas Lindgren0c904882018-12-07 11:08:04 +010090 "androidx.annotation_annotation",
Hungming Chenb5b6e692020-05-29 20:09:23 +080091 "netd_aidl_interface-unstable-java",
Remi NGUYEN VAN1fc930c2019-08-09 13:23:47 +090092 "netlink-client",
Remi NGUYEN VANbbb97032019-08-08 15:53:54 +090093 "networkstack-client",
Remi NGUYEN VAN5b00d422020-06-08 15:34:22 +090094 "net-utils-framework-common",
Chiachang Wang8b5f84a2019-02-22 11:13:07 +080095 "datastallprotosnano",
lifrcb15db32020-05-21 20:32:36 +080096 "statsprotos",
paulhu5982eff2019-03-29 19:21:30 +080097 "captiveportal-lib",
Chalard Jean6f675212020-06-25 23:41:16 +090098 "net-utils-device-common",
Remi NGUYEN VAN0a4df5a2019-03-08 17:20:49 +090099 ],
Kun Niuf3b69042019-07-01 17:03:20 -0700100 plugins: ["java_api_finder"],
Remi NGUYEN VAN0a4df5a2019-03-08 17:20:49 +0900101}
102
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900103// The versions of the android library containing network stack code compiled for each SDK variant
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900104// API current uses the sources of the API current shims directly.
105// This allows API current code to be treated identically to code in src/ (it will be moved
106// there eventually), and to use the compat shim as fallback on older devices.
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900107android_library {
108 name: "NetworkStackApiCurrentLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900109 defaults: ["NetworkStackDevApiLevel", "NetworkStackAndroidLibraryDefaults"],
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800110 srcs: [
111 ":NetworkStackApiCurrentShims",
112 "src/**/*.java",
113 ":statslog-networkstack-java-gen"
114 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900115 manifest: "AndroidManifestBase.xml",
116}
117
118// For API stable, first build the dependencies using jarjar compat rules, then build the sources
119// linking with the dependencies.
120java_library {
121 name: "NetworkStackApiStableDependencies",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900122 defaults: ["NetworkStackReleaseApiLevel", "NetworkStackAndroidLibraryDefaults"],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900123 srcs: [":NetworkStackApiStableShims"],
124 jarjar_rules: "apishim/jarjar-rules-compat.txt",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900125}
126
127android_library {
128 name: "NetworkStackApiStableLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900129 defaults: ["NetworkStackReleaseApiLevel"],
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800130 srcs: [
131 "src/**/*.java",
132 ":statslog-networkstack-java-gen-q",
133 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900134 // API stable uses a jarjared version of the shims
135 static_libs: [
136 "NetworkStackApiStableDependencies",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900137 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900138 manifest: "AndroidManifestBase.xml",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900139}
140
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900141filegroup {
142 name: "NetworkStackJarJarRules",
143 srcs: ["jarjar-rules-shared.txt"],
144 visibility: [
145 "//packages/modules/NetworkStack/tests/unit",
146 "//packages/modules/NetworkStack/tests/integration",
paulhua9949882020-04-06 23:33:00 +0800147 "//frameworks/base/packages/Tethering/tests/integration",
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900148 ]
149}
150
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900151// Common defaults for compiling the actual APK, based on the NetworkStackApiXBase android libraries
152java_defaults {
153 name: "NetworkStackAppDefaults",
154 privileged: true,
155 jni_libs: [
156 "libnativehelper_compat_libc++",
157 "libnetworkstackutilsjni",
158 ],
159 // Resources already included in NetworkStackBase
160 resource_dirs: [],
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900161 jarjar_rules: ":NetworkStackJarJarRules",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900162 use_embedded_native_libs: true,
163 optimize: {
164 proguard_flags_files: ["proguard.flags"],
165 },
166}
167
168// Non-updatable network stack running in the system server process for devices not using the module
169android_app {
170 name: "InProcessNetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900171 defaults: [ "NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900172 static_libs: ["NetworkStackApiCurrentLib"],
173 certificate: "platform",
174 manifest: "AndroidManifest_InProcess.xml",
175 // InProcessNetworkStack is a replacement for NetworkStack
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000176 overrides: ["NetworkStack", "NetworkStackNext"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900177 // The permission configuration *must* be included to ensure security of the device
178 // The InProcessNetworkStack goes together with the PlatformCaptivePortalLogin, which replaces
179 // the default CaptivePortalLogin.
180 required: ["PlatformNetworkPermissionConfig", "PlatformCaptivePortalLogin"],
181}
182
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900183// Pre-merge the AndroidManifest for NetworkStackNext, so that its manifest can be merged on top
184android_library {
185 name: "NetworkStackNextManifestBase",
186 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
187 static_libs: ["NetworkStackApiCurrentLib"],
188 manifest: "AndroidManifest.xml"
189}
190
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900191// NetworkStack build targeting the current API release, for testing on in-development SDK
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900192android_app {
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000193 name: "NetworkStackNext",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900194 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900195 static_libs: ["NetworkStackNextManifestBase"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900196 certificate: "networkstack",
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900197 manifest: "AndroidManifest_Next.xml",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900198 // The permission configuration *must* be included to ensure security of the device
199 required: ["NetworkPermissionConfig"],
200}
201
202// Updatable network stack for finalized API
203android_app {
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000204 name: "NetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900205 defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900206 static_libs: ["NetworkStackApiStableLib"],
207 certificate: "networkstack",
208 manifest: "AndroidManifest.xml",
209 // The permission configuration *must* be included to ensure security of the device
210 required: ["NetworkPermissionConfig"],
Artur Satayev862a1a12020-04-09 11:35:52 +0100211 updatable: true,
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900212}
213
214// Android library to derive test APKs for integration tests
215android_library {
216 name: "TestNetworkStackLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900217 defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"],
218 static_libs: ["NetworkStackApiStableLib"],
Remi NGUYEN VANae18aed2019-10-30 18:20:36 +0900219 manifest: "AndroidManifestBase.xml",
Remi NGUYEN VAN2c18f6b2020-05-25 18:27:59 +0900220 visibility: [
221 "//frameworks/base/tests/net/integration",
222 "//cts/tests/tests/net",
223 ],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900224}
225
paulhue455e2a2019-03-29 17:22:20 +0800226cc_library_shared {
227 name: "libnetworkstackutilsjni",
228 srcs: [
229 "jni/network_stack_utils_jni.cpp"
230 ],
Jooyung Hand3fb9f52020-04-29 02:43:03 +0900231 sdk_version: "29",
232 min_sdk_version: "29",
paulhue455e2a2019-03-29 17:22:20 +0800233 shared_libs: [
234 "liblog",
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900235 "libnativehelper_compat_libc++",
paulhue455e2a2019-03-29 17:22:20 +0800236 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900237
238 // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
239 // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
240 // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
241 // build because soong complains of:
242 // module NetworkStack missing dependencies: libc++_shared
243 //
244 // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
245 // we depend on do not dynamically link libc++. This is currently the case, because liblog is
246 // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
247 //
248 // TODO: find a better solution for this in R.
249 stl: "c++_static",
paulhue455e2a2019-03-29 17:22:20 +0800250 cflags: [
251 "-Wall",
252 "-Werror",
253 "-Wno-unused-parameter",
254 ],
255}
256
Chiachang Wang80242272019-04-11 21:24:28 +0800257genrule {
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800258 name: "statslog-networkstack-java-gen-q",
259 tools: ["stats-log-api-gen"],
260 cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
261 " --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog" +
262 " --compileQ",
263 out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
264}
265
266genrule {
Chiachang Wang80242272019-04-11 21:24:28 +0800267 name: "statslog-networkstack-java-gen",
268 tools: ["stats-log-api-gen"],
269 cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
Muhammad Qureshi8e0e9bc2019-12-31 11:26:33 -0800270 " --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog" +
271 " --supportQ",
Chiachang Wang80242272019-04-11 21:24:28 +0800272 out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
273}
Kun Niu8e89dd42019-07-16 18:33:45 -0700274
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900275version_code_networkstack_next = "300000000"
276version_code_networkstack_test = "999999999"
277
Kun Niu8e89dd42019-07-16 18:33:45 -0700278genrule {
279 name: "NetworkStackTestAndroidManifest",
280 srcs: ["AndroidManifest.xml"],
281 out: ["TestAndroidManifest.xml"],
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900282 cmd: "sed -E 's/versionCode=\"[0-9]+\"/versionCode=\""
283 + version_code_networkstack_test
284 + "\"/' $(in) > $(out)",
285 visibility: ["//visibility:private"],
286}
287
Kun Niu8e89dd42019-07-16 18:33:45 -0700288android_app {
289 name: "TestNetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900290 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900291 static_libs: ["NetworkStackApiCurrentLib"],
Kun Niu8e89dd42019-07-16 18:33:45 -0700292 certificate: "networkstack",
293 manifest: ":NetworkStackTestAndroidManifest",
Kun Niu8e89dd42019-07-16 18:33:45 -0700294 // The permission configuration *must* be included to ensure security of the device
295 required: ["NetworkPermissionConfig"],
296}
lifrcb15db32020-05-21 20:32:36 +0800297
298java_library_static {
299 name: "statsprotos",
300 proto: {
301 type: "lite",
302 },
303 srcs: [
304 "src/com/android/networkstack/metrics/stats.proto",
305 ],
306 static_libs: [
307 "networkstackprotos",
308 ],
309 defaults: ["NetworkStackReleaseApiLevel"],
310}