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// Common metalava configs 28///////////////////////////////////////////////////////////////////// 29 30stubs_defaults { 31 name: "metalava-non-updatable-api-stubs-default", 32 defaults: ["android-non-updatable-stubs-defaults"], 33 api_levels_annotations_enabled: false, 34 defaults_visibility: ["//visibility:private"], 35} 36 37///////////////////////////////////////////////////////////////////// 38// These modules provide source files for the stub libraries 39///////////////////////////////////////////////////////////////////// 40 41droidstubs { 42 name: "api-stubs-docs-non-updatable", 43 defaults: ["metalava-non-updatable-api-stubs-default"], 44 args: metalava_framework_docs_args, 45 check_api: { 46 current: { 47 api_file: "core/api/current.txt", 48 removed_api_file: "core/api/removed.txt", 49 }, 50 last_released: { 51 api_file: ":android-non-updatable.api.public.latest", 52 removed_api_file: ":android-non-updatable-removed.api.public.latest", 53 baseline_file: ":android-non-updatable-incompatibilities.api.public.latest", 54 }, 55 api_lint: { 56 enabled: true, 57 new_since: ":android.api.public.latest", 58 }, 59 }, 60 dists: [ 61 { 62 targets: [ 63 "sdk", 64 "win_sdk", 65 ], 66 dir: "apistubs/android/public/api", 67 dest: "android-non-updatable.txt", 68 tag: ".api.txt", 69 }, 70 { 71 targets: [ 72 "sdk", 73 "win_sdk", 74 ], 75 dir: "apistubs/android/public/api", 76 dest: "android-non-updatable-removed.txt", 77 tag: ".removed-api.txt", 78 }, 79 ], 80} 81 82priv_apps = " --show-annotation android.annotation.SystemApi\\(" + 83 "client=android.annotation.SystemApi.Client.PRIVILEGED_APPS" + 84 "\\)" 85 86priv_apps_in_stubs = " --show-for-stub-purposes-annotation android.annotation.SystemApi\\(" + 87 "client=android.annotation.SystemApi.Client.PRIVILEGED_APPS" + 88 "\\)" 89 90test = " --show-annotation android.annotation.TestApi" 91 92module_libs = " --show-annotation android.annotation.SystemApi\\(" + 93 "client=android.annotation.SystemApi.Client.MODULE_LIBRARIES" + 94 "\\)" 95 96droidstubs { 97 name: "system-api-stubs-docs-non-updatable", 98 defaults: ["metalava-non-updatable-api-stubs-default"], 99 args: metalava_framework_docs_args + priv_apps, 100 check_api: { 101 current: { 102 api_file: "core/api/system-current.txt", 103 removed_api_file: "core/api/system-removed.txt", 104 }, 105 last_released: { 106 api_file: ":android-non-updatable.api.system.latest", 107 removed_api_file: ":android-non-updatable-removed.api.system.latest", 108 baseline_file: ":android-non-updatable-incompatibilities.api.system.latest", 109 }, 110 api_lint: { 111 enabled: true, 112 new_since: ":android.api.system.latest", 113 baseline_file: "core/api/system-lint-baseline.txt", 114 }, 115 }, 116 dists: [ 117 { 118 targets: [ 119 "sdk", 120 "win_sdk", 121 ], 122 dir: "apistubs/android/system/api", 123 dest: "android-non-updatable.txt", 124 tag: ".api.txt", 125 }, 126 { 127 targets: [ 128 "sdk", 129 "win_sdk", 130 ], 131 dir: "apistubs/android/system/api", 132 dest: "android-non-updatable-removed.txt", 133 tag: ".removed-api.txt", 134 }, 135 ], 136} 137 138droidstubs { 139 name: "test-api-stubs-docs-non-updatable", 140 defaults: ["metalava-non-updatable-api-stubs-default"], 141 args: metalava_framework_docs_args + test + priv_apps_in_stubs, 142 check_api: { 143 current: { 144 api_file: "core/api/test-current.txt", 145 removed_api_file: "core/api/test-removed.txt", 146 }, 147 api_lint: { 148 enabled: true, 149 baseline_file: "core/api/test-lint-baseline.txt", 150 }, 151 }, 152 dists: [ 153 { 154 targets: [ 155 "sdk", 156 "win_sdk", 157 ], 158 dir: "apistubs/android/test/api", 159 dest: "android.txt", 160 tag: ".api.txt", 161 }, 162 { 163 targets: [ 164 "sdk", 165 "win_sdk", 166 ], 167 dir: "apistubs/android/test/api", 168 dest: "removed.txt", 169 tag: ".removed-api.txt", 170 }, 171 { 172 targets: [ 173 "sdk", 174 "win_sdk", 175 ], 176 dir: "apistubs/android/test/api", 177 dest: "android-non-updatable.txt", 178 tag: ".api.txt", 179 }, 180 { 181 targets: [ 182 "sdk", 183 "win_sdk", 184 ], 185 dir: "apistubs/android/test/api", 186 dest: "android-non-updatable-removed.txt", 187 tag: ".removed-api.txt", 188 }, 189 ], 190} 191 192droidstubs { 193 name: "module-lib-api-stubs-docs-non-updatable", 194 defaults: ["metalava-non-updatable-api-stubs-default"], 195 args: metalava_framework_docs_args + priv_apps_in_stubs + module_libs, 196 check_api: { 197 current: { 198 api_file: "core/api/module-lib-current.txt", 199 removed_api_file: "core/api/module-lib-removed.txt", 200 }, 201 last_released: { 202 api_file: ":android-non-updatable.api.module-lib.latest", 203 removed_api_file: ":android-non-updatable-removed.api.module-lib.latest", 204 }, 205 api_lint: { 206 enabled: true, 207 new_since: ":android.api.module-lib.latest", 208 baseline_file: "core/api/module-lib-lint-baseline.txt", 209 }, 210 }, 211 dists: [ 212 { 213 targets: [ 214 "sdk", 215 "win_sdk", 216 ], 217 dir: "apistubs/android/module-lib/api", 218 dest: "android-non-updatable.txt", 219 tag: ".api.txt", 220 }, 221 { 222 targets: [ 223 "sdk", 224 "win_sdk", 225 ], 226 dir: "apistubs/android/module-lib/api", 227 dest: "android-non-updatable-removed.txt", 228 tag: ".removed-api.txt", 229 }, 230 ], 231} 232 233///////////////////////////////////////////////////////////////////// 234// android_*_stubs_current modules are the stubs libraries compiled 235// from stub sources 236///////////////////////////////////////////////////////////////////// 237 238modules_public_stubs = [ 239 "android.net.ipsec.ike.stubs", 240 "art.module.public.api.stubs", 241 "conscrypt.module.public.api.stubs", 242 "framework-appsearch.stubs", 243 "framework-connectivity.stubs", 244 "framework-graphics.stubs", 245 "framework-media.stubs", 246 "framework-mediaprovider.stubs", 247 "framework-permission.stubs", 248 "framework-permission-s.stubs", 249 "framework-scheduling.stubs", 250 "framework-sdkextensions.stubs", 251 "framework-statsd.stubs", 252 "framework-tethering.stubs", 253 "framework-wifi.stubs", 254 "i18n.module.public.api.stubs", 255] 256 257modules_system_stubs = [ 258 "android.net.ipsec.ike.stubs.system", 259 "art.module.public.api.stubs.system", 260 "conscrypt.module.public.api.stubs", // Only has public stubs 261 "framework-appsearch.stubs.system", 262 "framework-connectivity.stubs.system", 263 "framework-graphics.stubs.system", 264 "framework-media.stubs.system", 265 "framework-mediaprovider.stubs.system", 266 "framework-permission.stubs.system", 267 "framework-permission-s.stubs.system", 268 "framework-scheduling.stubs.system", 269 "framework-sdkextensions.stubs.system", 270 "framework-statsd.stubs.system", 271 "framework-tethering.stubs.system", 272 "framework-wifi.stubs.system", 273 "i18n.module.public.api.stubs", // Only has public stubs 274] 275 276java_defaults { 277 name: "android-non-updatable_defaults_stubs_current", 278 libs: ["stub-annotations"], 279 static_libs: ["framework-res-package-jar"], // Export package of framework-res 280 sdk_version: "none", 281 system_modules: "none", 282 java_version: "1.8", 283 compile_dex: true, 284 dist: { 285 targets: [ 286 "sdk", 287 "win_sdk", 288 ], 289 tag: ".jar", 290 dest: "android-non-updatable.jar", 291 }, 292 defaults_visibility: ["//visibility:private"], 293 visibility: ["//visibility:private"], 294} 295 296java_library { 297 name: "android-non-updatable.stubs", 298 defaults: ["android-non-updatable_defaults_stubs_current"], 299 srcs: [":api-stubs-docs-non-updatable"], 300 libs: modules_public_stubs, 301 dist: { 302 dir: "apistubs/android/public", 303 }, 304} 305 306java_library { 307 name: "android-non-updatable.stubs.system", 308 defaults: ["android-non-updatable_defaults_stubs_current"], 309 srcs: [":system-api-stubs-docs-non-updatable"], 310 libs: modules_system_stubs, 311 dist: { 312 dir: "apistubs/android/system", 313 }, 314} 315 316java_library { 317 name: "android-non-updatable.stubs.module_lib", 318 defaults: ["android-non-updatable_defaults_stubs_current"], 319 srcs: [":module-lib-api-stubs-docs-non-updatable"], 320 libs: [ 321 "sdk_system_current_android", 322 // NOTE: The below can be removed once the prebuilt stub contains IKE. 323 "sdk_system_current_android.net.ipsec.ike", 324 ], 325 dist: { 326 dir: "apistubs/android/module-lib", 327 }, 328} 329 330java_library { 331 name: "android-non-updatable.stubs.test", 332 defaults: ["android-non-updatable_defaults_stubs_current"], 333 srcs: [":test-api-stubs-docs-non-updatable"], 334 libs: modules_system_stubs, 335 dist: { 336 dir: "apistubs/android/test", 337 }, 338} 339 340java_defaults { 341 name: "android_stubs_dists_default", 342 dist: { 343 targets: [ 344 "sdk", 345 "win_sdk", 346 ], 347 tag: ".jar", 348 dest: "android.jar", 349 }, 350 defaults_visibility: ["//frameworks/base/services"], 351} 352 353java_library { 354 name: "android_stubs_current", 355 static_libs: modules_public_stubs + [ 356 "android-non-updatable.stubs", 357 "private-stub-annotations-jar", 358 ], 359 defaults: ["android.jar_defaults"], 360} 361 362java_library { 363 name: "android_system_stubs_current", 364 static_libs: modules_system_stubs + [ 365 "android-non-updatable.stubs.system", 366 "private-stub-annotations-jar", 367 ], 368 defaults: [ 369 "android.jar_defaults", 370 "android_stubs_dists_default", 371 ], 372 dist: { 373 dir: "apistubs/android/system", 374 }, 375 dists: [ 376 { 377 // Legacy dist path 378 targets: [ 379 "sdk", 380 "win_sdk", 381 ], 382 tag: ".jar", 383 dest: "android_system.jar", 384 }, 385 ], 386} 387 388java_library { 389 name: "android_test_stubs_current", 390 // Modules do not have test APIs, but we want to include their SystemApis, like we include 391 // the SystemApi of framework-non-updatable-sources. 392 static_libs: modules_system_stubs + [ 393 "android-non-updatable.stubs.test", 394 "private-stub-annotations-jar", 395 ], 396 defaults: [ 397 "android.jar_defaults", 398 "android_stubs_dists_default", 399 ], 400 dist: { 401 dir: "apistubs/android/test", 402 }, 403} 404 405java_library { 406 name: "android_module_lib_stubs_current", 407 defaults: [ 408 "android.jar_defaults", 409 "android_stubs_dists_default", 410 ], 411 static_libs: [ 412 "android-non-updatable.stubs.module_lib", 413 "art.module.public.api.stubs.module_lib", 414 ], 415 dist: { 416 dir: "apistubs/android/module-lib", 417 }, 418} 419 420java_library { 421 name: "android_system_server_stubs_current", 422 defaults: ["android_stubs_dists_default"], 423 srcs: [":services-non-updatable-stubs"], 424 installable: false, 425 static_libs: [ 426 "android_module_lib_stubs_current", 427 ], 428 sdk_version: "none", 429 system_modules: "none", 430 java_version: "1.8", 431 dist: { 432 dir: "apistubs/android/system-server", 433 }, 434} 435 436///////////////////////////////////////////////////////////////////// 437// hwbinder.stubs provides APIs required for building HIDL Java 438// libraries. 439///////////////////////////////////////////////////////////////////// 440 441droidstubs { 442 name: "hwbinder-stubs-docs", 443 srcs: [ 444 "core/java/android/os/HidlSupport.java", 445 "core/java/android/os/HidlMemory.java", 446 "core/java/android/os/HwBinder.java", 447 "core/java/android/os/HwBlob.java", 448 "core/java/android/os/HwParcel.java", 449 "core/java/android/os/IHwBinder.java", 450 "core/java/android/os/IHwInterface.java", 451 "core/java/android/os/DeadObjectException.java", 452 "core/java/android/os/DeadSystemException.java", 453 "core/java/android/os/NativeHandle.java", 454 "core/java/android/os/RemoteException.java", 455 "core/java/android/util/AndroidException.java", 456 ], 457 libs: ["framework-annotations-lib"], 458 installable: false, 459 sdk_version: "core_platform", 460 annotations_enabled: true, 461 previous_api: ":android.api.public.latest", 462 merge_annotations_dirs: [ 463 "metalava-manual", 464 ], 465 args: priv_apps, 466 visibility: ["//visibility:private"], 467} 468 469java_library { 470 name: "hwbinder.stubs", 471 sdk_version: "core_current", 472 libs: ["framework-annotations-lib"], 473 srcs: [ 474 ":hwbinder-stubs-docs", 475 ], 476 visibility: ["//visibility:public"], 477} 478