blob: b6857ff62debb200e1778d70ba23db949fb9b583 [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
24// +NetworkStackApiStableLevel / \ +NetworkStackApiCurrentLevel
25// +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// | |
37// | <-- +NetworkStackApiStableLevel | <-- +NetworkStackApiCurrentLevel
38// | |
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 VAN99645762019-07-11 14:33:15 +090045 name: "NetworkStackApiCurrentLevel",
Remi NGUYEN VAN40369562019-03-20 16:40:54 +090046 sdk_version: "system_current",
47 min_sdk_version: "28",
48}
49
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090050java_defaults {
51 name: "NetworkStackApiStableLevel",
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +090052 sdk_version: "system_29",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090053 min_sdk_version: "28",
54}
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",
Chiachang Wang80242272019-04-11 21:24:28 +080084 ":statslog-networkstack-java-gen",
Remi NGUYEN VANded23152018-12-07 16:52:24 +090085 ],
Artur Satayev0eb158a2019-12-10 12:54:01 +000086 libs: ["unsupportedappusage"],
Remi NGUYEN VAN057bf202018-12-04 12:13:09 +090087 static_libs: [
Niklas Lindgren0c904882018-12-07 11:08:04 +010088 "androidx.annotation_annotation",
Chiachang Wang2abb2cc2019-12-11 21:20:24 +080089 "netd_aidl_interface-unstable-java",
Remi NGUYEN VAN1fc930c2019-08-09 13:23:47 +090090 "netlink-client",
Remi NGUYEN VANbbb97032019-08-08 15:53:54 +090091 "networkstack-client",
Chiachang Wang8b5f84a2019-02-22 11:13:07 +080092 "datastallprotosnano",
Chiachang Wang54663a82019-03-21 20:40:01 +080093 "networkstackprotosnano",
paulhu5982eff2019-03-29 19:21:30 +080094 "captiveportal-lib",
Remi NGUYEN VAN0a4df5a2019-03-08 17:20:49 +090095 ],
Kun Niuf3b69042019-07-01 17:03:20 -070096 plugins: ["java_api_finder"],
Remi NGUYEN VAN0a4df5a2019-03-08 17:20:49 +090097}
98
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090099// The versions of the android library containing network stack code compiled for each SDK variant
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900100// API current uses the sources of the API current shims directly.
101// This allows API current code to be treated identically to code in src/ (it will be moved
102// there eventually), and to use the compat shim as fallback on older devices.
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900103android_library {
104 name: "NetworkStackApiCurrentLib",
105 defaults: ["NetworkStackApiCurrentLevel", "NetworkStackAndroidLibraryDefaults"],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900106 srcs: [":NetworkStackApiCurrentShims", "src/**/*.java"],
107 manifest: "AndroidManifestBase.xml",
108}
109
110// For API stable, first build the dependencies using jarjar compat rules, then build the sources
111// linking with the dependencies.
112java_library {
113 name: "NetworkStackApiStableDependencies",
114 defaults: ["NetworkStackApiStableLevel", "NetworkStackAndroidLibraryDefaults"],
115 srcs: [":NetworkStackApiStableShims"],
116 jarjar_rules: "apishim/jarjar-rules-compat.txt",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900117}
118
119android_library {
120 name: "NetworkStackApiStableLib",
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900121 defaults: ["NetworkStackApiStableLevel"],
Remi NGUYEN VAN87790c22019-09-12 14:39:24 +0900122 srcs: ["src/**/*.java"],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900123 // API stable uses a jarjared version of the shims
124 static_libs: [
125 "NetworkStackApiStableDependencies",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900126 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900127 manifest: "AndroidManifestBase.xml",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900128}
129
130// Common defaults for compiling the actual APK, based on the NetworkStackApiXBase android libraries
131java_defaults {
132 name: "NetworkStackAppDefaults",
133 privileged: true,
134 jni_libs: [
135 "libnativehelper_compat_libc++",
136 "libnetworkstackutilsjni",
137 ],
138 // Resources already included in NetworkStackBase
139 resource_dirs: [],
140 jarjar_rules: "jarjar-rules-shared.txt",
141 use_embedded_native_libs: true,
142 optimize: {
143 proguard_flags_files: ["proguard.flags"],
144 },
145}
146
147// Non-updatable network stack running in the system server process for devices not using the module
148android_app {
149 name: "InProcessNetworkStack",
150 defaults: [ "NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"],
151 static_libs: ["NetworkStackApiCurrentLib"],
152 certificate: "platform",
153 manifest: "AndroidManifest_InProcess.xml",
154 // InProcessNetworkStack is a replacement for NetworkStack
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000155 overrides: ["NetworkStack", "NetworkStackNext"],
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900156 // The permission configuration *must* be included to ensure security of the device
157 // The InProcessNetworkStack goes together with the PlatformCaptivePortalLogin, which replaces
158 // the default CaptivePortalLogin.
159 required: ["PlatformNetworkPermissionConfig", "PlatformCaptivePortalLogin"],
160}
161
162// Updatable network stack packaged as an application
163android_app {
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000164 name: "NetworkStackNext",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900165 defaults: ["NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"],
166 static_libs: ["NetworkStackApiCurrentLib"],
167 certificate: "networkstack",
168 manifest: "AndroidManifest.xml",
169 // The permission configuration *must* be included to ensure security of the device
170 required: ["NetworkPermissionConfig"],
171}
172
173// Updatable network stack for finalized API
174android_app {
Remi NGUYEN VANec9d8a62019-11-11 03:52:43 +0000175 name: "NetworkStack",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900176 defaults: ["NetworkStackAppDefaults", "NetworkStackApiStableLevel"],
177 static_libs: ["NetworkStackApiStableLib"],
178 certificate: "networkstack",
179 manifest: "AndroidManifest.xml",
180 // The permission configuration *must* be included to ensure security of the device
181 required: ["NetworkPermissionConfig"],
182}
183
184// Android library to derive test APKs for integration tests
185android_library {
186 name: "TestNetworkStackLib",
187 defaults: ["NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"],
188 static_libs: ["NetworkStackApiCurrentLib"],
Remi NGUYEN VANae18aed2019-10-30 18:20:36 +0900189 manifest: "AndroidManifestBase.xml",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900190}
191
paulhue455e2a2019-03-29 17:22:20 +0800192cc_library_shared {
193 name: "libnetworkstackutilsjni",
194 srcs: [
195 "jni/network_stack_utils_jni.cpp"
196 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900197 sdk_version: "current",
paulhue455e2a2019-03-29 17:22:20 +0800198 shared_libs: [
199 "liblog",
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900200 "libnativehelper_compat_libc++",
paulhue455e2a2019-03-29 17:22:20 +0800201 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900202
203 // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
204 // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
205 // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
206 // build because soong complains of:
207 // module NetworkStack missing dependencies: libc++_shared
208 //
209 // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
210 // we depend on do not dynamically link libc++. This is currently the case, because liblog is
211 // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
212 //
213 // TODO: find a better solution for this in R.
214 stl: "c++_static",
paulhue455e2a2019-03-29 17:22:20 +0800215 cflags: [
216 "-Wall",
217 "-Werror",
218 "-Wno-unused-parameter",
219 ],
220}
221
Chiachang Wang80242272019-04-11 21:24:28 +0800222genrule {
223 name: "statslog-networkstack-java-gen",
224 tools: ["stats-log-api-gen"],
225 cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
Muhammad Qureshi8e0e9bc2019-12-31 11:26:33 -0800226 " --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog" +
227 " --supportQ",
Chiachang Wang80242272019-04-11 21:24:28 +0800228 out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
229}
Kun Niu8e89dd42019-07-16 18:33:45 -0700230
231genrule {
232 name: "NetworkStackTestAndroidManifest",
233 srcs: ["AndroidManifest.xml"],
234 out: ["TestAndroidManifest.xml"],
235 cmd: "sed 's/versionCode=\".*\"/versionCode=\"300000000\"/' $(in) > $(out)",
236}
237
238android_app {
239 name: "TestNetworkStack",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900240 defaults: ["NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"],
241 static_libs: ["NetworkStackApiCurrentLib"],
Kun Niu8e89dd42019-07-16 18:33:45 -0700242 certificate: "networkstack",
243 manifest: ":NetworkStackTestAndroidManifest",
Kun Niu8e89dd42019-07-16 18:33:45 -0700244 // The permission configuration *must* be included to ensure security of the device
245 required: ["NetworkPermissionConfig"],
246}