blob: 91ed0ed26e8df24e627dce6abaac6a4374a273c0 [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 VAN794a4b52019-09-06 13:00:33 +090063 ":net-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",
74 ":net-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",
Chiachang Wang2abb2cc2019-12-11 21:20:24 +080088 "netd_aidl_interface-unstable-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
136// Common defaults for compiling the actual APK, based on the NetworkStackApiXBase android libraries
137java_defaults {
138 name: "NetworkStackAppDefaults",
139 privileged: true,
140 jni_libs: [
141 "libnativehelper_compat_libc++",
142 "libnetworkstackutilsjni",
143 ],
144 // Resources already included in NetworkStackBase
145 resource_dirs: [],
146 jarjar_rules: "jarjar-rules-shared.txt",
147 use_embedded_native_libs: true,
148 optimize: {
149 proguard_flags_files: ["proguard.flags"],
150 },
151}
152
153// Non-updatable network stack running in the system server process for devices not using the module
154android_app {
155 name: "InProcessNetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900156 defaults: [ "NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900157 static_libs: ["NetworkStackApiCurrentLib"],
158 certificate: "platform",
159 manifest: "AndroidManifest_InProcess.xml",
160 // InProcessNetworkStack is a replacement for NetworkStack
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000161 overrides: ["NetworkStack", "NetworkStackNext"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900162 // The permission configuration *must* be included to ensure security of the device
163 // The InProcessNetworkStack goes together with the PlatformCaptivePortalLogin, which replaces
164 // the default CaptivePortalLogin.
165 required: ["PlatformNetworkPermissionConfig", "PlatformCaptivePortalLogin"],
166}
167
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900168// Pre-merge the AndroidManifest for NetworkStackNext, so that its manifest can be merged on top
169android_library {
170 name: "NetworkStackNextManifestBase",
171 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
172 static_libs: ["NetworkStackApiCurrentLib"],
173 manifest: "AndroidManifest.xml"
174}
175
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900176// NetworkStack build targeting the current API release, for testing on in-development SDK
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900177android_app {
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000178 name: "NetworkStackNext",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900179 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900180 static_libs: ["NetworkStackNextManifestBase"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900181 certificate: "networkstack",
Remi NGUYEN VAN255d4912020-02-05 13:42:45 +0900182 manifest: "AndroidManifest_Next.xml",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900183 // The permission configuration *must* be included to ensure security of the device
184 required: ["NetworkPermissionConfig"],
185}
186
187// Updatable network stack for finalized API
188android_app {
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000189 name: "NetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900190 defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900191 static_libs: ["NetworkStackApiStableLib"],
192 certificate: "networkstack",
193 manifest: "AndroidManifest.xml",
194 // The permission configuration *must* be included to ensure security of the device
195 required: ["NetworkPermissionConfig"],
196}
197
198// Android library to derive test APKs for integration tests
199android_library {
200 name: "TestNetworkStackLib",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900201 defaults: ["NetworkStackAppDefaults", "NetworkStackReleaseApiLevel"],
202 static_libs: ["NetworkStackApiStableLib"],
Remi NGUYEN VANae18aed2019-10-30 18:20:36 +0900203 manifest: "AndroidManifestBase.xml",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900204}
205
paulhue455e2a2019-03-29 17:22:20 +0800206cc_library_shared {
207 name: "libnetworkstackutilsjni",
208 srcs: [
209 "jni/network_stack_utils_jni.cpp"
210 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900211 sdk_version: "current",
paulhue455e2a2019-03-29 17:22:20 +0800212 shared_libs: [
213 "liblog",
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900214 "libnativehelper_compat_libc++",
paulhue455e2a2019-03-29 17:22:20 +0800215 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900216
217 // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
218 // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
219 // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
220 // build because soong complains of:
221 // module NetworkStack missing dependencies: libc++_shared
222 //
223 // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
224 // we depend on do not dynamically link libc++. This is currently the case, because liblog is
225 // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
226 //
227 // TODO: find a better solution for this in R.
228 stl: "c++_static",
paulhue455e2a2019-03-29 17:22:20 +0800229 cflags: [
230 "-Wall",
231 "-Werror",
232 "-Wno-unused-parameter",
233 ],
234}
235
Chiachang Wang80242272019-04-11 21:24:28 +0800236genrule {
Muhammad Qureshiaa428cc2020-01-29 11:15:16 -0800237 name: "statslog-networkstack-java-gen-q",
238 tools: ["stats-log-api-gen"],
239 cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
240 " --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog" +
241 " --compileQ",
242 out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
243}
244
245genrule {
Chiachang Wang80242272019-04-11 21:24:28 +0800246 name: "statslog-networkstack-java-gen",
247 tools: ["stats-log-api-gen"],
248 cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
Muhammad Qureshi8e0e9bc2019-12-31 11:26:33 -0800249 " --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog" +
250 " --supportQ",
Chiachang Wang80242272019-04-11 21:24:28 +0800251 out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
252}
Kun Niu8e89dd42019-07-16 18:33:45 -0700253
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900254version_code_networkstack_next = "300000000"
255version_code_networkstack_test = "999999999"
256
Kun Niu8e89dd42019-07-16 18:33:45 -0700257genrule {
258 name: "NetworkStackTestAndroidManifest",
259 srcs: ["AndroidManifest.xml"],
260 out: ["TestAndroidManifest.xml"],
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900261 cmd: "sed -E 's/versionCode=\"[0-9]+\"/versionCode=\""
262 + version_code_networkstack_test
263 + "\"/' $(in) > $(out)",
264 visibility: ["//visibility:private"],
265}
266
Kun Niu8e89dd42019-07-16 18:33:45 -0700267android_app {
268 name: "TestNetworkStack",
Remi NGUYEN VAN16fe4542020-01-16 13:48:38 +0900269 defaults: ["NetworkStackAppDefaults", "NetworkStackDevApiLevel"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900270 static_libs: ["NetworkStackApiCurrentLib"],
Kun Niu8e89dd42019-07-16 18:33:45 -0700271 certificate: "networkstack",
272 manifest: ":NetworkStackTestAndroidManifest",
Kun Niu8e89dd42019-07-16 18:33:45 -0700273 // The permission configuration *must* be included to ensure security of the device
274 required: ["NetworkPermissionConfig"],
275}