blob: d64327d4ca10105104c1962928291e06b77e3d91 [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",
142 ]
143}
144
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900145// Common defaults for compiling the actual APK, based on the NetworkStackApiXBase android libraries
146java_defaults {
147 name: "NetworkStackAppDefaults",
148 privileged: true,
149 jni_libs: [
150 "libnativehelper_compat_libc++",
151 "libnetworkstackutilsjni",
152 ],
153 // Resources already included in NetworkStackBase
154 resource_dirs: [],
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900155 jarjar_rules: ":NetworkStackJarJarRules",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900156 use_embedded_native_libs: true,
157 optimize: {
158 proguard_flags_files: ["proguard.flags"],
159 },
160}
161
162// Non-updatable network stack running in the system server process for devices not using the module
163android_app {
164 name: "InProcessNetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900165 defaults: [ "NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900166 static_libs: ["NetworkStackApiCurrentLib"],
167 certificate: "platform",
168 manifest: "AndroidManifest_InProcess.xml",
169 // InProcessNetworkStack is a replacement for NetworkStack
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000170 overrides: ["NetworkStack", "NetworkStackNext"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900171 // The permission configuration *must* be included to ensure security of the device
172 // The InProcessNetworkStack goes together with the PlatformCaptivePortalLogin, which replaces
173 // the default CaptivePortalLogin.
174 required: ["PlatformNetworkPermissionConfig", "PlatformCaptivePortalLogin"],
175}
176
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900177// Pre-merge the AndroidManifest for NetworkStackNext, so that its manifest can be merged on top
178android_library {
179 name: "NetworkStackNextManifestBase",
180 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
181 static_libs: ["NetworkStackApiCurrentLib"],
182 manifest: "AndroidManifest.xml"
183}
184
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900185// NetworkStack build targeting the current API release, for testing on in-development SDK
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900186android_app {
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000187 name: "NetworkStackNext",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900188 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900189 static_libs: ["NetworkStackNextManifestBase"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900190 certificate: "networkstack",
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900191 manifest: "AndroidManifest_Next.xml",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900192 // The permission configuration *must* be included to ensure security of the device
193 required: ["NetworkPermissionConfig"],
194}
195
196// Updatable network stack for finalized API
197android_app {
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000198 name: "NetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900199 defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900200 static_libs: ["NetworkStackApiStableLib"],
201 certificate: "networkstack",
202 manifest: "AndroidManifest.xml",
203 // The permission configuration *must* be included to ensure security of the device
204 required: ["NetworkPermissionConfig"],
Artur Satayev862a1a12020-04-09 11:35:52 +0100205 updatable: true,
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900206}
207
208// Android library to derive test APKs for integration tests
209android_library {
210 name: "TestNetworkStackLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900211 defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"],
212 static_libs: ["NetworkStackApiStableLib"],
Remi NGUYEN VANae18aed2019-10-30 18:20:36 +0900213 manifest: "AndroidManifestBase.xml",
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900214 visibility: ["//frameworks/base/tests/net/integration"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900215}
216
paulhue455e2a2019-03-29 17:22:20 +0800217cc_library_shared {
218 name: "libnetworkstackutilsjni",
219 srcs: [
220 "jni/network_stack_utils_jni.cpp"
221 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900222 sdk_version: "current",
paulhue455e2a2019-03-29 17:22:20 +0800223 shared_libs: [
224 "liblog",
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900225 "libnativehelper_compat_libc++",
paulhue455e2a2019-03-29 17:22:20 +0800226 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900227
228 // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
229 // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
230 // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
231 // build because soong complains of:
232 // module NetworkStack missing dependencies: libc++_shared
233 //
234 // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
235 // we depend on do not dynamically link libc++. This is currently the case, because liblog is
236 // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
237 //
238 // TODO: find a better solution for this in R.
239 stl: "c++_static",
paulhue455e2a2019-03-29 17:22:20 +0800240 cflags: [
241 "-Wall",
242 "-Werror",
243 "-Wno-unused-parameter",
244 ],
245}
246
Chiachang Wang80242272019-04-11 21:24:28 +0800247genrule {
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800248 name: "statslog-networkstack-java-gen-q",
249 tools: ["stats-log-api-gen"],
250 cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
251 " --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog" +
252 " --compileQ",
253 out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
254}
255
256genrule {
Chiachang Wang80242272019-04-11 21:24:28 +0800257 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}