Remi NGUYEN VAN | ded2315 | 2018-12-07 16:52:24 +0900 | [diff] [blame] | 1 | // |
| 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 VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 17 | // 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 VAN | 794a4b5 | 2019-09-06 13:00:33 +0900 | [diff] [blame] | 22 | // / \ |
| 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 VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 42 | |
Remi NGUYEN VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 43 | // Common defaults to define SDK level |
Remi NGUYEN VAN | 4036956 | 2019-03-20 16:40:54 +0900 | [diff] [blame] | 44 | java_defaults { |
Remi NGUYEN VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 45 | name: "NetworkStackApiCurrentLevel", |
Remi NGUYEN VAN | 4036956 | 2019-03-20 16:40:54 +0900 | [diff] [blame] | 46 | sdk_version: "system_current", |
| 47 | min_sdk_version: "28", |
| 48 | } |
| 49 | |
Remi NGUYEN VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 50 | java_defaults { |
| 51 | name: "NetworkStackApiStableLevel", |
Remi NGUYEN VAN | 794a4b5 | 2019-09-06 13:00:33 +0900 | [diff] [blame] | 52 | sdk_version: "system_29", |
Remi NGUYEN VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 53 | min_sdk_version: "28", |
| 54 | } |
| 55 | |
Remi NGUYEN VAN | 794a4b5 | 2019-09-06 13:00:33 +0900 | [diff] [blame] | 56 | // Filegroups for the API shims |
Remi NGUYEN VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 57 | filegroup { |
| 58 | name: "NetworkStackApiCurrentShims", |
| 59 | srcs: [ |
Remi NGUYEN VAN | 794a4b5 | 2019-09-06 13:00:33 +0900 | [diff] [blame] | 60 | "apishim/common/**/*.java", |
| 61 | "apishim/29/**/*.java", |
| 62 | "apishim/current/**/*.java", |
| 63 | ":net-module-utils-srcs", |
Remi NGUYEN VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 64 | ], |
| 65 | } |
| 66 | |
Remi NGUYEN VAN | 794a4b5 | 2019-09-06 13:00:33 +0900 | [diff] [blame] | 67 | // API stable shims only include the compat package, but it is jarjared to replace the non-compat |
| 68 | // package |
Remi NGUYEN VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 69 | filegroup { |
| 70 | name: "NetworkStackApiStableShims", |
| 71 | srcs: [ |
Remi NGUYEN VAN | 794a4b5 | 2019-09-06 13:00:33 +0900 | [diff] [blame] | 72 | "apishim/common/**/*.java", |
| 73 | "apishim/29/**/*.java", |
| 74 | ":net-module-utils-srcs", |
Remi NGUYEN VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 75 | ], |
| 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 |
| 80 | java_defaults { |
| 81 | name: "NetworkStackAndroidLibraryDefaults", |
Remi NGUYEN VAN | ded2315 | 2018-12-07 16:52:24 +0900 | [diff] [blame] | 82 | srcs: [ |
Remi NGUYEN VAN | 82b4b42 | 2019-01-20 09:35:10 +0900 | [diff] [blame] | 83 | ":framework-networkstack-shared-srcs", |
Remi NGUYEN VAN | 5daa370 | 2018-12-27 16:43:56 +0900 | [diff] [blame] | 84 | ":services-networkstack-shared-srcs", |
Chiachang Wang | 8024227 | 2019-04-11 21:24:28 +0800 | [diff] [blame] | 85 | ":statslog-networkstack-java-gen", |
Remi NGUYEN VAN | ded2315 | 2018-12-07 16:52:24 +0900 | [diff] [blame] | 86 | ], |
Remi NGUYEN VAN | 057bf20 | 2018-12-04 12:13:09 +0900 | [diff] [blame] | 87 | static_libs: [ |
Niklas Lindgren | 0c90488 | 2018-12-07 11:08:04 +0100 | [diff] [blame] | 88 | "androidx.annotation_annotation", |
Lorenzo Colitti | 81fc3e6 | 2019-05-21 19:45:09 +0900 | [diff] [blame] | 89 | "netd_aidl_interface-V2-java", |
Remi NGUYEN VAN | bbb9703 | 2019-08-08 15:53:54 +0900 | [diff] [blame] | 90 | "networkstack-client", |
Chiachang Wang | 8b5f84a | 2019-02-22 11:13:07 +0800 | [diff] [blame] | 91 | "datastallprotosnano", |
Chiachang Wang | 54663a8 | 2019-03-21 20:40:01 +0800 | [diff] [blame] | 92 | "networkstackprotosnano", |
paulhu | 5982eff | 2019-03-29 19:21:30 +0800 | [diff] [blame] | 93 | "captiveportal-lib", |
Remi NGUYEN VAN | 0a4df5a | 2019-03-08 17:20:49 +0900 | [diff] [blame] | 94 | ], |
Kun Niu | f3b6904 | 2019-07-01 17:03:20 -0700 | [diff] [blame] | 95 | plugins: ["java_api_finder"], |
Remi NGUYEN VAN | 0a4df5a | 2019-03-08 17:20:49 +0900 | [diff] [blame] | 96 | } |
| 97 | |
Remi NGUYEN VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 98 | // The versions of the android library containing network stack code compiled for each SDK variant |
Remi NGUYEN VAN | 794a4b5 | 2019-09-06 13:00:33 +0900 | [diff] [blame] | 99 | // 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 VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 102 | android_library { |
| 103 | name: "NetworkStackApiCurrentLib", |
| 104 | defaults: ["NetworkStackApiCurrentLevel", "NetworkStackAndroidLibraryDefaults"], |
Remi NGUYEN VAN | 794a4b5 | 2019-09-06 13:00:33 +0900 | [diff] [blame] | 105 | 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. |
| 111 | java_library { |
| 112 | name: "NetworkStackApiStableDependencies", |
| 113 | defaults: ["NetworkStackApiStableLevel", "NetworkStackAndroidLibraryDefaults"], |
| 114 | srcs: [":NetworkStackApiStableShims"], |
| 115 | jarjar_rules: "apishim/jarjar-rules-compat.txt", |
Remi NGUYEN VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | android_library { |
| 119 | name: "NetworkStackApiStableLib", |
Remi NGUYEN VAN | 794a4b5 | 2019-09-06 13:00:33 +0900 | [diff] [blame] | 120 | defaults: ["NetworkStackApiStableLevel"], |
| 121 | srcs: [":framework-annotations", "src/**/*.java"], |
| 122 | // API stable uses a jarjared version of the shims |
| 123 | static_libs: [ |
| 124 | "NetworkStackApiStableDependencies", |
Remi NGUYEN VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 125 | ], |
Remi NGUYEN VAN | 794a4b5 | 2019-09-06 13:00:33 +0900 | [diff] [blame] | 126 | manifest: "AndroidManifestBase.xml", |
Remi NGUYEN VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | // Common defaults for compiling the actual APK, based on the NetworkStackApiXBase android libraries |
| 130 | java_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 |
| 147 | android_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 |
Remi NGUYEN VAN | ec9d8a6 | 2019-11-11 03:52:43 +0000 | [diff] [blame^] | 154 | overrides: ["NetworkStack", "NetworkStackNext"], |
Remi NGUYEN VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 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 |
| 162 | android_app { |
Remi NGUYEN VAN | ec9d8a6 | 2019-11-11 03:52:43 +0000 | [diff] [blame^] | 163 | name: "NetworkStackNext", |
Remi NGUYEN VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 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 |
| 173 | android_app { |
Remi NGUYEN VAN | ec9d8a6 | 2019-11-11 03:52:43 +0000 | [diff] [blame^] | 174 | name: "NetworkStack", |
Remi NGUYEN VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 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 |
| 184 | android_library { |
| 185 | name: "TestNetworkStackLib", |
| 186 | defaults: ["NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"], |
| 187 | static_libs: ["NetworkStackApiCurrentLib"], |
| 188 | manifest: "AndroidManifest.xml", |
| 189 | } |
| 190 | |
paulhu | e455e2a | 2019-03-29 17:22:20 +0800 | [diff] [blame] | 191 | cc_library_shared { |
| 192 | name: "libnetworkstackutilsjni", |
| 193 | srcs: [ |
| 194 | "jni/network_stack_utils_jni.cpp" |
| 195 | ], |
Lorenzo Colitti | 88ddd88 | 2019-05-01 11:54:33 +0900 | [diff] [blame] | 196 | sdk_version: "current", |
paulhu | e455e2a | 2019-03-29 17:22:20 +0800 | [diff] [blame] | 197 | shared_libs: [ |
| 198 | "liblog", |
Lorenzo Colitti | 88ddd88 | 2019-05-01 11:54:33 +0900 | [diff] [blame] | 199 | "libnativehelper_compat_libc++", |
paulhu | e455e2a | 2019-03-29 17:22:20 +0800 | [diff] [blame] | 200 | ], |
Lorenzo Colitti | 88ddd88 | 2019-05-01 11:54:33 +0900 | [diff] [blame] | 201 | |
| 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", |
paulhu | e455e2a | 2019-03-29 17:22:20 +0800 | [diff] [blame] | 214 | cflags: [ |
| 215 | "-Wall", |
| 216 | "-Werror", |
| 217 | "-Wno-unused-parameter", |
| 218 | ], |
| 219 | } |
| 220 | |
Chiachang Wang | 8024227 | 2019-04-11 21:24:28 +0800 | [diff] [blame] | 221 | genrule { |
| 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 Niu | 8e89dd4 | 2019-07-16 18:33:45 -0700 | [diff] [blame] | 228 | |
| 229 | genrule { |
| 230 | name: "NetworkStackTestAndroidManifest", |
| 231 | srcs: ["AndroidManifest.xml"], |
| 232 | out: ["TestAndroidManifest.xml"], |
| 233 | cmd: "sed 's/versionCode=\".*\"/versionCode=\"300000000\"/' $(in) > $(out)", |
| 234 | } |
| 235 | |
| 236 | android_app { |
| 237 | name: "TestNetworkStack", |
Remi NGUYEN VAN | 9964576 | 2019-07-11 14:33:15 +0900 | [diff] [blame] | 238 | defaults: ["NetworkStackAppDefaults", "NetworkStackApiCurrentLevel"], |
| 239 | static_libs: ["NetworkStackApiCurrentLib"], |
Kun Niu | 8e89dd4 | 2019-07-16 18:33:45 -0700 | [diff] [blame] | 240 | certificate: "networkstack", |
| 241 | manifest: ":NetworkStackTestAndroidManifest", |
Kun Niu | 8e89dd4 | 2019-07-16 18:33:45 -0700 | [diff] [blame] | 242 | // The permission configuration *must* be included to ensure security of the device |
| 243 | required: ["NetworkPermissionConfig"], |
| 244 | } |