blob: f17412deee078027f129940d6dec1ae38651e140 [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
22// / \
23// +NetworkStackApiStableShims --> / \ <-- +NetworkStackApiCurrentShims
24// +NetworkStackApiStableLevel / \ +NetworkStackApiCurrentLevel
25// / \
26// NetworkStackApiStableLib NetworkStackApiCurrentLib <-- android libs w/ all code
27// | | (also used in unit tests)
28// | <-- +NetworkStackAppDefaults --> |
29// | (APK build params) |
30// | |
31// | <-- +NetworkStackApiStableLevel | <-- +NetworkStackApiCurrentLevel
32// | |
33// | |
34// NetworkStackApiStable NetworkStack, InProcessNetworkStack, <-- output APKs
35// TestNetworkStack
36
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090037// Common defaults to define SDK level
Remi NGUYEN VAN40369562019-03-20 16:40:54 +090038java_defaults {
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090039 name: "NetworkStackApiCurrentLevel",
Remi NGUYEN VAN40369562019-03-20 16:40:54 +090040 sdk_version: "system_current",
41 min_sdk_version: "28",
42}
43
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090044java_defaults {
45 name: "NetworkStackApiStableLevel",
46 sdk_version: "system_current", // TODO: change to system_29
47 min_sdk_version: "28",
48}
49
50// Java libraries for the API shims
51filegroup {
52 name: "NetworkStackApiCurrentShims",
53 srcs: [
54 "apishim/current/**/*.java"
55 ],
56}
57
58filegroup {
59 name: "NetworkStackApiStableShims",
60 srcs: [
61 "apishim/29/**/*.java"
62 ],
63}
64
65// Common defaults for android libraries containing network stack code, used to compile variants of
66// the network stack in the system process and in the network_stack process
67java_defaults {
68 name: "NetworkStackAndroidLibraryDefaults",
Remi NGUYEN VANded23152018-12-07 16:52:24 +090069 srcs: [
70 "src/**/*.java",
Remi NGUYEN VAN82b4b422019-01-20 09:35:10 +090071 ":framework-networkstack-shared-srcs",
Remi NGUYEN VAN5daa3702018-12-27 16:43:56 +090072 ":services-networkstack-shared-srcs",
Chiachang Wang80242272019-04-11 21:24:28 +080073 ":statslog-networkstack-java-gen",
Remi NGUYEN VANded23152018-12-07 16:52:24 +090074 ],
Remi NGUYEN VAN057bf202018-12-04 12:13:09 +090075 static_libs: [
Niklas Lindgren0c904882018-12-07 11:08:04 +010076 "androidx.annotation_annotation",
Lorenzo Colitti81fc3e62019-05-21 19:45:09 +090077 "netd_aidl_interface-V2-java",
Remi NGUYEN VANbbb97032019-08-08 15:53:54 +090078 "networkstack-client",
Chiachang Wang8b5f84a2019-02-22 11:13:07 +080079 "datastallprotosnano",
Chiachang Wang54663a82019-03-21 20:40:01 +080080 "networkstackprotosnano",
paulhu5982eff2019-03-29 19:21:30 +080081 "captiveportal-lib",
Remi NGUYEN VAN0a4df5a2019-03-08 17:20:49 +090082 ],
83 manifest: "AndroidManifestBase.xml",
Kun Niuf3b69042019-07-01 17:03:20 -070084 plugins: ["java_api_finder"],
Remi NGUYEN VAN0a4df5a2019-03-08 17:20:49 +090085}
86
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090087// The versions of the android library containing network stack code compiled for each SDK variant
88android_library {
89 name: "NetworkStackApiCurrentLib",
90 defaults: ["NetworkStackApiCurrentLevel", "NetworkStackAndroidLibraryDefaults"],
91 srcs: [
92 ":NetworkStackApiCurrentShims",
93 ],
94}
95
96android_library {
97 name: "NetworkStackApiStableLib",
98 defaults: ["NetworkStackApiStableLevel", "NetworkStackAndroidLibraryDefaults"],
99 srcs: [
100 ":NetworkStackApiStableShims",
101 ],
102}
103
104// Common defaults for compiling the actual APK, based on the NetworkStackApiXBase android libraries
105java_defaults {
106 name: "NetworkStackAppDefaults",
107 privileged: true,
108 jni_libs: [
109 "libnativehelper_compat_libc++",
110 "libnetworkstackutilsjni",
111 ],
112 // Resources already included in NetworkStackBase
113 resource_dirs: [],
114 jarjar_rules: "jarjar-rules-shared.txt",
115 use_embedded_native_libs: true,
116 optimize: {
117 proguard_flags_files: ["proguard.flags"],
118 },
119}
120
121// Non-updatable network stack running in the system server process for devices not using the module
122android_app {
123 name: "InProcessNetworkStack",
124 defaults: [ "NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"],
125 static_libs: ["NetworkStackApiCurrentLib"],
126 certificate: "platform",
127 manifest: "AndroidManifest_InProcess.xml",
128 // InProcessNetworkStack is a replacement for NetworkStack
129 overrides: ["NetworkStack"],
130 // The permission configuration *must* be included to ensure security of the device
131 // The InProcessNetworkStack goes together with the PlatformCaptivePortalLogin, which replaces
132 // the default CaptivePortalLogin.
133 required: ["PlatformNetworkPermissionConfig", "PlatformCaptivePortalLogin"],
134}
135
136// Updatable network stack packaged as an application
137android_app {
138 name: "NetworkStack",
139 defaults: ["NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"],
140 static_libs: ["NetworkStackApiCurrentLib"],
141 certificate: "networkstack",
142 manifest: "AndroidManifest.xml",
143 // The permission configuration *must* be included to ensure security of the device
144 required: ["NetworkPermissionConfig"],
145}
146
147// Updatable network stack for finalized API
148android_app {
149 name: "NetworkStackApiStable",
150 defaults: ["NetworkStackAppDefaults", "NetworkStackApiStableLevel"],
151 static_libs: ["NetworkStackApiStableLib"],
152 certificate: "networkstack",
153 manifest: "AndroidManifest.xml",
154 // The permission configuration *must* be included to ensure security of the device
155 required: ["NetworkPermissionConfig"],
156}
157
158// Android library to derive test APKs for integration tests
159android_library {
160 name: "TestNetworkStackLib",
161 defaults: ["NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"],
162 static_libs: ["NetworkStackApiCurrentLib"],
163 manifest: "AndroidManifest.xml",
164}
165
paulhue455e2a2019-03-29 17:22:20 +0800166cc_library_shared {
167 name: "libnetworkstackutilsjni",
168 srcs: [
169 "jni/network_stack_utils_jni.cpp"
170 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900171 sdk_version: "current",
paulhue455e2a2019-03-29 17:22:20 +0800172 shared_libs: [
173 "liblog",
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900174 "libnativehelper_compat_libc++",
paulhue455e2a2019-03-29 17:22:20 +0800175 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900176
177 // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
178 // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
179 // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
180 // build because soong complains of:
181 // module NetworkStack missing dependencies: libc++_shared
182 //
183 // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
184 // we depend on do not dynamically link libc++. This is currently the case, because liblog is
185 // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
186 //
187 // TODO: find a better solution for this in R.
188 stl: "c++_static",
paulhue455e2a2019-03-29 17:22:20 +0800189 cflags: [
190 "-Wall",
191 "-Werror",
192 "-Wno-unused-parameter",
193 ],
194}
195
Chiachang Wang80242272019-04-11 21:24:28 +0800196genrule {
197 name: "statslog-networkstack-java-gen",
198 tools: ["stats-log-api-gen"],
199 cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
200 " --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog",
201 out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
202}
Kun Niu8e89dd42019-07-16 18:33:45 -0700203
204genrule {
205 name: "NetworkStackTestAndroidManifest",
206 srcs: ["AndroidManifest.xml"],
207 out: ["TestAndroidManifest.xml"],
208 cmd: "sed 's/versionCode=\".*\"/versionCode=\"300000000\"/' $(in) > $(out)",
209}
210
211android_app {
212 name: "TestNetworkStack",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900213 defaults: ["NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"],
214 static_libs: ["NetworkStackApiCurrentLib"],
Kun Niu8e89dd42019-07-16 18:33:45 -0700215 certificate: "networkstack",
216 manifest: ":NetworkStackTestAndroidManifest",
Kun Niu8e89dd42019-07-16 18:33:45 -0700217 // The permission configuration *must* be included to ensure security of the device
218 required: ["NetworkPermissionConfig"],
219}