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 // Libraries not including Tethering's own framework-tethering (different flavors of that one 36 // are needed depending on the build rule) 37 libs: [ 38 "connectivity-internal-api-util", 39 "framework-configinfrastructure", 40 "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 { 51 name: "TetheringAndroidLibraryDefaults", 52 srcs: [ 53 "apishim/**/*.java", 54 "src/**/*.java", 55 ":framework-connectivity-shared-srcs", 56 ":services-tethering-shared-srcs", 57 ":statslog-tethering-java-gen", 58 ], 59 static_libs: [ 60 "androidx.annotation_annotation", 61 "connectivity-net-module-utils-bpf", 62 "modules-utils-build", 63 "modules-utils-statemachine", 64 "networkstack-client", 65 // AIDL tetheroffload implementation 66 "android.hardware.tetheroffload-V1-java", 67 // HIDL tetheroffload implementation 68 "android.hardware.tetheroffload.config-V1.0-java", 69 "android.hardware.tetheroffload.control-V1.0-java", 70 "android.hardware.tetheroffload.control-V1.1-java", 71 "android.hidl.manager-V1.2-java", 72 "net-utils-framework-common", 73 "net-utils-device-common", 74 "net-utils-device-common-bpf", 75 "net-utils-device-common-ip", 76 "net-utils-device-common-netlink", 77 "net-utils-device-common-struct", 78 "net-utils-device-common-struct-base", 79 "netd-client", 80 "tetheringstatsprotos", 81 ], 82 defaults: ["TetheringExternalLibs"], 83 libs: [ 84 "framework-tethering.impl", 85 ], 86 manifest: "AndroidManifestBase.xml", 87 lint: { 88 error_checks: ["NewApi"], 89 }, 90} 91 92// build tethering static library, used to compile both variants of the tethering. 93android_library { 94 name: "TetheringApiCurrentLib", 95 defaults: [ 96 "ConnectivityNextEnableDefaults", 97 "TetheringAndroidLibraryDefaults", 98 "TetheringApiLevel", 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 "TetheringApiLevel", 115 "TetheringReleaseTargetSdk", 116 ], 117 static_libs: [ 118 "NetworkStackApiStableShims", 119 ], 120 apex_available: ["com.android.tethering"], 121 lint: { 122 baseline_filename: "lint-baseline.xml", 123 }, 124} 125 126// Due to b/143733063, APK can't access a jni lib that is in APEX (but not in the APK). 127cc_library { 128 name: "libcom_android_networkstack_tethering_util_jni", 129 sdk_version: "current", 130 apex_available: [ 131 "com.android.tethering", 132 ], 133 min_sdk_version: "30", 134 header_libs: [ 135 "bpf_connectivity_headers", 136 ], 137 srcs: [ 138 "jni/*.cpp", 139 ], 140 shared_libs: [ 141 "liblog", 142 "libnativehelper_compat_libc++", 143 ], 144 static_libs: [ 145 "libnet_utils_device_common_bpfjni", 146 "libnetjniutils", 147 ], 148 149 // We cannot use plain "libc++" here to link libc++ dynamically because it results in: 150 // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found 151 // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't 152 // build because soong complains of: 153 // module Tethering missing dependencies: libc++_shared 154 // 155 // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries 156 // we depend on do not dynamically link libc++. This is currently the case, because liblog is 157 // C-only and libnativehelper_compat_libc also uses stl: "c++_static". 158 stl: "c++_static", 159 160 cflags: [ 161 "-Wall", 162 "-Werror", 163 "-Wno-unused-parameter", 164 "-Wthread-safety", 165 ], 166 167 ldflags: ["-Wl,--exclude-libs=ALL,--error-limit=0"], 168} 169 170// Common defaults for compiling the actual APK. 171java_defaults { 172 name: "TetheringAppDefaults", 173 privileged: true, 174 jni_libs: [ 175 "libcom_android_networkstack_tethering_util_jni", 176 ], 177 resource_dirs: [ 178 "res", 179 ], 180 // Libs are not actually needed to build here since build rules using these defaults are just 181 // packaging the TetheringApiXLibs in APKs, but they are necessary so that R8 has the right 182 // references to optimize the code. Without these, there will be missing class warnings and code 183 // may be wrongly optimized. 184 // R8 runs after jarjar, so the framework-X libraries need to be the post-jarjar artifacts 185 // (framework-tethering.impl), if they are not just stubs, so that the name of jarjared 186 // classes match. 187 // TODO(b/229727645): ensure R8 fails the build fully if libraries are missing 188 defaults: ["TetheringExternalLibs"], 189 libs: [ 190 "framework-tethering.impl", 191 ], 192 jarjar_rules: "jarjar-rules.txt", 193 optimize: { 194 proguard_flags_files: ["proguard.flags"], 195 }, 196} 197 198// Updatable tethering packaged for finalized API 199android_app { 200 name: "Tethering", 201 defaults: [ 202 "TetheringAppDefaults", 203 "TetheringApiLevel", 204 ], 205 static_libs: ["TetheringApiStableLib"], 206 certificate: "networkstack", 207 manifest: "AndroidManifest.xml", 208 use_embedded_native_libs: true, 209 privapp_allowlist: ":privapp_allowlist_com.android.tethering", 210 apex_available: ["com.android.tethering"], 211} 212 213android_app { 214 name: "TetheringNext", 215 defaults: [ 216 "TetheringAppDefaults", 217 "TetheringApiLevel", 218 "ConnectivityNextEnableDefaults", 219 ], 220 static_libs: ["TetheringApiCurrentLib"], 221 certificate: "networkstack", 222 manifest: "AndroidManifest.xml", 223 use_embedded_native_libs: true, 224 privapp_allowlist: ":privapp_allowlist_com.android.tethering", 225 apex_available: ["com.android.tethering"], 226 lint: { 227 error_checks: ["NewApi"], 228 }, 229} 230 231sdk { 232 name: "tethering-module-sdk", 233 apexes: [ 234 // Adds exportable dependencies of the APEX to the sdk, 235 // e.g. *classpath_fragments. 236 "com.android.tethering", 237 ], 238 native_shared_libs: [ 239 "libcom.android.tethering.dns_helper", 240 "libnetd_updatable", 241 ], 242} 243 244java_library_static { 245 name: "tetheringstatsprotos", 246 proto: { 247 type: "lite", 248 }, 249 srcs: [ 250 "src/com/android/networkstack/tethering/metrics/stats.proto", 251 ], 252 static_libs: ["tetheringprotos"], 253 apex_available: ["com.android.tethering"], 254 min_sdk_version: "30", 255} 256 257genrule { 258 name: "statslog-tethering-java-gen", 259 tools: ["stats-log-api-gen"], 260 cmd: "$(location stats-log-api-gen) --java $(out) --module network_tethering" + 261 " --javaPackage com.android.networkstack.tethering.metrics --javaClass TetheringStatsLog", 262 out: ["com/android/networkstack/tethering/metrics/TetheringStatsLog.java"], 263} 264