blob: d2f6d154c717af063abaadfd4cb809606485c010 [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",
Nikita Ioffe583e35a2020-10-31 22:41:41 +000024 min_sdk_version: "30",
markchien5a8c8062021-10-27 13:22:27 +080025}
26
27java_defaults {
Harshit Mahajane210c272022-08-23 19:27:39 +000028 name: "TetheringReleaseTargetSdk",
29 target_sdk_version: "33",
30}
31
32java_defaults {
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +090033 name: "TetheringExternalLibs",
34 // Libraries not including Tethering's own framework-tethering (different flavors of that one
35 // are needed depending on the build rule)
36 libs: [
Igor Chernyshev9dac6602022-12-13 19:28:32 -080037 "connectivity-internal-api-util",
Hassan Alic4f63fa2022-11-17 16:13:48 +000038 "framework-configinfrastructure",
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +090039 "framework-connectivity.stubs.module_lib",
40 "framework-connectivity-t.stubs.module_lib",
41 "framework-statsd.stubs.module_lib",
42 "framework-wifi",
43 "framework-bluetooth",
44 "unsupportedappusage",
45 ],
46 defaults_visibility: ["//visibility:private"],
47}
48
49java_defaults {
markchien5a8c8062021-10-27 13:22:27 +080050 name: "TetheringAndroidLibraryDefaults",
markchien932da862019-08-27 10:19:38 +080051 srcs: [
Hungming Chendd55b912020-12-26 17:13:22 +080052 "apishim/**/*.java",
markchien932da862019-08-27 10:19:38 +080053 "src/**/*.java",
Aaron Huangb401e582021-01-22 18:35:00 +080054 ":framework-connectivity-shared-srcs",
markchien43e97e02019-09-03 15:58:06 +080055 ":services-tethering-shared-srcs",
Wayne Ma7ecded82022-03-10 16:19:24 +080056 ":statslog-tethering-java-gen",
markchien932da862019-08-27 10:19:38 +080057 ],
58 static_libs: [
59 "androidx.annotation_annotation",
Hungming Chen01f25502022-06-28 22:47:00 +080060 "connectivity-net-module-utils-bpf",
Hungming Chendd55b912020-12-26 17:13:22 +080061 "modules-utils-build",
William Escandeea9e22e2021-08-19 12:26:52 +020062 "modules-utils-statemachine",
Jeongik Chad05f9902021-01-26 22:35:02 +090063 "networkstack-client",
markchien547e1682020-02-05 12:42:25 +080064 "android.hardware.tetheroffload.config-V1.0-java",
markchien6aa38892019-09-25 14:33:39 +080065 "android.hardware.tetheroffload.control-V1.0-java",
junyulai177dc862021-03-10 15:26:50 +080066 "android.hardware.tetheroffload.control-V1.1-java",
markchien75fc6ab2020-01-14 17:28:47 +080067 "net-utils-framework-common",
Chalard Jeanbdcca922020-06-26 00:19:33 +090068 "net-utils-device-common",
markchien782a5682021-11-10 01:11:33 +080069 "net-utils-device-common-bpf",
Xiao Mac81c0662022-06-17 14:58:03 +090070 "net-utils-device-common-ip",
Xiao Ma09c07272021-07-01 14:00:34 +000071 "net-utils-device-common-netlink",
lucaslinee661df2020-12-28 16:44:49 +080072 "netd-client",
Wayne Ma71d66392022-03-03 10:15:09 +080073 "tetheringstatsprotos",
markchien932da862019-08-27 10:19:38 +080074 ],
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +090075 defaults: ["TetheringExternalLibs"],
markchien9d353822019-12-16 20:15:20 +080076 libs: [
Paul Duffin2dae2722020-05-13 12:28:49 +010077 "framework-tethering.impl",
markchien9d353822019-12-16 20:15:20 +080078 ],
markchien932da862019-08-27 10:19:38 +080079 manifest: "AndroidManifestBase.xml",
Chiachang Wang3bc52762021-11-25 14:17:57 +080080 lint: { strict_updatability_linting: true },
markchien932da862019-08-27 10:19:38 +080081}
82
markchien5a8c8062021-10-27 13:22:27 +080083// build tethering static library, used to compile both variants of the tethering.
markchien932da862019-08-27 10:19:38 +080084android_library {
85 name: "TetheringApiCurrentLib",
markchien5a8c8062021-10-27 13:22:27 +080086 defaults: [
Remi NGUYEN VANf826bce2022-01-26 17:43:53 +090087 "ConnectivityNextEnableDefaults",
markchien5a8c8062021-10-27 13:22:27 +080088 "TetheringAndroidLibraryDefaults",
Harshit Mahajane210c272022-08-23 19:27:39 +000089 "TetheringApiLevel",
90 "TetheringReleaseTargetSdk"
markchien5a8c8062021-10-27 13:22:27 +080091 ],
92 static_libs: [
93 "NetworkStackApiCurrentShims",
94 ],
95 apex_available: ["com.android.tethering"],
Chiachang Wang3bc52762021-11-25 14:17:57 +080096 lint: { strict_updatability_linting: true },
markchien5a8c8062021-10-27 13:22:27 +080097}
98
99android_library {
100 name: "TetheringApiStableLib",
101 defaults: [
102 "TetheringAndroidLibraryDefaults",
Harshit Mahajane210c272022-08-23 19:27:39 +0000103 "TetheringApiLevel",
104 "TetheringReleaseTargetSdk"
markchien5a8c8062021-10-27 13:22:27 +0800105 ],
106 static_libs: [
107 "NetworkStackApiStableShims",
108 ],
109 apex_available: ["com.android.tethering"],
Chiachang Wang3bc52762021-11-25 14:17:57 +0800110 lint: { strict_updatability_linting: true },
markchien932da862019-08-27 10:19:38 +0800111}
112
markchien810aa682019-10-23 16:27:52 +0800113// Due to b/143733063, APK can't access a jni lib that is in APEX (but not in the APK).
114cc_library {
markchienf967b112021-11-09 16:56:23 +0800115 name: "libcom_android_networkstack_tethering_util_jni",
markchien5a8c8062021-10-27 13:22:27 +0800116 sdk_version: "30",
Jooyung Han8182d8b2020-04-29 02:43:30 +0900117 apex_available: [
118 "//apex_available:platform", // Used by InProcessTethering
119 "com.android.tethering",
120 ],
Nikita Ioffe583e35a2020-10-31 22:41:41 +0000121 min_sdk_version: "30",
Lorenzo Colitti734b14e2021-02-05 23:56:09 +0900122 header_libs: [
Ken Chenbb57fa92021-10-22 00:49:13 +0800123 "bpf_connectivity_headers",
Lorenzo Colitti734b14e2021-02-05 23:56:09 +0900124 ],
markchien6aa38892019-09-25 14:33:39 +0800125 srcs: [
markchien70526882020-11-12 00:17:15 +0800126 "jni/*.cpp",
markchien6aa38892019-09-25 14:33:39 +0800127 ],
128 shared_libs: [
markchien6aa38892019-09-25 14:33:39 +0800129 "liblog",
markchien547e1682020-02-05 12:42:25 +0800130 "libnativehelper_compat_libc++",
markchien6aa38892019-09-25 14:33:39 +0800131 ],
Orion Hodsone5bd0db2020-12-08 09:57:42 +0000132 static_libs: [
markchien782a5682021-11-10 01:11:33 +0800133 "libnet_utils_device_common_bpfjni",
Orion Hodsone5bd0db2020-12-08 09:57:42 +0000134 "libnetjniutils",
135 ],
markchien6aa38892019-09-25 14:33:39 +0800136
markchien547e1682020-02-05 12:42:25 +0800137 // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
138 // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
139 // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
140 // build because soong complains of:
141 // module Tethering missing dependencies: libc++_shared
142 //
143 // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
144 // we depend on do not dynamically link libc++. This is currently the case, because liblog is
145 // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
146 stl: "c++_static",
147
markchien6aa38892019-09-25 14:33:39 +0800148 cflags: [
149 "-Wall",
150 "-Werror",
151 "-Wno-unused-parameter",
152 "-Wthread-safety",
153 ],
markchien810aa682019-10-23 16:27:52 +0800154
Yi Kong20a996e2022-06-22 03:41:56 +0800155 ldflags: ["-Wl,--exclude-libs=ALL,--error-limit=0"],
markchien6aa38892019-09-25 14:33:39 +0800156}
157
markchien932da862019-08-27 10:19:38 +0800158// Common defaults for compiling the actual APK.
159java_defaults {
160 name: "TetheringAppDefaults",
markchien932da862019-08-27 10:19:38 +0800161 privileged: true,
markchien6aa38892019-09-25 14:33:39 +0800162 jni_libs: [
markchienf967b112021-11-09 16:56:23 +0800163 "libcom_android_networkstack_tethering_util_jni",
markchien6aa38892019-09-25 14:33:39 +0800164 ],
markchien932da862019-08-27 10:19:38 +0800165 resource_dirs: [
166 "res",
167 ],
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +0900168 // Libs are not actually needed to build here since build rules using these defaults are just
169 // packaging the TetheringApiXLibs in APKs, but they are necessary so that R8 has the right
170 // references to optimize the code. Without these, there will be missing class warnings and code
171 // may be wrongly optimized.
172 // R8 runs after jarjar, so the framework-X libraries need to be the post-jarjar artifacts
173 // (framework-tethering.impl), if they are not just stubs, so that the name of jarjared
174 // classes match.
175 // TODO(b/229727645): ensure R8 fails the build fully if libraries are missing
176 defaults: ["TetheringExternalLibs"],
markchien9d353822019-12-16 20:15:20 +0800177 libs: [
Remi NGUYEN VAN37dc1e22022-08-04 11:52:54 +0900178 "framework-tethering.impl",
markchien9d353822019-12-16 20:15:20 +0800179 ],
180 jarjar_rules: "jarjar-rules.txt",
markchien932da862019-08-27 10:19:38 +0800181 optimize: {
182 proguard_flags_files: ["proguard.flags"],
183 },
Chiachang Wang3bc52762021-11-25 14:17:57 +0800184 lint: { strict_updatability_linting: true },
markchien932da862019-08-27 10:19:38 +0800185}
186
187// Non-updatable tethering running in the system server process for devices not using the module
markchienee6ad372019-09-30 14:40:57 +0800188android_app {
189 name: "InProcessTethering",
Harshit Mahajane210c272022-08-23 19:27:39 +0000190 defaults: [
191 "TetheringAppDefaults",
192 "TetheringApiLevel",
193 "ConnectivityNextEnableDefaults",
194 "TetheringReleaseTargetSdk"
195 ],
markchienee6ad372019-09-30 14:40:57 +0800196 static_libs: ["TetheringApiCurrentLib"],
197 certificate: "platform",
198 manifest: "AndroidManifest_InProcess.xml",
199 // InProcessTethering is a replacement for Tethering
200 overrides: ["Tethering"],
markchiendbaff662020-05-05 17:42:44 +0800201 apex_available: ["com.android.tethering"],
Chiachang Wang3bc52762021-11-25 14:17:57 +0800202 lint: { strict_updatability_linting: true },
markchienee6ad372019-09-30 14:40:57 +0800203}
markchien932da862019-08-27 10:19:38 +0800204
markchien5a8c8062021-10-27 13:22:27 +0800205// Updatable tethering packaged for finalized API
markchien932da862019-08-27 10:19:38 +0800206android_app {
207 name: "Tethering",
markchien5a8c8062021-10-27 13:22:27 +0800208 defaults: ["TetheringAppDefaults", "TetheringApiLevel"],
209 static_libs: ["TetheringApiStableLib"],
210 certificate: "networkstack",
211 manifest: "AndroidManifest.xml",
212 use_embedded_native_libs: true,
Motomu Utsumiae279012022-04-20 08:30:24 +0000213 // The network stack *must* be included to ensure security of the device
markchien5a8c8062021-10-27 13:22:27 +0800214 required: [
Motomu Utsumiae279012022-04-20 08:30:24 +0000215 "NetworkStack",
Andrei Onea52eac022021-12-03 15:11:27 +0000216 "privapp_allowlist_com.android.tethering",
markchien5a8c8062021-10-27 13:22:27 +0800217 ],
218 apex_available: ["com.android.tethering"],
Chiachang Wang3bc52762021-11-25 14:17:57 +0800219 lint: { strict_updatability_linting: true },
markchien5a8c8062021-10-27 13:22:27 +0800220}
221
222android_app {
223 name: "TetheringNext",
markchien598a75b2021-11-22 10:36:32 +0800224 defaults: [
225 "TetheringAppDefaults",
226 "TetheringApiLevel",
227 "ConnectivityNextEnableDefaults",
228 ],
markchien932da862019-08-27 10:19:38 +0800229 static_libs: ["TetheringApiCurrentLib"],
230 certificate: "networkstack",
231 manifest: "AndroidManifest.xml",
232 use_embedded_native_libs: true,
Motomu Utsumiae279012022-04-20 08:30:24 +0000233 // The network stack *must* be included to ensure security of the device
Aaron Huang3f69f1c2021-04-27 20:24:24 +0800234 required: [
Motomu Utsumiae279012022-04-20 08:30:24 +0000235 "NetworkStackNext",
Andrei Onea52eac022021-12-03 15:11:27 +0000236 "privapp_allowlist_com.android.tethering",
Aaron Huang3f69f1c2021-04-27 20:24:24 +0800237 ],
Jiyong Park1eb89332020-01-06 13:30:59 +0900238 apex_available: ["com.android.tethering"],
Chiachang Wang3bc52762021-11-25 14:17:57 +0800239 lint: { strict_updatability_linting: true },
markchien932da862019-08-27 10:19:38 +0800240}
Hai Zhang6d71f102021-02-14 06:38:22 +0000241
242sdk {
243 name: "tethering-module-sdk",
Paul Duffin1514c032022-07-13 11:18:50 +0000244 apexes: [
245 // Adds exportable dependencies of the APEX to the sdk,
246 // e.g. *classpath_fragments.
247 "com.android.tethering",
248 ],
Hai Zhang6d71f102021-02-14 06:38:22 +0000249}
Wayne Ma71d66392022-03-03 10:15:09 +0800250
251java_library_static {
252 name: "tetheringstatsprotos",
253 proto: {type: "lite"},
254 srcs: [
255 "src/com/android/networkstack/tethering/metrics/stats.proto",
256 ],
257 static_libs: ["tetheringprotos"],
258 apex_available: ["com.android.tethering"],
259 min_sdk_version: "30",
260}
Wayne Ma7ecded82022-03-10 16:19:24 +0800261
262genrule {
263 name: "statslog-tethering-java-gen",
264 tools: ["stats-log-api-gen"],
265 cmd: "$(location stats-log-api-gen) --java $(out) --module network_tethering" +
266 " --javaPackage com.android.networkstack.tethering.metrics --javaClass TetheringStatsLog",
267 out: ["com/android/networkstack/tethering/metrics/TetheringStatsLog.java"],
Yi Kong20a996e2022-06-22 03:41:56 +0800268}