1// Copyright (C) 2018 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
15package {
16    default_applicable_licenses: ["Android-Apache-2.0"],
17}
18
19filegroup {
20    name: "libcarpowermanager_aidl",
21    srcs: [
22        "src/android/car/ICar.aidl",
23        "src/android/car/hardware/power/CarPowerPolicy.aidl",
24        "src/android/car/hardware/power/CarPowerPolicyFilter.aidl",
25        "src/android/car/hardware/power/ICarPower.aidl",
26        "src/android/car/hardware/power/ICarPowerPolicyListener.aidl",
27        "src/android/car/hardware/power/ICarPowerStateListener.aidl",
28    ],
29    path: "src",
30}
31
32cc_library {
33    name: "libcarpowermanager",
34    vendor_available: true,
35
36    aidl: {
37        export_aidl_headers: true,
38        local_include_dirs: [
39            "src",
40        ],
41    },
42
43    cflags: [
44        "-Wall",
45        "-Werror",
46        "-Wextra",
47        "-Wno-unused-parameter",
48    ],
49
50    include_dirs: [
51        "packages/services/Car/car-lib/native/include",
52    ],
53
54    shared_libs: [
55        "libbinder",
56        "liblog",
57        "libutils",
58    ],
59
60    srcs: [
61        ":libcarpowermanager_aidl",
62        "native/CarPowerManager/CarPowerManager.cpp",
63        "native/CarPowerManager/CarPowerPolicy.cpp",
64        "native/CarPowerManager/CarPowerPolicyFilter.cpp",
65    ],
66}
67
68java_library {
69    name: "android.car.cluster.navigation",
70    proto: {
71        type: "lite",
72    },
73    static_libs: ["libprotobuf-java-lite"],
74    srcs: ["src/android/car/navigation/navigation_state.proto"]
75}
76
77// library to access settings from CarSettings
78java_library {
79    name: "android.car.settings",
80    srcs: ["src/android/car/settings/CarSettings.java"]
81}
82
83// library to access common constants between carlibrary and system server.
84java_library {
85    name: "com.android.car.internal.common",
86    srcs: [
87        "src/com/android/car/internal/common/**/*.java",
88        "src/com/android/car/internal/common/EventLogTags.logtags",
89        "src/com/android/car/internal/ExcludeFromCodeCoverageGeneratedReport.java",
90    ],
91}
92
93java_library {
94    name: "android.car",
95    srcs: [
96        "src/**/*.java",
97        "src/**/*.aidl",
98        "src/com/android/car/internal/common/EventLogTags.logtags",
99    ],
100    aidl: {
101        include_dirs: [
102            "system/bt/binder",
103        ],
104    },
105    exclude_srcs: [
106        "src/android/car/storagemonitoring/IoStats.aidl",
107        "src/android/car/storagemonitoring/IoStatsEntry.aidl",
108    ],
109    product_variables: {
110        pdk: {
111            enabled: false,
112        },
113    },
114    installable: true,
115}
116
117stubs_defaults {
118    name: "android.car-docs-default",
119    srcs: [
120        "src/**/*.java",
121    ],
122    libs: [
123        "android.car",
124    ],
125    product_variables: {
126        pdk: {
127            enabled: false,
128        },
129    },
130}
131
132genrule {
133    name: "android-car-last-released-api",
134    srcs: [
135        "api/released/*.txt",
136    ],
137    cmd: "cp -f $$(echo $(in) | tr \" \" \"\\n\" | sort -n | tail -1) $(genDir)/last-released-api.txt",
138    out: [
139        "last-released-api.txt",
140    ],
141}
142
143genrule {
144    name: "android-car-last-released-system-api",
145    srcs: [
146        "api/system-released/*.txt",
147    ],
148    cmd: "cp -f $$(echo $(in) | tr \" \" \"\\n\" | sort -n | tail -1) $(genDir)/last-released-system-api.txt",
149    out: [
150        "last-released-system-api.txt",
151    ],
152}
153
154droidstubs {
155    name: "android.car-stubs-docs",
156    defaults: ["android.car-docs-default"],
157    args: "--hide UnavailableSymbol --no-docs --stub-packages android.car* " +
158        "--hide-package com.android.internal ",
159    installable: false,
160    check_api: {
161        last_released: {
162            api_file: ":android-car-last-released-api",
163            removed_api_file: "api/removed.txt",
164            args: " -hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 -hide 26 -hide 27 " +
165                " -warning 7 -warning 8 -warning 9 -warning 10 -warning 11 -warning 12 " +
166                " -warning 13 -warning 14 -warning 15 -warning 16 -warning 17 -warning 18 -hide 113 ",
167        },
168        current: {
169            api_file: "api/current.txt",
170            removed_api_file: "api/removed.txt",
171            args: " -error 2 -error 3 -error 4 -error 5 -error 6 -error 7 -error 8 -error 9 -error 10 -error 11 " +
172                " -error 12 -error 13 -error 14 -error 15 -error 16 -error 17 -error 18 -error 19 -error 20 " +
173                " -error 21 -error 23 -error 24 -error 25 -hide 113 ",
174        },
175        api_lint: {
176            enabled: true,
177            baseline_file: "api/lint-baseline.txt",
178        }
179    },
180}
181
182droidstubs {
183    name: "android.car-system-stubs-docs",
184    defaults: ["android.car-docs-default"],
185    // TODO(b/174572385): Remove CallbackInterface once this b/174572385 is fixed
186    args: "--hide CallbackInterface --hide UnavailableSymbol --hide HiddenSuperclass " +
187        "--no-docs --stub-packages android.car* " +
188        "--show-annotation android.annotation.SystemApi --hide-package com.android.internal ",
189    installable: false,
190    check_api: {
191        last_released: {
192            api_file: ":android-car-last-released-system-api",
193            removed_api_file: "api/system-removed.txt",
194            args: " -hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 -hide 26 -hide 27 " +
195                " -warning 7 -warning 8 -warning 9 -warning 10 -warning 11 -warning 12 " +
196                " -warning 13 -warning 14 -warning 15 -warning 16 -warning 17 -warning 18 -hide 113 ",
197        },
198        current: {
199            api_file: "api/system-current.txt",
200            removed_api_file: "api/system-removed.txt",
201            args: " -error 2 -error 3 -error 4 -error 5 -error 6 -error 7 -error 8 -error 9 -error 10 -error 11 " +
202                " -error 12 -error 13 -error 14 -error 15 -error 16 -error 17 -error 18 -error 19 -error 20 " +
203                " -error 21 -error 23 -error 24 -error 25 -hide 113 ",
204        },
205        api_lint: {
206            enabled: true,
207            baseline_file: "api/system-lint-baseline.txt",
208        }
209    },
210}
211
212droidstubs {
213    name: "android.car-test-stubs-docs",
214    defaults: ["android.car-docs-default"],
215    args: "--hide HiddenSuperclass --hide UnavailableSymbol --no-docs --stub-packages android.car* " +
216        "--show-annotation android.annotation.TestApi ",
217    installable: false,
218    check_api: {
219        current: {
220            api_file: "api/test-current.txt",
221            removed_api_file: "api/test-removed.txt",
222            args: " -error 2 -error 3 -error 4 -error 5 -error 6 -error 7 -error 8 -error 9 -error 10 -error 11 " +
223                  " -error 12 -error 13 -error 14 -error 15 -error 16 -error 17 -error 18 -error 19 -error 20 " +
224                  " -error 21 -error 23 -error 24 -error 25 -hide 113 ",
225        },
226    },
227}
228
229droidstubs {
230    name: "android.car-stub-docs",
231    srcs: [
232        "src/**/*.java",
233    ],
234    libs: [
235        "android.car",
236    ],
237    api_filename: "api.txt",
238    args: "--hide HiddenSuperclass --hide UnavailableSymbol --no-docs --stub-packages android.car* ",
239    installable: false,
240    product_variables: {
241        pdk: {
242            enabled: false,
243        },
244    },
245}
246
247// Generates stubs for API documentation.
248droidstubs {
249    name: "car-doc-stubs",
250    srcs: [
251        "src/**/*.java",
252    ],
253    create_doc_stubs: true,
254    annotations_enabled: true,
255    api_levels_annotations_enabled: true,
256    api_levels_jar_filename: "android.car.jar",
257    api_levels_annotations_dirs: [
258        "sdk-dir",
259        "api-versions-jars-dir",
260    ],
261    previous_api: ":android-car-last-released-api",
262    merge_annotations_dirs: [
263        "metalava-manual",
264    ],
265    arg_files: [
266        "AndroidManifest.xml",
267    ],
268    // Add --verbose to print metalava details.
269    args: "--manifest $(location AndroidManifest.xml) " +
270          "--error UnhiddenSystemApi " +
271          "--hide RequiresPermission " +
272          "--hide CallbackInterface " +
273          "--hide MissingPermission " +
274          "--hide HiddenSuperclass --hide DeprecationMismatch --hide UnavailableSymbol " +
275          "--hide SdkConstant --hide HiddenTypeParameter --hide Todo --hide Typo " +
276          "--hide Todo --hide Typo ",
277    write_sdk_values: true,
278}
279
280// Generates API docs for go/devsite.
281//
282// How API docs are generated:
283//    source files -> (droidstubs/metalava) -> stub source files -> (droiddoc/doclava) -> docs
284//
285// The metalava conversion is done by droidstub module "car-doc-stubs".
286//
287// TODO(b/162958231): Remove "ds-car-docs" from build/soong/java/legacy_core_platform_api_usage.go.
288droiddoc {
289    name: "ds-car-docs",
290    srcs: [
291        ":car-doc-stubs",
292    ],
293    libs: [
294        "stub-annotations",
295        "unsupportedappusage",
296    ],
297    custom_template: "droiddoc-templates-sdk",
298    // These variables that are used in doclava templates.
299    hdf: [
300        "dac true",
301        "sdk.preview 0", // Not a preview version.
302        "sdk.version 31",
303        "android.whichdoc online",
304        "android.hasSamples false",
305    ],
306    arg_files: [
307        "AndroidManifest.xml",
308    ],
309    proofread_file: "ds-sdk-docs-proofrerad.txt",
310    // See doclava docs in https://github.com/tinks/doclava.
311    // See error numbers in external/doclava/src/com/google/doclava/Errors.java.
312    // TODO(b/163831343): Add -werror -lerror to catch bad javadocs
313    args: "-android -manifest $(location AndroidManifest.xml) -toroot / -devsite -yamlV2 -metalavaApiSince " +
314        "-hide 111 -hide 113 -hide 125 -hide 126 -hide 127 -hide 128 " +
315        "-stubpackages android.car -dac_libraryroot android/car ",
316}
317
318java_library {
319    name: "android.car-stubs",
320    srcs: [
321        ":android.car-stub-docs",
322    ],
323    sdk_version: "current",
324    product_variables: {
325        pdk: {
326            enabled: false,
327        },
328    },
329    installable: false,
330    dist: {
331        targets: ["dist_files"],
332    }
333}
334
335java_library {
336    name: "android.car-stubs-dex",
337    static_libs: ["android.car-stubs"],
338    sdk_version: "current",
339    product_variables: {
340        pdk: {
341            enabled: false,
342        },
343    },
344    compile_dex: true,
345}
346
347java_library {
348    name: "android.car-system-stubs",
349    srcs: [
350        ":android.car-system-stubs-docs",
351    ],
352    sdk_version: "system_current",
353    product_variables: {
354        pdk: {
355            enabled: false,
356        },
357    },
358    installable: false,
359    dist: {
360        targets: ["dist_files"],
361    }
362}
363
364java_library {
365    name: "android.car-system-stubs-dex",
366    static_libs: ["android.car-system-stubs"],
367    sdk_version: "system_current",
368    product_variables: {
369        pdk: {
370            enabled: false,
371        },
372    },
373    compile_dex: true,
374}
375
376java_library {
377    name: "android.car-test-stubs",
378    srcs: [
379        ":android.car-test-stubs-docs",
380    ],
381    sdk_version: "test_current",
382    product_variables: {
383        pdk: {
384            enabled: false,
385        },
386    },
387    installable: false,
388}
389
390java_library {
391    name: "android.car-test-stubs-dex",
392    static_libs: ["android.car-test-stubs"],
393    sdk_version: "test_current",
394    product_variables: {
395        pdk: {
396            enabled: false,
397        },
398    },
399    compile_dex: true,
400    dist: {
401        targets: ["dist_files"],
402    }
403}
404
405// Export the api/system-current.txt file.
406filegroup {
407    name: "car-api-system-current.txt",
408    visibility: [
409        "//cts/tests/signature/api",
410    ],
411    srcs: [
412        "api/system-current.txt",
413    ],
414}
415
416// Export the api/system-removed.txt file.
417filegroup {
418    name: "car-api-system-removed.txt",
419    visibility: [
420        "//cts/tests/signature/api",
421    ],
422    srcs: [
423        "api/system-removed.txt",
424    ],
425}
426