blob: 3ab1ec2b10f2e5b43022c163785014de2d4c6a4a [file] [log] [blame]
markchien932da862019-08-27 10:19:38 +08001//
2// Copyright (C) 2019 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
Bob Badour97e6be22021-02-12 14:45:04 -080017package {
18 default_applicable_licenses: ["Android-Apache-2.0"],
19}
20
markchien932da862019-08-27 10:19:38 +080021java_defaults {
markchien5a8c8062021-10-27 13:22:27 +080022 name: "TetheringApiLevel",
Anton Hanssonbbe4af12020-03-18 14:15:42 +000023 sdk_version: "module_current",
Mark Chiend25a1e02022-05-19 01:01:26 +080024 target_sdk_version: "33",
Nikita Ioffe583e35a2020-10-31 22:41:41 +000025 min_sdk_version: "30",
markchien5a8c8062021-10-27 13:22:27 +080026}
27
28java_defaults {
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +090029 name: "TetheringExternalLibs",
30 // Libraries not including Tethering's own framework-tethering (different flavors of that one
31 // are needed depending on the build rule)
32 libs: [
33 "framework-connectivity.stubs.module_lib",
34 "framework-connectivity-t.stubs.module_lib",
35 "framework-statsd.stubs.module_lib",
36 "framework-wifi",
37 "framework-bluetooth",
38 "unsupportedappusage",
39 ],
40 defaults_visibility: ["//visibility:private"],
41}
42
43java_defaults {
markchien5a8c8062021-10-27 13:22:27 +080044 name: "TetheringAndroidLibraryDefaults",
markchien932da862019-08-27 10:19:38 +080045 srcs: [
Hungming Chendd55b912020-12-26 17:13:22 +080046 "apishim/**/*.java",
markchien932da862019-08-27 10:19:38 +080047 "src/**/*.java",
Aaron Huangb401e582021-01-22 18:35:00 +080048 ":framework-connectivity-shared-srcs",
markchien43e97e02019-09-03 15:58:06 +080049 ":services-tethering-shared-srcs",
Wayne Ma7ecded82022-03-10 16:19:24 +080050 ":statslog-tethering-java-gen",
markchien932da862019-08-27 10:19:38 +080051 ],
52 static_libs: [
53 "androidx.annotation_annotation",
Hungming Chen01f25502022-06-28 22:47:00 +080054 "connectivity-net-module-utils-bpf",
Hungming Chendd55b912020-12-26 17:13:22 +080055 "modules-utils-build",
William Escandeea9e22e2021-08-19 12:26:52 +020056 "modules-utils-statemachine",
Jeongik Chad05f9902021-01-26 22:35:02 +090057 "networkstack-client",
markchien547e1682020-02-05 12:42:25 +080058 "android.hardware.tetheroffload.config-V1.0-java",
markchien6aa38892019-09-25 14:33:39 +080059 "android.hardware.tetheroffload.control-V1.0-java",
junyulai177dc862021-03-10 15:26:50 +080060 "android.hardware.tetheroffload.control-V1.1-java",
markchien75fc6ab2020-01-14 17:28:47 +080061 "net-utils-framework-common",
Chalard Jeanbdcca922020-06-26 00:19:33 +090062 "net-utils-device-common",
markchien782a5682021-11-10 01:11:33 +080063 "net-utils-device-common-bpf",
Xiao Mac81c0662022-06-17 14:58:03 +090064 "net-utils-device-common-ip",
Xiao Ma09c07272021-07-01 14:00:34 +000065 "net-utils-device-common-netlink",
lucaslinee661df2020-12-28 16:44:49 +080066 "netd-client",
Wayne Ma71d66392022-03-03 10:15:09 +080067 "tetheringstatsprotos",
markchien932da862019-08-27 10:19:38 +080068 ],
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +090069 defaults: ["TetheringExternalLibs"],
markchien9d353822019-12-16 20:15:20 +080070 libs: [
Paul Duffin2dae2722020-05-13 12:28:49 +010071 "framework-tethering.impl",
markchien9d353822019-12-16 20:15:20 +080072 ],
markchien84a92822020-01-16 11:21:53 +080073 plugins: ["java_api_finder"],
markchien932da862019-08-27 10:19:38 +080074 manifest: "AndroidManifestBase.xml",
Chiachang Wang3bc52762021-11-25 14:17:57 +080075 lint: { strict_updatability_linting: true },
markchien932da862019-08-27 10:19:38 +080076}
77
markchien5a8c8062021-10-27 13:22:27 +080078// build tethering static library, used to compile both variants of the tethering.
markchien932da862019-08-27 10:19:38 +080079android_library {
80 name: "TetheringApiCurrentLib",
markchien5a8c8062021-10-27 13:22:27 +080081 defaults: [
Remi NGUYEN VANf826bce2022-01-26 17:43:53 +090082 "ConnectivityNextEnableDefaults",
markchien5a8c8062021-10-27 13:22:27 +080083 "TetheringAndroidLibraryDefaults",
84 "TetheringApiLevel"
85 ],
86 static_libs: [
87 "NetworkStackApiCurrentShims",
88 ],
89 apex_available: ["com.android.tethering"],
Chiachang Wang3bc52762021-11-25 14:17:57 +080090 lint: { strict_updatability_linting: true },
markchien5a8c8062021-10-27 13:22:27 +080091}
92
93android_library {
94 name: "TetheringApiStableLib",
95 defaults: [
96 "TetheringAndroidLibraryDefaults",
97 "TetheringApiLevel"
98 ],
99 static_libs: [
100 "NetworkStackApiStableShims",
101 ],
102 apex_available: ["com.android.tethering"],
Chiachang Wang3bc52762021-11-25 14:17:57 +0800103 lint: { strict_updatability_linting: true },
markchien932da862019-08-27 10:19:38 +0800104}
105
markchien810aa682019-10-23 16:27:52 +0800106// Due to b/143733063, APK can't access a jni lib that is in APEX (but not in the APK).
107cc_library {
markchienf967b112021-11-09 16:56:23 +0800108 name: "libcom_android_networkstack_tethering_util_jni",
markchien5a8c8062021-10-27 13:22:27 +0800109 sdk_version: "30",
Jooyung Han8182d8b2020-04-29 02:43:30 +0900110 apex_available: [
111 "//apex_available:platform", // Used by InProcessTethering
112 "com.android.tethering",
113 ],
Nikita Ioffe583e35a2020-10-31 22:41:41 +0000114 min_sdk_version: "30",
Lorenzo Colitti734b14e2021-02-05 23:56:09 +0900115 header_libs: [
Ken Chenbb57fa92021-10-22 00:49:13 +0800116 "bpf_connectivity_headers",
Lorenzo Colitti734b14e2021-02-05 23:56:09 +0900117 ],
markchien6aa38892019-09-25 14:33:39 +0800118 srcs: [
markchien70526882020-11-12 00:17:15 +0800119 "jni/*.cpp",
markchien6aa38892019-09-25 14:33:39 +0800120 ],
121 shared_libs: [
markchien6aa38892019-09-25 14:33:39 +0800122 "liblog",
markchien547e1682020-02-05 12:42:25 +0800123 "libnativehelper_compat_libc++",
markchien6aa38892019-09-25 14:33:39 +0800124 ],
Orion Hodsone5bd0db2020-12-08 09:57:42 +0000125 static_libs: [
markchien782a5682021-11-10 01:11:33 +0800126 "libnet_utils_device_common_bpfjni",
Orion Hodsone5bd0db2020-12-08 09:57:42 +0000127 "libnetjniutils",
128 ],
markchien6aa38892019-09-25 14:33:39 +0800129
markchien547e1682020-02-05 12:42:25 +0800130 // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
131 // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
132 // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
133 // build because soong complains of:
134 // module Tethering missing dependencies: libc++_shared
135 //
136 // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
137 // we depend on do not dynamically link libc++. This is currently the case, because liblog is
138 // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
139 stl: "c++_static",
140
markchien6aa38892019-09-25 14:33:39 +0800141 cflags: [
142 "-Wall",
143 "-Werror",
144 "-Wno-unused-parameter",
145 "-Wthread-safety",
146 ],
markchien810aa682019-10-23 16:27:52 +0800147
Yi Kong20a996e2022-06-22 03:41:56 +0800148 ldflags: ["-Wl,--exclude-libs=ALL,--error-limit=0"],
markchien6aa38892019-09-25 14:33:39 +0800149}
150
markchien932da862019-08-27 10:19:38 +0800151// Common defaults for compiling the actual APK.
152java_defaults {
153 name: "TetheringAppDefaults",
markchien932da862019-08-27 10:19:38 +0800154 privileged: true,
markchien6aa38892019-09-25 14:33:39 +0800155 jni_libs: [
markchienf967b112021-11-09 16:56:23 +0800156 "libcom_android_networkstack_tethering_util_jni",
markchien6aa38892019-09-25 14:33:39 +0800157 ],
markchien932da862019-08-27 10:19:38 +0800158 resource_dirs: [
159 "res",
160 ],
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +0900161 // Libs are not actually needed to build here since build rules using these defaults are just
162 // packaging the TetheringApiXLibs in APKs, but they are necessary so that R8 has the right
163 // references to optimize the code. Without these, there will be missing class warnings and code
164 // may be wrongly optimized.
165 // R8 runs after jarjar, so the framework-X libraries need to be the post-jarjar artifacts
166 // (framework-tethering.impl), if they are not just stubs, so that the name of jarjared
167 // classes match.
168 // TODO(b/229727645): ensure R8 fails the build fully if libraries are missing
169 defaults: ["TetheringExternalLibs"],
markchien9d353822019-12-16 20:15:20 +0800170 libs: [
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +0900171 "framework-tethering.impl",
markchien9d353822019-12-16 20:15:20 +0800172 ],
173 jarjar_rules: "jarjar-rules.txt",
markchien932da862019-08-27 10:19:38 +0800174 optimize: {
175 proguard_flags_files: ["proguard.flags"],
176 },
Chiachang Wang3bc52762021-11-25 14:17:57 +0800177 lint: { strict_updatability_linting: true },
markchien932da862019-08-27 10:19:38 +0800178}
179
180// Non-updatable tethering running in the system server process for devices not using the module
markchienee6ad372019-09-30 14:40:57 +0800181android_app {
182 name: "InProcessTethering",
Remi NGUYEN VANf826bce2022-01-26 17:43:53 +0900183 defaults: ["TetheringAppDefaults", "TetheringApiLevel", "ConnectivityNextEnableDefaults"],
markchienee6ad372019-09-30 14:40:57 +0800184 static_libs: ["TetheringApiCurrentLib"],
185 certificate: "platform",
186 manifest: "AndroidManifest_InProcess.xml",
187 // InProcessTethering is a replacement for Tethering
188 overrides: ["Tethering"],
markchiendbaff662020-05-05 17:42:44 +0800189 apex_available: ["com.android.tethering"],
Chiachang Wang3bc52762021-11-25 14:17:57 +0800190 lint: { strict_updatability_linting: true },
markchienee6ad372019-09-30 14:40:57 +0800191}
markchien932da862019-08-27 10:19:38 +0800192
markchien5a8c8062021-10-27 13:22:27 +0800193// Updatable tethering packaged for finalized API
markchien932da862019-08-27 10:19:38 +0800194android_app {
195 name: "Tethering",
markchien5a8c8062021-10-27 13:22:27 +0800196 defaults: ["TetheringAppDefaults", "TetheringApiLevel"],
197 static_libs: ["TetheringApiStableLib"],
198 certificate: "networkstack",
199 manifest: "AndroidManifest.xml",
200 use_embedded_native_libs: true,
Motomu Utsumiae279012022-04-20 08:30:24 +0000201 // The network stack *must* be included to ensure security of the device
markchien5a8c8062021-10-27 13:22:27 +0800202 required: [
Motomu Utsumiae279012022-04-20 08:30:24 +0000203 "NetworkStack",
Andrei Onea52eac022021-12-03 15:11:27 +0000204 "privapp_allowlist_com.android.tethering",
markchien5a8c8062021-10-27 13:22:27 +0800205 ],
206 apex_available: ["com.android.tethering"],
Chiachang Wang3bc52762021-11-25 14:17:57 +0800207 lint: { strict_updatability_linting: true },
markchien5a8c8062021-10-27 13:22:27 +0800208}
209
210android_app {
211 name: "TetheringNext",
markchien598a75b2021-11-22 10:36:32 +0800212 defaults: [
213 "TetheringAppDefaults",
214 "TetheringApiLevel",
215 "ConnectivityNextEnableDefaults",
216 ],
markchien932da862019-08-27 10:19:38 +0800217 static_libs: ["TetheringApiCurrentLib"],
218 certificate: "networkstack",
219 manifest: "AndroidManifest.xml",
220 use_embedded_native_libs: true,
Motomu Utsumiae279012022-04-20 08:30:24 +0000221 // The network stack *must* be included to ensure security of the device
Aaron Huang3f69f1c2021-04-27 20:24:24 +0800222 required: [
Motomu Utsumiae279012022-04-20 08:30:24 +0000223 "NetworkStackNext",
Andrei Onea52eac022021-12-03 15:11:27 +0000224 "privapp_allowlist_com.android.tethering",
Aaron Huang3f69f1c2021-04-27 20:24:24 +0800225 ],
Jiyong Park1eb89332020-01-06 13:30:59 +0900226 apex_available: ["com.android.tethering"],
Chiachang Wang3bc52762021-11-25 14:17:57 +0800227 lint: { strict_updatability_linting: true },
markchien932da862019-08-27 10:19:38 +0800228}
Hai Zhang6d71f102021-02-14 06:38:22 +0000229
230sdk {
231 name: "tethering-module-sdk",
Paul Duffin1514c032022-07-13 11:18:50 +0000232 apexes: [
233 // Adds exportable dependencies of the APEX to the sdk,
234 // e.g. *classpath_fragments.
235 "com.android.tethering",
236 ],
Hai Zhang6d71f102021-02-14 06:38:22 +0000237}
Wayne Ma71d66392022-03-03 10:15:09 +0800238
239java_library_static {
240 name: "tetheringstatsprotos",
241 proto: {type: "lite"},
242 srcs: [
243 "src/com/android/networkstack/tethering/metrics/stats.proto",
244 ],
245 static_libs: ["tetheringprotos"],
246 apex_available: ["com.android.tethering"],
247 min_sdk_version: "30",
248}
Wayne Ma7ecded82022-03-10 16:19:24 +0800249
250genrule {
251 name: "statslog-tethering-java-gen",
252 tools: ["stats-log-api-gen"],
253 cmd: "$(location stats-log-api-gen) --java $(out) --module network_tethering" +
254 " --javaPackage com.android.networkstack.tethering.metrics --javaClass TetheringStatsLog",
255 out: ["com/android/networkstack/tethering/metrics/TetheringStatsLog.java"],
Yi Kong20a996e2022-06-22 03:41:56 +0800256}