blob: d0fdc4a6570fe320ac92ca2648c91967d06ced02 [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",
Chiachang Wang8b5f84a2019-02-22 11:13:07 +080094 "datastallprotosnano",
Chiachang Wang54663a82019-03-21 20:40:01 +080095 "networkstackprotosnano",
paulhu5982eff2019-03-29 19:21:30 +080096 "captiveportal-lib",
Remi NGUYEN VAN0a4df5a2019-03-08 17:20:49 +090097 ],
Kun Niuf3b69042019-07-01 17:03:20 -070098 plugins: ["java_api_finder"],
Remi NGUYEN VAN0a4df5a2019-03-08 17:20:49 +090099}
100
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900101// The versions of the android library containing network stack code compiled for each SDK variant
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900102// API current uses the sources of the API current shims directly.
103// This allows API current code to be treated identically to code in src/ (it will be moved
104// there eventually), and to use the compat shim as fallback on older devices.
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900105android_library {
106 name: "NetworkStackApiCurrentLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900107 defaults: ["NetworkStackDevApiLevel", "NetworkStackAndroidLibraryDefaults"],
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800108 srcs: [
109 ":NetworkStackApiCurrentShims",
110 "src/**/*.java",
111 ":statslog-networkstack-java-gen"
112 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900113 manifest: "AndroidManifestBase.xml",
114}
115
116// For API stable, first build the dependencies using jarjar compat rules, then build the sources
117// linking with the dependencies.
118java_library {
119 name: "NetworkStackApiStableDependencies",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900120 defaults: ["NetworkStackReleaseApiLevel", "NetworkStackAndroidLibraryDefaults"],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900121 srcs: [":NetworkStackApiStableShims"],
122 jarjar_rules: "apishim/jarjar-rules-compat.txt",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900123}
124
125android_library {
126 name: "NetworkStackApiStableLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900127 defaults: ["NetworkStackReleaseApiLevel"],
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800128 srcs: [
129 "src/**/*.java",
130 ":statslog-networkstack-java-gen-q",
131 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900132 // API stable uses a jarjared version of the shims
133 static_libs: [
134 "NetworkStackApiStableDependencies",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900135 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900136 manifest: "AndroidManifestBase.xml",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900137}
138
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900139filegroup {
140 name: "NetworkStackJarJarRules",
141 srcs: ["jarjar-rules-shared.txt"],
142 visibility: [
143 "//packages/modules/NetworkStack/tests/unit",
144 "//packages/modules/NetworkStack/tests/integration",
paulhua9949882020-04-06 23:33:00 +0800145 "//frameworks/base/packages/Tethering/tests/integration",
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900146 ]
147}
148
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900149// Common defaults for compiling the actual APK, based on the NetworkStackApiXBase android libraries
150java_defaults {
151 name: "NetworkStackAppDefaults",
152 privileged: true,
153 jni_libs: [
154 "libnativehelper_compat_libc++",
155 "libnetworkstackutilsjni",
156 ],
157 // Resources already included in NetworkStackBase
158 resource_dirs: [],
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900159 jarjar_rules: ":NetworkStackJarJarRules",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900160 use_embedded_native_libs: true,
161 optimize: {
162 proguard_flags_files: ["proguard.flags"],
163 },
164}
165
166// Non-updatable network stack running in the system server process for devices not using the module
167android_app {
168 name: "InProcessNetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900169 defaults: [ "NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900170 static_libs: ["NetworkStackApiCurrentLib"],
171 certificate: "platform",
172 manifest: "AndroidManifest_InProcess.xml",
173 // InProcessNetworkStack is a replacement for NetworkStack
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000174 overrides: ["NetworkStack", "NetworkStackNext"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900175 // The permission configuration *must* be included to ensure security of the device
176 // The InProcessNetworkStack goes together with the PlatformCaptivePortalLogin, which replaces
177 // the default CaptivePortalLogin.
178 required: ["PlatformNetworkPermissionConfig", "PlatformCaptivePortalLogin"],
179}
180
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900181// Pre-merge the AndroidManifest for NetworkStackNext, so that its manifest can be merged on top
182android_library {
183 name: "NetworkStackNextManifestBase",
184 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
185 static_libs: ["NetworkStackApiCurrentLib"],
186 manifest: "AndroidManifest.xml"
187}
188
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900189// NetworkStack build targeting the current API release, for testing on in-development SDK
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900190android_app {
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000191 name: "NetworkStackNext",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900192 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900193 static_libs: ["NetworkStackNextManifestBase"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900194 certificate: "networkstack",
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900195 manifest: "AndroidManifest_Next.xml",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900196 // The permission configuration *must* be included to ensure security of the device
197 required: ["NetworkPermissionConfig"],
198}
199
200// Updatable network stack for finalized API
201android_app {
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000202 name: "NetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900203 defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900204 static_libs: ["NetworkStackApiStableLib"],
205 certificate: "networkstack",
206 manifest: "AndroidManifest.xml",
207 // The permission configuration *must* be included to ensure security of the device
208 required: ["NetworkPermissionConfig"],
Artur Satayev862a1a12020-04-09 11:35:52 +0100209 updatable: true,
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900210}
211
212// Android library to derive test APKs for integration tests
213android_library {
214 name: "TestNetworkStackLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900215 defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"],
216 static_libs: ["NetworkStackApiStableLib"],
Remi NGUYEN VANae18aed2019-10-30 18:20:36 +0900217 manifest: "AndroidManifestBase.xml",
Lorenzo Colittib891b5e2020-02-05 16:48:09 +0900218 visibility: ["//frameworks/base/tests/net/integration"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900219}
220
paulhue455e2a2019-03-29 17:22:20 +0800221cc_library_shared {
222 name: "libnetworkstackutilsjni",
223 srcs: [
224 "jni/network_stack_utils_jni.cpp"
225 ],
Jooyung Hand3fb9f52020-04-29 02:43:03 +0900226 sdk_version: "29",
227 min_sdk_version: "29",
paulhue455e2a2019-03-29 17:22:20 +0800228 shared_libs: [
229 "liblog",
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900230 "libnativehelper_compat_libc++",
paulhue455e2a2019-03-29 17:22:20 +0800231 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900232
233 // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
234 // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
235 // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
236 // build because soong complains of:
237 // module NetworkStack missing dependencies: libc++_shared
238 //
239 // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
240 // we depend on do not dynamically link libc++. This is currently the case, because liblog is
241 // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
242 //
243 // TODO: find a better solution for this in R.
244 stl: "c++_static",
paulhue455e2a2019-03-29 17:22:20 +0800245 cflags: [
246 "-Wall",
247 "-Werror",
248 "-Wno-unused-parameter",
249 ],
250}
251
Chiachang Wang80242272019-04-11 21:24:28 +0800252genrule {
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800253 name: "statslog-networkstack-java-gen-q",
254 tools: ["stats-log-api-gen"],
255 cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
256 " --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog" +
257 " --compileQ",
258 out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
259}
260
261genrule {
Chiachang Wang80242272019-04-11 21:24:28 +0800262 name: "statslog-networkstack-java-gen",
263 tools: ["stats-log-api-gen"],
264 cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
Muhammad Qureshi8e0e9bc2019-12-31 11:26:33 -0800265 " --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog" +
266 " --supportQ",
Chiachang Wang80242272019-04-11 21:24:28 +0800267 out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
268}
Kun Niu8e89dd42019-07-16 18:33:45 -0700269
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900270version_code_networkstack_next = "300000000"
271version_code_networkstack_test = "999999999"
272
Kun Niu8e89dd42019-07-16 18:33:45 -0700273genrule {
274 name: "NetworkStackTestAndroidManifest",
275 srcs: ["AndroidManifest.xml"],
276 out: ["TestAndroidManifest.xml"],
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900277 cmd: "sed -E 's/versionCode=\"[0-9]+\"/versionCode=\""
278 + version_code_networkstack_test
279 + "\"/' $(in) > $(out)",
280 visibility: ["//visibility:private"],
281}
282
Kun Niu8e89dd42019-07-16 18:33:45 -0700283android_app {
284 name: "TestNetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900285 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900286 static_libs: ["NetworkStackApiCurrentLib"],
Kun Niu8e89dd42019-07-16 18:33:45 -0700287 certificate: "networkstack",
288 manifest: ":NetworkStackTestAndroidManifest",
Kun Niu8e89dd42019-07-16 18:33:45 -0700289 // The permission configuration *must* be included to ensure security of the device
290 required: ["NetworkPermissionConfig"],
291}