markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 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 | |
Bob Badour | 97e6be2 | 2021-02-12 14:45:04 -0800 | [diff] [blame] | 17 | package { |
Aditya Choudhary | 01b5ede | 2024-01-31 11:08:57 +0000 | [diff] [blame] | 18 | default_team: "trendy_team_fwk_core_networking", |
Bob Badour | 97e6be2 | 2021-02-12 14:45:04 -0800 | [diff] [blame] | 19 | default_applicable_licenses: ["Android-Apache-2.0"], |
| 20 | } |
| 21 | |
markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 22 | java_defaults { |
markchien | 5a8c806 | 2021-10-27 13:22:27 +0800 | [diff] [blame] | 23 | name: "TetheringApiLevel", |
Anton Hansson | bbe4af1 | 2020-03-18 14:15:42 +0000 | [diff] [blame] | 24 | sdk_version: "module_current", |
Nikita Ioffe | 583e35a | 2020-10-31 22:41:41 +0000 | [diff] [blame] | 25 | min_sdk_version: "30", |
markchien | 5a8c806 | 2021-10-27 13:22:27 +0800 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | java_defaults { |
Harshit Mahajan | e210c27 | 2022-08-23 19:27:39 +0000 | [diff] [blame] | 29 | name: "TetheringReleaseTargetSdk", |
| 30 | target_sdk_version: "33", |
| 31 | } |
| 32 | |
| 33 | java_defaults { |
Remi NGUYEN VAN | 37dc1e2 | 2022-08-04 11:52:54 +0900 | [diff] [blame] | 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: [ |
Igor Chernyshev | 9dac660 | 2022-12-13 19:28:32 -0800 | [diff] [blame] | 38 | "connectivity-internal-api-util", |
Hassan Ali | c4f63fa | 2022-11-17 16:13:48 +0000 | [diff] [blame] | 39 | "framework-configinfrastructure", |
Remi NGUYEN VAN | 37dc1e2 | 2022-08-04 11:52:54 +0900 | [diff] [blame] | 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 | |
| 50 | java_defaults { |
markchien | 5a8c806 | 2021-10-27 13:22:27 +0800 | [diff] [blame] | 51 | name: "TetheringAndroidLibraryDefaults", |
markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 52 | srcs: [ |
Hungming Chen | dd55b91 | 2020-12-26 17:13:22 +0800 | [diff] [blame] | 53 | "apishim/**/*.java", |
markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 54 | "src/**/*.java", |
Aaron Huang | b401e58 | 2021-01-22 18:35:00 +0800 | [diff] [blame] | 55 | ":framework-connectivity-shared-srcs", |
markchien | 43e97e0 | 2019-09-03 15:58:06 +0800 | [diff] [blame] | 56 | ":services-tethering-shared-srcs", |
Wayne Ma | 7ecded8 | 2022-03-10 16:19:24 +0800 | [diff] [blame] | 57 | ":statslog-tethering-java-gen", |
markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 58 | ], |
| 59 | static_libs: [ |
| 60 | "androidx.annotation_annotation", |
Hungming Chen | 01f2550 | 2022-06-28 22:47:00 +0800 | [diff] [blame] | 61 | "connectivity-net-module-utils-bpf", |
Hungming Chen | dd55b91 | 2020-12-26 17:13:22 +0800 | [diff] [blame] | 62 | "modules-utils-build", |
William Escande | ea9e22e | 2021-08-19 12:26:52 +0200 | [diff] [blame] | 63 | "modules-utils-statemachine", |
Jeongik Cha | d05f990 | 2021-01-26 22:35:02 +0900 | [diff] [blame] | 64 | "networkstack-client", |
KH Shi | 3d5e65c | 2022-12-26 17:39:54 +0800 | [diff] [blame] | 65 | // AIDL tetheroffload implementation |
| 66 | "android.hardware.tetheroffload-V1-java", |
| 67 | // HIDL tetheroffload implementation |
markchien | 547e168 | 2020-02-05 12:42:25 +0800 | [diff] [blame] | 68 | "android.hardware.tetheroffload.config-V1.0-java", |
markchien | 6aa3889 | 2019-09-25 14:33:39 +0800 | [diff] [blame] | 69 | "android.hardware.tetheroffload.control-V1.0-java", |
junyulai | 177dc86 | 2021-03-10 15:26:50 +0800 | [diff] [blame] | 70 | "android.hardware.tetheroffload.control-V1.1-java", |
KH Shi | 3d5e65c | 2022-12-26 17:39:54 +0800 | [diff] [blame] | 71 | "android.hidl.manager-V1.2-java", |
Xiao Ma | 6793fd0 | 2024-07-26 13:07:50 +0900 | [diff] [blame] | 72 | "net-utils-connectivity-apks", |
lucaslin | ee661df | 2020-12-28 16:44:49 +0800 | [diff] [blame] | 73 | "netd-client", |
Wayne Ma | 71d6639 | 2022-03-03 10:15:09 +0800 | [diff] [blame] | 74 | "tetheringstatsprotos", |
markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 75 | ], |
Remi NGUYEN VAN | 37dc1e2 | 2022-08-04 11:52:54 +0900 | [diff] [blame] | 76 | defaults: ["TetheringExternalLibs"], |
markchien | 9d35382 | 2019-12-16 20:15:20 +0800 | [diff] [blame] | 77 | libs: [ |
Paul Duffin | 2dae272 | 2020-05-13 12:28:49 +0100 | [diff] [blame] | 78 | "framework-tethering.impl", |
markchien | 9d35382 | 2019-12-16 20:15:20 +0800 | [diff] [blame] | 79 | ], |
markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 80 | manifest: "AndroidManifestBase.xml", |
Motomu Utsumi | ac7c572 | 2023-11-15 11:51:42 +0900 | [diff] [blame] | 81 | lint: { |
Motomu Utsumi | ac7c572 | 2023-11-15 11:51:42 +0900 | [diff] [blame] | 82 | error_checks: ["NewApi"], |
| 83 | }, |
markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 84 | } |
| 85 | |
markchien | 5a8c806 | 2021-10-27 13:22:27 +0800 | [diff] [blame] | 86 | // build tethering static library, used to compile both variants of the tethering. |
markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 87 | android_library { |
| 88 | name: "TetheringApiCurrentLib", |
markchien | 5a8c806 | 2021-10-27 13:22:27 +0800 | [diff] [blame] | 89 | defaults: [ |
Remi NGUYEN VAN | f826bce | 2022-01-26 17:43:53 +0900 | [diff] [blame] | 90 | "ConnectivityNextEnableDefaults", |
markchien | 5a8c806 | 2021-10-27 13:22:27 +0800 | [diff] [blame] | 91 | "TetheringAndroidLibraryDefaults", |
Harshit Mahajan | e210c27 | 2022-08-23 19:27:39 +0000 | [diff] [blame] | 92 | "TetheringApiLevel", |
Cole Faust | a52ecf0 | 2023-12-20 11:57:07 -0800 | [diff] [blame] | 93 | "TetheringReleaseTargetSdk", |
markchien | 5a8c806 | 2021-10-27 13:22:27 +0800 | [diff] [blame] | 94 | ], |
| 95 | static_libs: [ |
| 96 | "NetworkStackApiCurrentShims", |
| 97 | ], |
| 98 | apex_available: ["com.android.tethering"], |
Cole Faust | a52ecf0 | 2023-12-20 11:57:07 -0800 | [diff] [blame] | 99 | lint: { |
Cole Faust | a52ecf0 | 2023-12-20 11:57:07 -0800 | [diff] [blame] | 100 | baseline_filename: "lint-baseline.xml", |
| 101 | }, |
markchien | 5a8c806 | 2021-10-27 13:22:27 +0800 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | android_library { |
| 105 | name: "TetheringApiStableLib", |
| 106 | defaults: [ |
| 107 | "TetheringAndroidLibraryDefaults", |
Harshit Mahajan | e210c27 | 2022-08-23 19:27:39 +0000 | [diff] [blame] | 108 | "TetheringApiLevel", |
Cole Faust | a52ecf0 | 2023-12-20 11:57:07 -0800 | [diff] [blame] | 109 | "TetheringReleaseTargetSdk", |
markchien | 5a8c806 | 2021-10-27 13:22:27 +0800 | [diff] [blame] | 110 | ], |
| 111 | static_libs: [ |
| 112 | "NetworkStackApiStableShims", |
| 113 | ], |
| 114 | apex_available: ["com.android.tethering"], |
Cole Faust | a52ecf0 | 2023-12-20 11:57:07 -0800 | [diff] [blame] | 115 | lint: { |
Cole Faust | a52ecf0 | 2023-12-20 11:57:07 -0800 | [diff] [blame] | 116 | baseline_filename: "lint-baseline.xml", |
| 117 | }, |
markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 118 | } |
| 119 | |
markchien | 810aa68 | 2019-10-23 16:27:52 +0800 | [diff] [blame] | 120 | // Due to b/143733063, APK can't access a jni lib that is in APEX (but not in the APK). |
| 121 | cc_library { |
markchien | f967b11 | 2021-11-09 16:56:23 +0800 | [diff] [blame] | 122 | name: "libcom_android_networkstack_tethering_util_jni", |
Patrick Rohr | 1575424 | 2024-05-16 11:38:57 -0700 | [diff] [blame] | 123 | sdk_version: "current", |
Jooyung Han | 8182d8b | 2020-04-29 02:43:30 +0900 | [diff] [blame] | 124 | apex_available: [ |
Jooyung Han | 8182d8b | 2020-04-29 02:43:30 +0900 | [diff] [blame] | 125 | "com.android.tethering", |
| 126 | ], |
Nikita Ioffe | 583e35a | 2020-10-31 22:41:41 +0000 | [diff] [blame] | 127 | min_sdk_version: "30", |
Lorenzo Colitti | 734b14e | 2021-02-05 23:56:09 +0900 | [diff] [blame] | 128 | header_libs: [ |
Ken Chen | bb57fa9 | 2021-10-22 00:49:13 +0800 | [diff] [blame] | 129 | "bpf_connectivity_headers", |
Lorenzo Colitti | 734b14e | 2021-02-05 23:56:09 +0900 | [diff] [blame] | 130 | ], |
markchien | 6aa3889 | 2019-09-25 14:33:39 +0800 | [diff] [blame] | 131 | srcs: [ |
markchien | 7052688 | 2020-11-12 00:17:15 +0800 | [diff] [blame] | 132 | "jni/*.cpp", |
markchien | 6aa3889 | 2019-09-25 14:33:39 +0800 | [diff] [blame] | 133 | ], |
| 134 | shared_libs: [ |
markchien | 6aa3889 | 2019-09-25 14:33:39 +0800 | [diff] [blame] | 135 | "liblog", |
markchien | 547e168 | 2020-02-05 12:42:25 +0800 | [diff] [blame] | 136 | "libnativehelper_compat_libc++", |
markchien | 6aa3889 | 2019-09-25 14:33:39 +0800 | [diff] [blame] | 137 | ], |
Orion Hodson | e5bd0db | 2020-12-08 09:57:42 +0000 | [diff] [blame] | 138 | static_libs: [ |
markchien | 782a568 | 2021-11-10 01:11:33 +0800 | [diff] [blame] | 139 | "libnet_utils_device_common_bpfjni", |
Orion Hodson | e5bd0db | 2020-12-08 09:57:42 +0000 | [diff] [blame] | 140 | "libnetjniutils", |
| 141 | ], |
markchien | 6aa3889 | 2019-09-25 14:33:39 +0800 | [diff] [blame] | 142 | |
markchien | 547e168 | 2020-02-05 12:42:25 +0800 | [diff] [blame] | 143 | // We cannot use plain "libc++" here to link libc++ dynamically because it results in: |
| 144 | // java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found |
| 145 | // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't |
| 146 | // build because soong complains of: |
| 147 | // module Tethering missing dependencies: libc++_shared |
| 148 | // |
| 149 | // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries |
| 150 | // we depend on do not dynamically link libc++. This is currently the case, because liblog is |
| 151 | // C-only and libnativehelper_compat_libc also uses stl: "c++_static". |
| 152 | stl: "c++_static", |
| 153 | |
markchien | 6aa3889 | 2019-09-25 14:33:39 +0800 | [diff] [blame] | 154 | cflags: [ |
| 155 | "-Wall", |
| 156 | "-Werror", |
| 157 | "-Wno-unused-parameter", |
| 158 | "-Wthread-safety", |
| 159 | ], |
markchien | 810aa68 | 2019-10-23 16:27:52 +0800 | [diff] [blame] | 160 | |
Yi Kong | 20a996e | 2022-06-22 03:41:56 +0800 | [diff] [blame] | 161 | ldflags: ["-Wl,--exclude-libs=ALL,--error-limit=0"], |
markchien | 6aa3889 | 2019-09-25 14:33:39 +0800 | [diff] [blame] | 162 | } |
| 163 | |
markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 164 | // Common defaults for compiling the actual APK. |
| 165 | java_defaults { |
| 166 | name: "TetheringAppDefaults", |
markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 167 | privileged: true, |
markchien | 6aa3889 | 2019-09-25 14:33:39 +0800 | [diff] [blame] | 168 | jni_libs: [ |
markchien | f967b11 | 2021-11-09 16:56:23 +0800 | [diff] [blame] | 169 | "libcom_android_networkstack_tethering_util_jni", |
markchien | 6aa3889 | 2019-09-25 14:33:39 +0800 | [diff] [blame] | 170 | ], |
markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 171 | resource_dirs: [ |
| 172 | "res", |
| 173 | ], |
Remi NGUYEN VAN | 37dc1e2 | 2022-08-04 11:52:54 +0900 | [diff] [blame] | 174 | // Libs are not actually needed to build here since build rules using these defaults are just |
| 175 | // packaging the TetheringApiXLibs in APKs, but they are necessary so that R8 has the right |
| 176 | // references to optimize the code. Without these, there will be missing class warnings and code |
| 177 | // may be wrongly optimized. |
| 178 | // R8 runs after jarjar, so the framework-X libraries need to be the post-jarjar artifacts |
| 179 | // (framework-tethering.impl), if they are not just stubs, so that the name of jarjared |
| 180 | // classes match. |
| 181 | // TODO(b/229727645): ensure R8 fails the build fully if libraries are missing |
| 182 | defaults: ["TetheringExternalLibs"], |
markchien | 9d35382 | 2019-12-16 20:15:20 +0800 | [diff] [blame] | 183 | libs: [ |
Remi NGUYEN VAN | 37dc1e2 | 2022-08-04 11:52:54 +0900 | [diff] [blame] | 184 | "framework-tethering.impl", |
markchien | 9d35382 | 2019-12-16 20:15:20 +0800 | [diff] [blame] | 185 | ], |
| 186 | jarjar_rules: "jarjar-rules.txt", |
markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 187 | optimize: { |
| 188 | proguard_flags_files: ["proguard.flags"], |
| 189 | }, |
| 190 | } |
| 191 | |
markchien | 5a8c806 | 2021-10-27 13:22:27 +0800 | [diff] [blame] | 192 | // Updatable tethering packaged for finalized API |
markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 193 | android_app { |
| 194 | name: "Tethering", |
Cole Faust | a52ecf0 | 2023-12-20 11:57:07 -0800 | [diff] [blame] | 195 | defaults: [ |
| 196 | "TetheringAppDefaults", |
| 197 | "TetheringApiLevel", |
| 198 | ], |
markchien | 5a8c806 | 2021-10-27 13:22:27 +0800 | [diff] [blame] | 199 | static_libs: ["TetheringApiStableLib"], |
| 200 | certificate: "networkstack", |
| 201 | manifest: "AndroidManifest.xml", |
| 202 | use_embedded_native_libs: true, |
Anton Hansson | 1397a10 | 2023-05-25 07:04:33 +0000 | [diff] [blame] | 203 | privapp_allowlist: ":privapp_allowlist_com.android.tethering", |
markchien | 5a8c806 | 2021-10-27 13:22:27 +0800 | [diff] [blame] | 204 | apex_available: ["com.android.tethering"], |
| 205 | } |
| 206 | |
| 207 | android_app { |
| 208 | name: "TetheringNext", |
markchien | 598a75b | 2021-11-22 10:36:32 +0800 | [diff] [blame] | 209 | defaults: [ |
| 210 | "TetheringAppDefaults", |
| 211 | "TetheringApiLevel", |
| 212 | "ConnectivityNextEnableDefaults", |
| 213 | ], |
markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 214 | static_libs: ["TetheringApiCurrentLib"], |
| 215 | certificate: "networkstack", |
| 216 | manifest: "AndroidManifest.xml", |
| 217 | use_embedded_native_libs: true, |
Anton Hansson | 1397a10 | 2023-05-25 07:04:33 +0000 | [diff] [blame] | 218 | privapp_allowlist: ":privapp_allowlist_com.android.tethering", |
Jiyong Park | 1eb8933 | 2020-01-06 13:30:59 +0900 | [diff] [blame] | 219 | apex_available: ["com.android.tethering"], |
Motomu Utsumi | ac7c572 | 2023-11-15 11:51:42 +0900 | [diff] [blame] | 220 | lint: { |
Motomu Utsumi | ac7c572 | 2023-11-15 11:51:42 +0900 | [diff] [blame] | 221 | error_checks: ["NewApi"], |
| 222 | }, |
markchien | 932da86 | 2019-08-27 10:19:38 +0800 | [diff] [blame] | 223 | } |
Hai Zhang | 6d71f10 | 2021-02-14 06:38:22 +0000 | [diff] [blame] | 224 | |
| 225 | sdk { |
| 226 | name: "tethering-module-sdk", |
Paul Duffin | 1514c03 | 2022-07-13 11:18:50 +0000 | [diff] [blame] | 227 | apexes: [ |
| 228 | // Adds exportable dependencies of the APEX to the sdk, |
| 229 | // e.g. *classpath_fragments. |
| 230 | "com.android.tethering", |
| 231 | ], |
Spandan Das | b06f9d6 | 2023-04-04 20:48:54 +0000 | [diff] [blame] | 232 | native_shared_libs: [ |
Ken Chen | ec0f7ac | 2023-09-08 14:14:55 +0800 | [diff] [blame] | 233 | "libcom.android.tethering.dns_helper", |
Spandan Das | b06f9d6 | 2023-04-04 20:48:54 +0000 | [diff] [blame] | 234 | "libnetd_updatable", |
| 235 | ], |
Hai Zhang | 6d71f10 | 2021-02-14 06:38:22 +0000 | [diff] [blame] | 236 | } |
Wayne Ma | 71d6639 | 2022-03-03 10:15:09 +0800 | [diff] [blame] | 237 | |
| 238 | java_library_static { |
| 239 | name: "tetheringstatsprotos", |
Cole Faust | a52ecf0 | 2023-12-20 11:57:07 -0800 | [diff] [blame] | 240 | proto: { |
| 241 | type: "lite", |
| 242 | }, |
Wayne Ma | 71d6639 | 2022-03-03 10:15:09 +0800 | [diff] [blame] | 243 | srcs: [ |
| 244 | "src/com/android/networkstack/tethering/metrics/stats.proto", |
| 245 | ], |
| 246 | static_libs: ["tetheringprotos"], |
| 247 | apex_available: ["com.android.tethering"], |
| 248 | min_sdk_version: "30", |
| 249 | } |
Wayne Ma | 7ecded8 | 2022-03-10 16:19:24 +0800 | [diff] [blame] | 250 | |
| 251 | genrule { |
| 252 | name: "statslog-tethering-java-gen", |
| 253 | tools: ["stats-log-api-gen"], |
| 254 | cmd: "$(location stats-log-api-gen) --java $(out) --module network_tethering" + |
Cole Faust | a52ecf0 | 2023-12-20 11:57:07 -0800 | [diff] [blame] | 255 | " --javaPackage com.android.networkstack.tethering.metrics --javaClass TetheringStatsLog", |
Wayne Ma | 7ecded8 | 2022-03-10 16:19:24 +0800 | [diff] [blame] | 256 | out: ["com/android/networkstack/tethering/metrics/TetheringStatsLog.java"], |
Yi Kong | 20a996e | 2022-06-22 03:41:56 +0800 | [diff] [blame] | 257 | } |