• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
2// Copyright (C) 2020 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    // See: http://go/android-license-faq
20    default_applicable_licenses: ["Android-Apache-2.0"],
21}
22
23filegroup {
24    name: "framework-connectivity-internal-sources",
25    srcs: [
26        "src/**/*.java",
27        "src/**/*.aidl",
28    ],
29    path: "src",
30    visibility: [
31        "//visibility:private",
32    ],
33}
34
35filegroup {
36    name: "framework-connectivity-aidl-export-sources",
37    srcs: [
38        "aidl-export/**/*.aidl",
39    ],
40    path: "aidl-export",
41    visibility: [
42        "//visibility:private",
43    ],
44}
45
46// TODO: use a java_library in the bootclasspath instead
47filegroup {
48    name: "framework-connectivity-sources",
49    defaults: ["framework-sources-module-defaults"],
50    srcs: [
51        ":framework-connectivity-internal-sources",
52        ":framework-connectivity-aidl-export-sources",
53    ],
54    visibility: ["//packages/modules/Connectivity:__subpackages__"],
55}
56
57java_defaults {
58    name: "framework-connectivity-defaults",
59    defaults: ["framework-module-defaults"],
60    sdk_version: "module_current",
61    min_sdk_version: "30",
62    srcs: [
63        ":framework-connectivity-sources",
64        ":net-utils-framework-common-srcs",
65        ":framework-connectivity-api-shared-srcs",
66        ":framework-networksecurity-sources",
67        ":statslog-framework-connectivity-java-gen",
68    ],
69    aidl: {
70        generate_get_transaction_name: true,
71        include_dirs: [
72            // Include directories for parcelables that are part of the stable API, and need a
73            // one-line "parcelable X" .aidl declaration to be used in AIDL interfaces.
74            // TODO(b/180293679): remove these dependencies as they should not be necessary once
75            // the module builds against API (the parcelable declarations exist in framework.aidl)
76            "frameworks/base/core/java", // For framework parcelables
77            "frameworks/native/aidl/binder", // For PersistableBundle.aidl
78            "packages/modules/Connectivity/Tethering/common/TetheringLib/src",
79        ],
80    },
81    stub_only_libs: [
82        "framework-connectivity-t.stubs.module_lib",
83    ],
84    impl_only_libs: [
85        // TODO: figure out why just using "framework-tethering" uses the stubs, even though both
86        // framework-connectivity and framework-tethering are in the same APEX.
87        "framework-location.stubs.module_lib",
88        "framework-tethering.impl",
89        "framework-wifi.stubs.module_lib",
90    ],
91    static_libs: [
92        "com.android.net.flags-aconfig-java",
93        // Not using the latest stable version because all functions in the latest version of
94        // mdns_aidl_interface are deprecated.
95        "mdns_aidl_interface-V1-java",
96        "modules-utils-backgroundthread",
97        "modules-utils-build",
98        "modules-utils-preconditions",
99        "networksecurity_flags_java_lib",
100        "framework-connectivity-javastream-protos",
101    ],
102    impl_only_static_libs: [
103        "net-utils-framework-connectivity",
104    ],
105    libs: [
106        "androidx.annotation_annotation",
107        "app-compat-annotations",
108        "framework-connectivity-t.stubs.module_lib",
109        "framework-statsd.stubs.module_lib",
110        "unsupportedappusage",
111    ],
112    apex_available: [
113        "com.android.tethering",
114    ],
115}
116
117// Library to allow Cronet to use hidden APIs
118java_library {
119    name: "framework-connectivity-pre-jarjar-without-cronet",
120    defaults: [
121        "framework-connectivity-defaults",
122    ],
123    static_libs: [
124        // Framework-connectivity-pre-jarjar is identical to framework-connectivity
125        // implementation, but without the jarjar rules. However, framework-connectivity
126        // is not based on framework-connectivity-pre-jarjar, it's rebuilt from source
127        // to generate the SDK stubs.
128        // Even if the library is included in "impl_only_static_libs" of defaults. This is still
129        // needed because java_library which doesn't understand "impl_only_static_libs".
130        "net-utils-framework-connectivity",
131    ],
132    libs: [
133        // This cannot be in the defaults clause above because if it were, it would be used
134        // to generate the connectivity stubs. That would create a circular dependency
135        // because the tethering impl depend on the connectivity stubs (e.g.,
136        // TetheringRequest depends on LinkAddress).
137        "framework-location.stubs.module_lib",
138        "framework-tethering.impl",
139        "framework-wifi.stubs.module_lib",
140    ],
141    visibility: ["//external/cronet:__subpackages__"],
142}
143
144java_library {
145    name: "framework-connectivity-pre-jarjar",
146    defaults: ["framework-module-defaults"],
147    installable: false,
148    min_sdk_version: "30",
149    static_libs: [
150        "framework-connectivity-pre-jarjar-without-cronet",
151        "httpclient_api",
152        "httpclient_impl",
153    ],
154    apex_available: [
155        "com.android.tethering",
156    ],
157    visibility: ["//packages/modules/Connectivity:__subpackages__"],
158}
159
160java_defaults {
161    name: "CronetJavaDefaults",
162    srcs: [":httpclient_api_sources"],
163    static_libs: [
164        "com.android.net.http.flags-aconfig-java",
165    ],
166    libs: [
167        "androidx.annotation_annotation",
168    ],
169    impl_only_static_libs: [
170        "httpclient_impl",
171    ],
172}
173
174java_sdk_library {
175    name: "framework-connectivity",
176    defaults: [
177        "framework-connectivity-defaults",
178        "CronetJavaDefaults",
179    ],
180    installable: true,
181    jarjar_rules: ":framework-connectivity-jarjar-rules",
182    permitted_packages: ["android.net"],
183    impl_library_visibility: [
184        "//packages/modules/Connectivity/Tethering/apex",
185        // In preparation for future move
186        "//packages/modules/Connectivity/apex",
187        "//packages/modules/Connectivity/framework-t",
188        "//packages/modules/Connectivity/remoteauth/service",
189        "//packages/modules/Connectivity/service",
190        "//packages/modules/Connectivity/service-t",
191        "//packages/modules/Connectivity/staticlibs",
192        "//frameworks/base",
193
194        // Tests using hidden APIs
195        "//cts/tests/netlegacy22.api",
196        "//cts/tests/tests/app.usage", // NetworkUsageStatsTest
197
198        // TODO: b/374174952 Remove it when VCN CTS is moved to Connectivity/
199        "//cts/tests/tests/vcn",
200
201        "//external/sl4a:__subpackages__",
202        "//frameworks/base/core/tests/bandwidthtests",
203        "//frameworks/base/core/tests/benchmarks",
204        "//frameworks/base/core/tests/utillib",
205        "//frameworks/base/services/tests/VpnTests",
206        "//frameworks/base/tests/vcn",
207        "//frameworks/opt/net/ethernet/tests:__subpackages__",
208        "//frameworks/opt/telephony/tests/telephonytests",
209        "//packages/modules/CaptivePortalLogin/tests",
210        "//packages/modules/Connectivity/staticlibs/testutils",
211        "//packages/modules/Connectivity/staticlibs/tests:__subpackages__",
212        "//packages/modules/Connectivity/Cronet/tests:__subpackages__",
213        "//packages/modules/Connectivity/Tethering/tests:__subpackages__",
214        "//packages/modules/Connectivity/tests:__subpackages__",
215        "//packages/modules/Connectivity/thread/tests:__subpackages__",
216        "//packages/modules/IPsec/tests/iketests",
217        "//packages/modules/NetworkStack",
218        "//packages/modules/NetworkStack/tests:__subpackages__",
219        "//packages/modules/Wifi/service/tests/wifitests",
220    ],
221    lint: {
222        baseline_filename: "lint-baseline.xml",
223    },
224    aconfig_declarations: [
225        "com.android.net.flags-aconfig",
226        "com.android.net.http.flags-aconfig",
227        "com.android.networksecurity.flags-aconfig",
228    ],
229}
230
231platform_compat_config {
232    name: "connectivity-platform-compat-config",
233    src: ":framework-connectivity",
234}
235
236cc_library_shared {
237    name: "libframework-connectivity-jni",
238    min_sdk_version: "30",
239    cflags: [
240        "-Wall",
241        "-Werror",
242        "-Wno-unused-parameter",
243        // Don't warn about S API usage even with
244        // min_sdk 30: the library is only loaded
245        // on S+ devices
246        "-Wno-unguarded-availability",
247        "-Wthread-safety",
248    ],
249    srcs: [
250        "jni/android_net_NetworkUtils.cpp",
251        "jni/onload.cpp",
252    ],
253    shared_libs: [
254        "libandroid",
255        "liblog",
256        "libnativehelper",
257    ],
258    header_libs: [
259        "bpf_headers",
260        "dnsproxyd_protocol_headers",
261    ],
262    stl: "none",
263    apex_available: [
264        "com.android.tethering",
265    ],
266}
267
268filegroup {
269    name: "framework-connectivity-protos",
270    srcs: [
271        "proto/**/*.proto",
272    ],
273    visibility: ["//frameworks/base"],
274}
275
276java_library {
277    name: "framework-connectivity-javastream-protos",
278    proto: {
279        type: "stream",
280    },
281    srcs: [":framework-connectivity-protos"],
282    installable: false,
283    sdk_version: "module_current",
284    min_sdk_version: "30",
285    apex_available: [
286        "com.android.tethering",
287    ],
288}
289
290java_genrule {
291    name: "framework-connectivity-jarjar-rules",
292    tool_files: [
293        ":connectivity-hiddenapi-files",
294        ":framework-connectivity-pre-jarjar{.jar}",
295        ":framework-connectivity-t-pre-jarjar{.jar}",
296        ":framework-connectivity.stubs.module_lib{.jar}",
297        ":framework-connectivity-t.stubs.module_lib{.jar}",
298        "jarjar-excludes.txt",
299    ],
300    tools: [
301        "jarjar-rules-generator",
302    ],
303    out: ["framework_connectivity_jarjar_rules.txt"],
304    cmd: "$(location jarjar-rules-generator) " +
305        "$(location :framework-connectivity-pre-jarjar{.jar}) " +
306        "$(location :framework-connectivity-t-pre-jarjar{.jar}) " +
307        "--prefix android.net.connectivity " +
308        "--apistubs $(location :framework-connectivity.stubs.module_lib{.jar}) " +
309        "--apistubs $(location :framework-connectivity-t.stubs.module_lib{.jar}) " +
310        // Make a ":"-separated list. There will be an extra ":" but empty items are ignored.
311        "--unsupportedapi $$(printf ':%s' $(locations :connectivity-hiddenapi-files)) " +
312        "--excludes $(location jarjar-excludes.txt) " +
313        "--output $(out)",
314    visibility: [
315        "//packages/modules/Connectivity/framework:__subpackages__",
316        "//packages/modules/Connectivity/framework-t:__subpackages__",
317        "//packages/modules/Connectivity/service",
318    ],
319}
320
321// Library providing limited APIs within the connectivity module, so that R+ components like
322// Tethering have a controlled way to depend on newer components like framework-connectivity that
323// are not loaded on R.
324// Note that this target needs to have access to hidden classes, and as such needs to list
325// the full libraries instead of the .impl lib (which only expose API classes).
326java_library {
327    name: "connectivity-internal-api-util",
328    sdk_version: "module_current",
329    libs: [
330        "androidx.annotation_annotation",
331        "framework-connectivity-pre-jarjar",
332    ],
333    jarjar_rules: ":framework-connectivity-jarjar-rules",
334    srcs: [
335        // Files listed here MUST all be annotated with @RequiresApi(Build.VERSION_CODES.S)
336        // or above as appropriate so that API checks are enforced for R+ users of this library
337        "src/android/net/connectivity/ConnectivityInternalApiUtil.java",
338    ],
339    visibility: [
340        "//packages/modules/Connectivity/Tethering:__subpackages__",
341    ],
342}
343