1// List of clang-tidy checks that are reported as errors. 2// Please keep this list ordered lexicographically. 3package { 4 default_applicable_licenses: ["Android-Apache-2.0"], 5} 6 7tidy_errors = [ 8 "android-*", 9 "bugprone-infinite-loop", 10 "bugprone-macro-parentheses", 11 "bugprone-misplaced-widening-cast", 12 "bugprone-move-forwarding-reference", 13 "bugprone-sizeof-container", 14 "bugprone-sizeof-expression", 15 "bugprone-string-constructor", 16 "bugprone-terminating-continue", 17 "bugprone-undefined-memory-manipulation", 18 "bugprone-undelegated-constructor", 19 // "bugprone-unhandled-self-assignment", // found in apex_manifest.proto 20 "bugprone-unused-raii", 21 "cert-err34-c", 22 "google-default-arguments", 23 // "google-explicit-constructor", // found in com_android_apex.h 24 "google-readability-avoid-underscore-in-googletest-name", 25 "google-readability-todo", 26 "google-runtime-int", 27 "google-runtime-member-string-references", 28 "misc-move-const-arg", 29 "misc-move-forwarding-reference", 30 // "misc-unused-parameters", // found in apexd_utils.h 31 "misc-unused-using-decls", 32 "misc-use-after-move", 33 // "modernize-pass-by-value", // found in apex_database.h 34 "performance-faster-string-find", 35 "performance-for-range-copy", 36 "performance-implicit-conversion-in-loop", 37 "performance-inefficient-vector-operation", 38 "performance-move-const-arg", 39 // "performance-move-constructor-init", // found in apexd_loop.h 40 "performance-noexcept-move-constructor", 41 "performance-unnecessary-copy-initialization", 42 "performance-unnecessary-value-param", 43 // "readability-avoid-const-params-in-decls", // found in apexd.h 44] 45 46cc_defaults { 47 name: "apex_flags_defaults", 48 cflags: [ 49 "-Wall", 50 "-Wextra", 51 "-Werror", 52 "-Wno-unused-parameter", 53 54 // Some extra flags. 55 "-fstrict-aliasing", 56 "-Wredundant-decls", 57 "-Wshadow", 58 "-Wstrict-aliasing", 59 "-Wthread-safety", 60 "-Wthread-safety-negative", 61 "-Wunreachable-code", 62 "-Wunreachable-code-break", 63 "-Wunreachable-code-return", 64 "-Wunused", 65 "-Wused-but-marked-unused", 66 ], 67 tidy: true, 68 tidy_checks: tidy_errors, 69 tidy_checks_as_errors: tidy_errors, 70 tidy_flags: [ 71 "-format-style=file", 72 "-header-filter=system/apex/", 73 ], 74} 75 76 77cc_defaults { 78 name: "libapexd-deps", 79 defaults: ["libapex-deps"], 80 shared_libs: [ 81 "libbinder", 82 "liblog", 83 "liblogwrap", 84 ], 85 static_libs: [ 86 "libapex", 87 "libavb", 88 "libdm", 89 "libext2_uuid", 90 "libverity_tree", 91 "libvold_binder", 92 "libxml2", 93 ], 94 whole_static_libs: ["com.android.sysprop.apex"], 95} 96 97aidl_interface { 98 name: "apex_aidl_interface", 99 unstable: true, 100 srcs: [ 101 "aidl/android/apex/ApexInfo.aidl", 102 "aidl/android/apex/ApexInfoList.aidl", 103 "aidl/android/apex/ApexSessionInfo.aidl", 104 "aidl/android/apex/ApexSessionParams.aidl", 105 "aidl/android/apex/CompressedApexInfo.aidl", 106 "aidl/android/apex/CompressedApexInfoList.aidl", 107 "aidl/android/apex/IApexService.aidl", 108 ], 109 local_include_dir: "aidl", 110 backend: { 111 java: { 112 sdk_version: "28", 113 }, 114 ndk: { 115 enabled: false, 116 }, 117 }, 118} 119 120cc_binary { 121 name: "apexd", 122 defaults: [ 123 "apex_flags_defaults", 124 "libapex-deps", 125 "libapexd-deps", 126 "libapexservice-deps", 127 ], 128 srcs: [ 129 "apexd_main.cpp", 130 ], 131 static_libs: [ 132 "libapex", 133 "libapexd", 134 "libapexd_checkpoint_vold", 135 "libapexservice", 136 ], 137 init_rc: ["apexd.rc"], 138 // Just like the init, apexd should be able to run without 139 // any APEX activated. To do so, it uses the bootstrap linker 140 // and the bootstrap bionic libraries. 141 bootstrap: true, 142} 143 144cc_library_static { 145 name: "libapexd", 146 defaults: [ 147 "apex_flags_defaults", 148 "libapexd-deps", 149 ], 150 srcs: [ 151 "apex_database.cpp", 152 "apexd.cpp", 153 "apexd_lifecycle.cpp", 154 "apexd_loop.cpp", 155 "apexd_prepostinstall.cpp", 156 "apexd_private.cpp", 157 "apexd_session.cpp", 158 "apexd_verity.cpp", 159 ], 160 export_include_dirs: ["."], 161 generated_sources: ["apex-info-list"], 162 // Don't add shared/static libs here; add to libapexd_defaults instead. 163} 164 165cc_library_static { 166 name: "libapexd_checkpoint_vold", 167 defaults: ["apex_flags_defaults"], 168 srcs: [ "apexd_checkpoint_vold.cpp" ], 169 static_libs: [ 170 "libbase", 171 "libutils", 172 "libvold_binder", 173 ], 174 export_include_dirs: ["."], 175} 176 177cc_defaults { 178 name: "libapexservice-deps", 179 shared_libs: [ 180 "apex_aidl_interface-cpp", 181 "libbinder", 182 "libutils", 183 ], 184} 185 186cc_library_static { 187 name: "libapexservice", 188 defaults: [ 189 "apex_flags_defaults", 190 "libapexd-deps", 191 "libapexservice-deps", 192 ], 193 srcs: ["apexservice.cpp"], 194 static_libs: [ 195 "libapexd", 196 ], 197 cflags: [ 198 "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION", 199 ], 200} 201 202cc_defaults { 203 name: "libapex-deps", 204 shared_libs: [ 205 "libbase", 206 "libcrypto", 207 "libcutils", 208 "libprotobuf-cpp-full", 209 "libziparchive", 210 "libselinux", 211 ], 212 static_libs: [ 213 "lib_apex_session_state_proto", 214 "lib_apex_manifest_proto", 215 "libavb", 216 ], 217 static: { 218 whole_static_libs: ["libc++fs"], 219 }, 220 cpp_std: "experimental", 221 shared: { 222 static_libs: ["libc++fs"], 223 }, 224} 225 226cc_library_static { 227 name: "libapex", 228 defaults: [ 229 "apex_flags_defaults", 230 "libapex-deps" 231 ], 232 srcs: [ 233 "apex_file.cpp", 234 "apex_file_repository.cpp", 235 "apex_manifest.cpp", 236 "apex_shim.cpp", 237 ], 238 host_supported: true, 239 target: { 240 darwin: { 241 enabled: false, 242 }, 243 }, 244 header_libs: [ 245 "libutils_headers", 246 ], 247 export_header_lib_headers: [ 248 "libutils_headers", 249 ], 250} 251 252genrule { 253 // Generates an apex which has a different manifest outside the filesystem 254 // image. 255 name: "gen_manifest_mismatch_apex", 256 out: ["apex.apexd_test_manifest_mismatch.apex"], 257 srcs: [":apex.apexd_test"], 258 tools: ["soong_zip", "zipalign", "conv_apex_manifest"], 259 cmd: "unzip -q $(in) -d $(genDir) && " + 260 "$(location conv_apex_manifest) setprop version 137 $(genDir)/apex_manifest.pb && " + 261 "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + 262 "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + 263 "-o $(genDir)/unaligned.apex && " + 264 "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + 265 "$(genDir)/apex.apexd_test_manifest_mismatch.apex" 266} 267 268genrule { 269 // Generates an apex which has a different manifest outside the filesystem 270 // image. 271 name: "gen_manifest_mismatch_apex_no_hashtree", 272 out: ["apex.apexd_test_no_hashtree_manifest_mismatch.apex"], 273 srcs: [":apex.apexd_test_no_hashtree"], 274 tools: ["soong_zip", "zipalign", "conv_apex_manifest"], 275 cmd: "unzip -q $(in) -d $(genDir) && " + 276 "$(location conv_apex_manifest) setprop version 137 $(genDir)/apex_manifest.pb && " + 277 "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + 278 "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + 279 "-o $(genDir)/unaligned.apex && " + 280 "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + 281 "$(genDir)/apex.apexd_test_no_hashtree_manifest_mismatch.apex" 282} 283 284genrule { 285 // Generates an apex with a corrupted filesystem superblock, which should cause 286 // Apex::Open to fail 287 name: "gen_corrupt_superblock_apex", 288 out: ["apex.apexd_test_corrupt_superblock_apex.apex"], 289 srcs: [":apex.apexd_test"], 290 tools: ["soong_zip", "zipalign"], 291 cmd: "unzip -q $(in) -d $(genDir) && " + 292 "dd if=/dev/zero of=$(genDir)/apex_payload.img conv=notrunc bs=1024 seek=1 count=1 && " + 293 "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + 294 "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + 295 "-o $(genDir)/unaligned.apex && " + 296 "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + 297 "$(genDir)/apex.apexd_test_corrupt_superblock_apex.apex" 298} 299 300genrule { 301 // Generates an apex with a corrupted filesystem image, which should cause 302 // dm-verity verification to fail 303 name: "gen_corrupt_apex", 304 out: ["apex.apexd_test_corrupt_apex.apex"], 305 srcs: [":apex.apexd_test"], 306 tools: ["soong_zip", "zipalign"], 307 cmd: "unzip -q $(in) -d $(genDir) && " + 308 "dd if=/dev/zero of=$(genDir)/apex_payload.img conv=notrunc bs=1024 seek=16 count=1 && " + 309 "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + 310 "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + 311 "-o $(genDir)/unaligned.apex && " + 312 "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + 313 "$(genDir)/apex.apexd_test_corrupt_apex.apex" 314} 315 316genrule { 317 // Extract the root digest with avbtool 318 name: "apex.apexd_test_digest", 319 out: ["apex.apexd_test_digest.txt"], 320 srcs: [":apex.apexd_test"], 321 tools: ["avbtool"], 322 cmd: "unzip -q $(in) -d $(genDir) apex_payload.img && " + 323 "$(location avbtool) print_partition_digests --image $(genDir)/apex_payload.img " + 324 "| cut -c 3-| tee $(out)" 325} 326 327genrule { 328 // Extract the root digest with avbtool 329 name: "apex.apexd_test_f2fs_digest", 330 out: ["apex.apexd_test_f2fs_digest.txt"], 331 srcs: [":apex.apexd_test_f2fs"], 332 tools: ["avbtool"], 333 cmd: "unzip -q $(in) -d $(genDir) apex_payload.img && " + 334 "$(location avbtool) print_partition_digests --image $(genDir)/apex_payload.img " + 335 "| cut -c 3-| tee $(out)" 336} 337 338genrule { 339 // Generates an apex which has same module name as apex.apexd_test.apex, but 340 // is actually signed with a different key. 341 name: "gen_key_mismatch_apex", 342 out: ["apex.apexd_test_different_key.apex"], 343 srcs: [":apex.apexd_test_no_inst_key"], 344 tools: ["soong_zip", "zipalign", "conv_apex_manifest"], 345 cmd: "unzip -q $(in) -d $(genDir) && " + 346 "$(location conv_apex_manifest) setprop name com.android.apex.test_package $(genDir)/apex_manifest.pb && " + 347 "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + 348 "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + 349 "-o $(genDir)/unaligned.apex && " + 350 "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + 351 "$(genDir)/apex.apexd_test_different_key.apex" 352} 353 354genrule { 355 // Generates an apex which has same module name as apex.apexd_test.apex, but 356 // is actually signed with a different key. 357 name: "gen_key_mismatch_apex_v2", 358 out: ["apex.apexd_test_different_key_v2.apex"], 359 srcs: [":apex.apexd_test_no_inst_key"], 360 tools: ["soong_zip", "zipalign", "conv_apex_manifest"], 361 cmd: "unzip -q $(in) -d $(genDir) && " + 362 "$(location conv_apex_manifest) setprop name com.android.apex.test_package $(genDir)/apex_manifest.pb && " + 363 "$(location conv_apex_manifest) setprop version 2 $(genDir)/apex_manifest.pb && " + 364 "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + 365 "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + 366 "-o $(genDir)/unaligned.apex && " + 367 "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + 368 "$(genDir)/apex.apexd_test_different_key_v2.apex" 369} 370 371genrule { 372 // Generates an apex which has a different manifest outside the filesystem 373 // image. 374 name: "gen_manifest_mismatch_rebootless_apex", 375 out: ["test.rebootless_apex_manifest_mismatch.apex"], 376 srcs: [":test.rebootless_apex_v1"], 377 tools: ["soong_zip", "zipalign", "conv_apex_manifest"], 378 cmd: "unzip -q $(in) -d $(genDir) && " + 379 "$(location conv_apex_manifest) setprop version 137 $(genDir)/apex_manifest.pb && " + 380 "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + 381 "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + 382 "-o $(genDir)/unaligned.apex && " + 383 "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + 384 "$(genDir)/test.rebootless_apex_manifest_mismatch.apex" 385} 386 387genrule { 388 // Generates an apex with a corrupted filesystem image, which should cause 389 // dm-verity verification to fail 390 name: "gen_corrupt_rebootless_apex", 391 out: ["test.rebootless_apex_corrupted.apex"], 392 srcs: [":test.rebootless_apex_v1"], 393 tools: ["soong_zip", "zipalign"], 394 cmd: "unzip -q $(in) -d $(genDir) && " + 395 "dd if=/dev/zero of=$(genDir)/apex_payload.img conv=notrunc bs=1024 seek=16 count=1 && " + 396 "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + 397 "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + 398 "-o $(genDir)/unaligned.apex && " + 399 "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + 400 "$(genDir)/test.rebootless_apex_corrupted.apex" 401} 402 403cc_test { 404 name: "ApexTestCases", 405 defaults: [ 406 "apex_flags_defaults", 407 "libapex-deps", 408 "libapexd-deps" 409 ], 410 require_root: true, 411 cflags: [ 412 // Otherwise libgmock won't compile. 413 "-Wno-used-but-marked-unused", 414 ], 415 data: [ 416 ":apex.apexd_test", 417 ":apex.apexd_test_f2fs", 418 ":apex.apexd_test_digest", 419 ":apex.apexd_test_f2fs_digest", 420 ":apex.apexd_test_different_app", 421 ":apex.apexd_test_no_hashtree", 422 ":apex.apexd_test_no_hashtree_2", 423 ":apex.apexd_test_no_inst_key", 424 ":apex.apexd_test_f2fs_no_inst_key", 425 ":apex.apexd_test_nocode", 426 ":apex.apexd_test_postinstall", 427 ":apex.apexd_test_preinstall", 428 ":apex.apexd_test_prepostinstall.fail", 429 ":apex.apexd_test_v2", 430 ":apex.corrupted_b146895998", 431 ":apex.banned_name", 432 ":gen_key_mismatch_apex", 433 ":gen_key_mismatch_apex_v2", 434 ":gen_key_mismatch_capex", 435 ":gen_manifest_mismatch_apex", 436 ":gen_manifest_mismatch_apex_no_hashtree", 437 ":gen_corrupt_superblock_apex", 438 ":gen_corrupt_apex", 439 ":gen_capex_not_decompressible", 440 ":gen_capex_without_apex", 441 ":gen_capex_with_v2_apex", 442 ":gen_key_mismatch_with_original_capex", 443 ":com.android.apex.cts.shim.v1_prebuilt", 444 ":com.android.apex.cts.shim.v2_prebuilt", 445 ":com.android.apex.cts.shim.v2_wrong_sha_prebuilt", 446 ":com.android.apex.cts.shim.v2_additional_file_prebuilt", 447 ":com.android.apex.cts.shim.v2_additional_folder_prebuilt", 448 ":com.android.apex.cts.shim.v2_with_pre_install_hook_prebuilt", 449 ":com.android.apex.cts.shim.v2_with_post_install_hook_prebuilt", 450 ":com.android.apex.compressed_sharedlibs", 451 ":com.android.apex.compressed.v1", 452 ":com.android.apex.compressed.v1_different_digest", 453 ":com.android.apex.compressed.v1_different_digest_original", 454 ":com.android.apex.compressed.v1_original", 455 ":com.android.apex.compressed.v2", 456 ":com.android.apex.compressed.v2_original", 457 ":gen_manifest_mismatch_compressed_apex_v2", 458 "apexd_testdata/com.android.apex.test_package.avbpubkey", 459 "apexd_testdata/com.android.apex.compressed.avbpubkey", 460 ":com.android.apex.test.sharedlibs_generated.v1.libvX_prebuilt", 461 ":com.android.apex.test.sharedlibs_generated.v2.libvY_prebuilt", 462 ":test.rebootless_apex_v1", 463 ":test.rebootless_apex_v2", 464 ":test.rebootless_apex_v2_no_hashtree", 465 ":gen_manifest_mismatch_rebootless_apex", 466 ":gen_corrupt_rebootless_apex", 467 ":test.rebootless_apex_provides_sharedlibs", 468 ":test.rebootless_apex_provides_native_libs", 469 ":test.rebootless_apex_requires_shared_apex_libs", 470 ":test.rebootless_apex_jni_libs", 471 ":test.rebootless_apex_add_native_lib", 472 ":test.rebootless_apex_remove_native_lib", 473 ":test.rebootless_apex_app_in_apex", 474 ":test.rebootless_apex_priv_app_in_apex", 475 ], 476 srcs: [ 477 "apex_database_test.cpp", 478 "apex_file_test.cpp", 479 "apex_file_repository_test.cpp", 480 "apex_manifest_test.cpp", 481 "apexd_test.cpp", 482 "apexd_session_test.cpp", 483 "apexd_verity_test.cpp", 484 "apexd_utils_test.cpp", 485 "apexservice_test.cpp", 486 ], 487 host_supported: false, 488 compile_multilib: "first", 489 static_libs: [ 490 "apex_aidl_interface-cpp", 491 "libapex", 492 "libapexd", 493 "libfstab", 494 "libgmock", 495 ], 496 shared_libs: [ 497 "libbinder", 498 "libfs_mgr", 499 "libutils", 500 ], 501 generated_sources: ["apex-info-list"], 502 test_suites: ["device-tests"], 503 test_config: "AndroidTest.xml", 504} 505 506cc_test { 507 name: "flattened_apex_test", 508 defaults: [ 509 "apex_flags_defaults", 510 "libapex-deps", 511 "libapexd-deps" 512 ], 513 srcs: ["flattened_apex_test.cpp"], 514 host_supported: false, 515 compile_multilib: "first", 516 static_libs: [ 517 "libapex", 518 "libapexd", 519 ], 520 test_suites: ["device-tests"], 521 test_config: "flattened_apex_test_config.xml", 522} 523 524xsd_config { 525 name: "apex-info-list", 526 srcs: ["ApexInfoList.xsd"], 527 package_name: "com.android.apex", 528 api_dir: "apex-info-list-api", 529 gen_writer: true, 530} 531