xref: /aosp_15_r20/frameworks/base/services/Android.bp (revision d57664e9bc4670b3ecf6748a746a57c557b6bc9e)
1package {
2    // See: http://go/android-license-faq
3    // A large-scale-change added 'default_applicable_licenses' to import
4    // all of the 'license_kinds' from "frameworks_base_license"
5    // to get the below license kinds:
6    //   SPDX-license-identifier-Apache-2.0
7    default_applicable_licenses: ["frameworks_base_license"],
8}
9
10// Defaults for platform code that runs inside system_server
11java_defaults {
12    name: "platform_service_defaults",
13    plugins: ["error_prone_android_framework"],
14    errorprone: {
15        javacflags: [
16            "-Xep:AndroidFrameworkCompatChange:ERROR",
17            // "-Xep:AndroidFrameworkUid:ERROR",
18            "-Xep:SelfEquals:ERROR",
19            "-Xep:NullTernary:ERROR",
20            "-Xep:TryFailThrowable:ERROR",
21            "-Xep:HashtableContains:ERROR",
22            "-Xep:FormatString:ERROR",
23            "-Xep:ArrayHashCode:ERROR",
24            "-Xep:SelfAssignment:ERROR",
25            "-Xep:ArrayEquals:ERROR",
26            "-Xep:IdentityBinaryExpression:ERROR",
27            // NOTE: only enable to generate local patchfiles
28            // "-XepPatchChecks:refaster:frameworks/base/errorprone/refaster/EfficientXml.java.refaster",
29            // "-XepPatchLocation:/tmp/refaster/",
30        ],
31    },
32    lint: {
33        extra_check_modules: ["AndroidFrameworkLintChecker"],
34    },
35}
36
37// Config to control optimizing and shrinking the services target using R8.
38// Set via `export SYSTEM_OPTIMIZE_JAVA=true|false`, or explicitly in Make via the
39// `SOONG_CONFIG_ANDROID_SYSTEM_OPTIMIZE_JAVA` variable.
40soong_config_module_type {
41    name: "system_optimized_java_defaults",
42    module_type: "java_defaults",
43    config_namespace: "ANDROID",
44    bool_variables: [
45        "SYSTEM_OPTIMIZE_JAVA",
46        "FULL_SYSTEM_OPTIMIZE_JAVA",
47    ],
48    properties: [
49        "optimize",
50        "dxflags",
51    ],
52}
53
54system_optimized_java_defaults {
55    name: "services_java_defaults",
56    soong_config_variables: {
57        SYSTEM_OPTIMIZE_JAVA: {
58            optimize: {
59                enabled: true,
60                // TODO(b/210510433): Enable optimizations after improving
61                // retracing infra.
62                // See also FULL_SYSTEM_OPTIMIZE_JAVA.
63                optimize: false,
64                shrink: true,
65                ignore_warnings: false,
66                proguard_compatibility: false,
67                proguard_flags_files: [
68                    "proguard.flags",
69                    // Ensure classes referenced in the framework-res manifest
70                    // and implemented in system_server are kept.
71                    ":framework-res{.aapt.proguardOptionsFile}",
72                ],
73            },
74            conditions_default: {
75                optimize: {
76                    enabled: true,
77                    optimize: false,
78                    shrink: true,
79                    ignore_warnings: false,
80                    // Note that this proguard config is very conservative, only shrinking the
81                    // permission subpackage to prune unused jarjar'ed Kotlin dependencies.
82                    proguard_flags_files: ["proguard_permission.flags"],
83                },
84                // Explicitly configure R8 to preserve debug info, as this path should
85                // really only allow stripping of permission-specific code and deps.
86                dxflags: ["--debug"],
87            },
88        },
89        // Allow form factors to opt-in full system java optimization
90        FULL_SYSTEM_OPTIMIZE_JAVA: {
91            optimize: {
92                optimize: true,
93            },
94        },
95    },
96}
97
98filegroup {
99    name: "services-main-sources",
100    srcs: [
101        "java/**/*.java",
102        "java/**/package.html",
103    ],
104    path: "java",
105    visibility: ["//visibility:private"],
106}
107
108filegroup {
109    name: "services-non-updatable-sources",
110    srcs: [
111        ":incremental_aidl",
112        ":services.core-aidl-sources",
113        ":services.core-sources",
114        ":services.core-sources-am-wm",
115        "core/java/com/android/server/am/package.html",
116        ":services.accessibility-sources",
117        ":services.appprediction-sources",
118        ":services.appwidget-sources",
119        ":services.autofill-sources",
120        ":services.backup-sources",
121        ":services.companion-sources",
122        ":services.contentcapture-sources",
123        ":services.appfunctions-sources",
124        ":services.contentsuggestions-sources",
125        ":services.contextualsearch-sources",
126        ":services.coverage-sources",
127        ":services.credentials-sources",
128        ":services.devicepolicy-sources",
129        ":services.midi-sources",
130        ":services.musicsearch-sources",
131        ":services.net-sources",
132        ":services.permission-sources",
133        ":services.print-sources",
134        ":services.profcollect-sources",
135        ":services.restrictions-sources",
136        ":services.searchui-sources",
137        ":services.smartspace-sources",
138        ":services.soundtrigger-sources",
139        ":services.supervision-sources",
140        ":services.systemcaptions-sources",
141        ":services.translation-sources",
142        ":services.texttospeech-sources",
143        ":services.usage-sources",
144        ":services.usb-sources",
145        ":services.voiceinteraction-sources",
146        ":services.wallpapereffectsgeneration-sources",
147        ":services.wifi-sources",
148        ":framework-pm-common-shared-srcs",
149    ],
150    visibility: ["//visibility:private"],
151}
152
153java_library {
154    name: "Slogf",
155    srcs: ["core/java/com/android/server/utils/Slogf.java"],
156}
157
158soong_config_module_type {
159    name: "art_profile_java_defaults",
160    module_type: "java_defaults",
161    config_namespace: "art_profile",
162    variables: ["services_profile_path"],
163    properties: ["dex_preopt"],
164}
165
166soong_config_string_variable {
167    name: "services_profile_path",
168    values: ["art_wear_profile"],
169}
170
171art_profile_java_defaults {
172    name: "art_profile_java_defaults",
173    soong_config_variables: {
174        services_profile_path: {
175            art_wear_profile: {
176                dex_preopt: {
177                    app_image: true,
178                    profile: "art-wear-profile",
179                },
180            },
181            conditions_default: {
182                dex_preopt: {
183                    app_image: true,
184                    profile: "art-profile",
185                },
186            },
187        },
188    },
189}
190
191// Conditionally add crashrecovery stubs library
192soong_config_module_type {
193    name: "crashrecovery_java_defaults",
194    module_type: "java_defaults",
195    config_namespace: "ANDROID",
196    bool_variables: [
197        "release_crashrecovery_module",
198    ],
199    properties: [
200        "libs",
201    ],
202}
203
204crashrecovery_java_defaults {
205    name: "services_crashrecovery_stubs_conditionally",
206    soong_config_variables: {
207        release_crashrecovery_module: {
208            libs: ["service-crashrecovery.stubs.system_server"],
209        },
210    },
211}
212
213soong_config_module_type {
214    name: "ondeviceintelligence_module_java_defaults",
215    module_type: "java_defaults",
216    config_namespace: "ANDROID",
217    bool_variables: [
218        "release_ondevice_intelligence_module",
219        "release_ondevice_intelligence_platform",
220    ],
221    properties: [
222        "libs",
223        "srcs",
224        "static_libs",
225    ],
226}
227
228// Conditionally add ondeviceintelligence stubs library
229ondeviceintelligence_module_java_defaults {
230    name: "ondeviceintelligence_conditionally",
231    soong_config_variables: {
232        release_ondevice_intelligence_module: {
233            libs: ["service-ondeviceintelligence.stubs.system_server"],
234        },
235        release_ondevice_intelligence_platform: {
236            srcs: [":service-ondeviceintelligence-sources-platform"],
237        },
238    },
239}
240
241// merge all required services into one jar
242// ============================================================
243soong_config_module_type {
244    name: "system_java_library",
245    module_type: "java_library",
246    config_namespace: "system_services",
247    bool_variables: ["without_vibrator"],
248    properties: ["vintf_fragment_modules"],
249}
250
251vintf_fragment {
252    name: "manifest_services.xml",
253    src: "manifest_services.xml",
254}
255
256vintf_fragment {
257    name: "manifest_services_android.frameworks.vibrator.xml",
258    src: "manifest_services_android.frameworks.vibrator.xml",
259}
260
261system_java_library {
262    name: "services",
263    defaults: [
264        "services_java_defaults",
265        "art_profile_java_defaults",
266        "services_crashrecovery_stubs_conditionally",
267        "ondeviceintelligence_conditionally",
268    ],
269    installable: true,
270
271    exclude_kotlinc_generated_files: true,
272
273    srcs: [":services-main-sources"],
274
275    // The convention is to name each service module 'services.$(module_name)'
276    static_libs: [
277        "services.core",
278        "services.accessibility",
279        "services.appprediction",
280        "services.appwidget",
281        "services.autofill",
282        "services.backup",
283        "services.companion",
284        "services.appfunctions",
285        "services.contentcapture",
286        "services.contentsuggestions",
287        "services.contextualsearch",
288        "services.coverage",
289        "services.credentials",
290        "services.devicepolicy",
291        "services.flags",
292        "services.midi",
293        "services.musicsearch",
294        "services.net",
295        "services.people",
296        "services.permission",
297        "services.print",
298        "services.profcollect",
299        "services.restrictions",
300        "services.searchui",
301        "services.smartspace",
302        "services.soundtrigger",
303        "services.supervision",
304        "services.systemcaptions",
305        "services.translation",
306        "services.texttospeech",
307        "services.usage",
308        "services.usb",
309        "services.voiceinteraction",
310        "services.wallpapereffectsgeneration",
311        "services.wifi",
312        "service-blobstore",
313        "service-jobscheduler",
314        "service-connectivity-b-pre-jarjar", // Move it to mainline module
315        "android.hidl.base-V1.0-java",
316    ],
317
318    libs: [
319        "android.hidl.manager-V1.0-java",
320        "framework-tethering.stubs.module_lib",
321        "keepanno-annotations",
322        "service-art.stubs.system_server",
323        "service-permission.stubs.system_server",
324        "service-rkp.stubs.system_server",
325        "service-sdksandbox.stubs.system_server",
326    ],
327
328    soong_config_variables: {
329        without_vibrator: {
330            vintf_fragment_modules: [
331                "manifest_services.xml",
332            ],
333            conditions_default: {
334                vintf_fragment_modules: [
335                    "manifest_services.xml",
336                    "manifest_services_android.frameworks.vibrator.xml",
337                ],
338            },
339        },
340    },
341
342    required: [
343        "libukey2_jni_shared",
344        "protolog.conf.json.gz",
345        "core.protolog.pb",
346    ],
347    lint: {
348        baseline_filename: "lint-baseline.xml",
349    },
350
351    // Uncomment to enable output of certain warnings (deprecated, unchecked)
352    //javacflags: ["-Xlint"],
353}
354
355// native library
356// =============================================================
357
358cc_library_shared {
359    name: "libandroid_servers",
360    defaults: ["libservices.core-libs"],
361    whole_static_libs: ["libservices.core"],
362}
363
364platform_compat_config {
365    name: "services-platform-compat-config",
366    src: ":services",
367}
368
369filegroup {
370    name: "art-profile",
371    srcs: ["art-profile"],
372}
373
374// API stub
375// =============================================================
376
377soong_config_module_type_import {
378    from: "frameworks/base/api/Android.bp",
379    module_types: ["non_updatable_exportable_droidstubs"],
380}
381
382stubs_defaults {
383    name: "services-stubs-default",
384    installable: false,
385    flags: [
386        "--show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.SYSTEM_SERVER\\)",
387        "--hide-annotation android.annotation.Hide",
388        "--hide InternalClasses", // com.android.* classes are okay in this interface
389        // TODO: remove the --hide options below
390        "--hide DeprecationMismatch",
391        "--hide HiddenTypedefConstant",
392    ],
393    visibility: ["//frameworks/base:__subpackages__"],
394    filter_packages: ["com.android."],
395}
396
397non_updatable_exportable_droidstubs {
398    name: "services-non-updatable-stubs",
399    srcs: [":services-non-updatable-sources"],
400    defaults: [
401        "services-stubs-default",
402    ],
403    check_api: {
404        current: {
405            api_file: "api/current.txt",
406            removed_api_file: "api/removed.txt",
407        },
408        api_lint: {
409            enabled: true,
410            new_since: ":android-non-updatable.api.system-server.latest",
411            baseline_file: "api/lint-baseline.txt",
412        },
413    },
414    soong_config_variables: {
415        release_hidden_api_exportable_stubs: {
416            dists: [
417                {
418                    targets: ["sdk"],
419                    dir: "apistubs/android/system-server/api",
420                    dest: "android-non-updatable.txt",
421                    tag: ".exportable.api.txt",
422                },
423                {
424                    targets: ["sdk"],
425                    dir: "apistubs/android/system-server/api",
426                    dest: "android-non-updatable-removed.txt",
427                    tag: ".exportable.removed-api.txt",
428                },
429            ],
430            conditions_default: {
431                dists: [
432                    {
433                        targets: ["sdk"],
434                        dir: "apistubs/android/system-server/api",
435                        dest: "android-non-updatable.txt",
436                        tag: ".api.txt",
437                    },
438                    {
439                        targets: ["sdk"],
440                        dir: "apistubs/android/system-server/api",
441                        dest: "android-non-updatable-removed.txt",
442                        tag: ".removed-api.txt",
443                    },
444                ],
445            },
446        },
447    },
448    api_surface: "system-server",
449    sdk_version: "module_current",
450    libs: [
451        "framework-annotations-lib",
452    ],
453}
454