blob: 498a1fe758c665e20ffcd4d3296e67737af2610a [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",
35 // Libraries not including Tethering's own framework-tethering (different flavors of that one
36 // are needed depending on the build rule)
37 libs: [
Igor Chernyshev9dac6602022-12-13 19:28:32 -080038 "connectivity-internal-api-util",
Hassan Alic4f63fa2022-11-17 16:13:48 +000039 "framework-configinfrastructure",
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +090040 "framework-connectivity.stubs.module_lib",
41 "framework-connectivity-t.stubs.module_lib",
42 "framework-statsd.stubs.module_lib",
43 "framework-wifi",
44 "framework-bluetooth",
45 "unsupportedappusage",
46 ],
47 defaults_visibility: ["//visibility:private"],
48}
49
50java_defaults {
markchien5a8c8062021-10-27 13:22:27 +080051 name: "TetheringAndroidLibraryDefaults",
markchien932da862019-08-27 10:19:38 +080052 srcs: [
Hungming Chendd55b912020-12-26 17:13:22 +080053 "apishim/**/*.java",
markchien932da862019-08-27 10:19:38 +080054 "src/**/*.java",
Aaron Huangb401e582021-01-22 18:35:00 +080055 ":framework-connectivity-shared-srcs",
markchien43e97e02019-09-03 15:58:06 +080056 ":services-tethering-shared-srcs",
Junyu Lai06b81b62024-09-02 16:18:24 +080057 ":statslog-connectivity-java-gen",
Wayne Ma7ecded82022-03-10 16:19:24 +080058 ":statslog-tethering-java-gen",
markchien932da862019-08-27 10:19:38 +080059 ],
60 static_libs: [
61 "androidx.annotation_annotation",
Hungming Chen01f25502022-06-28 22:47:00 +080062 "connectivity-net-module-utils-bpf",
Hungming Chendd55b912020-12-26 17:13:22 +080063 "modules-utils-build",
William Escandeea9e22e2021-08-19 12:26:52 +020064 "modules-utils-statemachine",
Jeongik Chad05f9902021-01-26 22:35:02 +090065 "networkstack-client",
KH Shi3d5e65c2022-12-26 17:39:54 +080066 // AIDL tetheroffload implementation
67 "android.hardware.tetheroffload-V1-java",
68 // HIDL tetheroffload implementation
markchien547e1682020-02-05 12:42:25 +080069 "android.hardware.tetheroffload.config-V1.0-java",
markchien6aa38892019-09-25 14:33:39 +080070 "android.hardware.tetheroffload.control-V1.0-java",
junyulai177dc862021-03-10 15:26:50 +080071 "android.hardware.tetheroffload.control-V1.1-java",
KH Shi3d5e65c2022-12-26 17:39:54 +080072 "android.hidl.manager-V1.2-java",
Xiao Ma6793fd02024-07-26 13:07:50 +090073 "net-utils-connectivity-apks",
lucaslinee661df2020-12-28 16:44:49 +080074 "netd-client",
Wayne Ma71d66392022-03-03 10:15:09 +080075 "tetheringstatsprotos",
markchien932da862019-08-27 10:19:38 +080076 ],
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +090077 defaults: ["TetheringExternalLibs"],
markchien9d353822019-12-16 20:15:20 +080078 libs: [
Paul Duffin2dae2722020-05-13 12:28:49 +010079 "framework-tethering.impl",
markchien9d353822019-12-16 20:15:20 +080080 ],
markchien932da862019-08-27 10:19:38 +080081 manifest: "AndroidManifestBase.xml",
Motomu Utsumiac7c5722023-11-15 11:51:42 +090082 lint: {
Motomu Utsumiac7c5722023-11-15 11:51:42 +090083 error_checks: ["NewApi"],
84 },
markchien932da862019-08-27 10:19:38 +080085}
86
markchien5a8c8062021-10-27 13:22:27 +080087// build tethering static library, used to compile both variants of the tethering.
markchien932da862019-08-27 10:19:38 +080088android_library {
89 name: "TetheringApiCurrentLib",
markchien5a8c8062021-10-27 13:22:27 +080090 defaults: [
Remi NGUYEN VANf826bce2022-01-26 17:43:53 +090091 "ConnectivityNextEnableDefaults",
markchien5a8c8062021-10-27 13:22:27 +080092 "TetheringAndroidLibraryDefaults",
Harshit Mahajane210c272022-08-23 19:27:39 +000093 "TetheringApiLevel",
Cole Fausta52ecf02023-12-20 11:57:07 -080094 "TetheringReleaseTargetSdk",
markchien5a8c8062021-10-27 13:22:27 +080095 ],
96 static_libs: [
97 "NetworkStackApiCurrentShims",
98 ],
99 apex_available: ["com.android.tethering"],
Cole Fausta52ecf02023-12-20 11:57:07 -0800100 lint: {
Cole Fausta52ecf02023-12-20 11:57:07 -0800101 baseline_filename: "lint-baseline.xml",
102 },
markchien5a8c8062021-10-27 13:22:27 +0800103}
104
105android_library {
106 name: "TetheringApiStableLib",
107 defaults: [
108 "TetheringAndroidLibraryDefaults",
Harshit Mahajane210c272022-08-23 19:27:39 +0000109 "TetheringApiLevel",
Cole Fausta52ecf02023-12-20 11:57:07 -0800110 "TetheringReleaseTargetSdk",
markchien5a8c8062021-10-27 13:22:27 +0800111 ],
112 static_libs: [
113 "NetworkStackApiStableShims",
114 ],
115 apex_available: ["com.android.tethering"],
Cole Fausta52ecf02023-12-20 11:57:07 -0800116 lint: {
Cole Fausta52ecf02023-12-20 11:57:07 -0800117 baseline_filename: "lint-baseline.xml",
118 },
markchien932da862019-08-27 10:19:38 +0800119}
120
markchien810aa682019-10-23 16:27:52 +0800121// Due to b/143733063, APK can't access a jni lib that is in APEX (but not in the APK).
122cc_library {
markchienf967b112021-11-09 16:56:23 +0800123 name: "libcom_android_networkstack_tethering_util_jni",
Patrick Rohr15754242024-05-16 11:38:57 -0700124 sdk_version: "current",
Jooyung Han8182d8b2020-04-29 02:43:30 +0900125 apex_available: [
Jooyung Han8182d8b2020-04-29 02:43:30 +0900126 "com.android.tethering",
127 ],
Nikita Ioffe583e35a2020-10-31 22:41:41 +0000128 min_sdk_version: "30",
Lorenzo Colitti734b14e2021-02-05 23:56:09 +0900129 header_libs: [
Ken Chenbb57fa92021-10-22 00:49:13 +0800130 "bpf_connectivity_headers",
Lorenzo Colitti734b14e2021-02-05 23:56:09 +0900131 ],
markchien6aa38892019-09-25 14:33:39 +0800132 srcs: [
markchien70526882020-11-12 00:17:15 +0800133 "jni/*.cpp",
markchien6aa38892019-09-25 14:33:39 +0800134 ],
135 shared_libs: [
markchien6aa38892019-09-25 14:33:39 +0800136 "liblog",
markchien547e1682020-02-05 12:42:25 +0800137 "libnativehelper_compat_libc++",
markchien6aa38892019-09-25 14:33:39 +0800138 ],
Orion Hodsone5bd0db2020-12-08 09:57:42 +0000139 static_libs: [
markchien782a5682021-11-10 01:11:33 +0800140 "libnet_utils_device_common_bpfjni",
Orion Hodsone5bd0db2020-12-08 09:57:42 +0000141 "libnetjniutils",
142 ],
markchien6aa38892019-09-25 14:33:39 +0800143
markchien547e1682020-02-05 12:42:25 +0800144 // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
145 // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
146 // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
147 // build because soong complains of:
148 // module Tethering missing dependencies: libc++_shared
149 //
150 // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
151 // we depend on do not dynamically link libc++. This is currently the case, because liblog is
152 // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
153 stl: "c++_static",
154
markchien6aa38892019-09-25 14:33:39 +0800155 cflags: [
156 "-Wall",
157 "-Werror",
158 "-Wno-unused-parameter",
159 "-Wthread-safety",
160 ],
markchien810aa682019-10-23 16:27:52 +0800161
Yi Kong20a996e2022-06-22 03:41:56 +0800162 ldflags: ["-Wl,--exclude-libs=ALL,--error-limit=0"],
markchien6aa38892019-09-25 14:33:39 +0800163}
164
markchien932da862019-08-27 10:19:38 +0800165// Common defaults for compiling the actual APK.
166java_defaults {
167 name: "TetheringAppDefaults",
markchien932da862019-08-27 10:19:38 +0800168 privileged: true,
markchien6aa38892019-09-25 14:33:39 +0800169 jni_libs: [
markchienf967b112021-11-09 16:56:23 +0800170 "libcom_android_networkstack_tethering_util_jni",
markchien6aa38892019-09-25 14:33:39 +0800171 ],
markchien932da862019-08-27 10:19:38 +0800172 resource_dirs: [
173 "res",
174 ],
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +0900175 // Libs are not actually needed to build here since build rules using these defaults are just
176 // packaging the TetheringApiXLibs in APKs, but they are necessary so that R8 has the right
177 // references to optimize the code. Without these, there will be missing class warnings and code
178 // may be wrongly optimized.
179 // R8 runs after jarjar, so the framework-X libraries need to be the post-jarjar artifacts
180 // (framework-tethering.impl), if they are not just stubs, so that the name of jarjared
181 // classes match.
182 // TODO(b/229727645): ensure R8 fails the build fully if libraries are missing
183 defaults: ["TetheringExternalLibs"],
markchien9d353822019-12-16 20:15:20 +0800184 libs: [
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +0900185 "framework-tethering.impl",
markchien9d353822019-12-16 20:15:20 +0800186 ],
187 jarjar_rules: "jarjar-rules.txt",
markchien932da862019-08-27 10:19:38 +0800188 optimize: {
189 proguard_flags_files: ["proguard.flags"],
190 },
191}
192
markchien5a8c8062021-10-27 13:22:27 +0800193// Updatable tethering packaged for finalized API
markchien932da862019-08-27 10:19:38 +0800194android_app {
195 name: "Tethering",
Cole Fausta52ecf02023-12-20 11:57:07 -0800196 defaults: [
197 "TetheringAppDefaults",
198 "TetheringApiLevel",
199 ],
markchien5a8c8062021-10-27 13:22:27 +0800200 static_libs: ["TetheringApiStableLib"],
201 certificate: "networkstack",
202 manifest: "AndroidManifest.xml",
203 use_embedded_native_libs: true,
Anton Hansson1397a102023-05-25 07:04:33 +0000204 privapp_allowlist: ":privapp_allowlist_com.android.tethering",
markchien5a8c8062021-10-27 13:22:27 +0800205 apex_available: ["com.android.tethering"],
206}
207
208android_app {
209 name: "TetheringNext",
markchien598a75b2021-11-22 10:36:32 +0800210 defaults: [
211 "TetheringAppDefaults",
212 "TetheringApiLevel",
213 "ConnectivityNextEnableDefaults",
214 ],
markchien932da862019-08-27 10:19:38 +0800215 static_libs: ["TetheringApiCurrentLib"],
216 certificate: "networkstack",
217 manifest: "AndroidManifest.xml",
218 use_embedded_native_libs: true,
Anton Hansson1397a102023-05-25 07:04:33 +0000219 privapp_allowlist: ":privapp_allowlist_com.android.tethering",
Jiyong Park1eb89332020-01-06 13:30:59 +0900220 apex_available: ["com.android.tethering"],
Motomu Utsumiac7c5722023-11-15 11:51:42 +0900221 lint: {
Motomu Utsumiac7c5722023-11-15 11:51:42 +0900222 error_checks: ["NewApi"],
223 },
markchien932da862019-08-27 10:19:38 +0800224}
Hai Zhang6d71f102021-02-14 06:38:22 +0000225
226sdk {
227 name: "tethering-module-sdk",
Paul Duffin1514c032022-07-13 11:18:50 +0000228 apexes: [
229 // Adds exportable dependencies of the APEX to the sdk,
230 // e.g. *classpath_fragments.
231 "com.android.tethering",
232 ],
Spandan Dasb06f9d62023-04-04 20:48:54 +0000233 native_shared_libs: [
Ken Chenec0f7ac2023-09-08 14:14:55 +0800234 "libcom.android.tethering.dns_helper",
Spandan Dasb06f9d62023-04-04 20:48:54 +0000235 "libnetd_updatable",
236 ],
Hai Zhang6d71f102021-02-14 06:38:22 +0000237}
Wayne Ma71d66392022-03-03 10:15:09 +0800238
239java_library_static {
240 name: "tetheringstatsprotos",
Cole Fausta52ecf02023-12-20 11:57:07 -0800241 proto: {
242 type: "lite",
243 },
Wayne Ma71d66392022-03-03 10:15:09 +0800244 srcs: [
245 "src/com/android/networkstack/tethering/metrics/stats.proto",
246 ],
247 static_libs: ["tetheringprotos"],
248 apex_available: ["com.android.tethering"],
249 min_sdk_version: "30",
250}
Wayne Ma7ecded82022-03-10 16:19:24 +0800251
252genrule {
253 name: "statslog-tethering-java-gen",
254 tools: ["stats-log-api-gen"],
255 cmd: "$(location stats-log-api-gen) --java $(out) --module network_tethering" +
Cole Fausta52ecf02023-12-20 11:57:07 -0800256 " --javaPackage com.android.networkstack.tethering.metrics --javaClass TetheringStatsLog",
Wayne Ma7ecded82022-03-10 16:19:24 +0800257 out: ["com/android/networkstack/tethering/metrics/TetheringStatsLog.java"],
Yi Kong20a996e2022-06-22 03:41:56 +0800258}