• 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
17java_defaults {
18    name: "TetheringAndroidLibraryDefaults",
19    sdk_version: "module_current",
20    srcs: [
21        "src/**/*.java",
22        ":framework-tethering-shared-srcs",
23        ":tethering-module-utils-srcs",
24        ":services-tethering-shared-srcs",
25    ],
26    static_libs: [
27        "androidx.annotation_annotation",
28        "netd_aidl_interface-java",
29        "netlink-client",
30        "networkstack-aidl-interfaces-java",
31        "android.hardware.tetheroffload.config-V1.0-java",
32        "android.hardware.tetheroffload.control-V1.0-java",
33        "net-utils-framework-common",
34    ],
35    libs: [
36        "framework-statsd.stubs.module_lib",
37        "framework-tethering.impl",
38        "framework-wifi",
39        "unsupportedappusage",
40    ],
41    plugins: ["java_api_finder"],
42    manifest: "AndroidManifestBase.xml",
43}
44
45// Build tethering static library, used to compile both variants of the tethering.
46android_library {
47    name: "TetheringApiCurrentLib",
48    defaults: ["TetheringAndroidLibraryDefaults"],
49}
50
51// Due to b/143733063, APK can't access a jni lib that is in APEX (but not in the APK).
52cc_library {
53    name: "libtetherutilsjni",
54    sdk_version: "current",
55    apex_available: [
56        "//apex_available:platform", // Used by InProcessTethering
57        "com.android.tethering",
58    ],
59    min_sdk_version: "current",
60    srcs: [
61        "jni/android_net_util_TetheringUtils.cpp",
62    ],
63    shared_libs: [
64        "liblog",
65        "libnativehelper_compat_libc++",
66    ],
67
68    // We cannot use plain "libc++" here to link libc++ dynamically because it results in:
69    //   java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
70    // even if "libc++" is added into jni_libs below. Adding "libc++_shared" into jni_libs doesn't
71    // build because soong complains of:
72    //   module Tethering missing dependencies: libc++_shared
73    //
74    // So, link libc++ statically. This means that we also need to ensure that all the C++ libraries
75    // we depend on do not dynamically link libc++. This is currently the case, because liblog is
76    // C-only and libnativehelper_compat_libc also uses stl: "c++_static".
77    stl: "c++_static",
78
79    cflags: [
80        "-Wall",
81        "-Werror",
82        "-Wno-unused-parameter",
83        "-Wthread-safety",
84    ],
85
86    ldflags: ["-Wl,--exclude-libs=ALL,-error-limit=0"],
87}
88
89// Common defaults for compiling the actual APK.
90java_defaults {
91    name: "TetheringAppDefaults",
92    sdk_version: "module_current",
93    privileged: true,
94    jni_libs: [
95        "libtetherutilsjni",
96    ],
97    resource_dirs: [
98        "res",
99    ],
100    libs: [
101        "framework-tethering",
102    ],
103    jarjar_rules: "jarjar-rules.txt",
104    optimize: {
105        proguard_flags_files: ["proguard.flags"],
106    },
107}
108
109// Non-updatable tethering running in the system server process for devices not using the module
110android_app {
111    name: "InProcessTethering",
112    defaults: ["TetheringAppDefaults"],
113    static_libs: ["TetheringApiCurrentLib"],
114    certificate: "platform",
115    manifest: "AndroidManifest_InProcess.xml",
116    // InProcessTethering is a replacement for Tethering
117    overrides: ["Tethering"],
118    apex_available: ["com.android.tethering"],
119    min_sdk_version: "current",
120}
121
122// Updatable tethering packaged as an application
123android_app {
124    name: "Tethering",
125    defaults: ["TetheringAppDefaults"],
126    static_libs: ["TetheringApiCurrentLib"],
127    certificate: "networkstack",
128    manifest: "AndroidManifest.xml",
129    use_embedded_native_libs: true,
130    // The permission configuration *must* be included to ensure security of the device
131    required: ["NetworkPermissionConfig"],
132    apex_available: ["com.android.tethering"],
133    min_sdk_version: "current",
134}
135