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 15mainline_stubs_args = 16 "--error UnhiddenSystemApi " + 17 "--hide BroadcastBehavior " + 18 "--hide DeprecationMismatch " + 19 "--hide HiddenSuperclass " + 20 "--hide HiddenTypedefConstant " + 21 "--hide HiddenTypeParameter " + 22 "--hide MissingPermission " + 23 "--hide RequiresPermission " + 24 "--hide SdkConstant " + 25 "--hide Todo " + 26 "--hide Typo " + 27 "--hide UnavailableSymbol " 28 29// TODO: modularize this so not every module has the same whitelist 30framework_packages_to_document = [ 31 "android", 32 "dalvik", 33 "java", 34 "javax", 35 "junit", 36 "org.apache.http", 37 "org.json", 38 "org.w3c.dom", 39 "org.xml.sax", 40 "org.xmlpull", 41] 42 43// TODO: remove the hiding when server classes are cleaned up. 44mainline_framework_stubs_args = 45 mainline_stubs_args + 46 "--hide-package com.android.server " 47 48priv_apps = " " + 49 "--show-annotation android.annotation.SystemApi\\(" + 50 "client=android.annotation.SystemApi.Client.PRIVILEGED_APPS" + 51 "\\) " 52 53module_libs = " " + 54 " --show-annotation android.annotation.SystemApi\\(" + 55 "client=android.annotation.SystemApi.Client.MODULE_LIBRARIES" + 56 "\\) " 57 58mainline_service_stubs_args = 59 mainline_stubs_args + 60 "--show-annotation android.annotation.SystemApi\\(" + 61 "client=android.annotation.SystemApi.Client.SYSTEM_SERVER" + 62 "\\) " + 63 "--hide-annotation android.annotation.Hide " + 64 "--hide InternalClasses " // com.android.* classes are okay in this interface 65 66// Defaults common to all mainline module java_sdk_library instances. 67java_defaults { 68 name: "framework-module-common-defaults", 69 70 // Additional annotations used for compiling both the implementation and the 71 // stubs libraries. 72 libs: ["framework-annotations-lib"], 73 74 // Framework modules are not generally shared libraries, i.e. they are not 75 // intended, and must not be allowed, to be used in a <uses-library> manifest 76 // entry. 77 shared_library: false, 78 79 // Enable api lint. This will eventually become the default for java_sdk_library 80 // but it cannot yet be turned on because some usages have not been cleaned up. 81 // TODO(b/156126315) - Remove when no longer needed. 82 api_lint: { 83 enabled: true, 84 }, 85 86 // The API scope specific properties. 87 public: { 88 enabled: true, 89 sdk_version: "module_current", 90 }, 91 92 // Configure framework module specific metalava options. 93 droiddoc_options: [mainline_stubs_args], 94 95 annotations_enabled: true, 96 97 stubs_library_visibility: [ 98 "//visibility:public", 99 ], 100 101 // Set the visibility of the modules creating the stubs source. 102 stubs_source_visibility: [ 103 // Ignore any visibility rules specified on the java_sdk_library when 104 // setting the visibility of the stubs source modules. 105 "//visibility:override", 106 107 // Currently, the stub source is not required for anything other than building 108 // the stubs library so is private to avoid misuse. 109 "//visibility:private", 110 ], 111 112 // Collates API usages from each module for further analysis. 113 plugins: ["java_api_finder"], 114 115 // Mainline modules should only rely on 'module_lib' APIs provided by other modules 116 // and the non updatable parts of the platform. 117 sdk_version: "module_current", 118} 119 120// Defaults for mainline module provided java_sdk_library instances. 121java_defaults { 122 name: "framework-module-defaults", 123 defaults: ["framework-module-common-defaults"], 124 125 system: { 126 enabled: true, 127 sdk_version: "module_current", 128 }, 129 module_lib: { 130 enabled: true, 131 sdk_version: "module_current", 132 }, 133} 134 135// Defaults for mainline module system server provided java_sdk_library instances. 136java_defaults { 137 name: "framework-system-server-module-defaults", 138 defaults: ["framework-module-common-defaults"], 139 140 system_server: { 141 enabled: true, 142 sdk_version: "module_current", 143 }, 144} 145 146stubs_defaults { 147 name: "framework-module-stubs-defaults-publicapi", 148 args: mainline_framework_stubs_args, 149 installable: false, 150 sdk_version: "module_current", 151 annotations_enabled: true, 152 merge_annotations_dirs: [ 153 "metalava-manual", 154 ], 155 filter_packages: framework_packages_to_document, 156 check_api: { 157 current: { 158 api_file: "api/current.txt", 159 removed_api_file: "api/removed.txt", 160 }, 161 api_lint: { 162 enabled: true, 163 }, 164 }, 165 dist: { 166 targets: ["sdk", "win_sdk"], 167 dir: "apistubs/android/public/api", 168 }, 169} 170 171stubs_defaults { 172 name: "framework-module-stubs-defaults-systemapi", 173 args: mainline_framework_stubs_args + priv_apps, 174 libs: ["framework-annotations-lib"], 175 installable: false, 176 sdk_version: "module_current", 177 annotations_enabled: true, 178 merge_annotations_dirs: [ 179 "metalava-manual", 180 ], 181 filter_packages: framework_packages_to_document, 182 check_api: { 183 current: { 184 api_file: "api/system-current.txt", 185 removed_api_file: "api/system-removed.txt", 186 }, 187 api_lint: { 188 enabled: true, 189 }, 190 }, 191 dist: { 192 targets: ["sdk", "win_sdk"], 193 dir: "apistubs/android/system/api", 194 }, 195} 196 197java_defaults { 198 name: "framework-module-stubs-lib-defaults-publicapi", 199 installable: false, 200 sdk_version: "module_current", 201 libs: [ "stub-annotations" ], 202 java_version: "1.8", 203 dist: { 204 targets: ["sdk", "win_sdk"], 205 dir: "apistubs/android/public", 206 }, 207} 208 209java_defaults { 210 name: "framework-module-stubs-lib-defaults-systemapi", 211 installable: false, 212 sdk_version: "module_current", 213 libs: [ "stub-annotations" ], 214 java_version: "1.8", 215 dist: { 216 targets: ["sdk", "win_sdk"], 217 dir: "apistubs/android/system", 218 }, 219} 220 221java_defaults { 222 name: "framework-module-stubs-lib-defaults-module_libs_api", 223 installable: false, 224 sdk_version: "module_current", 225 libs: [ "stub-annotations" ], 226 java_version: "1.8", 227 dist: { 228 targets: ["sdk", "win_sdk"], 229 dir: "apistubs/android/module-lib", 230 }, 231} 232 233// The defaults for module_libs comes in two parts - defaults for API checks 234// and defaults for stub generation. This is because we want the API txt 235// files to *only* include the module_libs_api, but the stubs to include 236// module_libs_api as well as priv_apps. 237 238stubs_defaults { 239 name: "framework-module-api-defaults-module_libs_api", 240 args: mainline_framework_stubs_args + module_libs, 241 libs: ["framework-annotations-lib"], 242 installable: false, 243 sdk_version: "module_current", 244 annotations_enabled: true, 245 merge_annotations_dirs: [ 246 "metalava-manual", 247 ], 248 filter_packages: framework_packages_to_document, 249 check_api: { 250 current: { 251 api_file: "api/module-lib-current.txt", 252 removed_api_file: "api/module-lib-removed.txt", 253 }, 254 api_lint: { 255 enabled: true, 256 }, 257 }, 258 dist: { 259 targets: ["sdk", "win_sdk"], 260 dir: "apistubs/android/module-lib/api", 261 }, 262} 263 264stubs_defaults { 265 name: "framework-module-stubs-defaults-module_libs_api", 266 args: mainline_framework_stubs_args + module_libs + priv_apps, 267 libs: ["framework-annotations-lib"], 268 installable: false, 269 sdk_version: "module_current", 270 annotations_enabled: true, 271 merge_annotations_dirs: [ 272 "metalava-manual", 273 ], 274 filter_packages: framework_packages_to_document, 275} 276 277stubs_defaults { 278 name: "service-module-stubs-srcs-defaults", 279 args: mainline_service_stubs_args, 280 installable: false, 281 annotations_enabled: true, 282 merge_annotations_dirs: [ 283 "metalava-manual", 284 ], 285 filter_packages: ["com.android."], 286 check_api: { 287 current: { 288 api_file: "api/current.txt", 289 removed_api_file: "api/removed.txt", 290 }, 291 api_lint: { 292 enabled: true, 293 }, 294 }, 295 dist: { 296 targets: ["sdk", "win_sdk"], 297 dir: "apistubs/android/system-server/api", 298 }, 299} 300 301// Empty for now, but a convenient place to add rules for all 302// module java_library system_server stub libs. 303java_defaults { 304 name: "service-module-stubs-defaults", 305 dist: { 306 targets: ["sdk", "win_sdk"], 307 dir: "apistubs/android/system-server", 308 }, 309} 310