• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2009 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//      http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package {
16    // See: http://go/android-license-faq
17    // A large-scale-change added 'default_applicable_licenses' to import
18    // all of the 'license_kinds' from "frameworks_native_license"
19    // to get the below license kinds:
20    //   SPDX-license-identifier-Apache-2.0
21    default_applicable_licenses: ["frameworks_native_license"],
22}
23
24cc_library_headers {
25    name: "libbinder_headers",
26    export_include_dirs: ["include"],
27    vendor_available: true,
28    host_supported: true,
29    // TODO(b/153609531): remove when no longer needed.
30    native_bridge_supported: true,
31
32    header_libs: [
33        "libbase_headers",
34        "libbinder_headers_platform_shared",
35        "libcutils_headers",
36        "libutils_headers",
37    ],
38    export_header_lib_headers: [
39        "libbase_headers",
40        "libbinder_headers_platform_shared",
41        "libcutils_headers",
42        "libutils_headers",
43    ],
44    apex_available: [
45        "//apex_available:platform",
46        "com.android.media",
47        "com.android.media.swcodec",
48    ],
49    min_sdk_version: "29",
50    target: {
51        darwin: {
52            enabled: false,
53        },
54    },
55}
56
57// These interfaces are android-specific implementation unrelated to binder
58// transport itself and should be moved to AIDL or in domain-specific libs.
59//
60// Currently, these are only on system android (not vendor, not host)
61// TODO(b/183654927) - move these into separate libraries
62libbinder_device_interface_sources = [
63    "IPermissionController.cpp",
64    "PermissionCache.cpp",
65    "PermissionController.cpp",
66]
67
68cc_library {
69    name: "libbinder",
70
71    // for vndbinder
72    vendor_available: true,
73    vndk: {
74        enabled: true,
75    },
76    double_loadable: true,
77    host_supported: true,
78    // TODO(b/153609531): remove when no longer needed.
79    native_bridge_supported: true,
80
81    // TODO(b/31559095): get headers from bionic on host
82    include_dirs: [
83        "bionic/libc/kernel/android/uapi/",
84        "bionic/libc/kernel/uapi/",
85    ],
86
87    // libbinder does not offer a stable wire protocol.
88    // if a second copy of it is installed, then it may break after security
89    // or dessert updates. Instead, apex users should use libbinder_ndk.
90    apex_available: [
91        "//apex_available:platform",
92    ],
93
94    srcs: [
95        "Binder.cpp",
96        "BpBinder.cpp",
97        "BufferedTextOutput.cpp",
98        "Debug.cpp",
99        "IInterface.cpp",
100        "IMemory.cpp",
101        "IPCThreadState.cpp",
102        "IResultReceiver.cpp",
103        "IServiceManager.cpp",
104        "IShellCallback.cpp",
105        "LazyServiceRegistrar.cpp",
106        "MemoryBase.cpp",
107        "MemoryDealer.cpp",
108        "MemoryHeapBase.cpp",
109        "Parcel.cpp",
110        "ParcelableHolder.cpp",
111        "ParcelFileDescriptor.cpp",
112        "PersistableBundle.cpp",
113        "ProcessState.cpp",
114        "RpcAddress.cpp",
115        "RpcSession.cpp",
116        "RpcServer.cpp",
117        "RpcState.cpp",
118        "Static.cpp",
119        "Stability.cpp",
120        "Status.cpp",
121        "TextOutput.cpp",
122        "Utils.cpp",
123        ":packagemanager_aidl",
124        ":libbinder_aidl",
125    ],
126
127    target: {
128        android: {
129            srcs: libbinder_device_interface_sources,
130
131            // NOT static to keep the wire protocol unfrozen
132            static: {
133                enabled: false,
134            },
135        },
136        android_arm64: {
137            // b/189438896 Sampling PGO restricted to arm64, arm32 in sc-dev
138            pgo: {
139                sampling: true,
140                profile_file: "libbinder/libbinder.profdata",
141            },
142            // b/189438896 Add exported symbols in a map file for ABI stability
143            version_script: "libbinder.arm64.map",
144            target: {
145                vendor: {
146                    version_script: "libbinder.arm64.vendor.map",
147                },
148            },
149        },
150        android_arm: {
151            // b/189438896 Sampling PGO restricted to arm64, arm32 in sc-dev
152            pgo: {
153                sampling: true,
154                profile_file: "libbinder/libbinder.profdata",
155            },
156            // b/189438896 Add exported symbols in a map file for ABI stability
157            version_script: "libbinder.arm32.map",
158            target: {
159                vendor: {
160                    version_script: "libbinder.arm32.vendor.map",
161                },
162            },
163        },
164        vendor: {
165            exclude_srcs: libbinder_device_interface_sources,
166        },
167        darwin: {
168            enabled: false,
169        },
170    },
171
172    aidl: {
173        export_aidl_headers: true,
174    },
175
176    // TODO(b/142684679): for com.android.media which is compiled
177    // as vendor and used as system code.
178    use_apex_name_macro: true,
179
180    cflags: [
181        "-Wall",
182        "-Wextra",
183        "-Wextra-semi",
184        "-Werror",
185        "-Wzero-as-null-pointer-constant",
186        "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
187        "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION",
188    ],
189    product_variables: {
190        binder32bit: {
191            cflags: ["-DBINDER_IPC_32BIT=1"],
192        },
193    },
194
195    shared_libs: [
196        "liblog",
197        "libcutils",
198        "libutils",
199    ],
200
201    header_libs: [
202        "libbinder_headers",
203    ],
204
205    export_header_lib_headers: [
206        "libbinder_headers",
207    ],
208
209    clang: true,
210    sanitize: {
211        misc_undefined: ["integer"],
212    },
213    min_sdk_version: "29",
214
215    tidy: true,
216    tidy_flags: [
217        // Only check our headers
218        "--header-filter=^.*frameworks/native/libs/binder/.*.h$",
219    ],
220    tidy_checks: [
221        "-performance-no-int-to-ptr",
222    ],
223    tidy_checks_as_errors: [
224        // Explicitly list the checks that should not occur in this module.
225        "abseil-*",
226        "android-*",
227        "bugprone-*",
228        "cert-*",
229        "clang-analyzer-*",
230        "google-*",
231        "misc-*",
232        "performance*",
233        "portability*",
234    ],
235}
236
237// AIDL interface between libbinder and framework.jar
238filegroup {
239    name: "libbinder_aidl",
240    srcs: [
241        "aidl/android/os/IClientCallback.aidl",
242        "aidl/android/os/IServiceCallback.aidl",
243        "aidl/android/os/IServiceManager.aidl",
244        "aidl/android/os/ServiceDebugInfo.aidl",
245    ],
246    path: "aidl",
247}
248
249filegroup {
250    name: "packagemanager_aidl",
251    srcs: [
252        "aidl/android/content/pm/IPackageChangeObserver.aidl",
253        "aidl/android/content/pm/IPackageManagerNative.aidl",
254        "aidl/android/content/pm/PackageChangeEvent.aidl",
255    ],
256    path: "aidl",
257}
258
259aidl_interface {
260    name: "libbinder_aidl_test_stub",
261    unstable: true,
262    local_include_dir: "aidl",
263    srcs: [":libbinder_aidl"],
264    vendor_available: true,
265    backend: {
266        java: {
267            enabled: false,
268        },
269    },
270}
271
272// libbinder historically contained additional interfaces that provided specific
273// functionality in the platform but have nothing to do with binder itself. These
274// are moved out of libbinder in order to avoid the overhead of their vtables.
275// If you are working on or own one of these interfaces, the responsible things
276// to would be:
277// - give them a new home
278// - convert them to AIDL instead of having manually written parceling code
279
280cc_library {
281    name: "libbatterystats_aidl",
282    srcs: [
283        "IBatteryStats.cpp",
284    ],
285    export_include_dirs: ["include_batterystats"],
286    shared_libs: [
287        "libbinder",
288        "libutils",
289    ],
290}
291
292cc_library {
293    name: "libprocessinfoservice_aidl",
294    srcs: [
295        "IProcessInfoService.cpp",
296        "ProcessInfoService.cpp",
297    ],
298    export_include_dirs: ["include_processinfo"],
299    shared_libs: [
300        "libbinder",
301        "libutils",
302        "liblog",
303    ],
304}
305
306cc_library {
307    name: "libactivitymanager_aidl",
308    srcs: [
309        "ActivityManager.cpp",
310        "IActivityManager.cpp",
311        "IUidObserver.cpp",
312        ":activity_manager_procstate_aidl",
313    ],
314    export_include_dirs: ["include_activitymanager"],
315    shared_libs: [
316        "libbinder",
317        "libutils",
318        "liblog",
319    ],
320    aidl: {
321        export_aidl_headers: true,
322    },
323}
324