• 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
30soong_config_module_type_import {
31    from: "frameworks/base/api/Android.bp",
32    module_types: ["non_updatable_exportable_droidstubs"],
33}
34
35non_updatable_exportable_droidstubs {
36    name: "api-stubs-docs-non-updatable",
37    defaults: [
38        "android-non-updatable-stubs-defaults",
39        "module-classpath-stubs-defaults",
40    ],
41    check_api: {
42        current: {
43            api_file: ":non-updatable-current.txt",
44            removed_api_file: ":non-updatable-removed.txt",
45        },
46        last_released: {
47            api_file: ":android-non-updatable.api.combined.public.latest",
48            removed_api_file: ":android-non-updatable-removed.api.combined.public.latest",
49            baseline_file: ":android-non-updatable-incompatibilities.api.public.latest",
50        },
51        api_lint: {
52            enabled: true,
53            new_since: ":android.api.combined.public.latest",
54            baseline_file: ":non-updatable-lint-baseline.txt",
55        },
56    },
57    soong_config_variables: {
58        release_hidden_api_exportable_stubs: {
59            dists: [
60                {
61                    targets: ["sdk"],
62                    dir: "apistubs/android/public/api",
63                    dest: "android-non-updatable.txt",
64                    tag: ".exportable.api.txt",
65                },
66                {
67                    targets: ["sdk"],
68                    dir: "apistubs/android/public/api",
69                    dest: "android-non-updatable-removed.txt",
70                    tag: ".exportable.removed-api.txt",
71                },
72            ],
73            conditions_default: {
74                dists: [
75                    {
76                        targets: ["sdk"],
77                        dir: "apistubs/android/public/api",
78                        dest: "android-non-updatable.txt",
79                        tag: ".api.txt",
80                    },
81                    {
82                        targets: ["sdk"],
83                        dir: "apistubs/android/public/api",
84                        dest: "android-non-updatable-removed.txt",
85                        tag: ".removed-api.txt",
86                    },
87                ],
88            },
89        },
90    },
91    api_surface: "public",
92}
93
94priv_apps = [
95    "--show-annotation android.annotation.SystemApi\\(" +
96        "client=android.annotation.SystemApi.Client.PRIVILEGED_APPS" +
97        "\\)",
98]
99
100priv_apps_in_stubs = [
101    "--show-for-stub-purposes-annotation android.annotation.SystemApi\\(" +
102        "client=android.annotation.SystemApi.Client.PRIVILEGED_APPS" +
103        "\\)",
104]
105
106test = ["--show-annotation android.annotation.TestApi"]
107
108module_libs = [
109    "--show-annotation android.annotation.SystemApi\\(" +
110        "client=android.annotation.SystemApi.Client.MODULE_LIBRARIES" +
111        "\\)",
112]
113
114non_updatable_exportable_droidstubs {
115    name: "system-api-stubs-docs-non-updatable",
116    defaults: [
117        "android-non-updatable-stubs-defaults",
118        "module-classpath-stubs-defaults",
119    ],
120    flags: priv_apps,
121    check_api: {
122        current: {
123            api_file: ":non-updatable-system-current.txt",
124            removed_api_file: ":non-updatable-system-removed.txt",
125        },
126        last_released: {
127            api_file: ":android-non-updatable.api.combined.system.latest",
128            removed_api_file: ":android-non-updatable-removed.api.combined.system.latest",
129            baseline_file: ":android-non-updatable-incompatibilities.api.system.latest",
130        },
131        api_lint: {
132            enabled: true,
133            new_since: ":android.api.combined.system.latest",
134            baseline_file: ":non-updatable-system-lint-baseline.txt",
135        },
136    },
137    soong_config_variables: {
138        release_hidden_api_exportable_stubs: {
139            dists: [
140                {
141                    targets: ["sdk"],
142                    dir: "apistubs/android/system/api",
143                    dest: "android-non-updatable.txt",
144                    tag: ".exportable.api.txt",
145                },
146                {
147                    targets: ["sdk"],
148                    dir: "apistubs/android/system/api",
149                    dest: "android-non-updatable-removed.txt",
150                    tag: ".exportable.removed-api.txt",
151                },
152            ],
153            conditions_default: {
154                dists: [
155                    {
156                        targets: ["sdk"],
157                        dir: "apistubs/android/system/api",
158                        dest: "android-non-updatable.txt",
159                        tag: ".api.txt",
160                    },
161                    {
162                        targets: ["sdk"],
163                        dir: "apistubs/android/system/api",
164                        dest: "android-non-updatable-removed.txt",
165                        tag: ".removed-api.txt",
166                    },
167                ],
168            },
169        },
170    },
171    api_surface: "system",
172}
173
174non_updatable_exportable_droidstubs {
175    name: "test-api-stubs-docs-non-updatable",
176    defaults: [
177        "android-non-updatable-stubs-defaults",
178        "module-classpath-stubs-defaults",
179    ],
180    flags: test + priv_apps_in_stubs,
181    check_api: {
182        current: {
183            api_file: ":non-updatable-test-current.txt",
184            removed_api_file: ":non-updatable-test-removed.txt",
185        },
186        api_lint: {
187            enabled: true,
188            new_since: ":android.api.combined.test.latest",
189            baseline_file: ":non-updatable-test-lint-baseline.txt",
190        },
191    },
192    soong_config_variables: {
193        release_hidden_api_exportable_stubs: {
194            dists: [
195                {
196                    targets: ["sdk"],
197                    dir: "apistubs/android/test/api",
198                    dest: "android.txt",
199                    tag: ".exportable.api.txt",
200                },
201                {
202                    targets: ["sdk"],
203                    dir: "apistubs/android/test/api",
204                    dest: "removed.txt",
205                    tag: ".exportable.removed-api.txt",
206                },
207                {
208                    targets: ["sdk"],
209                    dir: "apistubs/android/test/api",
210                    dest: "android-non-updatable.txt",
211                    tag: ".exportable.api.txt",
212                },
213                {
214                    targets: ["sdk"],
215                    dir: "apistubs/android/test/api",
216                    dest: "android-non-updatable-removed.txt",
217                    tag: ".exportable.removed-api.txt",
218                },
219            ],
220            conditions_default: {
221                dists: [
222                    {
223                        targets: ["sdk"],
224                        dir: "apistubs/android/test/api",
225                        dest: "android.txt",
226                        tag: ".api.txt",
227                    },
228                    {
229                        targets: ["sdk"],
230                        dir: "apistubs/android/test/api",
231                        dest: "removed.txt",
232                        tag: ".removed-api.txt",
233                    },
234                    {
235                        targets: ["sdk"],
236                        dir: "apistubs/android/test/api",
237                        dest: "android-non-updatable.txt",
238                        tag: ".api.txt",
239                    },
240                    {
241                        targets: ["sdk"],
242                        dir: "apistubs/android/test/api",
243                        dest: "android-non-updatable-removed.txt",
244                        tag: ".removed-api.txt",
245                    },
246                ],
247            },
248        },
249    },
250    api_surface: "test",
251}
252
253non_updatable_exportable_droidstubs {
254    name: "module-lib-api-stubs-docs-non-updatable",
255    defaults: [
256        "android-non-updatable-stubs-defaults",
257        "module-classpath-stubs-defaults",
258    ],
259    flags: priv_apps_in_stubs + module_libs,
260    check_api: {
261        current: {
262            api_file: ":non-updatable-module-lib-current.txt",
263            removed_api_file: ":non-updatable-module-lib-removed.txt",
264        },
265        last_released: {
266            api_file: ":android-non-updatable.api.combined.module-lib.latest",
267            removed_api_file: ":android-non-updatable-removed.api.combined.module-lib.latest",
268            baseline_file: ":android-non-updatable-incompatibilities.api.module-lib.latest",
269        },
270        api_lint: {
271            enabled: true,
272            new_since: ":android.api.combined.module-lib.latest",
273            baseline_file: ":non-updatable-module-lib-lint-baseline.txt",
274        },
275    },
276    soong_config_variables: {
277        release_hidden_api_exportable_stubs: {
278            dists: [
279                {
280                    targets: ["sdk"],
281                    dir: "apistubs/android/module-lib/api",
282                    dest: "android-non-updatable.txt",
283                    tag: ".exportable.api.txt",
284                },
285                {
286                    targets: ["sdk"],
287                    dir: "apistubs/android/module-lib/api",
288                    dest: "android-non-updatable-removed.txt",
289                    tag: ".exportable.removed-api.txt",
290                },
291            ],
292            conditions_default: {
293                dists: [
294                    {
295                        targets: ["sdk"],
296                        dir: "apistubs/android/module-lib/api",
297                        dest: "android-non-updatable.txt",
298                        tag: ".api.txt",
299                    },
300                    {
301                        targets: ["sdk"],
302                        dir: "apistubs/android/module-lib/api",
303                        dest: "android-non-updatable-removed.txt",
304                        tag: ".removed-api.txt",
305                    },
306                ],
307            },
308        },
309    },
310    api_surface: "module-lib",
311}
312
313/////////////////////////////////////////////////////////////////////
314// android_*_stubs_current modules are the stubs libraries compiled
315// from stub sources
316/////////////////////////////////////////////////////////////////////
317
318java_defaults {
319    name: "android.jar_defaults",
320    sdk_version: "none",
321    system_modules: "none",
322    java_version: "1.8",
323    compile_dex: true,
324    visibility: ["//visibility:public"],
325    is_stubs_module: true,
326}
327
328java_defaults {
329    name: "android-non-updatable_defaults",
330    sdk_version: "none",
331    system_modules: "none",
332    java_version: "1.8",
333    compile_dex: true,
334    is_stubs_module: true,
335}
336
337java_defaults {
338    name: "android-non-updatable_from_source_defaults",
339    libs: ["stub-annotations"],
340    static_libs: ["framework-res-package-jar"], // Export package of framework-res
341}
342
343java_defaults {
344    name: "android-non-updatable_exportable_from_source_defaults",
345    dist: {
346        targets: ["sdk"],
347        tag: ".jar",
348        dest: "android-non-updatable.jar",
349    },
350}
351
352java_library {
353    name: "android-non-updatable.stubs",
354    defaults: ["android-non-updatable_defaults"],
355    static_libs: [
356        "android-non-updatable.stubs.from-source",
357    ],
358    product_variables: {
359        build_from_text_stub: {
360            static_libs: [
361                "android-non-updatable.stubs.from-text",
362            ],
363            exclude_static_libs: [
364                "android-non-updatable.stubs.from-source",
365            ],
366        },
367    },
368}
369
370java_library {
371    name: "android-non-updatable.stubs.exportable",
372    defaults: ["android-non-updatable_defaults"],
373    static_libs: [
374        "android-non-updatable.stubs.exportable.from-source",
375    ],
376}
377
378java_library {
379    name: "android-non-updatable.stubs.system",
380    defaults: ["android-non-updatable_defaults"],
381    static_libs: [
382        "android-non-updatable.stubs.system.from-source",
383    ],
384    product_variables: {
385        build_from_text_stub: {
386            static_libs: [
387                "android-non-updatable.stubs.system.from-text",
388            ],
389            exclude_static_libs: [
390                "android-non-updatable.stubs.system.from-source",
391            ],
392        },
393    },
394}
395
396java_library {
397    name: "android-non-updatable.stubs.exportable.system",
398    defaults: ["android-non-updatable_defaults"],
399    static_libs: [
400        "android-non-updatable.stubs.exportable.system.from-source",
401    ],
402}
403
404java_library {
405    name: "android-non-updatable.stubs.module_lib",
406    defaults: ["android-non-updatable_defaults"],
407    static_libs: [
408        "android-non-updatable.stubs.module_lib.from-source",
409    ],
410    product_variables: {
411        build_from_text_stub: {
412            static_libs: [
413                "android-non-updatable.stubs.module_lib.from-text",
414            ],
415            exclude_static_libs: [
416                "android-non-updatable.stubs.module_lib.from-source",
417            ],
418        },
419    },
420}
421
422java_library {
423    name: "android-non-updatable.stubs.exportable.module_lib",
424    defaults: ["android-non-updatable_defaults"],
425    static_libs: [
426        "android-non-updatable.stubs.exportable.module_lib.from-source",
427    ],
428}
429
430java_library {
431    name: "android-non-updatable.stubs.test",
432    defaults: ["android-non-updatable_defaults"],
433    static_libs: [
434        "android-non-updatable.stubs.test.from-source",
435    ],
436    product_variables: {
437        build_from_text_stub: {
438            static_libs: [
439                "android-non-updatable.stubs.test.from-text",
440            ],
441            exclude_static_libs: [
442                "android-non-updatable.stubs.test.from-source",
443            ],
444        },
445    },
446}
447
448java_library {
449    name: "android-non-updatable.stubs.exportable.test",
450    defaults: ["android-non-updatable_defaults"],
451    static_libs: [
452        "android-non-updatable.stubs.exportable.test.from-source",
453    ],
454}
455
456java_library {
457    name: "android-non-updatable.stubs.from-source",
458    defaults: [
459        "android-non-updatable_defaults",
460        "android-non-updatable_from_source_defaults",
461    ],
462    srcs: [":api-stubs-docs-non-updatable"],
463    libs: ["all-modules-public-stubs"],
464}
465
466java_library {
467    name: "android-non-updatable.stubs.exportable.from-source",
468    defaults: [
469        "android-non-updatable_defaults",
470        "android-non-updatable_from_source_defaults",
471        "android-non-updatable_exportable_from_source_defaults",
472    ],
473    srcs: [":api-stubs-docs-non-updatable{.exportable}"],
474    libs: ["all-modules-public-stubs"],
475    dist: {
476        dir: "apistubs/android/public",
477    },
478}
479
480java_library {
481    name: "android-non-updatable.stubs.system.from-source",
482    defaults: [
483        "android-non-updatable_defaults",
484        "android-non-updatable_from_source_defaults",
485    ],
486    srcs: [":system-api-stubs-docs-non-updatable"],
487    libs: ["all-modules-system-stubs"],
488}
489
490java_library {
491    name: "android-non-updatable.stubs.exportable.system.from-source",
492    defaults: [
493        "android-non-updatable_defaults",
494        "android-non-updatable_from_source_defaults",
495        "android-non-updatable_exportable_from_source_defaults",
496    ],
497    srcs: [":system-api-stubs-docs-non-updatable{.exportable}"],
498    libs: ["all-modules-system-stubs"],
499    dist: {
500        dir: "apistubs/android/system",
501    },
502}
503
504java_library {
505    name: "android-non-updatable.stubs.module_lib.from-source",
506    defaults: [
507        "android-non-updatable_defaults",
508        "android-non-updatable_from_source_defaults",
509    ],
510    srcs: [":module-lib-api-stubs-docs-non-updatable"],
511    libs: non_updatable_api_deps_on_modules,
512}
513
514java_library {
515    name: "android-non-updatable.stubs.exportable.module_lib.from-source",
516    defaults: [
517        "android-non-updatable_defaults",
518        "android-non-updatable_from_source_defaults",
519        "android-non-updatable_exportable_from_source_defaults",
520    ],
521    srcs: [":module-lib-api-stubs-docs-non-updatable{.exportable}"],
522    libs: non_updatable_api_deps_on_modules,
523    dist: {
524        dir: "apistubs/android/module-lib",
525    },
526}
527
528java_library {
529    name: "android-non-updatable.stubs.test.from-source",
530    defaults: [
531        "android-non-updatable_defaults",
532        "android-non-updatable_from_source_defaults",
533    ],
534    srcs: [":test-api-stubs-docs-non-updatable"],
535    libs: ["all-modules-system-stubs"],
536}
537
538java_library {
539    name: "android-non-updatable.stubs.exportable.test.from-source",
540    defaults: [
541        "android-non-updatable_defaults",
542        "android-non-updatable_from_source_defaults",
543        "android-non-updatable_exportable_from_source_defaults",
544    ],
545    srcs: [":test-api-stubs-docs-non-updatable{.exportable}"],
546    libs: ["all-modules-system-stubs"],
547    dist: {
548        dir: "apistubs/android/test",
549    },
550}
551
552java_defaults {
553    name: "android-non-updatable_from_text_defaults",
554    static_libs: ["framework-res-package-jar"],
555    libs: ["stub-annotations"],
556}
557
558java_defaults {
559    name: "android-non-updatable_everything_from_text_defaults",
560    defaults: [
561        "android-non-updatable_from_text_defaults",
562    ],
563    stubs_type: "everything",
564}
565
566java_api_library {
567    name: "android-non-updatable.stubs.from-text",
568    api_surface: "public",
569    api_contributions: [
570        "api-stubs-docs-non-updatable.api.contribution",
571    ],
572    defaults: ["android-non-updatable_everything_from_text_defaults"],
573    full_api_surface_stub: "android_stubs_current.from-text",
574}
575
576java_api_library {
577    name: "android-non-updatable.stubs.system.from-text",
578    api_surface: "system",
579    api_contributions: [
580        "api-stubs-docs-non-updatable.api.contribution",
581        "system-api-stubs-docs-non-updatable.api.contribution",
582    ],
583    defaults: ["android-non-updatable_everything_from_text_defaults"],
584    full_api_surface_stub: "android_system_stubs_current.from-text",
585}
586
587java_api_library {
588    name: "android-non-updatable.stubs.test.from-text",
589    api_surface: "test",
590    api_contributions: [
591        "api-stubs-docs-non-updatable.api.contribution",
592        "system-api-stubs-docs-non-updatable.api.contribution",
593        "test-api-stubs-docs-non-updatable.api.contribution",
594    ],
595    defaults: ["android-non-updatable_everything_from_text_defaults"],
596    full_api_surface_stub: "android_test_stubs_current.from-text",
597}
598
599java_api_library {
600    name: "android-non-updatable.stubs.module_lib.from-text",
601    api_surface: "module_lib",
602    api_contributions: [
603        "api-stubs-docs-non-updatable.api.contribution",
604        "system-api-stubs-docs-non-updatable.api.contribution",
605        "module-lib-api-stubs-docs-non-updatable.api.contribution",
606    ],
607    defaults: ["android-non-updatable_everything_from_text_defaults"],
608    full_api_surface_stub: "android_module_lib_stubs_current_full.from-text",
609}
610
611// This module generates a stub jar that is a union of the test and module lib
612// non-updatable api contributions. Modules should not depend on the stub jar
613// generated from this module, as this module is strictly used for hiddenapi only.
614java_api_library {
615    name: "android-non-updatable.stubs.test_module_lib",
616    api_surface: "module_lib",
617    api_contributions: [
618        "api-stubs-docs-non-updatable.api.contribution",
619        "system-api-stubs-docs-non-updatable.api.contribution",
620        "test-api-stubs-docs-non-updatable.api.contribution",
621        "module-lib-api-stubs-docs-non-updatable.api.contribution",
622    ],
623    defaults: ["android-non-updatable_everything_from_text_defaults"],
624    full_api_surface_stub: "android_test_module_lib_stubs_current.from-text",
625
626    // This module is only used for hiddenapi, and other modules should not
627    // depend on this module.
628    visibility: ["//visibility:private"],
629}
630
631java_defaults {
632    name: "android_stubs_dists_default",
633    dist: {
634        targets: ["sdk"],
635        tag: ".jar",
636        dest: "android.jar",
637    },
638    defaults_visibility: ["//frameworks/base/services"],
639}
640
641java_library {
642    name: "android_stubs_current.from-source",
643    static_libs: [
644        "all-modules-public-stubs",
645        "android-non-updatable.stubs",
646        "private-stub-annotations-jar",
647    ],
648    defaults: ["android.jar_defaults"],
649}
650
651java_library {
652    name: "android_stubs_current_exportable.from-source",
653    static_libs: [
654        "all-modules-public-stubs-exportable",
655        "android-non-updatable.stubs.exportable",
656        "private-stub-annotations-jar",
657    ],
658    defaults: ["android.jar_defaults"],
659}
660
661java_library {
662    name: "android_system_stubs_current.from-source",
663    static_libs: [
664        "all-modules-system-stubs",
665        "android-non-updatable.stubs.system",
666        "private-stub-annotations-jar",
667    ],
668    defaults: [
669        "android.jar_defaults",
670    ],
671    visibility: ["//frameworks/base/services"],
672}
673
674java_library {
675    name: "android_system_stubs_current_exportable.from-source",
676    static_libs: [
677        "all-modules-system-stubs-exportable",
678        "android-non-updatable.stubs.exportable.system",
679        "private-stub-annotations-jar",
680    ],
681    defaults: [
682        "android.jar_defaults",
683        "android_stubs_dists_default",
684    ],
685    dist: {
686        dir: "apistubs/android/system",
687    },
688    dists: [
689        {
690            // Legacy dist path
691            targets: ["sdk"],
692            tag: ".jar",
693            dest: "android_system.jar",
694        },
695    ],
696}
697
698java_library {
699    name: "android_test_stubs_current.from-source",
700    static_libs: [
701        // Updatable modules do not have test APIs, but we want to include their SystemApis, like we
702        // include the SystemApi of framework-non-updatable-sources.
703        "all-updatable-modules-system-stubs",
704        // Non-updatable modules on the other hand can have test APIs, so include their test-stubs.
705        "all-non-updatable-modules-test-stubs",
706        "android-non-updatable.stubs.test",
707        "private-stub-annotations-jar",
708    ],
709    defaults: [
710        "android.jar_defaults",
711    ],
712    visibility: ["//frameworks/base/services"],
713}
714
715java_library {
716    name: "android_test_stubs_current_exportable.from-source",
717    static_libs: [
718        // Updatable modules do not have test APIs, but we want to include their SystemApis, like we
719        // include the SystemApi of framework-non-updatable-sources.
720        "all-updatable-modules-system-stubs-exportable",
721        // Non-updatable modules on the other hand can have test APIs, so include their test-stubs.
722        "all-non-updatable-modules-test-stubs-exportable",
723        "android-non-updatable.stubs.exportable.test",
724        "private-stub-annotations-jar",
725    ],
726    defaults: [
727        "android.jar_defaults",
728        "android_stubs_dists_default",
729    ],
730    dist: {
731        dir: "apistubs/android/test",
732    },
733}
734
735// This module does not need to be copied to dist
736java_library {
737    name: "android_test_frameworks_core_stubs_current.from-source",
738    static_libs: [
739        "all-updatable-modules-system-stubs",
740        "android-non-updatable.stubs.test",
741    ],
742    defaults: [
743        "android.jar_defaults",
744    ],
745    visibility: ["//frameworks/base/services"],
746}
747
748java_library {
749    name: "android_module_lib_stubs_current.from-source",
750    defaults: [
751        "android.jar_defaults",
752    ],
753    static_libs: [
754        "android-non-updatable.stubs.module_lib",
755        "art.module.public.api.stubs.module_lib",
756        "i18n.module.public.api.stubs",
757    ],
758    visibility: ["//frameworks/base/services"],
759}
760
761java_library {
762    name: "android_module_lib_stubs_current_exportable.from-source",
763    defaults: [
764        "android.jar_defaults",
765        "android_stubs_dists_default",
766    ],
767    static_libs: [
768        "android-non-updatable.stubs.exportable.module_lib",
769        "art.module.public.api.stubs.exportable.module_lib",
770        "i18n.module.public.api.stubs.exportable",
771    ],
772    dist: {
773        dir: "apistubs/android/module-lib",
774    },
775}
776
777java_library {
778    name: "android_system_server_stubs_current.from-source",
779    defaults: [
780        "android.jar_defaults",
781    ],
782    srcs: [":services-non-updatable-stubs"],
783    installable: false,
784    static_libs: [
785        "android_module_lib_stubs_current.from-source",
786    ],
787    visibility: ["//frameworks/base/services"],
788}
789
790java_library {
791    name: "android_system_server_stubs_current_exportable.from-source",
792    defaults: [
793        "android.jar_defaults",
794        "android_stubs_dists_default",
795    ],
796    srcs: [":services-non-updatable-stubs{.exportable}"],
797    installable: false,
798    static_libs: [
799        "android_module_lib_stubs_current_exportable.from-source",
800    ],
801    dist: {
802        dir: "apistubs/android/system-server",
803    },
804}
805
806java_library {
807    name: "android_stubs_private_jar",
808    defaults: ["android.jar_defaults"],
809    visibility: [
810        "//visibility:override",
811        "//visibility:private",
812    ],
813    static_libs: [
814        "stable.core.platform.api.stubs",
815        "core-lambda-stubs-for-system-modules",
816        "core-generated-annotation-stubs",
817        "framework",
818        "ext",
819        "framework-res-package-jar",
820        // The order of this matters, it has to be last to provide a
821        // package-private androidx.annotation.RecentlyNonNull without
822        // overriding the public android.annotation.Nullable in framework.jar
823        // with its own package-private android.annotation.Nullable.
824        "private-stub-annotations-jar",
825    ],
826    is_stubs_module: true,
827}
828
829java_genrule {
830    name: "android_stubs_private_hjar",
831    srcs: [":android_stubs_private_jar{.hjar}"],
832    out: ["android_stubs_private.jar"],
833    cmd: "cp $(in) $(out)",
834}
835
836java_library {
837    name: "android_stubs_private",
838    defaults: ["android_stubs_dists_default"],
839    sdk_version: "none",
840    system_modules: "none",
841    static_libs: ["android_stubs_private_hjar"],
842    dist: {
843        // Add to private_api_stubs dist target for easier packaging by scripts. This module is
844        // useful for creating a platform SDK, which can be packaged in ANDROID_HOME and used from
845        // Gradle, allowing for development of platform apps that make use of hidden APIs.
846        targets: ["private_api_stubs"],
847        dir: "apistubs/android/private",
848    },
849}
850
851java_genrule {
852    name: "android_stubs_private_framework_aidl",
853    tools: ["sdkparcelables"],
854    srcs: [":android_stubs_private"],
855    out: ["framework.aidl"],
856    cmd: "rm -f $(genDir)/framework.aidl.merged && " +
857        "for i in $(in); do " +
858        "  rm -f $(genDir)/framework.aidl.tmp && " +
859        "  $(location sdkparcelables) $$i $(genDir)/framework.aidl.tmp && " +
860        "  cat $(genDir)/framework.aidl.tmp >> $(genDir)/framework.aidl.merged; " +
861        "done && " +
862        "sort -u $(genDir)/framework.aidl.merged > $(out)",
863    dist: {
864        targets: [
865            "sdk",
866            // Add to private_api_stubs dist target for easier packaging by scripts.
867            // See explanation in the "android_stubs_private" module above.
868            "private_api_stubs",
869        ],
870        dir: "apistubs/android/private",
871    },
872}
873
874//
875// Java API defaults and libraries for single tree build
876//
877
878java_defaults {
879    name: "stub-annotation-defaults",
880    libs: [
881        "stub-annotations",
882    ],
883    static_libs: [
884        // stub annotations do not contribute to the API surfaces but are statically
885        // linked in the stubs for API surfaces (see frameworks/base/StubLibraries.bp).
886        // This is because annotation processors insist on loading the classes for any
887        // annotations found, thus should exist inside android.jar.
888        "private-stub-annotations-jar",
889    ],
890    is_stubs_module: true,
891}
892
893// Listing of API domains contribution and dependencies per API surfaces
894java_defaults {
895    name: "android_test_stubs_current_contributions",
896    api_surface: "test",
897    api_contributions: [
898        "framework-virtualization.stubs.source.test.api.contribution",
899        "framework-location.stubs.source.test.api.contribution",
900    ],
901}
902
903java_defaults {
904    name: "android_test_frameworks_core_stubs_current_contributions",
905    api_surface: "test",
906    api_contributions: [
907        "test-api-stubs-docs-non-updatable.api.contribution",
908    ],
909}
910
911java_defaults {
912    name: "android_module_lib_stubs_current_contributions",
913    api_surface: "module-lib",
914    api_contributions: [
915        "api-stubs-docs-non-updatable.api.contribution",
916        "system-api-stubs-docs-non-updatable.api.contribution",
917        "module-lib-api-stubs-docs-non-updatable.api.contribution",
918        "art.module.public.api.stubs.source.api.contribution",
919        "art.module.public.api.stubs.source.system.api.contribution",
920        "art.module.public.api.stubs.source.module_lib.api.contribution",
921        "i18n.module.public.api.stubs.source.api.contribution",
922        "i18n.module.public.api.stubs.source.system.api.contribution",
923        "i18n.module.public.api.stubs.source.module_lib.api.contribution",
924    ],
925}
926
927// Java API library definitions per API surface
928java_api_library {
929    name: "android_stubs_current.from-text",
930    api_surface: "public",
931    defaults: [
932        // This module is dynamically created at frameworks/base/api/api.go
933        // instead of being written out, in order to minimize edits in the codebase
934        // when there is a change in the list of modules.
935        // that contributes to an api surface.
936        "android_stubs_current_contributions",
937        "stub-annotation-defaults",
938    ],
939    api_contributions: [
940        "api-stubs-docs-non-updatable.api.contribution",
941    ],
942    visibility: ["//visibility:public"],
943    enable_validation: false,
944    stubs_type: "everything",
945}
946
947java_api_library {
948    name: "android_system_stubs_current.from-text",
949    api_surface: "system",
950    defaults: [
951        "android_stubs_current_contributions",
952        "android_system_stubs_current_contributions",
953        "stub-annotation-defaults",
954    ],
955    api_contributions: [
956        "api-stubs-docs-non-updatable.api.contribution",
957        "system-api-stubs-docs-non-updatable.api.contribution",
958    ],
959    visibility: ["//visibility:public"],
960    enable_validation: false,
961    stubs_type: "everything",
962}
963
964java_api_library {
965    name: "android_test_stubs_current.from-text",
966    api_surface: "test",
967    defaults: [
968        "android_stubs_current_contributions",
969        "android_system_stubs_current_contributions",
970        "android_test_stubs_current_contributions",
971        "stub-annotation-defaults",
972    ],
973    api_contributions: [
974        "api-stubs-docs-non-updatable.api.contribution",
975        "system-api-stubs-docs-non-updatable.api.contribution",
976        "test-api-stubs-docs-non-updatable.api.contribution",
977    ],
978    visibility: ["//visibility:public"],
979    enable_validation: false,
980    stubs_type: "everything",
981}
982
983java_api_library {
984    name: "android_test_frameworks_core_stubs_current.from-text",
985    api_surface: "test",
986    defaults: [
987        "android_stubs_current_contributions",
988        "android_system_stubs_current_contributions",
989        "android_test_frameworks_core_stubs_current_contributions",
990    ],
991    libs: [
992        "stub-annotations",
993    ],
994    api_contributions: [
995        "api-stubs-docs-non-updatable.api.contribution",
996        "system-api-stubs-docs-non-updatable.api.contribution",
997    ],
998    enable_validation: false,
999    stubs_type: "everything",
1000}
1001
1002java_api_library {
1003    name: "android_module_lib_stubs_current_full.from-text",
1004    api_surface: "module-lib",
1005    defaults: [
1006        "android_stubs_current_contributions",
1007        "android_system_stubs_current_contributions",
1008        "android_module_lib_stubs_current_contributions_full",
1009    ],
1010    libs: [
1011        "stub-annotations",
1012    ],
1013    api_contributions: [
1014        "api-stubs-docs-non-updatable.api.contribution",
1015        "system-api-stubs-docs-non-updatable.api.contribution",
1016        "module-lib-api-stubs-docs-non-updatable.api.contribution",
1017    ],
1018    visibility: ["//visibility:public"],
1019    enable_validation: false,
1020    stubs_type: "everything",
1021}
1022
1023java_api_library {
1024    name: "android_module_lib_stubs_current.from-text",
1025    api_surface: "module-lib",
1026    defaults: [
1027        "android_module_lib_stubs_current_contributions",
1028    ],
1029    libs: [
1030        "android_module_lib_stubs_current_full.from-text",
1031        "stub-annotations",
1032    ],
1033    visibility: ["//visibility:public"],
1034    enable_validation: false,
1035    stubs_type: "everything",
1036}
1037
1038java_api_library {
1039    name: "android_test_module_lib_stubs_current.from-text",
1040    api_surface: "module-lib",
1041    defaults: [
1042        "android_stubs_current_contributions",
1043        "android_system_stubs_current_contributions",
1044        "android_test_stubs_current_contributions",
1045        "android_module_lib_stubs_current_contributions",
1046    ],
1047    libs: [
1048        "android_module_lib_stubs_current_full.from-text",
1049        "stub-annotations",
1050    ],
1051    api_contributions: [
1052        "test-api-stubs-docs-non-updatable.api.contribution",
1053    ],
1054
1055    // This module is only used to build android-non-updatable.stubs.test_module_lib
1056    // and other modules should not depend on this module.
1057    visibility: [
1058        "//visibility:private",
1059    ],
1060    enable_validation: false,
1061    stubs_type: "everything",
1062}
1063
1064java_api_library {
1065    name: "android_system_server_stubs_current.from-text",
1066    api_surface: "system-server",
1067    api_contributions: [
1068        "services-non-updatable-stubs.api.contribution",
1069    ],
1070    libs: [
1071        "android_module_lib_stubs_current.from-text",
1072        "stub-annotations",
1073    ],
1074    static_libs: [
1075        "android_module_lib_stubs_current.from-text",
1076    ],
1077    visibility: ["//visibility:public"],
1078    enable_validation: false,
1079    stubs_type: "everything",
1080}
1081
1082////////////////////////////////////////////////////////////////////////
1083// api-versions.xml generation, for public and system. This API database
1084// also contains the android.test.* APIs.
1085////////////////////////////////////////////////////////////////////////
1086
1087java_library {
1088    name: "android_stubs_current_with_test_libs",
1089    static_libs: [
1090        "android_stubs_current_exportable",
1091        "android.test.base.stubs",
1092        "android.test.mock.stubs",
1093        "android.test.runner.stubs",
1094    ],
1095    defaults: ["android.jar_defaults"],
1096    visibility: [
1097        "//visibility:override",
1098        "//visibility:private",
1099    ],
1100}
1101
1102java_library {
1103    name: "android_system_stubs_current_with_test_libs",
1104    static_libs: [
1105        "android_system_stubs_current_exportable",
1106        "android.test.base.stubs.system",
1107        "android.test.mock.stubs.system",
1108        "android.test.runner.stubs.system",
1109    ],
1110    defaults: ["android.jar_defaults"],
1111    visibility: [
1112        "//visibility:override",
1113        "//visibility:private",
1114    ],
1115}
1116
1117java_library {
1118    name: "android_module_stubs_current_with_test_libs",
1119    static_libs: [
1120        "android_module_lib_stubs_current_exportable",
1121        "android.test.base.stubs",
1122        "android.test.mock.stubs",
1123        "android.test.runner.stubs",
1124    ],
1125    defaults: ["android.jar_defaults"],
1126    visibility: [
1127        "//visibility:override",
1128        "//visibility:private",
1129    ],
1130}
1131
1132java_library {
1133    name: "android_system_server_stubs_current_with_test_libs",
1134    static_libs: [
1135        "android_system_server_stubs_current_exportable",
1136        "android.test.base.stubs.system",
1137        "android.test.mock.stubs.system",
1138        "android.test.runner.stubs.system",
1139    ],
1140    defaults: ["android.jar_defaults"],
1141    visibility: [
1142        "//visibility:override",
1143        "//visibility:private",
1144    ],
1145}
1146
1147// Defaults for `droidstubs` modules that generate `api-versions.xml` files for
1148// the various API surfaces.
1149stubs_defaults {
1150    name: "api_versions_base_defaults",
1151    defaults_visibility: ["//visibility:private"],
1152    generate_stubs: false,
1153    api_levels_annotations_enabled: true,
1154    api_levels_annotations_dirs: [
1155        "sdk-dir",
1156        "api-versions-jars-dir",
1157    ],
1158}
1159
1160// Defaults for `droidstubs` modules that generate complete `api-versions.xml`
1161// files, i.e. include SDK extensions.
1162stubs_defaults {
1163    name: "api_versions_complete_defaults",
1164    defaults_visibility: ["//visibility:private"],
1165    defaults: ["api_versions_base_defaults"],
1166    extensions_info_file: ":sdk-extensions-info",
1167}
1168
1169// Produces an `api-versions.xml` file that includes up-to-date information
1170// about all the public APIs, both updatable and non-updatable and historic
1171// information about all previous dessert and SDK extension releases.
1172droidstubs {
1173    name: "api_versions_public",
1174    defaults: ["api_versions_complete_defaults"],
1175    srcs: [":android_stubs_current_with_test_libs{.jar}"],
1176    api_levels_sdk_type: "public",
1177    visibility: ["//frameworks/base"],
1178}
1179
1180// Produces an `api-versions.xml` file that includes up-to-date information
1181// about all the system APIs, both updatable and non-updatable and historic
1182// information about all previous dessert and SDK extension releases.
1183droidstubs {
1184    name: "api_versions_system",
1185    defaults: ["api_versions_complete_defaults"],
1186    srcs: [":android_system_stubs_current_with_test_libs{.jar}"],
1187    api_levels_sdk_type: "system",
1188    dists: [
1189        // Make the api-versions.xml file for the system API available in the
1190        // sdk build target.
1191        {
1192            targets: ["sdk"],
1193            dest: "api-versions_system.xml",
1194            tag: ".api_versions.xml",
1195        },
1196    ],
1197}
1198
1199// Defaults for `droidstubs` modules that generate `api-versions.xml` files that
1200// only include non-updatable code, i.e. for platform API only, not SDK
1201// extensions.
1202stubs_defaults {
1203    name: "api_versions_non_updatable_defaults",
1204    defaults_visibility: ["//visibility:private"],
1205    defaults: ["api_versions_base_defaults"],
1206    // this only has the non-updatable portions of the module lib sdk,
1207    // which can reference classes from updatable apexes, so remove references to them
1208    // from this api_versions file.
1209    flags: ["--remove-missing-class-references-in-api-levels"],
1210    // extensions_info_file is purposefully omitted, because this module should just be
1211    // the non-updatable portions of the sdk, and extension sdks are updatable.
1212}
1213
1214// Produces an `api-versions.xml` file that includes up-to-date information
1215// about only the non-updatable module-lib APIs and historic information about
1216// all previous dessert and SDK extension releases. That historic information
1217// may include information about APIs that were previously not-updatable which
1218// have since become updatable.
1219droidstubs {
1220    name: "api_versions_module_lib",
1221    defaults: ["api_versions_non_updatable_defaults"],
1222    srcs: [":android_module_stubs_current_with_test_libs{.jar}"],
1223    api_levels_sdk_type: "module-lib",
1224}
1225
1226// Create a single jar containing the whole module-lib API surface.
1227// This is needed because Metalava only consumes the first jar file it is given
1228// and ignores the rest.
1229java_library {
1230    name: "android_module_stubs_complete_current_with_test_libs",
1231    static_libs: [
1232        "android_module_stubs_current_with_test_libs",
1233        "framework-updatable-stubs-module_libs_api-exportable",
1234    ],
1235    defaults: ["android.jar_defaults"],
1236    visibility: [
1237        "//visibility:override",
1238        "//visibility:private",
1239    ],
1240}
1241
1242// Produces an `api-versions.xml` file that includes up-to-date information
1243// about all the module-lib APIs, both updatable and non-updatable and historic
1244// information about all previous dessert and SDK extension releases.
1245droidstubs {
1246    name: "api_versions_module_lib_complete",
1247    defaults: ["api_versions_complete_defaults"],
1248    srcs: [":android_module_stubs_complete_current_with_test_libs{.jar}"],
1249    api_levels_sdk_type: "module-lib",
1250}
1251
1252// Produces an `api-versions.xml` file that includes up-to-date information
1253// about only the non-updatable system-server APIs and historic information
1254// about all previous dessert and SDK extension releases. That historic
1255// information may include information about APIs that were previously
1256// not-updatable which have since become updatable.
1257droidstubs {
1258    name: "api_versions_system_server",
1259    defaults: ["api_versions_non_updatable_defaults"],
1260    srcs: [":android_system_server_stubs_current_with_test_libs{.jar}"],
1261    api_levels_sdk_type: "system-server",
1262}
1263
1264// Create a single jar containing the whole system-server API surface.
1265// This is needed because Metalava only consumes the first jar file it is given
1266// and ignores the rest.
1267java_library {
1268    name: "android_system_server_stubs_complete_current_with_test_libs",
1269    static_libs: [
1270        "android_system_server_stubs_current_with_test_libs",
1271        // system-server extends module-lib but libraries which only service-*
1272        // libraries provided system-server APIs, so include module-lib APIs for
1273        // the others, e.g. framework-* libraries.
1274        "framework-updatable-stubs-module_libs_api-exportable",
1275        "framework-updatable-stubs-system_server_api-exportable",
1276    ],
1277    defaults: ["android.jar_defaults"],
1278    visibility: [
1279        "//visibility:override",
1280        "//visibility:private",
1281    ],
1282}
1283
1284// Produces an `api-versions.xml` file that includes up-to-date information
1285// about all the system-server APIs, both updatable and non-updatable and
1286// historic information about all previous dessert and SDK extension releases.
1287droidstubs {
1288    name: "api_versions_system_server_complete",
1289    defaults: ["api_versions_complete_defaults"],
1290    srcs: [":android_system_server_stubs_complete_current_with_test_libs{.jar}"],
1291    api_levels_sdk_type: "system-server",
1292}
1293
1294/////////////////////////////////////////////////////////////////////
1295// hwbinder.stubs provides APIs required for building HIDL Java
1296// libraries.
1297/////////////////////////////////////////////////////////////////////
1298
1299droidstubs {
1300    name: "hwbinder-stubs-docs",
1301    srcs: [":hwbinder-stubs-srcs"],
1302    libs: ["framework-annotations-lib"],
1303    installable: false,
1304    sdk_version: "core_platform",
1305    annotations_enabled: true,
1306    previous_api: ":android.api.public.latest",
1307    merge_annotations_dirs: [
1308        "metalava-manual",
1309    ],
1310    flags: priv_apps,
1311}
1312
1313java_library {
1314    name: "hwbinder.stubs",
1315    sdk_version: "core_current",
1316    libs: ["framework-annotations-lib"],
1317    srcs: [
1318        ":hwbinder-stubs-docs",
1319    ],
1320    visibility: ["//visibility:public"],
1321}
1322