• 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
23service_remoteauth_pre_jarjar_lib = "service-remoteauth-pre-jarjar"
24
25// The above variables may have different values
26// depending on the branch, and this comment helps
27// separate them from the rest of the file to avoid merge conflicts
28
29aidl_interface {
30    name: "connectivity_native_aidl_interface",
31    local_include_dir: "binder",
32    srcs: [
33        "binder/android/net/connectivity/aidl/*.aidl",
34    ],
35    backend: {
36        java: {
37            apex_available: [
38                "com.android.tethering",
39            ],
40            min_sdk_version: "30",
41        },
42        ndk: {
43            apex_available: [
44                "com.android.tethering",
45            ],
46            min_sdk_version: "30",
47        },
48    },
49    versions: ["1"],
50
51}
52
53cc_library_static {
54    name: "connectivity_native_aidl_interface-lateststable-ndk",
55    min_sdk_version: "30",
56    whole_static_libs: [
57        "connectivity_native_aidl_interface-V1-ndk",
58    ],
59    apex_available: [
60        "com.android.tethering",
61    ],
62}
63
64java_library {
65    name: "connectivity_native_aidl_interface-lateststable-java",
66    sdk_version: "system_current",
67    min_sdk_version: "30",
68    static_libs: [
69        "connectivity_native_aidl_interface-V1-java",
70    ],
71    apex_available: [
72        "com.android.tethering",
73    ],
74}
75
76// The library name match the service-connectivity jarjar rules that put the JNI utils in the
77// android.net.connectivity.com.android.net.module.util package.
78cc_library_shared {
79    name: "libandroid_net_connectivity_com_android_net_module_util_jni",
80    min_sdk_version: "30",
81    cflags: [
82        "-Wall",
83        "-Werror",
84        "-Wno-unused-parameter",
85        "-Wthread-safety",
86    ],
87    srcs: [
88        "jni/com_android_net_module_util/onload.cpp",
89    ],
90    static_libs: [
91        "libnet_utils_device_common_bpfjni",
92        "libnet_utils_device_common_bpfutils",
93    ],
94    shared_libs: [
95        "liblog",
96        "libnativehelper",
97    ],
98    apex_available: [
99        "com.android.tethering",
100    ],
101}
102
103cc_library_shared {
104    name: "libservice-connectivity",
105    min_sdk_version: "30",
106    cflags: [
107        "-Wall",
108        "-Werror",
109        "-Wno-unused-parameter",
110        "-Wthread-safety",
111    ],
112    srcs: [
113        ":services.connectivity-netstats-jni-sources",
114        "jni/com_android_server_connectivity_ClatCoordinator.cpp",
115        "jni/com_android_server_ServiceManagerWrapper.cpp",
116        "jni/com_android_server_TestNetworkService.cpp",
117        "jni/onload.cpp",
118    ],
119    header_libs: [
120        "bpf_connectivity_headers",
121    ],
122    static_libs: [
123        "libclat",
124        "libip_checksum",
125        "libmodules-utils-build",
126        "libnetjniutils",
127        "libnet_utils_device_common_bpfjni",
128        "netd_aidl_interface-lateststable-ndk",
129    ],
130    shared_libs: [
131        "libbase",
132        "libbinder_ndk",
133        "libcutils",
134        "libnetdutils",
135        "liblog",
136        "libnativehelper",
137        "libnetworkstats",
138    ],
139    apex_available: [
140        "com.android.tethering",
141    ],
142}
143
144java_library {
145    name: "service-connectivity-pre-jarjar",
146    sdk_version: "system_server_current",
147    min_sdk_version: "30",
148    // NetworkStackApiShimSettingsForCurrentBranch provides the latest available shims depending on
149    // the branch to "service-connectivity".
150    // There are Tethering.apk and TetheringNext.apk variants for the tethering APEX,
151    // which use NetworkStackApiStableShims and NetworkStackApiCurrentShims respectively.
152    // Note that there can be no service-connectivity-next because it would need to be configured in
153    // default_art_config.mk which doesn't support conditionals, hence this scheme of using a
154    // variable here.
155    defaults: ["NetworkStackApiShimSettingsForCurrentBranch"],
156    srcs: [
157        "src/**/*.java",
158        ":framework-connectivity-shared-srcs",
159        ":services-connectivity-shared-srcs",
160        ":statslog-connectivity-java-gen",
161    ],
162    libs: [
163        "framework-annotations-lib",
164        "framework-configinfrastructure",
165        "framework-connectivity-pre-jarjar",
166        // The framework-connectivity-t library is only available on T+ platforms
167        // so any calls to it must be protected with a check to ensure that it is
168        // available. The linter will detect any unprotected calls through an API
169        // but not direct calls to the implementation. So, this depends on the
170        // module lib stubs directly to ensure the linter will work correctly
171        // as depending on framework-connectivity-t would cause it to be compiled
172        // against the implementation because the two libraries are in the same
173        // APEX.
174        "framework-connectivity-t.stubs.module_lib",
175        // TODO: figure out why just using "framework-tethering" uses the stubs, even though both
176        // service-connectivity and framework-tethering are in the same APEX.
177        "framework-tethering.impl",
178        "framework-wifi",
179        "unsupportedappusage",
180        "ServiceConnectivityResources",
181        "framework-statsd",
182        "framework-permission",
183        "framework-permission-s",
184    ],
185    static_libs: [
186        // Do not add libs here if they are already included
187        // in framework-connectivity
188        "androidx.annotation_annotation",
189        "connectivity-net-module-utils-bpf",
190        "connectivity_native_aidl_interface-lateststable-java",
191        "dnsresolver_aidl_interface-V15-java",
192        "modules-utils-shell-command-handler",
193        "net-utils-device-common",
194        "net-utils-device-common-ip",
195        "net-utils-device-common-netlink",
196        "net-utils-services-common",
197        "netd-client",
198        "networkstack-client",
199        "PlatformProperties",
200        "service-connectivity-protos",
201        "service-connectivity-stats-protos",
202        // The required dependency net-utils-device-common-struct-base is in the classpath via
203        // framework-connectivity
204        "net-utils-device-common-struct",
205    ],
206    apex_available: [
207        "com.android.tethering",
208    ],
209    lint: {
210        baseline_filename: "lint-baseline.xml",
211
212    },
213    visibility: [
214        "//packages/modules/Connectivity/service-t",
215        "//packages/modules/Connectivity/tests:__subpackages__",
216        "//packages/modules/Connectivity/thread/service:__subpackages__",
217        "//packages/modules/Connectivity/thread/tests:__subpackages__",
218    ],
219}
220
221java_library {
222    name: "service-connectivity-protos",
223    sdk_version: "system_current",
224    min_sdk_version: "30",
225    proto: {
226        type: "nano",
227    },
228    srcs: [
229        ":system-messages-proto-src",
230    ],
231    libs: ["libprotobuf-java-nano"],
232    apex_available: [
233        "com.android.tethering",
234    ],
235    lint: {
236        strict_updatability_linting: true,
237
238    },
239}
240
241java_defaults {
242    name: "service-connectivity-defaults",
243    sdk_version: "system_server_current",
244    min_sdk_version: "30",
245    defaults: [
246        "standalone-system-server-module-optimize-defaults",
247    ],
248    // This library combines system server jars that have access to different bootclasspath jars.
249    // Lower SDK service jars must not depend on higher SDK jars as that would let them
250    // transitively depend on the wrong bootclasspath jars. Sources also cannot be added here as
251    // they would depend on bootclasspath jars that may not be available.
252    static_libs: [
253        "service-connectivity-pre-jarjar",
254        "service-connectivity-tiramisu-pre-jarjar",
255        "service-nearby-pre-jarjar",
256        service_remoteauth_pre_jarjar_lib,
257        "service-thread-pre-jarjar",
258    ],
259    // The below libraries are not actually needed to build since no source is compiled
260    // (only combining prebuilt static_libs), but they are necessary so that R8 has the right
261    // references to optimize the code. Without these, there will be missing class warnings and
262    // code may be wrongly optimized.
263    // R8 runs after jarjar, so the framework-X libraries need to be the post-jarjar artifacts
264    // (.impl), if they are not just stubs, so that the name of jarjared classes match.
265    libs: [
266        "androidx.annotation_annotation",
267        "framework-annotations-lib",
268        "framework-connectivity.impl",
269        "framework-connectivity-t.impl",
270        "framework-tethering.impl",
271        "framework-wifi",
272        "libprotobuf-java-nano",
273        "framework-permission",
274        "framework-permission-s",
275    ],
276    jarjar_rules: ":connectivity-jarjar-rules",
277    apex_available: [
278        "com.android.tethering",
279    ],
280    optimize: {
281        proguard_flags_files: ["proguard.flags"],
282    },
283}
284
285// A special library created strictly for use by the tests as they need the
286// implementation library but that is not available when building from prebuilts.
287// Using a library with a different name to what is used by the prebuilts ensures
288// that this will never depend on the prebuilt.
289// Switching service-connectivity to a java_sdk_library would also have worked as
290// that has built in support for managing this but that is too big a change at this
291// point.
292java_library {
293    name: "service-connectivity-for-tests",
294    defaults: ["service-connectivity-defaults"],
295}
296
297java_library {
298    name: "service-connectivity",
299    defaults: ["service-connectivity-defaults"],
300    installable: true,
301}
302
303java_library_static {
304    name: "service-connectivity-stats-protos",
305    sdk_version: "system_current",
306    min_sdk_version: "30",
307    proto: {
308        type: "lite",
309    },
310    srcs: [
311        "src/com/android/metrics/stats.proto",
312    ],
313    static_libs: ["ConnectivityServiceprotos"],
314    apex_available: ["com.android.tethering"],
315}
316
317genrule {
318    name: "connectivity-jarjar-rules",
319    defaults: ["jarjar-rules-combine-defaults"],
320    srcs: [
321        ":framework-connectivity-jarjar-rules",
322        ":service-connectivity-jarjar-gen",
323        ":service-nearby-jarjar-gen",
324        ":service-remoteauth-jarjar-gen",
325        ":service-thread-jarjar-gen",
326    ],
327    out: ["connectivity-jarjar-rules.txt"],
328    visibility: ["//packages/modules/Connectivity:__subpackages__"],
329}
330
331// TODO: This filegroup temporary exposes for NetworkStats. It should be
332// removed right after NetworkStats moves into mainline module.
333filegroup {
334    name: "traffic-controller-utils",
335    srcs: ["src/com/android/server/BpfNetMaps.java"],
336    visibility: ["//packages/modules/Connectivity:__subpackages__"],
337}
338
339java_genrule {
340    name: "service-connectivity-jarjar-gen",
341    tool_files: [
342        ":service-connectivity-pre-jarjar{.jar}",
343        ":service-connectivity-tiramisu-pre-jarjar{.jar}",
344        "jarjar-excludes.txt",
345    ],
346    tools: [
347        "jarjar-rules-generator",
348    ],
349    out: ["service_connectivity_jarjar_rules.txt"],
350    cmd: "$(location jarjar-rules-generator) " +
351        "$(location :service-connectivity-pre-jarjar{.jar}) " +
352        "$(location :service-connectivity-tiramisu-pre-jarjar{.jar}) " +
353        "--prefix android.net.connectivity " +
354        "--excludes $(location jarjar-excludes.txt) " +
355        "--output $(out)",
356    visibility: ["//visibility:private"],
357}
358
359java_genrule {
360    name: "service-nearby-jarjar-gen",
361    tool_files: [
362        ":service-nearby-pre-jarjar{.jar}",
363        "jarjar-excludes.txt",
364    ],
365    tools: [
366        "jarjar-rules-generator",
367    ],
368    out: ["service_nearby_jarjar_rules.txt"],
369    cmd: "$(location jarjar-rules-generator) " +
370        "$(location :service-nearby-pre-jarjar{.jar}) " +
371        "--prefix com.android.server.nearby " +
372        "--excludes $(location jarjar-excludes.txt) " +
373        "--output $(out)",
374    visibility: ["//visibility:private"],
375}
376
377java_genrule {
378    name: "service-remoteauth-jarjar-gen",
379    tool_files: [
380        ":" + service_remoteauth_pre_jarjar_lib + "{.jar}",
381        "jarjar-excludes.txt",
382    ],
383    tools: [
384        "jarjar-rules-generator",
385    ],
386    out: ["service_remoteauth_jarjar_rules.txt"],
387    cmd: "$(location jarjar-rules-generator) " +
388        "$(location :" + service_remoteauth_pre_jarjar_lib + "{.jar}) " +
389        "--prefix com.android.server.remoteauth " +
390        "--excludes $(location jarjar-excludes.txt) " +
391        "--output $(out)",
392    visibility: ["//visibility:private"],
393}
394
395java_genrule {
396    name: "service-thread-jarjar-gen",
397    tool_files: [
398        ":service-thread-pre-jarjar{.jar}",
399        "jarjar-excludes.txt",
400    ],
401    tools: [
402        "jarjar-rules-generator",
403    ],
404    out: ["service_thread_jarjar_rules.txt"],
405    cmd: "$(location jarjar-rules-generator) " +
406        "$(location :service-thread-pre-jarjar{.jar}) " +
407        "--prefix com.android.server.thread " +
408        "--excludes $(location jarjar-excludes.txt) " +
409        "--output $(out)",
410    visibility: ["//visibility:private"],
411}
412
413genrule {
414    name: "statslog-connectivity-java-gen",
415    tools: ["stats-log-api-gen"],
416    cmd: "$(location stats-log-api-gen) --java $(out) --module connectivity --javaPackage com.android.server --javaClass ConnectivityStatsLog",
417    out: ["com/android/server/ConnectivityStatsLog.java"],
418}
419