• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
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
17package {
18    default_team: "trendy_team_fwk_core_networking",
19    default_applicable_licenses: ["Android-Apache-2.0"],
20}
21
22java_defaults {
23    name: "TetheringApiLevel",
24    sdk_version: "module_current",
25    min_sdk_version: "30",
26}
27
28java_defaults {
29    name: "TetheringReleaseTargetSdk",
30    target_sdk_version: "33",
31}
32
33java_defaults {
34    name: "TetheringExternalLibs",
35    defaults: [
36        "TetheringApiLevel",
37    ],
38    // Libraries not including Tethering's own framework-tethering (different flavors of that one
39    // are needed depending on the build rule)
40    libs: [
41        "connectivity-internal-api-util",
42        "framework-configinfrastructure.stubs.module_lib",
43        "framework-connectivity.stubs.module_lib",
44        "framework-connectivity-t.stubs.module_lib",
45        "framework-statsd.stubs.module_lib",
46        "framework-wifi.stubs.module_lib",
47        "framework-bluetooth.stubs.module_lib",
48        "unsupportedappusage",
49    ],
50    defaults_visibility: ["//visibility:private"],
51}
52
53java_defaults {
54    name: "TetheringAndroidLibraryDefaults",
55    srcs: [
56        "apishim/**/*.java",
57        "src/**/*.java",
58        ":framework-connectivity-shared-srcs",
59        ":services-tethering-shared-srcs",
60        ":statslog-connectivity-java-gen",
61        ":statslog-framework-connectivity-java-gen",
62        ":statslog-tethering-java-gen",
63    ],
64    static_libs: [
65        "androidx.annotation_annotation",
66        "connectivity-net-module-utils-bpf",
67        "com.android.net.flags-aconfig-java",
68        "modules-utils-build",
69        "modules-utils-statemachine",
70        "networkstack-client",
71        // AIDL tetheroffload implementation
72        "android.hardware.tetheroffload-V1-java",
73        // HIDL tetheroffload implementation
74        "android.hardware.tetheroffload.config-V1.0-java",
75        "android.hardware.tetheroffload.control-V1.0-java",
76        "android.hardware.tetheroffload.control-V1.1-java",
77        "android.hidl.manager-V1.2-java",
78        "net-utils-connectivity-apks",
79        "netd-client",
80        "tetheringstatsprotos",
81    ],
82    defaults: ["TetheringExternalLibs"],
83    libs: [
84        "framework-annotations-lib",
85        "framework-tethering.impl",
86    ],
87    manifest: "AndroidManifestBase.xml",
88    lint: {
89        error_checks: ["NewApi"],
90    },
91}
92
93// build tethering static library, used to compile both variants of the tethering.
94android_library {
95    name: "TetheringApiCurrentLib",
96    defaults: [
97        "ConnectivityNextEnableDefaults",
98        "TetheringAndroidLibraryDefaults",
99        "TetheringReleaseTargetSdk",
100    ],
101    static_libs: [
102        "NetworkStackApiCurrentShims",
103    ],
104    apex_available: ["com.android.tethering"],
105    lint: {
106        baseline_filename: "lint-baseline.xml",
107    },
108}
109
110android_library {
111    name: "TetheringApiStableLib",
112    defaults: [
113        "TetheringAndroidLibraryDefaults",
114        "TetheringReleaseTargetSdk",
115    ],
116    static_libs: [
117        "NetworkStackApiStableShims",
118    ],
119    apex_available: ["com.android.tethering"],
120    lint: {
121        baseline_filename: "lint-baseline.xml",
122    },
123}
124
125// Due to b/143733063, APK can't access a jni lib that is in APEX (but not in the APK).
126cc_library {
127    name: "libcom_android_networkstack_tethering_util_jni",
128    sdk_version: "current",
129    apex_available: [
130        "com.android.tethering",
131    ],
132    min_sdk_version: "30",
133    header_libs: [
134        "bpf_connectivity_headers",
135    ],
136    srcs: [
137        "jni/*.cpp",
138    ],
139    shared_libs: [
140        "liblog",
141        "libnativehelper_compat_libc++",
142    ],
143    static_libs: [
144        "libnet_utils_device_common_bpfjni",
145        "libnetjniutils",
146    ],
147
148    // 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
159    cflags: [
160        "-Wall",
161        "-Werror",
162        "-Wno-unused-parameter",
163        "-Wthread-safety",
164    ],
165
166    ldflags: ["-Wl,--exclude-libs=ALL,--error-limit=0"],
167}
168
169// Common defaults for compiling the actual APK.
170java_defaults {
171    name: "TetheringAppDefaults",
172    privileged: true,
173    jni_libs: [
174        "libcom_android_networkstack_tethering_util_jni",
175    ],
176    resource_dirs: [
177        "res",
178    ],
179    // 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"],
188    libs: [
189        "framework-tethering.impl",
190    ],
191    jarjar_rules: "jarjar-rules.txt",
192    optimize: {
193        proguard_flags_files: ["proguard.flags"],
194    },
195}
196
197// Updatable tethering packaged for finalized API
198android_app {
199    name: "Tethering",
200    defaults: [
201        "TetheringAppDefaults",
202    ],
203    static_libs: ["TetheringApiStableLib"],
204    certificate: "networkstack",
205    manifest: "AndroidManifest.xml",
206    use_embedded_native_libs: true,
207    privapp_allowlist: ":privapp_allowlist_com.android.tethering",
208    apex_available: ["com.android.tethering"],
209    updatable: true,
210}
211
212android_app {
213    name: "TetheringNext",
214    defaults: [
215        "TetheringAppDefaults",
216        "ConnectivityNextEnableDefaults",
217    ],
218    static_libs: ["TetheringApiCurrentLib"],
219    certificate: "networkstack",
220    manifest: "AndroidManifest.xml",
221    use_embedded_native_libs: true,
222    privapp_allowlist: ":privapp_allowlist_com.android.tethering",
223    apex_available: ["com.android.tethering"],
224    lint: {
225        error_checks: ["NewApi"],
226    },
227    updatable: true,
228}
229
230sdk {
231    name: "tethering-module-sdk",
232    apexes: [
233        // Adds exportable dependencies of the APEX to the sdk,
234        // e.g. *classpath_fragments.
235        "com.android.tethering",
236    ],
237    native_shared_libs: [
238        "libcom.android.tethering.dns_helper",
239        "libnetd_updatable",
240    ],
241}
242
243java_library_static {
244    name: "tetheringstatsprotos",
245    proto: {
246        type: "lite",
247    },
248    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}
255
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" +
260        " --javaPackage com.android.networkstack.tethering.metrics --javaClass TetheringStatsLog",
261    out: ["com/android/networkstack/tethering/metrics/TetheringStatsLog.java"],
262}
263