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