blob: 5c6ca9bda97a545f5fbe9a39c2f80dff0287d24c [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",
84}
85
Remi NGUYEN VAN99645762019-07-11 14:33:15 +090086// The versions of the android library containing network stack code compiled for each SDK variant
87android_library {
88 name: "NetworkStackApiCurrentLib",
89 defaults: ["NetworkStackApiCurrentLevel", "NetworkStackAndroidLibraryDefaults"],
90 srcs: [
91 ":NetworkStackApiCurrentShims",
92 ],
93}
94
95android_library {
96 name: "NetworkStackApiStableLib",
97 defaults: ["NetworkStackApiStableLevel", "NetworkStackAndroidLibraryDefaults"],
98 srcs: [
99 ":NetworkStackApiStableShims",
100 ],
101}
102
103// Common defaults for compiling the actual APK, based on the NetworkStackApiXBase android libraries
104java_defaults {
105 name: "NetworkStackAppDefaults",
106 privileged: true,
107 jni_libs: [
108 "libnativehelper_compat_libc++",
109 "libnetworkstackutilsjni",
110 ],
111 // Resources already included in NetworkStackBase
112 resource_dirs: [],
113 jarjar_rules: "jarjar-rules-shared.txt",
114 use_embedded_native_libs: true,
115 optimize: {
116 proguard_flags_files: ["proguard.flags"],
117 },
118}
119
120// Non-updatable network stack running in the system server process for devices not using the module
121android_app {
122 name: "InProcessNetworkStack",
123 defaults: [ "NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"],
124 static_libs: ["NetworkStackApiCurrentLib"],
125 certificate: "platform",
126 manifest: "AndroidManifest_InProcess.xml",
127 // InProcessNetworkStack is a replacement for NetworkStack
128 overrides: ["NetworkStack"],
129 // The permission configuration *must* be included to ensure security of the device
130 // The InProcessNetworkStack goes together with the PlatformCaptivePortalLogin, which replaces
131 // the default CaptivePortalLogin.
132 required: ["PlatformNetworkPermissionConfig", "PlatformCaptivePortalLogin"],
133}
134
135// Updatable network stack packaged as an application
136android_app {
137 name: "NetworkStack",
138 defaults: ["NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"],
139 static_libs: ["NetworkStackApiCurrentLib"],
140 certificate: "networkstack",
141 manifest: "AndroidManifest.xml",
142 // The permission configuration *must* be included to ensure security of the device
143 required: ["NetworkPermissionConfig"],
144}
145
146// Updatable network stack for finalized API
147android_app {
148 name: "NetworkStackApiStable",
149 defaults: ["NetworkStackAppDefaults", "NetworkStackApiStableLevel"],
150 static_libs: ["NetworkStackApiStableLib"],
151 certificate: "networkstack",
152 manifest: "AndroidManifest.xml",
153 // The permission configuration *must* be included to ensure security of the device
154 required: ["NetworkPermissionConfig"],
155}
156
157// Android library to derive test APKs for integration tests
158android_library {
159 name: "TestNetworkStackLib",
160 defaults: ["NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"],
161 static_libs: ["NetworkStackApiCurrentLib"],
162 manifest: "AndroidManifest.xml",
163}
164
paulhue455e2a2019-03-29 17:22:20 +0800165cc_library_shared {
166 name: "libnetworkstackutilsjni",
167 srcs: [
168 "jni/network_stack_utils_jni.cpp"
169 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900170 sdk_version: "current",
paulhue455e2a2019-03-29 17:22:20 +0800171 shared_libs: [
172 "liblog",
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900173 "libnativehelper_compat_libc++",
paulhue455e2a2019-03-29 17:22:20 +0800174 ],
Lorenzo Colitti88ddd882019-05-01 11:54:33 +0900175
176 // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
177 // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
178 // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
179 // build because soong complains of:
180 // module NetworkStack missing dependencies: libc++_shared
181 //
182 // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
183 // we depend on do not dynamically link libc++. This is currently the case, because liblog is
184 // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
185 //
186 // TODO: find a better solution for this in R.
187 stl: "c++_static",
paulhue455e2a2019-03-29 17:22:20 +0800188 cflags: [
189 "-Wall",
190 "-Werror",
191 "-Wno-unused-parameter",
192 ],
193}
194
Chiachang Wang80242272019-04-11 21:24:28 +0800195genrule {
196 name: "statslog-networkstack-java-gen",
197 tools: ["stats-log-api-gen"],
198 cmd: "$(location stats-log-api-gen) --java $(out) --module network_stack" +
199 " --javaPackage com.android.networkstack.metrics --javaClass NetworkStackStatsLog",
200 out: ["com/android/networkstack/metrics/NetworkStackStatsLog.java"],
201}
Kun Niu8e89dd42019-07-16 18:33:45 -0700202
203genrule {
204 name: "NetworkStackTestAndroidManifest",
205 srcs: ["AndroidManifest.xml"],
206 out: ["TestAndroidManifest.xml"],
207 cmd: "sed 's/versionCode=\".*\"/versionCode=\"300000000\"/' $(in) > $(out)",
208}
209
210android_app {
211 name: "TestNetworkStack",
Remi NGUYEN VAN99645762019-07-11 14:33:15 +0900212 defaults: ["NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"],
213 static_libs: ["NetworkStackApiCurrentLib"],
Kun Niu8e89dd42019-07-16 18:33:45 -0700214 certificate: "networkstack",
215 manifest: ":NetworkStackTestAndroidManifest",
Kun Niu8e89dd42019-07-16 18:33:45 -0700216 // The permission configuration *must* be included to ensure security of the device
217 required: ["NetworkPermissionConfig"],
218}