blob: 35eaf6c5e147ba46179526921223569f66f105cc [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",
Remi NGUYEN VAN5daa3702018-12-27 16:43:56 +090084 ":services-networkstack-shared-srcs",
Chiachang Wang80242272019-04-11 21:24:28 +080085 ":statslog-networkstack-java-gen",
Remi NGUYEN VANded23152018-12-07 16:52:24 +090086 ],
Remi NGUYEN VAN057bf202018-12-04 12:13:09 +090087 static_libs: [
Niklas Lindgren0c904882018-12-07 11:08:04 +010088 "androidx.annotation_annotation",
Lorenzo Colitti81fc3e62019-05-21 19:45:09 +090089 "netd_aidl_interface-V2-java",
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",
104 defaults: ["NetworkStackApiCurrentLevel", "NetworkStackAndroidLibraryDefaults"],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900105 srcs: [":NetworkStackApiCurrentShims", "src/**/*.java"],
106 manifest: "AndroidManifestBase.xml",
107}
108
109// For API stable, first build the dependencies using jarjar compat rules, then build the sources
110// linking with the dependencies.
111java_library {
112 name: "NetworkStackApiStableDependencies",
113 defaults: ["NetworkStackApiStableLevel", "NetworkStackAndroidLibraryDefaults"],
114 srcs: [":NetworkStackApiStableShims"],
115 jarjar_rules: "apishim/jarjar-rules-compat.txt",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900116}
117
118android_library {
119 name: "NetworkStackApiStableLib",
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900120 defaults: ["NetworkStackApiStableLevel"],
Remi NGUYEN VAN87790c22019-09-12 14:39:24 +0900121 srcs: ["src/**/*.java"],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900122 // API stable uses a jarjared version of the shims
123 static_libs: [
124 "NetworkStackApiStableDependencies",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900125 ],
Remi NGUYEN VAN794a4b52019-09-06 13:00:33 +0900126 manifest: "AndroidManifestBase.xml",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900127}
128
129// Common defaults for compiling the actual APK, based on the NetworkStackApiXBase android libraries
130java_defaults {
131 name: "NetworkStackAppDefaults",
132 privileged: true,
133 jni_libs: [
134 "libnativehelper_compat_libc++",
135 "libnetworkstackutilsjni",
136 ],
137 // Resources already included in NetworkStackBase
138 resource_dirs: [],
139 jarjar_rules: "jarjar-rules-shared.txt",
140 use_embedded_native_libs: true,
141 optimize: {
142 proguard_flags_files: ["proguard.flags"],
143 },
144}
145
146// Non-updatable network stack running in the system server process for devices not using the module
147android_app {
148 name: "InProcessNetworkStack",
149 defaults: [ "NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"],
150 static_libs: ["NetworkStackApiCurrentLib"],
151 certificate: "platform",
152 manifest: "AndroidManifest_InProcess.xml",
153 // InProcessNetworkStack is a replacement for NetworkStack
154 overrides: ["NetworkStack"],
155 // The permission configuration *must* be included to ensure security of the device
156 // The InProcessNetworkStack goes together with the PlatformCaptivePortalLogin, which replaces
157 // the default CaptivePortalLogin.
158 required: ["PlatformNetworkPermissionConfig", "PlatformCaptivePortalLogin"],
159}
160
161// Updatable network stack packaged as an application
162android_app {
163 name: "NetworkStack",
164 defaults: ["NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"],
165 static_libs: ["NetworkStackApiCurrentLib"],
166 certificate: "networkstack",
167 manifest: "AndroidManifest.xml",
168 // The permission configuration *must* be included to ensure security of the device
169 required: ["NetworkPermissionConfig"],
170}
171
172// Updatable network stack for finalized API
173android_app {
174 name: "NetworkStackApiStable",
175 defaults: ["NetworkStackAppDefaults", "NetworkStackApiStableLevel"],
176 static_libs: ["NetworkStackApiStableLib"],
177 certificate: "networkstack",
178 manifest: "AndroidManifest.xml",
179 // The permission configuration *must* be included to ensure security of the device
180 required: ["NetworkPermissionConfig"],
181}
182
183// Android library to derive test APKs for integration tests
184android_library {
185 name: "TestNetworkStackLib",
186 defaults: ["NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"],
187 static_libs: ["NetworkStackApiCurrentLib"],
188 manifest: "AndroidManifest.xml",
189}
190
paulhue455e2a2019-03-29 17:22:20 +0800191cc_library_shared {
192 name: "libnetworkstackutilsjni",
193 srcs: [
194 "jni/network_stack_utils_jni.cpp"
195 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900196 sdk_version: "current",
paulhue455e2a2019-03-29 17:22:20 +0800197 shared_libs: [
198 "liblog",
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900199 "libnativehelper_compat_libc++",
paulhue455e2a2019-03-29 17:22:20 +0800200 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900201
202 // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
203 // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
204 // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
205 // build because soong complains of:
206 // module NetworkStack missing dependencies: libc++_shared
207 //
208 // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
209 // we depend on do not dynamically link libc++. This is currently the case, because liblog is
210 // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
211 //
212 // TODO: find a better solution for this in R.
213 stl: "c++_static",
paulhue455e2a2019-03-29 17:22:20 +0800214 cflags: [
215 "-Wall",
216 "-Werror",
217 "-Wno-unused-parameter",
218 ],
219}
220
Chiachang Wang80242272019-04-11 21:24:28 +0800221genrule {
222 name: "statslog-networkstack-java-gen",
223 tools: ["stats-log-api-gen"],
224 cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
225 " --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog",
226 out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
227}
Kun Niu8e89dd42019-07-16 18:33:45 -0700228
229genrule {
230 name: "NetworkStackTestAndroidManifest",
231 srcs: ["AndroidManifest.xml"],
232 out: ["TestAndroidManifest.xml"],
233 cmd: "sed 's/versionCode=\".*\"/versionCode=\"300000000\"/' $(in) > $(out)",
234}
235
236android_app {
237 name: "TestNetworkStack",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900238 defaults: ["NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"],
239 static_libs: ["NetworkStackApiCurrentLib"],
Kun Niu8e89dd42019-07-16 18:33:45 -0700240 certificate: "networkstack",
241 manifest: ":NetworkStackTestAndroidManifest",
Kun Niu8e89dd42019-07-16 18:33:45 -0700242 // The permission configuration *must* be included to ensure security of the device
243 required: ["NetworkPermissionConfig"],
244}