• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-combined",
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
241soong_config_module_type {
242    name: "system_java_library",
243    module_type: "java_library",
244    config_namespace: "system_services",
245    variables: ["without_hal"],
246    properties: ["vintf_fragment_modules"],
247}
248
249soong_config_string_variable {
250    name: "without_hal",
251    values: [
252        "vibrator",
253        "devicestate",
254    ],
255}
256
257vintf_fragment {
258    name: "manifest_services_android.frameworks.location.xml",
259    src: "manifest_services_android.frameworks.location.xml",
260}
261
262vintf_fragment {
263    name: "manifest_services_android.frameworks.vibrator.xml",
264    src: "manifest_services_android.frameworks.vibrator.xml",
265}
266
267vintf_fragment {
268    name: "manifest_services_android.frameworks.devicestate.xml",
269    src: "manifest_services_android.frameworks.devicestate.xml",
270}
271
272// merge all required services into one intermediate jar
273// ============================================================
274java_library {
275    name: "services.impl",
276    defaults: [
277        "services_crashrecovery_stubs_conditionally",
278        "ondeviceintelligence_conditionally",
279    ],
280
281    exclude_kotlinc_generated_files: true,
282    optimize: {
283        d8_on_eng: true,
284    },
285
286    srcs: [":services-main-sources"],
287
288    // The convention is to name each service module 'services.$(module_name)'
289    static_libs: [
290        "services.core",
291        "services.accessibility",
292        "services.appprediction",
293        "services.appwidget",
294        "services.autofill",
295        "services.backup",
296        "services.companion",
297        "services.appfunctions",
298        "services.contentcapture",
299        "services.contentsuggestions",
300        "services.contextualsearch",
301        "services.coverage",
302        "services.credentials",
303        "services.devicepolicy",
304        "services.flags",
305        "services.midi",
306        "services.musicsearch",
307        "services.net",
308        "services.people",
309        "services.permission",
310        "services.print",
311        "services.profcollect",
312        "services.restrictions",
313        "services.searchui",
314        "services.smartspace",
315        "services.soundtrigger",
316        "services.supervision",
317        "services.systemcaptions",
318        "services.translation",
319        "services.texttospeech",
320        "services.usage",
321        "services.usb",
322        "services.voiceinteraction",
323        "services.wallpapereffectsgeneration",
324        "services.wifi",
325        "service-blobstore",
326        "service-jobscheduler",
327        "android.hidl.base-V1.0-java",
328    ] + select(release_flag("RELEASE_MOVE_VCN_TO_MAINLINE"), {
329        true: [],
330        default: ["service-connectivity-b-platform"],
331    }),
332
333    libs: [
334        "android.hidl.manager-V1.0-java",
335        "framework-tethering.stubs.module_lib",
336        "keepanno-annotations",
337        "service-art.stubs.system_server",
338        "service-permission.stubs.system_server",
339        "service-rkp.stubs.system_server",
340        "service-sdksandbox.stubs.system_server",
341    ],
342
343    // Uncomment to enable output of certain warnings (deprecated, unchecked)
344    //javacflags: ["-Xlint"],
345
346    visibility: [
347        ":__subpackages__",
348        "//frameworks/opt:__subpackages__",
349    ],
350}
351
352// merge all required services into one final installable jar
353// ============================================================
354system_java_library {
355    name: "services",
356    defaults: [
357        "services_java_defaults",
358        "art_profile_java_defaults",
359    ],
360    installable: true,
361
362    exclude_kotlinc_generated_files: true,
363
364    // Note: all srcs and static_libs deps should go in services.impl.
365    static_libs: ["services.impl"],
366
367    soong_config_variables: {
368        without_hal: {
369            vibrator: {
370                vintf_fragment_modules: [
371                    "manifest_services_android.frameworks.location.xml",
372                    "manifest_services_android.frameworks.devicestate.xml",
373                ],
374            },
375            devicestate: {
376                vintf_fragment_modules: [
377                    "manifest_services_android.frameworks.location.xml",
378                    "manifest_services_android.frameworks.vibrator.xml",
379                ],
380            },
381            conditions_default: {
382                vintf_fragment_modules: [
383                    "manifest_services_android.frameworks.location.xml",
384                    "manifest_services_android.frameworks.vibrator.xml",
385                    "manifest_services_android.frameworks.devicestate.xml",
386                ],
387            },
388        },
389    },
390
391    required: [
392        "libukey2_jni_shared",
393        "protolog.conf.json.gz",
394        "core.protolog.pb",
395    ],
396    lint: {
397        baseline_filename: "lint-baseline.xml",
398    },
399
400    // Uncomment to enable output of certain warnings (deprecated, unchecked)
401    //javacflags: ["-Xlint"],
402}
403
404// native library
405// =============================================================
406
407cc_library_shared {
408    name: "libandroid_servers",
409    defaults: ["libservices.core-libs"],
410    whole_static_libs: ["libservices.core"],
411}
412
413platform_compat_config {
414    name: "services-platform-compat-config",
415    src: ":services",
416}
417
418genrule {
419    name: "art-profile-combined",
420    srcs: [
421        "art-profile",
422        "art-profile-extra",
423    ],
424    out: ["art-profile-combined"],
425    cmd: "cat $(location art-profile) $(location art-profile-extra) > $(location art-profile-combined)",
426}
427
428// API stub
429// =============================================================
430
431soong_config_module_type_import {
432    from: "frameworks/base/api/Android.bp",
433    module_types: ["non_updatable_exportable_droidstubs"],
434}
435
436stubs_defaults {
437    name: "services-stubs-default",
438    installable: false,
439    flags: [
440        "--show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.SYSTEM_SERVER\\)",
441        "--hide-annotation android.annotation.Hide",
442        "--hide InternalClasses", // com.android.* classes are okay in this interface
443        // TODO: remove the --hide options below
444        "--hide DeprecationMismatch",
445        "--hide HiddenTypedefConstant",
446    ],
447    visibility: ["//frameworks/base:__subpackages__"],
448    filter_packages: ["com.android."],
449}
450
451non_updatable_exportable_droidstubs {
452    name: "services-non-updatable-stubs",
453    srcs: [":services-non-updatable-sources"],
454    defaults: [
455        "services-stubs-default",
456    ],
457    check_api: {
458        current: {
459            api_file: "api/current.txt",
460            removed_api_file: "api/removed.txt",
461        },
462        api_lint: {
463            enabled: true,
464            new_since: ":android-non-updatable.api.system-server.latest",
465            baseline_file: "api/lint-baseline.txt",
466        },
467    },
468    soong_config_variables: {
469        release_hidden_api_exportable_stubs: {
470            dists: [
471                {
472                    targets: ["sdk"],
473                    dir: "apistubs/android/system-server/api",
474                    dest: "android-non-updatable.txt",
475                    tag: ".exportable.api.txt",
476                },
477                {
478                    targets: ["sdk"],
479                    dir: "apistubs/android/system-server/api",
480                    dest: "android-non-updatable-removed.txt",
481                    tag: ".exportable.removed-api.txt",
482                },
483            ],
484            conditions_default: {
485                dists: [
486                    {
487                        targets: ["sdk"],
488                        dir: "apistubs/android/system-server/api",
489                        dest: "android-non-updatable.txt",
490                        tag: ".api.txt",
491                    },
492                    {
493                        targets: ["sdk"],
494                        dir: "apistubs/android/system-server/api",
495                        dest: "android-non-updatable-removed.txt",
496                        tag: ".removed-api.txt",
497                    },
498                ],
499            },
500        },
501    },
502    api_surface: "system-server",
503    sdk_version: "module_current",
504    libs: [
505        "framework-annotations-lib",
506    ],
507}
508