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// Opt-in config for optimizing and shrinking the services target using R8.
38// Enabled via `export SYSTEM_OPTIMIZE_JAVA=true`, or explicitly in Make via the
39// `SOONG_CONFIG_ANDROID_SYSTEM_OPTIMIZE_JAVA` variable.
40// TODO(b/196084106): Enable optimizations by default after stabilizing and
41// building out retrace infrastructure.
42soong_config_module_type {
43    name: "system_optimized_java_defaults",
44    module_type: "java_defaults",
45    config_namespace: "ANDROID",
46    bool_variables: ["SYSTEM_OPTIMIZE_JAVA"],
47    properties: ["optimize"],
48}
49
50system_optimized_java_defaults {
51    name: "services_java_defaults",
52    soong_config_variables: {
53        SYSTEM_OPTIMIZE_JAVA: {
54            optimize: {
55                enabled: true,
56                // TODO(b/210510433): Enable optimizations after improving
57                // retracing infra.
58                optimize: false,
59                shrink: true,
60                ignore_warnings: false,
61                proguard_flags_files: ["proguard.flags"],
62            },
63            conditions_default: {
64                optimize: {
65                    enabled: true,
66                    optimize: false,
67                    shrink: true,
68                    ignore_warnings: false,
69                    // Note that this proguard config is very conservative, only shrinking the
70                    // permission subpackage to prune unused jarjar'ed Kotlin dependencies.
71                    proguard_flags_files: ["proguard_permission.flags"],
72                },
73            },
74        },
75    },
76}
77
78filegroup {
79    name: "services-main-sources",
80    srcs: [
81        "java/**/*.java",
82        "java/**/package.html",
83    ],
84    path: "java",
85    visibility: ["//visibility:private"],
86}
87
88filegroup {
89    name: "services-non-updatable-sources",
90    srcs: [
91        ":services.core-sources",
92        ":services.core-sources-am-wm",
93        "core/java/com/android/server/am/package.html",
94        ":services.accessibility-sources",
95        ":services.appprediction-sources",
96        ":services.appwidget-sources",
97        ":services.autofill-sources",
98        ":services.backup-sources",
99        ":services.companion-sources",
100        ":services.contentcapture-sources",
101        ":services.contentsuggestions-sources",
102        ":services.coverage-sources",
103        ":services.credentials-sources",
104        ":services.devicepolicy-sources",
105        ":services.midi-sources",
106        ":services.musicsearch-sources",
107        ":services.net-sources",
108        ":services.permission-sources",
109        ":services.print-sources",
110        ":services.profcollect-sources",
111        ":services.restrictions-sources",
112        ":services.searchui-sources",
113        ":services.smartspace-sources",
114        ":services.soundtrigger-sources",
115        ":services.systemcaptions-sources",
116        ":services.translation-sources",
117        ":services.texttospeech-sources",
118        ":services.usage-sources",
119        ":services.usb-sources",
120        ":services.voiceinteraction-sources",
121        ":services.wallpapereffectsgeneration-sources",
122        ":services.wifi-sources",
123    ],
124    visibility: ["//visibility:private"],
125}
126
127java_library {
128    name: "Slogf",
129    srcs: ["core/java/com/android/server/utils/Slogf.java"],
130}
131
132// merge all required services into one jar
133// ============================================================
134java_library {
135    name: "services",
136    defaults: ["services_java_defaults"],
137    installable: true,
138
139    dex_preopt: {
140        app_image: true,
141        profile: "art-profile",
142    },
143    exclude_kotlinc_generated_files: true,
144
145    srcs: [":services-main-sources"],
146
147    // The convention is to name each service module 'services.$(module_name)'
148    static_libs: [
149        "services.core",
150        "services.accessibility",
151        "services.appprediction",
152        "services.appwidget",
153        "services.autofill",
154        "services.backup",
155        "services.companion",
156        "services.contentcapture",
157        "services.contentsuggestions",
158        "services.coverage",
159        "services.credentials",
160        "services.devicepolicy",
161        "services.flags",
162        "services.midi",
163        "services.musicsearch",
164        "services.net",
165        "services.people",
166        "services.permission",
167        "services.print",
168        "services.profcollect",
169        "services.restrictions",
170        "services.searchui",
171        "services.smartspace",
172        "services.soundtrigger",
173        "services.systemcaptions",
174        "services.translation",
175        "services.texttospeech",
176        "services.usage",
177        "services.usb",
178        "services.voiceinteraction",
179        "services.wallpapereffectsgeneration",
180        "services.wifi",
181        "service-blobstore",
182        "service-jobscheduler",
183        "android.hidl.base-V1.0-java",
184    ],
185
186    libs: [
187        "android.hidl.manager-V1.0-java",
188        "framework-tethering.stubs.module_lib",
189        "service-art.stubs.system_server",
190        "service-permission.stubs.system_server",
191        "service-rkp.stubs.system_server",
192        "service-sdksandbox.stubs.system_server",
193    ],
194
195    vintf_fragments: [
196        "manifest_services.xml",
197    ],
198
199    required: [
200        "libukey2_jni_shared",
201    ],
202
203    // Uncomment to enable output of certain warnings (deprecated, unchecked)
204    //javacflags: ["-Xlint"],
205}
206
207// native library
208// =============================================================
209
210cc_library_shared {
211    name: "libandroid_servers",
212    defaults: ["libservices.core-libs"],
213    whole_static_libs: ["libservices.core"],
214}
215
216platform_compat_config {
217    name: "services-platform-compat-config",
218    src: ":services",
219}
220
221filegroup {
222    name: "art-profile",
223    srcs: ["art-profile"],
224}
225
226// API stub
227// =============================================================
228
229stubs_defaults {
230    name: "services-stubs-default",
231    installable: false,
232    args: " --show-annotation android.annotation.SystemApi\\(client=android.annotation.SystemApi.Client.SYSTEM_SERVER\\)" +
233        " --hide-annotation android.annotation.Hide" +
234        " --hide InternalClasses" + // com.android.* classes are okay in this interface
235        // TODO: remove the --hide options below
236        " --hide DeprecationMismatch" +
237        " --hide HiddenTypedefConstant",
238    visibility: ["//frameworks/base:__subpackages__"],
239    filter_packages: ["com.android."],
240}
241
242droidstubs {
243    name: "services-non-updatable-stubs",
244    srcs: [":services-non-updatable-sources"],
245    defaults: ["services-stubs-default"],
246    check_api: {
247        current: {
248            api_file: "api/current.txt",
249            removed_api_file: "api/removed.txt",
250        },
251        api_lint: {
252            enabled: true,
253            new_since: ":android-non-updatable.api.system-server.latest",
254            baseline_file: "api/lint-baseline.txt",
255        },
256    },
257    dists: [
258        {
259            targets: ["sdk"],
260            dir: "apistubs/android/system-server/api",
261            dest: "android-non-updatable.txt",
262            tag: ".api.txt",
263        },
264        {
265            targets: ["sdk"],
266            dir: "apistubs/android/system-server/api",
267            dest: "android-non-updatable-removed.txt",
268            tag: ".removed-api.txt",
269        },
270    ],
271}
272