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        ":services.core-sources",
112        ":services.core-sources-am-wm",
113        "core/java/com/android/server/am/package.html",
114        ":services.accessibility-sources",
115        ":services.appprediction-sources",
116        ":services.appwidget-sources",
117        ":services.autofill-sources",
118        ":services.backup-sources",
119        ":services.companion-sources",
120        ":services.contentcapture-sources",
121        ":services.contentsuggestions-sources",
122        ":services.contextualsearch-sources",
123        ":services.coverage-sources",
124        ":services.credentials-sources",
125        ":services.devicepolicy-sources",
126        ":services.midi-sources",
127        ":services.musicsearch-sources",
128        ":services.net-sources",
129        ":services.permission-sources",
130        ":services.print-sources",
131        ":services.profcollect-sources",
132        ":services.restrictions-sources",
133        ":services.searchui-sources",
134        ":services.smartspace-sources",
135        ":services.soundtrigger-sources",
136        ":services.systemcaptions-sources",
137        ":services.translation-sources",
138        ":services.texttospeech-sources",
139        ":services.usage-sources",
140        ":services.usb-sources",
141        ":services.voiceinteraction-sources",
142        ":services.wallpapereffectsgeneration-sources",
143        ":services.wifi-sources",
144        ":framework-pm-common-shared-srcs",
145    ],
146    visibility: ["//visibility:private"],
147}
148
149java_library {
150    name: "Slogf",
151    srcs: ["core/java/com/android/server/utils/Slogf.java"],
152}
153
154soong_config_module_type {
155    name: "art_profile_java_defaults",
156    module_type: "java_defaults",
157    config_namespace: "art_profile",
158    variables: ["services_profile_path"],
159    properties: ["dex_preopt"],
160}
161
162soong_config_string_variable {
163    name: "services_profile_path",
164    values: ["art_wear_profile"],
165}
166
167art_profile_java_defaults {
168    name: "art_profile_java_defaults",
169    soong_config_variables: {
170        services_profile_path: {
171            art_wear_profile: {
172                dex_preopt: {
173                    app_image: true,
174                    profile: "art-wear-profile",
175                },
176            },
177            conditions_default: {
178                dex_preopt: {
179                    app_image: true,
180                    profile: "art-profile",
181                },
182            },
183        },
184    },
185}
186
187// merge all required services into one jar
188// ============================================================
189java_library {
190    name: "services",
191    defaults: [
192        "services_java_defaults",
193        "art_profile_java_defaults",
194    ],
195    installable: true,
196
197    exclude_kotlinc_generated_files: true,
198
199    srcs: [":services-main-sources"],
200
201    // The convention is to name each service module 'services.$(module_name)'
202    static_libs: [
203        "services.core",
204        "services.accessibility",
205        "services.appprediction",
206        "services.appwidget",
207        "services.autofill",
208        "services.backup",
209        "services.companion",
210        "services.contentcapture",
211        "services.contentsuggestions",
212        "services.contextualsearch",
213        "services.coverage",
214        "services.credentials",
215        "services.devicepolicy",
216        "services.flags",
217        "services.midi",
218        "services.musicsearch",
219        "services.net",
220        "services.people",
221        "services.permission",
222        "services.print",
223        "services.profcollect",
224        "services.restrictions",
225        "services.searchui",
226        "services.smartspace",
227        "services.soundtrigger",
228        "services.systemcaptions",
229        "services.translation",
230        "services.texttospeech",
231        "services.usage",
232        "services.usb",
233        "services.voiceinteraction",
234        "services.wallpapereffectsgeneration",
235        "services.wifi",
236        "service-blobstore",
237        "service-jobscheduler",
238        "android.hidl.base-V1.0-java",
239    ],
240
241    libs: [
242        "android.hidl.manager-V1.0-java",
243        "framework-tethering.stubs.module_lib",
244        "keepanno-annotations",
245        "service-art.stubs.system_server",
246        "service-permission.stubs.system_server",
247        "service-rkp.stubs.system_server",
248        "service-sdksandbox.stubs.system_server",
249    ],
250
251    vintf_fragments: [
252        "manifest_services.xml",
253    ],
254
255    required: [
256        "libukey2_jni_shared",
257        "protolog.conf.json.gz",
258        "core.protolog.pb",
259    ],
260    lint: {
261        baseline_filename: "lint-baseline.xml",
262    },
263
264    // Uncomment to enable output of certain warnings (deprecated, unchecked)
265    //javacflags: ["-Xlint"],
266}
267
268// native library
269// =============================================================
270
271cc_library_shared {
272    name: "libandroid_servers",
273    defaults: ["libservices.core-libs"],
274    whole_static_libs: ["libservices.core"],
275}
276
277platform_compat_config {
278    name: "services-platform-compat-config",
279    src: ":services",
280}
281
282filegroup {
283    name: "art-profile",
284    srcs: ["art-profile"],
285}
286
287// API stub
288// =============================================================
289
290soong_config_module_type_import {
291    from: "frameworks/base/api/Android.bp",
292    module_types: ["non_updatable_exportable_droidstubs"],
293}
294
295stubs_defaults {
296    name: "services-stubs-default",
297    installable: false,
298    flags: [
299        "--show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.SYSTEM_SERVER\\)",
300        "--hide-annotation android.annotation.Hide",
301        "--hide InternalClasses", // com.android.* classes are okay in this interface
302        // TODO: remove the --hide options below
303        "--hide DeprecationMismatch",
304        "--hide HiddenTypedefConstant",
305    ],
306    visibility: ["//frameworks/base:__subpackages__"],
307    filter_packages: ["com.android."],
308}
309
310non_updatable_exportable_droidstubs {
311    name: "services-non-updatable-stubs",
312    srcs: [":services-non-updatable-sources"],
313    defaults: [
314        "services-stubs-default",
315    ],
316    check_api: {
317        current: {
318            api_file: "api/current.txt",
319            removed_api_file: "api/removed.txt",
320        },
321        api_lint: {
322            enabled: true,
323            new_since: ":android-non-updatable.api.system-server.latest",
324            baseline_file: "api/lint-baseline.txt",
325        },
326    },
327    soong_config_variables: {
328        release_hidden_api_exportable_stubs: {
329            dists: [
330                {
331                    targets: ["sdk"],
332                    dir: "apistubs/android/system-server/api",
333                    dest: "android-non-updatable.txt",
334                    tag: ".exportable.api.txt",
335                },
336                {
337                    targets: ["sdk"],
338                    dir: "apistubs/android/system-server/api",
339                    dest: "android-non-updatable-removed.txt",
340                    tag: ".exportable.removed-api.txt",
341                },
342            ],
343            conditions_default: {
344                dists: [
345                    {
346                        targets: ["sdk"],
347                        dir: "apistubs/android/system-server/api",
348                        dest: "android-non-updatable.txt",
349                        tag: ".api.txt",
350                    },
351                    {
352                        targets: ["sdk"],
353                        dir: "apistubs/android/system-server/api",
354                        dest: "android-non-updatable-removed.txt",
355                        tag: ".removed-api.txt",
356                    },
357                ],
358            },
359        },
360    },
361    api_surface: "system-server",
362}
363