blob: 091849ba265d37b5766f80cf7ee58dc77128d317 [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 {
Aditya Choudhary01b5ede2024-01-31 11:08:57 +000018 default_team: "trendy_team_fwk_core_networking",
Bob Badour97e6be22021-02-12 14:45:04 -080019 default_applicable_licenses: ["Android-Apache-2.0"],
20}
21
markchien932da862019-08-27 10:19:38 +080022java_defaults {
markchien5a8c8062021-10-27 13:22:27 +080023 name: "TetheringApiLevel",
Anton Hanssonbbe4af12020-03-18 14:15:42 +000024 sdk_version: "module_current",
Nikita Ioffe583e35a2020-10-31 22:41:41 +000025 min_sdk_version: "30",
markchien5a8c8062021-10-27 13:22:27 +080026}
27
28java_defaults {
Harshit Mahajane210c272022-08-23 19:27:39 +000029 name: "TetheringReleaseTargetSdk",
30 target_sdk_version: "33",
31}
32
33java_defaults {
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +090034 name: "TetheringExternalLibs",
Jihoon Kang8401b6a2024-08-30 00:29:58 +000035 defaults: [
36 "TetheringApiLevel",
37 ],
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +090038 // Libraries not including Tethering's own framework-tethering (different flavors of that one
39 // are needed depending on the build rule)
40 libs: [
Igor Chernyshev9dac6602022-12-13 19:28:32 -080041 "connectivity-internal-api-util",
Jihoon Kang8401b6a2024-08-30 00:29:58 +000042 "framework-configinfrastructure.stubs.module_lib",
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +090043 "framework-connectivity.stubs.module_lib",
44 "framework-connectivity-t.stubs.module_lib",
45 "framework-statsd.stubs.module_lib",
Jihoon Kang8401b6a2024-08-30 00:29:58 +000046 "framework-wifi.stubs.module_lib",
47 "framework-bluetooth.stubs.module_lib",
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +090048 "unsupportedappusage",
49 ],
50 defaults_visibility: ["//visibility:private"],
51}
52
53java_defaults {
markchien5a8c8062021-10-27 13:22:27 +080054 name: "TetheringAndroidLibraryDefaults",
markchien932da862019-08-27 10:19:38 +080055 srcs: [
Hungming Chendd55b912020-12-26 17:13:22 +080056 "apishim/**/*.java",
markchien932da862019-08-27 10:19:38 +080057 "src/**/*.java",
Aaron Huangb401e582021-01-22 18:35:00 +080058 ":framework-connectivity-shared-srcs",
markchien43e97e02019-09-03 15:58:06 +080059 ":services-tethering-shared-srcs",
Junyu Lai06b81b62024-09-02 16:18:24 +080060 ":statslog-connectivity-java-gen",
Junyu Laia80fd3d2024-12-10 14:35:58 +080061 ":statslog-framework-connectivity-java-gen",
Wayne Ma7ecded82022-03-10 16:19:24 +080062 ":statslog-tethering-java-gen",
markchien932da862019-08-27 10:19:38 +080063 ],
64 static_libs: [
65 "androidx.annotation_annotation",
Hungming Chen01f25502022-06-28 22:47:00 +080066 "connectivity-net-module-utils-bpf",
Quang Anh Luong2782b3b2024-12-05 13:34:15 +090067 "com.android.net.flags-aconfig-java",
Hungming Chendd55b912020-12-26 17:13:22 +080068 "modules-utils-build",
William Escandeea9e22e2021-08-19 12:26:52 +020069 "modules-utils-statemachine",
Jeongik Chad05f9902021-01-26 22:35:02 +090070 "networkstack-client",
KH Shi3d5e65c2022-12-26 17:39:54 +080071 // AIDL tetheroffload implementation
72 "android.hardware.tetheroffload-V1-java",
73 // HIDL tetheroffload implementation
markchien547e1682020-02-05 12:42:25 +080074 "android.hardware.tetheroffload.config-V1.0-java",
markchien6aa38892019-09-25 14:33:39 +080075 "android.hardware.tetheroffload.control-V1.0-java",
junyulai177dc862021-03-10 15:26:50 +080076 "android.hardware.tetheroffload.control-V1.1-java",
KH Shi3d5e65c2022-12-26 17:39:54 +080077 "android.hidl.manager-V1.2-java",
Xiao Ma6793fd02024-07-26 13:07:50 +090078 "net-utils-connectivity-apks",
lucaslinee661df2020-12-28 16:44:49 +080079 "netd-client",
Wayne Ma71d66392022-03-03 10:15:09 +080080 "tetheringstatsprotos",
markchien932da862019-08-27 10:19:38 +080081 ],
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +090082 defaults: ["TetheringExternalLibs"],
markchien9d353822019-12-16 20:15:20 +080083 libs: [
Jared Dukedff99282024-09-27 18:41:54 +000084 "framework-annotations-lib",
Paul Duffin2dae2722020-05-13 12:28:49 +010085 "framework-tethering.impl",
markchien9d353822019-12-16 20:15:20 +080086 ],
markchien932da862019-08-27 10:19:38 +080087 manifest: "AndroidManifestBase.xml",
Motomu Utsumiac7c5722023-11-15 11:51:42 +090088 lint: {
Motomu Utsumiac7c5722023-11-15 11:51:42 +090089 error_checks: ["NewApi"],
90 },
markchien932da862019-08-27 10:19:38 +080091}
92
markchien5a8c8062021-10-27 13:22:27 +080093// build tethering static library, used to compile both variants of the tethering.
markchien932da862019-08-27 10:19:38 +080094android_library {
95 name: "TetheringApiCurrentLib",
markchien5a8c8062021-10-27 13:22:27 +080096 defaults: [
Remi NGUYEN VANf826bce2022-01-26 17:43:53 +090097 "ConnectivityNextEnableDefaults",
markchien5a8c8062021-10-27 13:22:27 +080098 "TetheringAndroidLibraryDefaults",
Cole Fausta52ecf02023-12-20 11:57:07 -080099 "TetheringReleaseTargetSdk",
markchien5a8c8062021-10-27 13:22:27 +0800100 ],
101 static_libs: [
102 "NetworkStackApiCurrentShims",
103 ],
104 apex_available: ["com.android.tethering"],
Cole Fausta52ecf02023-12-20 11:57:07 -0800105 lint: {
Cole Fausta52ecf02023-12-20 11:57:07 -0800106 baseline_filename: "lint-baseline.xml",
107 },
markchien5a8c8062021-10-27 13:22:27 +0800108}
109
110android_library {
111 name: "TetheringApiStableLib",
112 defaults: [
113 "TetheringAndroidLibraryDefaults",
Cole Fausta52ecf02023-12-20 11:57:07 -0800114 "TetheringReleaseTargetSdk",
markchien5a8c8062021-10-27 13:22:27 +0800115 ],
116 static_libs: [
117 "NetworkStackApiStableShims",
118 ],
119 apex_available: ["com.android.tethering"],
Cole Fausta52ecf02023-12-20 11:57:07 -0800120 lint: {
Cole Fausta52ecf02023-12-20 11:57:07 -0800121 baseline_filename: "lint-baseline.xml",
122 },
markchien932da862019-08-27 10:19:38 +0800123}
124
markchien810aa682019-10-23 16:27:52 +0800125// Due to b/143733063, APK can't access a jni lib that is in APEX (but not in the APK).
126cc_library {
markchienf967b112021-11-09 16:56:23 +0800127 name: "libcom_android_networkstack_tethering_util_jni",
Patrick Rohr15754242024-05-16 11:38:57 -0700128 sdk_version: "current",
Jooyung Han8182d8b2020-04-29 02:43:30 +0900129 apex_available: [
Jooyung Han8182d8b2020-04-29 02:43:30 +0900130 "com.android.tethering",
131 ],
Nikita Ioffe583e35a2020-10-31 22:41:41 +0000132 min_sdk_version: "30",
Lorenzo Colitti734b14e2021-02-05 23:56:09 +0900133 header_libs: [
Ken Chenbb57fa92021-10-22 00:49:13 +0800134 "bpf_connectivity_headers",
Lorenzo Colitti734b14e2021-02-05 23:56:09 +0900135 ],
markchien6aa38892019-09-25 14:33:39 +0800136 srcs: [
markchien70526882020-11-12 00:17:15 +0800137 "jni/*.cpp",
markchien6aa38892019-09-25 14:33:39 +0800138 ],
139 shared_libs: [
markchien6aa38892019-09-25 14:33:39 +0800140 "liblog",
markchien547e1682020-02-05 12:42:25 +0800141 "libnativehelper_compat_libc++",
markchien6aa38892019-09-25 14:33:39 +0800142 ],
Orion Hodsone5bd0db2020-12-08 09:57:42 +0000143 static_libs: [
markchien782a5682021-11-10 01:11:33 +0800144 "libnet_utils_device_common_bpfjni",
Orion Hodsone5bd0db2020-12-08 09:57:42 +0000145 "libnetjniutils",
146 ],
markchien6aa38892019-09-25 14:33:39 +0800147
markchien547e1682020-02-05 12:42:25 +0800148 // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
149 // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
150 // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
151 // build because soong complains of:
152 // module Tethering missing dependencies: libc++_shared
153 //
154 // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
155 // we depend on do not dynamically link libc++. This is currently the case, because liblog is
156 // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
157 stl: "c++_static",
158
markchien6aa38892019-09-25 14:33:39 +0800159 cflags: [
160 "-Wall",
161 "-Werror",
162 "-Wno-unused-parameter",
163 "-Wthread-safety",
164 ],
markchien810aa682019-10-23 16:27:52 +0800165
Yi Kong20a996e2022-06-22 03:41:56 +0800166 ldflags: ["-Wl,--exclude-libs=ALL,--error-limit=0"],
markchien6aa38892019-09-25 14:33:39 +0800167}
168
markchien932da862019-08-27 10:19:38 +0800169// Common defaults for compiling the actual APK.
170java_defaults {
171 name: "TetheringAppDefaults",
markchien932da862019-08-27 10:19:38 +0800172 privileged: true,
markchien6aa38892019-09-25 14:33:39 +0800173 jni_libs: [
markchienf967b112021-11-09 16:56:23 +0800174 "libcom_android_networkstack_tethering_util_jni",
markchien6aa38892019-09-25 14:33:39 +0800175 ],
markchien932da862019-08-27 10:19:38 +0800176 resource_dirs: [
177 "res",
178 ],
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +0900179 // Libs are not actually needed to build here since build rules using these defaults are just
180 // packaging the TetheringApiXLibs in APKs, but they are necessary so that R8 has the right
181 // references to optimize the code. Without these, there will be missing class warnings and code
182 // may be wrongly optimized.
183 // R8 runs after jarjar, so the framework-X libraries need to be the post-jarjar artifacts
184 // (framework-tethering.impl), if they are not just stubs, so that the name of jarjared
185 // classes match.
186 // TODO(b/229727645): ensure R8 fails the build fully if libraries are missing
187 defaults: ["TetheringExternalLibs"],
markchien9d353822019-12-16 20:15:20 +0800188 libs: [
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +0900189 "framework-tethering.impl",
markchien9d353822019-12-16 20:15:20 +0800190 ],
191 jarjar_rules: "jarjar-rules.txt",
markchien932da862019-08-27 10:19:38 +0800192 optimize: {
193 proguard_flags_files: ["proguard.flags"],
194 },
195}
196
markchien5a8c8062021-10-27 13:22:27 +0800197// Updatable tethering packaged for finalized API
markchien932da862019-08-27 10:19:38 +0800198android_app {
199 name: "Tethering",
Cole Fausta52ecf02023-12-20 11:57:07 -0800200 defaults: [
201 "TetheringAppDefaults",
Cole Fausta52ecf02023-12-20 11:57:07 -0800202 ],
markchien5a8c8062021-10-27 13:22:27 +0800203 static_libs: ["TetheringApiStableLib"],
204 certificate: "networkstack",
205 manifest: "AndroidManifest.xml",
206 use_embedded_native_libs: true,
Anton Hansson1397a102023-05-25 07:04:33 +0000207 privapp_allowlist: ":privapp_allowlist_com.android.tethering",
markchien5a8c8062021-10-27 13:22:27 +0800208 apex_available: ["com.android.tethering"],
Colin Cross558f56b2024-10-01 15:47:05 -0700209 updatable: true,
markchien5a8c8062021-10-27 13:22:27 +0800210}
211
212android_app {
213 name: "TetheringNext",
markchien598a75b2021-11-22 10:36:32 +0800214 defaults: [
215 "TetheringAppDefaults",
markchien598a75b2021-11-22 10:36:32 +0800216 "ConnectivityNextEnableDefaults",
217 ],
markchien932da862019-08-27 10:19:38 +0800218 static_libs: ["TetheringApiCurrentLib"],
219 certificate: "networkstack",
220 manifest: "AndroidManifest.xml",
221 use_embedded_native_libs: true,
Anton Hansson1397a102023-05-25 07:04:33 +0000222 privapp_allowlist: ":privapp_allowlist_com.android.tethering",
Jiyong Park1eb89332020-01-06 13:30:59 +0900223 apex_available: ["com.android.tethering"],
Motomu Utsumiac7c5722023-11-15 11:51:42 +0900224 lint: {
Motomu Utsumiac7c5722023-11-15 11:51:42 +0900225 error_checks: ["NewApi"],
226 },
Colin Cross558f56b2024-10-01 15:47:05 -0700227 updatable: 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 ],
Spandan Dasb06f9d62023-04-04 20:48:54 +0000237 native_shared_libs: [
Ken Chenec0f7ac2023-09-08 14:14:55 +0800238 "libcom.android.tethering.dns_helper",
Spandan Dasb06f9d62023-04-04 20:48:54 +0000239 "libnetd_updatable",
240 ],
Hai Zhang6d71f102021-02-14 06:38:22 +0000241}
Wayne Ma71d66392022-03-03 10:15:09 +0800242
243java_library_static {
244 name: "tetheringstatsprotos",
Cole Fausta52ecf02023-12-20 11:57:07 -0800245 proto: {
246 type: "lite",
247 },
Wayne Ma71d66392022-03-03 10:15:09 +0800248 srcs: [
249 "src/com/android/networkstack/tethering/metrics/stats.proto",
250 ],
251 static_libs: ["tetheringprotos"],
252 apex_available: ["com.android.tethering"],
253 min_sdk_version: "30",
254}
Wayne Ma7ecded82022-03-10 16:19:24 +0800255
256genrule {
257 name: "statslog-tethering-java-gen",
258 tools: ["stats-log-api-gen"],
259 cmd: "$(location stats-log-api-gen) --java $(out) --module network_tethering" +
Cole Fausta52ecf02023-12-20 11:57:07 -0800260 " --javaPackage com.android.networkstack.tethering.metrics --javaClass TetheringStatsLog",
Wayne Ma7ecded82022-03-10 16:19:24 +0800261 out: ["com/android/networkstack/tethering/metrics/TetheringStatsLog.java"],
Yi Kong20a996e2022-06-22 03:41:56 +0800262}