blob: 81a96a8fd9773356ec84148800bfba9cbe1c6ca8 [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 VAN794a4b52019-09-06 13:00:33 +090051 sdk_version: "system_29",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +090052 min_sdk_version: "29",
53 target_sdk_version: "29",
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 VAN44e8ebf2020-02-15 04:36:06 +090063 ":networkstack-module-utils-srcs",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090064 ],
65}
66
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +090067// API stable shims only include the compat package, but it is jarjared to replace the non-compat
68// package
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090069filegroup {
70 name: "NetworkStackApiStableShims",
71 srcs: [
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +090072 "apishim/common/**/*.java",
73 "apishim/29/**/*.java",
Remi NGUYEN VAN44e8ebf2020-02-15 04:36:06 +090074 ":networkstack-module-utils-srcs",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090075 ],
76}
77
78// Common defaults for android libraries containing network stack code, used to compile variants of
79// the network stack in the system process and in the network_stack process
80java_defaults {
81 name: "NetworkStackAndroidLibraryDefaults",
Remi NGUYEN VANded23152018-12-07 16:52:24 +090082 srcs: [
Remi NGUYEN VAN82b4b422019-01-20 09:35:10 +090083 ":framework-networkstack-shared-srcs",
Remi NGUYEN VANded23152018-12-07 16:52:24 +090084 ],
Artur Satayev0eb158a2019-12-10 12:54:01 +000085 libs: ["unsupportedappusage"],
Remi NGUYEN VAN057bf202018-12-04 12:13:09 +090086 static_libs: [
Niklas Lindgren0c904882018-12-07 11:08:04 +010087 "androidx.annotation_annotation",
Luke Huangddf63d02020-04-01 01:02:59 +080088 "netd_aidl_interface-V3-java",
Remi NGUYEN VAN1fc930c2019-08-09 13:23:47 +090089 "netlink-client",
Remi NGUYEN VANbbb97032019-08-08 15:53:54 +090090 "networkstack-client",
Chiachang Wang8b5f84a2019-02-22 11:13:07 +080091 "datastallprotosnano",
Chiachang Wang54663a82019-03-21 20:40:01 +080092 "networkstackprotosnano",
paulhu5982eff2019-03-29 19:21:30 +080093 "captiveportal-lib",
Remi NGUYEN VAN0a4df5a2019-03-08 17:20:49 +090094 ],
Kun Niuf3b69042019-07-01 17:03:20 -070095 plugins: ["java_api_finder"],
Remi NGUYEN VAN0a4df5a2019-03-08 17:20:49 +090096}
97
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090098// The versions of the android library containing network stack code compiled for each SDK variant
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +090099// API current uses the sources of the API current shims directly.
100// This allows API current code to be treated identically to code in src/ (it will be moved
101// there eventually), and to use the compat shim as fallback on older devices.
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900102android_library {
103 name: "NetworkStackApiCurrentLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900104 defaults: ["NetworkStackDevApiLevel", "NetworkStackAndroidLibraryDefaults"],
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800105 srcs: [
106 ":NetworkStackApiCurrentShims",
107 "src/**/*.java",
108 ":statslog-networkstack-java-gen"
109 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900110 manifest: "AndroidManifestBase.xml",
111}
112
113// For API stable, first build the dependencies using jarjar compat rules, then build the sources
114// linking with the dependencies.
115java_library {
116 name: "NetworkStackApiStableDependencies",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900117 defaults: ["NetworkStackReleaseApiLevel", "NetworkStackAndroidLibraryDefaults"],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900118 srcs: [":NetworkStackApiStableShims"],
119 jarjar_rules: "apishim/jarjar-rules-compat.txt",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900120}
121
122android_library {
123 name: "NetworkStackApiStableLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900124 defaults: ["NetworkStackReleaseApiLevel"],
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800125 srcs: [
126 "src/**/*.java",
127 ":statslog-networkstack-java-gen-q",
128 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900129 // API stable uses a jarjared version of the shims
130 static_libs: [
131 "NetworkStackApiStableDependencies",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900132 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900133 manifest: "AndroidManifestBase.xml",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900134}
135
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900136filegroup {
137 name: "NetworkStackJarJarRules",
138 srcs: ["jarjar-rules-shared.txt"],
139 visibility: [
140 "//packages/modules/NetworkStack/tests/unit",
141 "//packages/modules/NetworkStack/tests/integration",
paulhua9949882020-04-06 23:33:00 +0800142 "//frameworks/base/packages/Tethering/tests/integration",
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900143 ]
144}
145
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900146// Common defaults for compiling the actual APK, based on the NetworkStackApiXBase android libraries
147java_defaults {
148 name: "NetworkStackAppDefaults",
149 privileged: true,
150 jni_libs: [
151 "libnativehelper_compat_libc++",
152 "libnetworkstackutilsjni",
153 ],
154 // Resources already included in NetworkStackBase
155 resource_dirs: [],
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900156 jarjar_rules: ":NetworkStackJarJarRules",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900157 use_embedded_native_libs: true,
158 optimize: {
159 proguard_flags_files: ["proguard.flags"],
160 },
161}
162
163// Non-updatable network stack running in the system server process for devices not using the module
164android_app {
165 name: "InProcessNetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900166 defaults: [ "NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900167 static_libs: ["NetworkStackApiCurrentLib"],
168 certificate: "platform",
169 manifest: "AndroidManifest_InProcess.xml",
170 // InProcessNetworkStack is a replacement for NetworkStack
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000171 overrides: ["NetworkStack", "NetworkStackNext"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900172 // The permission configuration *must* be included to ensure security of the device
173 // The InProcessNetworkStack goes together with the PlatformCaptivePortalLogin, which replaces
174 // the default CaptivePortalLogin.
175 required: ["PlatformNetworkPermissionConfig", "PlatformCaptivePortalLogin"],
176}
177
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900178// Pre-merge the AndroidManifest for NetworkStackNext, so that its manifest can be merged on top
179android_library {
180 name: "NetworkStackNextManifestBase",
181 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
182 static_libs: ["NetworkStackApiCurrentLib"],
183 manifest: "AndroidManifest.xml"
184}
185
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900186// NetworkStack build targeting the current API release, for testing on in-development SDK
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900187android_app {
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000188 name: "NetworkStackNext",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900189 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900190 static_libs: ["NetworkStackNextManifestBase"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900191 certificate: "networkstack",
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900192 manifest: "AndroidManifest_Next.xml",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900193 // The permission configuration *must* be included to ensure security of the device
194 required: ["NetworkPermissionConfig"],
195}
196
197// Updatable network stack for finalized API
198android_app {
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000199 name: "NetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900200 defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900201 static_libs: ["NetworkStackApiStableLib"],
202 certificate: "networkstack",
203 manifest: "AndroidManifest.xml",
204 // The permission configuration *must* be included to ensure security of the device
205 required: ["NetworkPermissionConfig"],
Artur Satayev862a1a12020-04-09 11:35:52 +0100206 updatable: true,
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900207}
208
209// Android library to derive test APKs for integration tests
210android_library {
211 name: "TestNetworkStackLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900212 defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"],
213 static_libs: ["NetworkStackApiStableLib"],
Remi NGUYEN VANae18aed2019-10-30 18:20:36 +0900214 manifest: "AndroidManifestBase.xml",
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900215 visibility: ["//frameworks/base/tests/net/integration"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900216}
217
paulhue455e2a2019-03-29 17:22:20 +0800218cc_library_shared {
219 name: "libnetworkstackutilsjni",
220 srcs: [
221 "jni/network_stack_utils_jni.cpp"
222 ],
Jooyung Hand3fb9f52020-04-29 02:43:03 +0900223 sdk_version: "29",
224 min_sdk_version: "29",
paulhue455e2a2019-03-29 17:22:20 +0800225 shared_libs: [
226 "liblog",
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900227 "libnativehelper_compat_libc++",
paulhue455e2a2019-03-29 17:22:20 +0800228 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900229
230 // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
231 // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
232 // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
233 // build because soong complains of:
234 // module NetworkStack missing dependencies: libc++_shared
235 //
236 // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
237 // we depend on do not dynamically link libc++. This is currently the case, because liblog is
238 // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
239 //
240 // TODO: find a better solution for this in R.
241 stl: "c++_static",
paulhue455e2a2019-03-29 17:22:20 +0800242 cflags: [
243 "-Wall",
244 "-Werror",
245 "-Wno-unused-parameter",
246 ],
247}
248
Chiachang Wang80242272019-04-11 21:24:28 +0800249genrule {
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800250 name: "statslog-networkstack-java-gen-q",
251 tools: ["stats-log-api-gen"],
252 cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
253 " --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog" +
254 " --compileQ",
255 out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
256}
257
258genrule {
Chiachang Wang80242272019-04-11 21:24:28 +0800259 name: "statslog-networkstack-java-gen",
260 tools: ["stats-log-api-gen"],
261 cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
Muhammad Qureshi8e0e9bc2019-12-31 11:26:33 -0800262 " --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog" +
263 " --supportQ",
Chiachang Wang80242272019-04-11 21:24:28 +0800264 out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
265}
Kun Niu8e89dd42019-07-16 18:33:45 -0700266
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900267version_code_networkstack_next = "300000000"
268version_code_networkstack_test = "999999999"
269
Kun Niu8e89dd42019-07-16 18:33:45 -0700270genrule {
271 name: "NetworkStackTestAndroidManifest",
272 srcs: ["AndroidManifest.xml"],
273 out: ["TestAndroidManifest.xml"],
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900274 cmd: "sed -E 's/versionCode=\"[0-9]+\"/versionCode=\""
275 + version_code_networkstack_test
276 + "\"/' $(in) > $(out)",
277 visibility: ["//visibility:private"],
278}
279
Kun Niu8e89dd42019-07-16 18:33:45 -0700280android_app {
281 name: "TestNetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900282 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900283 static_libs: ["NetworkStackApiCurrentLib"],
Kun Niu8e89dd42019-07-16 18:33:45 -0700284 certificate: "networkstack",
285 manifest: ":NetworkStackTestAndroidManifest",
Kun Niu8e89dd42019-07-16 18:33:45 -0700286 // The permission configuration *must* be included to ensure security of the device
287 required: ["NetworkPermissionConfig"],
288}