• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright (C) 2019 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
15// How stubs are generated:
16//
17// raw source files --(metalava)--> stub source files --(javac)--> stub jar files
18//
19// - The metalava conversion is done by droidstub modules
20// - The javac compilation is done by java_library modules
21//
22// The metalava conversion is also responsible for creating API signature files
23// and comparing them against the checked in API signature, and also checking compatibility
24// with the latest frozen API signature.
25
26/////////////////////////////////////////////////////////////////////
27// These modules provide source files for the stub libraries
28/////////////////////////////////////////////////////////////////////
29
30droidstubs {
31    name: "api-stubs-docs-non-updatable",
32    defaults: [
33        "android-non-updatable-stubs-defaults",
34        "module-classpath-stubs-defaults",
35    ],
36    args: metalava_framework_docs_args,
37    check_api: {
38        current: {
39            api_file: ":non-updatable-current.txt",
40            removed_api_file: ":non-updatable-removed.txt",
41        },
42        last_released: {
43            api_file: ":android-non-updatable.api.public.latest",
44            removed_api_file: ":android-non-updatable-removed.api.public.latest",
45            baseline_file: ":android-non-updatable-incompatibilities.api.public.latest",
46        },
47        api_lint: {
48            enabled: true,
49            new_since: ":android.api.public.latest",
50        },
51    },
52    dists: [
53        {
54            targets: ["sdk"],
55            dir: "apistubs/android/public/api",
56            dest: "android-non-updatable.txt",
57            tag: ".api.txt",
58        },
59        {
60            targets: ["sdk"],
61            dir: "apistubs/android/public/api",
62            dest: "android-non-updatable-removed.txt",
63            tag: ".removed-api.txt",
64        },
65    ],
66}
67
68priv_apps = " --show-annotation android.annotation.SystemApi\\(" +
69    "client=android.annotation.SystemApi.Client.PRIVILEGED_APPS" +
70    "\\)"
71
72priv_apps_in_stubs = " --show-for-stub-purposes-annotation android.annotation.SystemApi\\(" +
73    "client=android.annotation.SystemApi.Client.PRIVILEGED_APPS" +
74    "\\)"
75
76test = " --show-annotation android.annotation.TestApi"
77
78module_libs = " --show-annotation android.annotation.SystemApi\\(" +
79    "client=android.annotation.SystemApi.Client.MODULE_LIBRARIES" +
80    "\\)"
81
82droidstubs {
83    name: "system-api-stubs-docs-non-updatable",
84    defaults: [
85        "android-non-updatable-stubs-defaults",
86        "module-classpath-stubs-defaults",
87    ],
88    args: metalava_framework_docs_args + priv_apps,
89    check_api: {
90        current: {
91            api_file: ":non-updatable-system-current.txt",
92            removed_api_file: ":non-updatable-system-removed.txt",
93        },
94        last_released: {
95            api_file: ":android-non-updatable.api.system.latest",
96            removed_api_file: ":android-non-updatable-removed.api.system.latest",
97            baseline_file: ":android-non-updatable-incompatibilities.api.system.latest",
98        },
99        api_lint: {
100            enabled: true,
101            new_since: ":android.api.system.latest",
102            baseline_file: ":non-updatable-system-lint-baseline.txt",
103        },
104    },
105    dists: [
106        {
107            targets: ["sdk"],
108            dir: "apistubs/android/system/api",
109            dest: "android-non-updatable.txt",
110            tag: ".api.txt",
111        },
112        {
113            targets: ["sdk"],
114            dir: "apistubs/android/system/api",
115            dest: "android-non-updatable-removed.txt",
116            tag: ".removed-api.txt",
117        },
118    ],
119}
120
121droidstubs {
122    name: "test-api-stubs-docs-non-updatable",
123    defaults: [
124        "android-non-updatable-stubs-defaults",
125        "module-classpath-stubs-defaults",
126    ],
127    args: metalava_framework_docs_args + test + priv_apps_in_stubs,
128    check_api: {
129        current: {
130            api_file: ":non-updatable-test-current.txt",
131            removed_api_file: ":non-updatable-test-removed.txt",
132        },
133        api_lint: {
134            enabled: true,
135            baseline_file: ":non-updatable-test-lint-baseline.txt",
136        },
137    },
138    dists: [
139        {
140            targets: ["sdk"],
141            dir: "apistubs/android/test/api",
142            dest: "android.txt",
143            tag: ".api.txt",
144        },
145        {
146            targets: ["sdk"],
147            dir: "apistubs/android/test/api",
148            dest: "removed.txt",
149            tag: ".removed-api.txt",
150        },
151        {
152            targets: ["sdk"],
153            dir: "apistubs/android/test/api",
154            dest: "android-non-updatable.txt",
155            tag: ".api.txt",
156        },
157        {
158            targets: ["sdk"],
159            dir: "apistubs/android/test/api",
160            dest: "android-non-updatable-removed.txt",
161            tag: ".removed-api.txt",
162        },
163    ],
164}
165
166droidstubs {
167    name: "module-lib-api-stubs-docs-non-updatable",
168    defaults: [
169        "android-non-updatable-stubs-defaults",
170        "module-classpath-stubs-defaults",
171    ],
172    args: metalava_framework_docs_args + priv_apps_in_stubs + module_libs,
173    check_api: {
174        current: {
175            api_file: ":non-updatable-module-lib-current.txt",
176            removed_api_file: ":non-updatable-module-lib-removed.txt",
177        },
178        last_released: {
179            api_file: ":android-non-updatable.api.module-lib.latest",
180            removed_api_file: ":android-non-updatable-removed.api.module-lib.latest",
181            baseline_file: ":android-non-updatable-incompatibilities.api.module-lib.latest",
182        },
183        api_lint: {
184            enabled: true,
185            new_since: ":android.api.module-lib.latest",
186            baseline_file: ":non-updatable-module-lib-lint-baseline.txt",
187        },
188    },
189    dists: [
190        {
191            targets: ["sdk"],
192            dir: "apistubs/android/module-lib/api",
193            dest: "android-non-updatable.txt",
194            tag: ".api.txt",
195        },
196        {
197            targets: ["sdk"],
198            dir: "apistubs/android/module-lib/api",
199            dest: "android-non-updatable-removed.txt",
200            tag: ".removed-api.txt",
201        },
202    ],
203}
204
205/////////////////////////////////////////////////////////////////////
206// android_*_stubs_current modules are the stubs libraries compiled
207// from stub sources
208/////////////////////////////////////////////////////////////////////
209
210java_defaults {
211    name: "android.jar_defaults",
212    sdk_version: "none",
213    system_modules: "none",
214    java_version: "1.8",
215    compile_dex: true,
216    defaults_visibility: ["//visibility:private"],
217    visibility: ["//visibility:public"],
218}
219
220java_defaults {
221    name: "android-non-updatable_defaults_stubs_current",
222    libs: ["stub-annotations"],
223    static_libs: ["framework-res-package-jar"], // Export package of framework-res
224    sdk_version: "none",
225    system_modules: "none",
226    java_version: "1.8",
227    compile_dex: true,
228    dist: {
229        targets: ["sdk"],
230        tag: ".jar",
231        dest: "android-non-updatable.jar",
232    },
233    defaults_visibility: ["//visibility:private"],
234    visibility: ["//visibility:private"],
235}
236
237java_library {
238    name: "android-non-updatable.stubs",
239    defaults: ["android-non-updatable_defaults_stubs_current"],
240    srcs: [":api-stubs-docs-non-updatable"],
241    libs: ["all-modules-public-stubs"],
242    dist: {
243        dir: "apistubs/android/public",
244    },
245}
246
247java_library {
248    name: "android-non-updatable.stubs.system",
249    defaults: ["android-non-updatable_defaults_stubs_current"],
250    srcs: [":system-api-stubs-docs-non-updatable"],
251    libs: ["all-modules-system-stubs"],
252    dist: {
253        dir: "apistubs/android/system",
254    },
255}
256
257java_library {
258    name: "android-non-updatable.stubs.module_lib",
259    defaults: ["android-non-updatable_defaults_stubs_current"],
260    srcs: [":module-lib-api-stubs-docs-non-updatable"],
261    libs: [
262        "sdk_module-lib_current_framework-tethering",
263        "sdk_module-lib_current_framework-connectivity-t",
264        "sdk_public_current_framework-bluetooth",
265        // NOTE: The below can be removed once the prebuilt stub contains bluetooth.
266        "sdk_system_current_android",
267        // NOTE: The below can be removed once the prebuilt stub contains IKE.
268        "sdk_system_current_android.net.ipsec.ike",
269    ],
270    dist: {
271        dir: "apistubs/android/module-lib",
272    },
273}
274
275java_library {
276    name: "android-non-updatable.stubs.test",
277    defaults: ["android-non-updatable_defaults_stubs_current"],
278    srcs: [":test-api-stubs-docs-non-updatable"],
279    libs: ["all-modules-system-stubs"],
280    dist: {
281        dir: "apistubs/android/test",
282    },
283}
284
285java_defaults {
286    name: "android_stubs_dists_default",
287    dist: {
288        targets: ["sdk"],
289        tag: ".jar",
290        dest: "android.jar",
291    },
292    defaults_visibility: ["//frameworks/base/services"],
293}
294
295java_library {
296    name: "android_stubs_current",
297    static_libs: [
298        "all-modules-public-stubs",
299        "android-non-updatable.stubs",
300        "private-stub-annotations-jar",
301    ],
302    defaults: ["android.jar_defaults"],
303}
304
305java_library {
306    name: "android_system_stubs_current",
307    static_libs: [
308        "all-modules-system-stubs",
309        "android-non-updatable.stubs.system",
310        "private-stub-annotations-jar",
311    ],
312    defaults: [
313        "android.jar_defaults",
314        "android_stubs_dists_default",
315    ],
316    dist: {
317        dir: "apistubs/android/system",
318    },
319    dists: [
320        {
321            // Legacy dist path
322            targets: ["sdk"],
323            tag: ".jar",
324            dest: "android_system.jar",
325        },
326    ],
327}
328
329java_library {
330    name: "android_test_stubs_current",
331    static_libs: [
332        // Updatable modules do not have test APIs, but we want to include their SystemApis, like we
333        // include the SystemApi of framework-non-updatable-sources.
334        "all-updatable-modules-system-stubs",
335        // Non-updatable modules on the other hand can have test APIs, so include their test-stubs.
336        "all-non-updatable-modules-test-stubs",
337        "android-non-updatable.stubs.test",
338        "private-stub-annotations-jar",
339    ],
340    defaults: [
341        "android.jar_defaults",
342        "android_stubs_dists_default",
343    ],
344    dist: {
345        dir: "apistubs/android/test",
346    },
347}
348
349java_library {
350    name: "android_module_lib_stubs_current",
351    defaults: [
352        "android.jar_defaults",
353        "android_stubs_dists_default",
354    ],
355    static_libs: [
356        "android-non-updatable.stubs.module_lib",
357        "art.module.public.api.stubs.module_lib",
358        "i18n.module.public.api.stubs",
359    ],
360    dist: {
361        dir: "apistubs/android/module-lib",
362    },
363}
364
365java_library {
366    name: "android_system_server_stubs_current",
367    defaults: [
368        "android.jar_defaults",
369        "android_stubs_dists_default",
370    ],
371    srcs: [":services-non-updatable-stubs"],
372    installable: false,
373    static_libs: [
374        "android_module_lib_stubs_current",
375    ],
376    dist: {
377        dir: "apistubs/android/system-server",
378    },
379}
380
381java_library {
382    name: "android_stubs_private_jar",
383    defaults: ["android.jar_defaults"],
384    visibility: [
385        "//visibility:override",
386        "//visibility:private",
387    ],
388    static_libs: [
389        "stable.core.platform.api.stubs",
390        "core-lambda-stubs-for-system-modules",
391        "core-generated-annotation-stubs",
392        "framework",
393        "ext",
394        "framework-res-package-jar",
395        // The order of this matters, it has to be last to provide a
396        // package-private androidx.annotation.RecentlyNonNull without
397        // overriding the public android.annotation.Nullable in framework.jar
398        // with its own package-private android.annotation.Nullable.
399        "private-stub-annotations-jar",
400    ],
401}
402
403java_genrule {
404    name: "android_stubs_private_hjar",
405    visibility: ["//visibility:private"],
406    srcs: [":android_stubs_private_jar{.hjar}"],
407    out: ["android_stubs_private.jar"],
408    cmd: "cp $(in) $(out)",
409}
410
411java_library {
412    name: "android_stubs_private",
413    defaults: ["android_stubs_dists_default"],
414    visibility: ["//visibility:private"],
415    sdk_version: "none",
416    system_modules: "none",
417    static_libs: ["android_stubs_private_hjar"],
418    dist: {
419        dir: "apistubs/android/private",
420    },
421}
422
423java_genrule {
424    name: "android_stubs_private_framework_aidl",
425    visibility: ["//visibility:private"],
426    tools: ["sdkparcelables"],
427    srcs: [":android_stubs_private"],
428    out: ["framework.aidl"],
429    cmd: "rm -f $(genDir)/framework.aidl.merged && " +
430        "for i in $(in); do " +
431        "  rm -f $(genDir)/framework.aidl.tmp && " +
432        "  $(location sdkparcelables) $$i $(genDir)/framework.aidl.tmp && " +
433        "  cat $(genDir)/framework.aidl.tmp >> $(genDir)/framework.aidl.merged; " +
434        "done && " +
435        "sort -u $(genDir)/framework.aidl.merged > $(out)",
436    dist: {
437        targets: ["sdk"],
438        dir: "apistubs/android/private",
439    },
440}
441
442////////////////////////////////////////////////////////////////////////
443// api-versions.xml generation, for public and system. This API database
444// also contains the android.test.* APIs.
445////////////////////////////////////////////////////////////////////////
446
447java_library {
448    name: "android_stubs_current_with_test_libs",
449    static_libs: [
450        "android_stubs_current",
451        "android.test.base.stubs",
452        "android.test.mock.stubs",
453        "android.test.runner.stubs",
454    ],
455    defaults: ["android.jar_defaults"],
456    visibility: [
457        "//visibility:override",
458        "//visibility:private",
459    ],
460}
461
462java_library {
463    name: "android_system_stubs_current_with_test_libs",
464    static_libs: [
465        "android_system_stubs_current",
466        "android.test.base.stubs.system",
467        "android.test.mock.stubs.system",
468        "android.test.runner.stubs.system",
469    ],
470    defaults: ["android.jar_defaults"],
471    visibility: [
472        "//visibility:override",
473        "//visibility:private",
474    ],
475}
476
477java_library {
478    name: "android_module_stubs_current_with_test_libs",
479    static_libs: [
480        "android_module_lib_stubs_current",
481        "android.test.base.stubs",
482        "android.test.mock.stubs",
483        "android.test.runner.stubs",
484    ],
485    defaults: ["android.jar_defaults"],
486    visibility: [
487        "//visibility:override",
488        "//visibility:private",
489    ],
490}
491
492java_library {
493    name: "android_system_server_stubs_current_with_test_libs",
494    static_libs: [
495        "android_system_server_stubs_current",
496        "android.test.base.stubs.system",
497        "android.test.mock.stubs.system",
498        "android.test.runner.stubs.system",
499    ],
500    defaults: ["android.jar_defaults"],
501    visibility: [
502        "//visibility:override",
503        "//visibility:private",
504    ],
505}
506
507droidstubs {
508    name: "api_versions_public",
509    srcs: [":android_stubs_current_with_test_libs{.jar}"],
510    generate_stubs: false,
511    api_levels_annotations_enabled: true,
512    api_levels_annotations_dirs: [
513        "sdk-dir",
514        "api-versions-jars-dir",
515    ],
516    api_levels_sdk_type: "public",
517    extensions_info_file: ":sdk-extensions-info",
518    visibility: ["//frameworks/base"],
519}
520
521droidstubs {
522    name: "api_versions_system",
523    srcs: [":android_system_stubs_current_with_test_libs{.jar}"],
524    generate_stubs: false,
525    api_levels_annotations_enabled: true,
526    api_levels_annotations_dirs: [
527        "sdk-dir",
528        "api-versions-jars-dir",
529    ],
530    api_levels_sdk_type: "system",
531    extensions_info_file: ":sdk-extensions-info",
532}
533
534// This module can be built with:
535// m out/soong/.intermediates/frameworks/base/api_versions_module_lib/android_common/metalava/api-versions.xml
536droidstubs {
537    name: "api_versions_module_lib",
538    srcs: [":android_module_stubs_current_with_test_libs{.jar}"],
539    generate_stubs: false,
540    api_levels_annotations_enabled: true,
541    // this only has the non-updatable portions of the module lib sdk,
542    // which can reference classes from updatable apexes, so remove references to them
543    // from this api_versions file.
544    flags: ["--remove-missing-class-references-in-api-levels"],
545    api_levels_annotations_dirs: [
546        "sdk-dir",
547        "api-versions-jars-dir",
548    ],
549    api_levels_sdk_type: "module-lib",
550    // extensions_info_file is purposefully omitted, because this module should just be
551    // the non-updatable portions of the sdk, and extension sdks are updatable.
552}
553
554droidstubs {
555    name: "api_versions_system_server",
556    srcs: [":android_system_server_stubs_current_with_test_libs{.jar}"],
557    generate_stubs: false,
558    api_levels_annotations_enabled: true,
559    // this only has the non-updatable portions of the system server sdk,
560    // which can reference classes from updatable apexes, so remove references to them
561    // from this api_versions file.
562    flags: ["--remove-missing-class-references-in-api-levels"],
563    api_levels_annotations_dirs: [
564        "sdk-dir",
565        "api-versions-jars-dir",
566    ],
567    api_levels_sdk_type: "system-server",
568    // extensions_info_file is purposefully omitted, because this module should just be
569    // the non-updatable portions of the sdk, and extension sdks are updatable.
570}
571
572/////////////////////////////////////////////////////////////////////
573// hwbinder.stubs provides APIs required for building HIDL Java
574// libraries.
575/////////////////////////////////////////////////////////////////////
576
577droidstubs {
578    name: "hwbinder-stubs-docs",
579    srcs: [":hwbinder-stubs-srcs"],
580    libs: ["framework-annotations-lib"],
581    installable: false,
582    sdk_version: "core_platform",
583    annotations_enabled: true,
584    previous_api: ":android.api.public.latest",
585    merge_annotations_dirs: [
586        "metalava-manual",
587    ],
588    args: priv_apps,
589    visibility: ["//visibility:private"],
590}
591
592java_library {
593    name: "hwbinder.stubs",
594    sdk_version: "core_current",
595    libs: ["framework-annotations-lib"],
596    srcs: [
597        ":hwbinder-stubs-docs",
598    ],
599    visibility: ["//visibility:public"],
600}
601