diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-04-30 21:46:25 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-04-30 21:46:25 +0000 |
commit | c15690fc8dd4e3136de4c64adb15bea5d988467a (patch) | |
tree | 8a2a92a862efe4d09774248c5b32a32d8bebc52b | |
parent | f656ef618b4034184e3d787234d52b2f14e19669 (diff) | |
parent | a9035b08ccd47626d8dd72287eb2decf42888ae0 (diff) | |
download | apex-build-tools-release.tar.gz |
Snap for 11784721 from a9035b08ccd47626d8dd72287eb2decf42888ae0 to build-tools-releasebuild-tools-release
Change-Id: I2ad62e46279b997aa9bcb27d964abac3c81d7d72
28 files changed, 1939 insertions, 1825 deletions
diff --git a/apexd/Android.bp b/apexd/Android.bp index 76c73b05..20265812 100644 --- a/apexd/Android.bp +++ b/apexd/Android.bp @@ -5,666 +5,695 @@ package { } tidy_errors = [ - "android-*", - "bugprone-infinite-loop", - "bugprone-macro-parentheses", - "bugprone-misplaced-widening-cast", - "bugprone-move-forwarding-reference", - "bugprone-sizeof-container", - "bugprone-sizeof-expression", - "bugprone-string-constructor", - "bugprone-terminating-continue", - "bugprone-undefined-memory-manipulation", - "bugprone-undelegated-constructor", - // "bugprone-unhandled-self-assignment", // found in apex_manifest.proto - "bugprone-unused-raii", - "cert-err34-c", - "google-default-arguments", - // "google-explicit-constructor", // found in com_android_apex.h - "google-readability-avoid-underscore-in-googletest-name", - "google-readability-todo", - "google-runtime-int", - "google-runtime-member-string-references", - "misc-move-const-arg", - "misc-move-forwarding-reference", - // "misc-unused-parameters", // found in apexd_utils.h - "misc-unused-using-decls", - "misc-use-after-move", - // "modernize-pass-by-value", // found in apex_database.h - "performance-faster-string-find", - "performance-for-range-copy", - "performance-implicit-conversion-in-loop", - "performance-inefficient-vector-operation", - "performance-move-const-arg", - // "performance-move-constructor-init", // found in apexd_loop.h - "performance-noexcept-move-constructor", - "performance-unnecessary-copy-initialization", - "performance-unnecessary-value-param", - // "readability-avoid-const-params-in-decls", // found in apexd.h + "android-*", + "bugprone-infinite-loop", + "bugprone-macro-parentheses", + "bugprone-misplaced-widening-cast", + "bugprone-move-forwarding-reference", + "bugprone-sizeof-container", + "bugprone-sizeof-expression", + "bugprone-string-constructor", + "bugprone-terminating-continue", + "bugprone-undefined-memory-manipulation", + "bugprone-undelegated-constructor", + // "bugprone-unhandled-self-assignment", // found in apex_manifest.proto + "bugprone-unused-raii", + "cert-err34-c", + "google-default-arguments", + // "google-explicit-constructor", // found in com_android_apex.h + "google-readability-avoid-underscore-in-googletest-name", + "google-readability-todo", + "google-runtime-int", + "google-runtime-member-string-references", + "misc-move-const-arg", + "misc-move-forwarding-reference", + // "misc-unused-parameters", // found in apexd_utils.h + "misc-unused-using-decls", + "misc-use-after-move", + // "modernize-pass-by-value", // found in apex_database.h + "performance-faster-string-find", + "performance-for-range-copy", + "performance-implicit-conversion-in-loop", + "performance-inefficient-vector-operation", + "performance-move-const-arg", + // "performance-move-constructor-init", // found in apexd_loop.h + "performance-noexcept-move-constructor", + "performance-unnecessary-copy-initialization", + "performance-unnecessary-value-param", + // "readability-avoid-const-params-in-decls", // found in apexd.h ] cc_defaults { - name: "apex_flags_defaults", - cflags: [ - "-Wall", - "-Wextra", - "-Werror", - "-Wno-unused-parameter", + name: "apex_flags_defaults", + cflags: [ + "-Wall", + "-Wextra", + "-Werror", + "-Wno-unused-parameter", - // Some extra flags. - "-fstrict-aliasing", - "-Wredundant-decls", - "-Wshadow", - "-Wstrict-aliasing", - "-Wthread-safety", - "-Wthread-safety-negative", - "-Wunreachable-code", - "-Wunreachable-code-break", - "-Wunreachable-code-return", - "-Wunused", - "-Wused-but-marked-unused", - ], - tidy: true, - tidy_checks: tidy_errors, - tidy_checks_as_errors: tidy_errors, - tidy_flags: [ - "-format-style=file", - "-header-filter=system/apex/", - ], + // Some extra flags. + "-fstrict-aliasing", + "-Wredundant-decls", + "-Wshadow", + "-Wstrict-aliasing", + "-Wthread-safety", + "-Wthread-safety-negative", + "-Wunreachable-code", + "-Wunreachable-code-break", + "-Wunreachable-code-return", + "-Wunused", + "-Wused-but-marked-unused", + ], + tidy: true, + tidy_checks: tidy_errors, + tidy_checks_as_errors: tidy_errors, + tidy_flags: [ + "-format-style=file", + "-header-filter=system/apex/", + ], } cc_defaults { - name: "libapexd-deps", - defaults: ["libapex-deps"], - shared_libs: [ - "liblog", - "liblogwrap", - "libvintf", - ], - static_libs: [ - "lib_microdroid_metadata_proto", - "libapex", - "libavb", - "libdm", - "libext2_uuid", - "libsigningutils", - "libtinyxml2", - "libverity_tree", - "libvold_binder", - ], - whole_static_libs: ["libcom.android.sysprop.apex"], + name: "libapexd-deps", + defaults: ["libapex-deps"], + shared_libs: [ + "liblog", + "liblogwrap", + "libvintf", + ], + static_libs: [ + "lib_microdroid_metadata_proto", + "libapex", + "libavb", + "libdm", + "libext2_uuid", + "libsigningutils", + "libtinyxml2", + "libverity_tree", + "libvold_binder", + ], + whole_static_libs: ["libcom.android.sysprop.apex"], } aidl_interface { - name: "apex_aidl_interface", - unstable: true, - srcs: [ - "aidl/android/apex/ApexInfo.aidl", - "aidl/android/apex/ApexInfoList.aidl", - "aidl/android/apex/ApexSessionInfo.aidl", - "aidl/android/apex/ApexSessionParams.aidl", - "aidl/android/apex/CompressedApexInfo.aidl", - "aidl/android/apex/CompressedApexInfoList.aidl", - "aidl/android/apex/IApexService.aidl", - ], - local_include_dir: "aidl", - backend: { - java: { - sdk_version: "28", - }, - ndk: { - enabled: false, - }, - }, + name: "apex_aidl_interface", + unstable: true, + srcs: [ + "aidl/android/apex/ApexInfo.aidl", + "aidl/android/apex/ApexInfoList.aidl", + "aidl/android/apex/ApexSessionInfo.aidl", + "aidl/android/apex/ApexSessionParams.aidl", + "aidl/android/apex/CompressedApexInfo.aidl", + "aidl/android/apex/CompressedApexInfoList.aidl", + "aidl/android/apex/IApexService.aidl", + ], + local_include_dir: "aidl", + backend: { + java: { + sdk_version: "28", + }, + ndk: { + enabled: false, + }, + }, } cc_binary { - name: "apexd", - defaults: [ - "apex_flags_defaults", - "libapex-deps", - "libapexd-deps", - "libapexservice-deps", - ], - srcs: [ - "apexd_main.cpp", - ], - static_libs: [ - "libapex", - "libapexd", - "libapexd_checkpoint_vold", - "libapexservice", - ], - init_rc: ["apexd.rc"], - // Just like the init, apexd should be able to run without - // any APEX activated. To do so, it uses the bootstrap linker - // and the bootstrap bionic libraries. - bootstrap: true, + name: "apexd", + defaults: [ + "apex_flags_defaults", + "libapex-deps", + "libapexd-deps", + "libapexservice-deps", + ], + srcs: [ + "apexd_main.cpp", + ], + static_libs: [ + "libapex", + "libapexd", + "libapexd_checkpoint_vold", + "libapexservice", + ], + init_rc: ["apexd.rc"], + // Just like the init, apexd should be able to run without + // any APEX activated. To do so, it uses the bootstrap linker + // and the bootstrap bionic libraries. + bootstrap: true, } cc_binary { - name: "apexd.microdroid", - defaults: [ - "apex_flags_defaults", - "libapex-deps", - "libapexd-deps", - ], - srcs: [ - "apexd_microdroid.cpp", - ], - static_libs: [ - "libapex", - "libapexd", - // Prefer static-link as, in microdroid, apexd is the only client. - // Using the -ndk variant since libprotobuf-cpp-full is supposed to be - // used as a shared lib in general in Android. - "libprotobuf-cpp-full-ndk", - ], - exclude_shared_libs: [ - "libprotobuf-cpp-full", - "libvintf", - ], - // Just like the init, apexd should be able to run without - // any APEX activated. To do so, it uses the bootstrap linker - // and the bootstrap bionic libraries. - bootstrap: true, - // This variant is for microdroid. - installable: false, - // init depends on the name "apexd". - stem: "apexd", + name: "apexd.microdroid", + defaults: [ + "apex_flags_defaults", + "libapex-deps", + "libapexd-deps", + ], + srcs: [ + "apexd_microdroid.cpp", + ], + static_libs: [ + "libapex", + "libapexd", + // Prefer static-link as, in microdroid, apexd is the only client. + // Using the -ndk variant since libprotobuf-cpp-full is supposed to be + // used as a shared lib in general in Android. + "libprotobuf-cpp-full-ndk", + ], + exclude_shared_libs: [ + "libprotobuf-cpp-full", + "libvintf", + ], + // Just like the init, apexd should be able to run without + // any APEX activated. To do so, it uses the bootstrap linker + // and the bootstrap bionic libraries. + bootstrap: true, + // This variant is for microdroid. + installable: false, + // init depends on the name "apexd". + stem: "apexd", } cc_library_static { - name: "libapexd", - defaults: [ - "apex_flags_defaults", - "libapexd-deps", - ], - srcs: [ - "apex_classpath.cpp", - "apex_database.cpp", - "apex_file_repository.cpp", - "apexd.cpp", - "apexd_lifecycle.cpp", - "apexd_loop.cpp", - "apexd_private.cpp", - "apexd_session.cpp", - "apexd_verity.cpp", - "apexd_vendor_apex.cpp", - ], - export_include_dirs: ["."], - generated_sources: ["apex-info-list-tinyxml"], - // Don't add shared/static libs here; add to libapexd_defaults instead. + name: "libapexd", + defaults: [ + "apex_flags_defaults", + "libapexd-deps", + ], + srcs: [ + "apex_classpath.cpp", + "apex_database.cpp", + "apex_file_repository.cpp", + "apexd.cpp", + "apexd_lifecycle.cpp", + "apexd_loop.cpp", + "apexd_private.cpp", + "apexd_session.cpp", + "apexd_verity.cpp", + "apexd_vendor_apex.cpp", + ], + export_include_dirs: ["."], + generated_sources: ["apex-info-list-tinyxml"], + // Don't add shared/static libs here; add to libapexd_defaults instead. } cc_library_static { - name: "libapexd_checkpoint_vold", - defaults: ["apex_flags_defaults"], - srcs: [ "apexd_checkpoint_vold.cpp" ], - static_libs: [ - "libbase", - "libutils", - "libvold_binder", - ], - export_include_dirs: ["."], + name: "libapexd_checkpoint_vold", + defaults: ["apex_flags_defaults"], + srcs: ["apexd_checkpoint_vold.cpp"], + static_libs: [ + "libbase", + "libutils", + "libvold_binder", + ], + export_include_dirs: ["."], } cc_defaults { - name: "libapexservice-deps", - shared_libs: [ - "apex_aidl_interface-cpp", - "libbinder", - "libutils", - ], + name: "libapexservice-deps", + shared_libs: [ + "apex_aidl_interface-cpp", + "libbinder", + "libutils", + ], } cc_library_static { - name: "libapexservice", - defaults: [ - "apex_flags_defaults", - "libapexd-deps", - "libapexservice-deps", - ], - srcs: ["apexservice.cpp"], - static_libs: [ - "libapexd", - ], - cflags: [ - "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION", - ], + name: "libapexservice", + defaults: [ + "apex_flags_defaults", + "libapexd-deps", + "libapexservice-deps", + ], + srcs: ["apexservice.cpp"], + static_libs: [ + "libapexd", + ], + cflags: [ + "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION", + ], } cc_defaults { - name: "libapex-deps", - shared_libs: [ - "libbase", - "libcrypto", - "libcutils", - "libprotobuf-cpp-full", - "libziparchive", - "libselinux", - ], - static_libs: [ - "lib_apex_session_state_proto", - "lib_apex_manifest_proto", - "libavb", - "libverity_tree", - ], - static: { - whole_static_libs: ["libc++fs"], - }, - cpp_std: "experimental", - shared: { - static_libs: ["libc++fs"], - }, + name: "libapex-deps", + shared_libs: [ + "libbase", + "libcrypto", + "libcutils", + "libprotobuf-cpp-full", + "libziparchive", + "libselinux", + ], + static_libs: [ + "lib_apex_session_state_proto", + "lib_apex_manifest_proto", + "libavb", + "libverity_tree", + ], + static: { + whole_static_libs: ["libc++fs"], + }, + cpp_std: "experimental", + shared: { + static_libs: ["libc++fs"], + }, } cc_library_static { - name: "libapex", - defaults: [ - "apex_flags_defaults", - "libapex-deps" - ], - srcs: [ - "apex_file.cpp", - "apex_manifest.cpp", - "apex_shim.cpp", - "apexd_verity.cpp", - ], - host_supported: true, - target: { - darwin: { - enabled: false, + name: "libapex", + defaults: [ + "apex_flags_defaults", + "libapex-deps", + ], + srcs: [ + "apex_file.cpp", + "apex_manifest.cpp", + "apex_shim.cpp", + "apexd_verity.cpp", + ], + host_supported: true, + target: { + darwin: { + enabled: false, + }, }, - }, - header_libs: [ - "libutils_headers", - ], - export_header_lib_headers: [ - "libutils_headers", - ], - export_include_dirs: ["."], + header_libs: [ + "libutils_headers", + ], + export_header_lib_headers: [ + "libutils_headers", + ], + export_include_dirs: ["."], } genrule { - // Generates an apex which has a different manifest outside the filesystem - // image. - name: "gen_manifest_mismatch_apex", - out: ["apex.apexd_test_manifest_mismatch.apex"], - srcs: [":apex.apexd_test"], - tools: ["soong_zip", "zipalign", "conv_apex_manifest"], - cmd: "unzip -q $(in) -d $(genDir) && " + - "$(location conv_apex_manifest) setprop version 137 $(genDir)/apex_manifest.pb && " + - "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + - "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + - "-o $(genDir)/unaligned.apex && " + - "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + - "$(genDir)/apex.apexd_test_manifest_mismatch.apex" + // Generates an apex which has a different manifest outside the filesystem + // image. + name: "gen_manifest_mismatch_apex", + out: ["apex.apexd_test_manifest_mismatch.apex"], + srcs: [":apex.apexd_test"], + tools: [ + "soong_zip", + "zipalign", + "conv_apex_manifest", + ], + cmd: "unzip -q $(in) -d $(genDir) && " + + "$(location conv_apex_manifest) setprop version 137 $(genDir)/apex_manifest.pb && " + + "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + + "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + + "-o $(genDir)/unaligned.apex && " + + "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + + "$(genDir)/apex.apexd_test_manifest_mismatch.apex", } genrule { - // Generates an apex which has a different manifest outside the filesystem - // image. - name: "gen_manifest_mismatch_apex_no_hashtree", - out: ["apex.apexd_test_no_hashtree_manifest_mismatch.apex"], - srcs: [":apex.apexd_test_no_hashtree"], - tools: ["soong_zip", "zipalign", "conv_apex_manifest"], - cmd: "unzip -q $(in) -d $(genDir) && " + - "$(location conv_apex_manifest) setprop version 137 $(genDir)/apex_manifest.pb && " + - "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + - "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + - "-o $(genDir)/unaligned.apex && " + - "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + - "$(genDir)/apex.apexd_test_no_hashtree_manifest_mismatch.apex" + // Generates an apex which has a different manifest outside the filesystem + // image. + name: "gen_manifest_mismatch_apex_no_hashtree", + out: ["apex.apexd_test_no_hashtree_manifest_mismatch.apex"], + srcs: [":apex.apexd_test_no_hashtree"], + tools: [ + "soong_zip", + "zipalign", + "conv_apex_manifest", + ], + cmd: "unzip -q $(in) -d $(genDir) && " + + "$(location conv_apex_manifest) setprop version 137 $(genDir)/apex_manifest.pb && " + + "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + + "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + + "-o $(genDir)/unaligned.apex && " + + "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + + "$(genDir)/apex.apexd_test_no_hashtree_manifest_mismatch.apex", } genrule { - // Generates an apex with a corrupted filesystem superblock, which should cause - // Apex::Open to fail - name: "gen_corrupt_superblock_apex", - out: ["apex.apexd_test_corrupt_superblock_apex.apex"], - srcs: [":apex.apexd_test"], - tools: ["soong_zip", "zipalign"], - cmd: "unzip -q $(in) -d $(genDir) && " + - "dd if=/dev/zero of=$(genDir)/apex_payload.img conv=notrunc bs=1024 seek=1 count=1 && " + - "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + - "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + - "-o $(genDir)/unaligned.apex && " + - "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + - "$(genDir)/apex.apexd_test_corrupt_superblock_apex.apex" + // Generates an apex with a corrupted filesystem superblock, which should cause + // Apex::Open to fail + name: "gen_corrupt_superblock_apex", + out: ["apex.apexd_test_corrupt_superblock_apex.apex"], + srcs: [":apex.apexd_test"], + tools: [ + "soong_zip", + "zipalign", + ], + cmd: "unzip -q $(in) -d $(genDir) && " + + "dd if=/dev/zero of=$(genDir)/apex_payload.img conv=notrunc bs=1024 seek=1 count=1 && " + + "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + + "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + + "-o $(genDir)/unaligned.apex && " + + "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + + "$(genDir)/apex.apexd_test_corrupt_superblock_apex.apex", } genrule { - // Generates an apex with a corrupted filesystem image, which should cause - // dm-verity verification to fail - name: "gen_corrupt_apex", - out: ["apex.apexd_test_corrupt_apex.apex"], - srcs: [":apex.apexd_test"], - tools: ["soong_zip", "zipalign"], - cmd: "unzip -q $(in) -d $(genDir) && " + - "dd if=/dev/zero of=$(genDir)/apex_payload.img conv=notrunc bs=1024 seek=16 count=1 && " + - "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + - "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + - "-o $(genDir)/unaligned.apex && " + - "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + - "$(genDir)/apex.apexd_test_corrupt_apex.apex" + // Generates an apex with a corrupted filesystem image, which should cause + // dm-verity verification to fail + name: "gen_corrupt_apex", + out: ["apex.apexd_test_corrupt_apex.apex"], + srcs: [":apex.apexd_test"], + tools: [ + "soong_zip", + "zipalign", + ], + cmd: "unzip -q $(in) -d $(genDir) && " + + "dd if=/dev/zero of=$(genDir)/apex_payload.img conv=notrunc bs=1024 seek=16 count=1 && " + + "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + + "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + + "-o $(genDir)/unaligned.apex && " + + "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + + "$(genDir)/apex.apexd_test_corrupt_apex.apex", } genrule { - // Extract the root digest with avbtool - name: "apex.apexd_test_digest", - out: ["apex.apexd_test_digest.txt"], - srcs: [":apex.apexd_test"], - tools: ["avbtool"], - cmd: "unzip -q $(in) -d $(genDir) apex_payload.img && " + - "$(location avbtool) print_partition_digests --image $(genDir)/apex_payload.img " + - "| cut -c 3-| tee $(out)" + // Extract the root digest with avbtool + name: "apex.apexd_test_digest", + out: ["apex.apexd_test_digest.txt"], + srcs: [":apex.apexd_test"], + tools: ["avbtool"], + cmd: "unzip -q $(in) -d $(genDir) apex_payload.img && " + + "$(location avbtool) print_partition_digests --image $(genDir)/apex_payload.img " + + "| cut -c 3-| tee $(out)", } genrule { - // Extract the root digest with avbtool - name: "apex.apexd_test_f2fs_digest", - out: ["apex.apexd_test_f2fs_digest.txt"], - srcs: [":apex.apexd_test_f2fs"], - tools: ["avbtool"], - cmd: "unzip -q $(in) -d $(genDir) apex_payload.img && " + - "$(location avbtool) print_partition_digests --image $(genDir)/apex_payload.img " + - "| cut -c 3-| tee $(out)" + // Extract the root digest with avbtool + name: "apex.apexd_test_f2fs_digest", + out: ["apex.apexd_test_f2fs_digest.txt"], + srcs: [":apex.apexd_test_f2fs"], + tools: ["avbtool"], + cmd: "unzip -q $(in) -d $(genDir) apex_payload.img && " + + "$(location avbtool) print_partition_digests --image $(genDir)/apex_payload.img " + + "| cut -c 3-| tee $(out)", } genrule { - // Extract the root digest with avbtool - name: "apex.apexd_test_erofs_digest", - out: ["apex.apexd_test_erofs_digest.txt"], - srcs: [":apex.apexd_test_erofs"], - tools: ["avbtool"], - cmd: "unzip -q $(in) -d $(genDir) apex_payload.img && " + - "$(location avbtool) print_partition_digests --image $(genDir)/apex_payload.img " + - "| cut -c 3-| tee $(out)" + // Extract the root digest with avbtool + name: "apex.apexd_test_erofs_digest", + out: ["apex.apexd_test_erofs_digest.txt"], + srcs: [":apex.apexd_test_erofs"], + tools: ["avbtool"], + cmd: "unzip -q $(in) -d $(genDir) apex_payload.img && " + + "$(location avbtool) print_partition_digests --image $(genDir)/apex_payload.img " + + "| cut -c 3-| tee $(out)", } genrule { - // Generates an apex which has same module name as apex.apexd_test.apex, but - // is actually signed with a different key. - name: "gen_key_mismatch_apex", - out: ["apex.apexd_test_different_key.apex"], - srcs: [":apex.apexd_test_no_inst_key"], - tools: ["soong_zip", "zipalign", "conv_apex_manifest"], - cmd: "unzip -q $(in) -d $(genDir) && " + - "$(location conv_apex_manifest) setprop name com.android.apex.test_package $(genDir)/apex_manifest.pb && " + - "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + - "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + - "-o $(genDir)/unaligned.apex && " + - "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + - "$(genDir)/apex.apexd_test_different_key.apex" + // Generates an apex which has same module name as apex.apexd_test.apex, but + // is actually signed with a different key. + name: "gen_key_mismatch_apex", + out: ["apex.apexd_test_different_key.apex"], + srcs: [":apex.apexd_test_no_inst_key"], + tools: [ + "soong_zip", + "zipalign", + "conv_apex_manifest", + ], + cmd: "unzip -q $(in) -d $(genDir) && " + + "$(location conv_apex_manifest) setprop name com.android.apex.test_package $(genDir)/apex_manifest.pb && " + + "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + + "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + + "-o $(genDir)/unaligned.apex && " + + "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + + "$(genDir)/apex.apexd_test_different_key.apex", } genrule { - // Generates an apex which has same module name as apex.apexd_test.apex, but - // is actually signed with a different key. - name: "gen_key_mismatch_apex_v2", - out: ["apex.apexd_test_different_key_v2.apex"], - srcs: [":apex.apexd_test_no_inst_key"], - tools: ["soong_zip", "zipalign", "conv_apex_manifest"], - cmd: "unzip -q $(in) -d $(genDir) && " + - "$(location conv_apex_manifest) setprop name com.android.apex.test_package $(genDir)/apex_manifest.pb && " + - "$(location conv_apex_manifest) setprop version 2 $(genDir)/apex_manifest.pb && " + - "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + - "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + - "-o $(genDir)/unaligned.apex && " + - "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + - "$(genDir)/apex.apexd_test_different_key_v2.apex" + // Generates an apex which has same module name as apex.apexd_test.apex, but + // is actually signed with a different key. + name: "gen_key_mismatch_apex_v2", + out: ["apex.apexd_test_different_key_v2.apex"], + srcs: [":apex.apexd_test_no_inst_key"], + tools: [ + "soong_zip", + "zipalign", + "conv_apex_manifest", + ], + cmd: "unzip -q $(in) -d $(genDir) && " + + "$(location conv_apex_manifest) setprop name com.android.apex.test_package $(genDir)/apex_manifest.pb && " + + "$(location conv_apex_manifest) setprop version 2 $(genDir)/apex_manifest.pb && " + + "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + + "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + + "-o $(genDir)/unaligned.apex && " + + "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + + "$(genDir)/apex.apexd_test_different_key_v2.apex", } genrule { - // Generates an apex which has a different manifest outside the filesystem - // image. - name: "gen_manifest_mismatch_rebootless_apex", - out: ["test.rebootless_apex_manifest_mismatch.apex"], - srcs: [":test.rebootless_apex_v1"], - tools: ["soong_zip", "zipalign", "conv_apex_manifest"], - cmd: "unzip -q $(in) -d $(genDir) && " + - "$(location conv_apex_manifest) setprop version 137 $(genDir)/apex_manifest.pb && " + - "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + - "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + - "-o $(genDir)/unaligned.apex && " + - "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + - "$(genDir)/test.rebootless_apex_manifest_mismatch.apex" + // Generates an apex which has a different manifest outside the filesystem + // image. + name: "gen_manifest_mismatch_rebootless_apex", + out: ["test.rebootless_apex_manifest_mismatch.apex"], + srcs: [":test.rebootless_apex_v1"], + tools: [ + "soong_zip", + "zipalign", + "conv_apex_manifest", + ], + cmd: "unzip -q $(in) -d $(genDir) && " + + "$(location conv_apex_manifest) setprop version 137 $(genDir)/apex_manifest.pb && " + + "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + + "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + + "-o $(genDir)/unaligned.apex && " + + "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + + "$(genDir)/test.rebootless_apex_manifest_mismatch.apex", } genrule { - // Generates an apex with a corrupted filesystem image, which should cause - // dm-verity verification to fail - name: "gen_corrupt_rebootless_apex", - out: ["test.rebootless_apex_corrupted.apex"], - srcs: [":test.rebootless_apex_v1"], - tools: ["soong_zip", "zipalign"], - cmd: "unzip -q $(in) -d $(genDir) && " + - "dd if=/dev/zero of=$(genDir)/apex_payload.img conv=notrunc bs=1024 seek=16 count=1 && " + - "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + - "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + - "-o $(genDir)/unaligned.apex && " + - "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + - "$(genDir)/test.rebootless_apex_corrupted.apex" + // Generates an apex with a corrupted filesystem image, which should cause + // dm-verity verification to fail + name: "gen_corrupt_rebootless_apex", + out: ["test.rebootless_apex_corrupted.apex"], + srcs: [":test.rebootless_apex_v1"], + tools: [ + "soong_zip", + "zipalign", + ], + cmd: "unzip -q $(in) -d $(genDir) && " + + "dd if=/dev/zero of=$(genDir)/apex_payload.img conv=notrunc bs=1024 seek=16 count=1 && " + + "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + + "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + + "-o $(genDir)/unaligned.apex && " + + "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + + "$(genDir)/test.rebootless_apex_corrupted.apex", } cc_test { - name: "ApexTestCases", - defaults: [ - "apex_flags_defaults", - "libapex-deps", - "libapexd-deps" - ], - require_root: true, - cflags: [ - // Otherwise libgmock won't compile. - "-Wno-used-but-marked-unused", - ], - data: [ - ":apex.apexd_test", - ":apex.apexd_test_erofs", - ":apex.apexd_test_f2fs", - ":apex.apexd_test_digest", - ":apex.apexd_test_erofs_digest", - ":apex.apexd_test_f2fs_digest", - ":apex.apexd_test_classpath", - ":apex.apexd_test_different_app", - ":apex.apexd_test_no_hashtree", - ":apex.apexd_test_no_hashtree_2", - ":apex.apexd_test_no_inst_key", - ":apex.apexd_test_f2fs_no_inst_key", - ":apex.apexd_test_nocode", - ":apex.apexd_test_v2", - ":apex.corrupted_b146895998", - ":apex.banned_name", - ":gen_key_mismatch_apex", - ":gen_key_mismatch_apex_v2", - ":gen_key_mismatch_capex", - ":gen_manifest_mismatch_apex", - ":gen_manifest_mismatch_apex_no_hashtree", - ":gen_corrupt_superblock_apex", - ":gen_corrupt_apex", - ":gen_capex_not_decompressible", - ":gen_capex_without_apex", - ":gen_capex_with_v2_apex", - ":gen_key_mismatch_with_original_capex", - ":com.android.apex.cts.shim.v1_prebuilt", - ":com.android.apex.cts.shim.v2_prebuilt", - ":com.android.apex.cts.shim.v2_wrong_sha_prebuilt", - ":com.android.apex.cts.shim.v2_additional_file_prebuilt", - ":com.android.apex.cts.shim.v2_additional_folder_prebuilt", - ":com.android.apex.cts.shim.v2_with_pre_install_hook_prebuilt", - ":com.android.apex.cts.shim.v2_with_post_install_hook_prebuilt", - ":com.android.apex.compressed_sharedlibs", - ":com.android.apex.compressed.v1", - ":com.android.apex.compressed.v1_different_digest", - ":com.android.apex.compressed.v1_different_digest_original", - ":com.android.apex.compressed.v1_original", - ":com.android.apex.compressed.v2", - ":com.android.apex.compressed.v2_original", - ":gen_manifest_mismatch_compressed_apex_v2", - "apexd_testdata/com.android.apex.test_package.avbpubkey", - "apexd_testdata/com.android.apex.compressed.avbpubkey", - ":com.android.apex.test.sharedlibs_generated.v1.libvX_prebuilt", - ":com.android.apex.test.sharedlibs_generated.v2.libvY_prebuilt", - ":test.rebootless_apex_v1", - ":test.rebootless_apex_v2", - ":test.rebootless_apex_v2_no_hashtree", - ":test.rebootless_apex_service_v1", - ":test.rebootless_apex_service_v2", - ":gen_manifest_mismatch_rebootless_apex", - ":gen_corrupt_rebootless_apex", - ":test.rebootless_apex_provides_sharedlibs", - ":test.rebootless_apex_provides_native_libs", - ":test.rebootless_apex_requires_shared_apex_libs", - ":test.rebootless_apex_jni_libs", - ":test.rebootless_apex_add_native_lib", - ":test.rebootless_apex_remove_native_lib", - ":test.rebootless_apex_app_in_apex", - ":test.rebootless_apex_priv_app_in_apex", - ], - srcs: [ - "apex_classpath_test.cpp", - "apex_database_test.cpp", - "apex_file_test.cpp", - "apex_file_repository_test.cpp", - "apex_manifest_test.cpp", - "apexd_test.cpp", - "apexd_session_test.cpp", - "apexd_verity_test.cpp", - "apexd_utils_test.cpp", - ], - host_supported: false, - compile_multilib: "first", - static_libs: [ - "apex_aidl_interface-cpp", - "libapex", - "libapexd", - "libfstab", - "libgmock", - ], - shared_libs: [ - "libbinder", - "libfs_mgr", - "libutils", - ], - generated_sources: ["apex-info-list-tinyxml"], - test_suites: ["device-tests"], - test_config: "ApexTestCases.xml", + name: "ApexTestCases", + defaults: [ + "apex_flags_defaults", + "libapex-deps", + "libapexd-deps", + ], + require_root: true, + cflags: [ + // Otherwise libgmock won't compile. + "-Wno-used-but-marked-unused", + ], + data: [ + ":apex.apexd_test", + ":apex.apexd_test_erofs", + ":apex.apexd_test_f2fs", + ":apex.apexd_test_digest", + ":apex.apexd_test_erofs_digest", + ":apex.apexd_test_f2fs_digest", + ":apex.apexd_test_classpath", + ":apex.apexd_test_different_app", + ":apex.apexd_test_no_hashtree", + ":apex.apexd_test_no_hashtree_2", + ":apex.apexd_test_no_inst_key", + ":apex.apexd_test_f2fs_no_inst_key", + ":apex.apexd_test_nocode", + ":apex.apexd_test_v2", + ":apex.corrupted_b146895998", + ":apex.banned_name", + ":gen_key_mismatch_apex", + ":gen_key_mismatch_apex_v2", + ":gen_key_mismatch_capex", + ":gen_manifest_mismatch_apex", + ":gen_manifest_mismatch_apex_no_hashtree", + ":gen_corrupt_superblock_apex", + ":gen_corrupt_apex", + ":gen_capex_not_decompressible", + ":gen_capex_without_apex", + ":gen_capex_with_v2_apex", + ":gen_key_mismatch_with_original_capex", + ":com.android.apex.cts.shim.v1_prebuilt", + ":com.android.apex.cts.shim.v2_prebuilt", + ":com.android.apex.cts.shim.v2_wrong_sha_prebuilt", + ":com.android.apex.cts.shim.v2_additional_file_prebuilt", + ":com.android.apex.cts.shim.v2_additional_folder_prebuilt", + ":com.android.apex.cts.shim.v2_with_pre_install_hook_prebuilt", + ":com.android.apex.cts.shim.v2_with_post_install_hook_prebuilt", + ":com.android.apex.compressed_sharedlibs", + ":com.android.apex.compressed.v1", + ":com.android.apex.compressed.v1_different_digest", + ":com.android.apex.compressed.v1_different_digest_original", + ":com.android.apex.compressed.v1_original", + ":com.android.apex.compressed.v2", + ":com.android.apex.compressed.v2_original", + ":gen_manifest_mismatch_compressed_apex_v2", + "apexd_testdata/com.android.apex.test_package.avbpubkey", + "apexd_testdata/com.android.apex.compressed.avbpubkey", + ":com.android.apex.test.sharedlibs_generated.v1.libvX_prebuilt", + ":com.android.apex.test.sharedlibs_generated.v2.libvY_prebuilt", + ":test.rebootless_apex_v1", + ":test.rebootless_apex_v2", + ":test.rebootless_apex_v2_no_hashtree", + ":test.rebootless_apex_service_v1", + ":test.rebootless_apex_service_v2", + ":gen_manifest_mismatch_rebootless_apex", + ":gen_corrupt_rebootless_apex", + ":test.rebootless_apex_provides_sharedlibs", + ":test.rebootless_apex_provides_native_libs", + ":test.rebootless_apex_requires_shared_apex_libs", + ":test.rebootless_apex_jni_libs", + ":test.rebootless_apex_add_native_lib", + ":test.rebootless_apex_remove_native_lib", + ":test.rebootless_apex_app_in_apex", + ":test.rebootless_apex_priv_app_in_apex", + ], + srcs: [ + "apex_classpath_test.cpp", + "apex_database_test.cpp", + "apex_file_test.cpp", + "apex_file_repository_test.cpp", + "apex_manifest_test.cpp", + "apexd_test.cpp", + "apexd_session_test.cpp", + "apexd_verity_test.cpp", + "apexd_utils_test.cpp", + ], + host_supported: false, + compile_multilib: "first", + static_libs: [ + "apex_aidl_interface-cpp", + "libapex", + "libapexd", + "libfstab", + "libgmock", + ], + shared_libs: [ + "libbinder", + "libfs_mgr", + "libutils", + ], + generated_sources: ["apex-info-list-tinyxml"], + test_suites: ["device-tests"], + test_config: "ApexTestCases.xml", } cc_test { - name: "ApexServiceTestCases", - defaults: [ - "apex_flags_defaults", - "libapex-deps", - "libapexd-deps" - ], - require_root: true, - cflags: [ - // Otherwise libgmock won't compile. - "-Wno-used-but-marked-unused", - ], - data: [ - ":apex.apexd_test", - ":apex.apexd_test_erofs", - ":apex.apexd_test_f2fs", - ":apex.apexd_test_digest", - ":apex.apexd_test_erofs_digest", - ":apex.apexd_test_f2fs_digest", - ":apex.apexd_test_classpath", - ":apex.apexd_test_different_app", - ":apex.apexd_test_no_hashtree", - ":apex.apexd_test_no_hashtree_2", - ":apex.apexd_test_no_inst_key", - ":apex.apexd_test_f2fs_no_inst_key", - ":apex.apexd_test_nocode", - ":apex.apexd_test_v2", - ":apex.corrupted_b146895998", - ":apex.banned_name", - ":gen_key_mismatch_apex", - ":gen_key_mismatch_apex_v2", - ":gen_key_mismatch_capex", - ":gen_manifest_mismatch_apex", - ":gen_manifest_mismatch_apex_no_hashtree", - ":gen_corrupt_superblock_apex", - ":gen_corrupt_apex", - ":gen_capex_not_decompressible", - ":gen_capex_without_apex", - ":gen_capex_with_v2_apex", - ":gen_key_mismatch_with_original_capex", - ":com.android.apex.cts.shim.v1_prebuilt", - ":com.android.apex.cts.shim.v2_prebuilt", - ":com.android.apex.cts.shim.v2_wrong_sha_prebuilt", - ":com.android.apex.cts.shim.v2_additional_file_prebuilt", - ":com.android.apex.cts.shim.v2_additional_folder_prebuilt", - ":com.android.apex.cts.shim.v2_with_pre_install_hook_prebuilt", - ":com.android.apex.cts.shim.v2_with_post_install_hook_prebuilt", - ":com.android.apex.compressed_sharedlibs", - ":com.android.apex.compressed.v1", - ":com.android.apex.compressed.v1_different_digest", - ":com.android.apex.compressed.v1_different_digest_original", - ":com.android.apex.compressed.v1_original", - ":com.android.apex.compressed.v2", - ":com.android.apex.compressed.v2_original", - ":gen_manifest_mismatch_compressed_apex_v2", - "apexd_testdata/com.android.apex.test_package.avbpubkey", - "apexd_testdata/com.android.apex.compressed.avbpubkey", - ":com.android.apex.test.sharedlibs_generated.v1.libvX_prebuilt", - ":com.android.apex.test.sharedlibs_generated.v2.libvY_prebuilt", - ":test.rebootless_apex_v1", - ":test.rebootless_apex_v2", - ":test.rebootless_apex_v2_no_hashtree", - ":test.rebootless_apex_service_v1", - ":test.rebootless_apex_service_v2", - ":gen_manifest_mismatch_rebootless_apex", - ":gen_corrupt_rebootless_apex", - ":test.rebootless_apex_provides_sharedlibs", - ":test.rebootless_apex_provides_native_libs", - ":test.rebootless_apex_requires_shared_apex_libs", - ":test.rebootless_apex_jni_libs", - ":test.rebootless_apex_add_native_lib", - ":test.rebootless_apex_remove_native_lib", - ":test.rebootless_apex_app_in_apex", - ":test.rebootless_apex_priv_app_in_apex", - ], - srcs: [ - "apexservice_test.cpp", - ], - host_supported: false, - compile_multilib: "first", - static_libs: [ - "apex_aidl_interface-cpp", - "libapex", - "libapexd", - "libfstab", - "libgmock", - ], - shared_libs: [ - "libbinder", - "libfs_mgr", - "libutils", - ], - generated_sources: ["apex-info-list-tinyxml"], - test_suites: ["device-tests"], - test_config: "ApexServiceTestCases.xml", + name: "ApexServiceTestCases", + defaults: [ + "apex_flags_defaults", + "libapex-deps", + "libapexd-deps", + ], + require_root: true, + cflags: [ + // Otherwise libgmock won't compile. + "-Wno-used-but-marked-unused", + ], + data: [ + ":apex.apexd_test", + ":apex.apexd_test_erofs", + ":apex.apexd_test_f2fs", + ":apex.apexd_test_digest", + ":apex.apexd_test_erofs_digest", + ":apex.apexd_test_f2fs_digest", + ":apex.apexd_test_classpath", + ":apex.apexd_test_different_app", + ":apex.apexd_test_no_hashtree", + ":apex.apexd_test_no_hashtree_2", + ":apex.apexd_test_no_inst_key", + ":apex.apexd_test_f2fs_no_inst_key", + ":apex.apexd_test_nocode", + ":apex.apexd_test_v2", + ":apex.corrupted_b146895998", + ":apex.banned_name", + ":gen_key_mismatch_apex", + ":gen_key_mismatch_apex_v2", + ":gen_key_mismatch_capex", + ":gen_manifest_mismatch_apex", + ":gen_manifest_mismatch_apex_no_hashtree", + ":gen_corrupt_superblock_apex", + ":gen_corrupt_apex", + ":gen_capex_not_decompressible", + ":gen_capex_without_apex", + ":gen_capex_with_v2_apex", + ":gen_key_mismatch_with_original_capex", + ":com.android.apex.cts.shim.v1_prebuilt", + ":com.android.apex.cts.shim.v2_prebuilt", + ":com.android.apex.cts.shim.v2_wrong_sha_prebuilt", + ":com.android.apex.cts.shim.v2_additional_file_prebuilt", + ":com.android.apex.cts.shim.v2_additional_folder_prebuilt", + ":com.android.apex.cts.shim.v2_with_pre_install_hook_prebuilt", + ":com.android.apex.cts.shim.v2_with_post_install_hook_prebuilt", + ":com.android.apex.compressed_sharedlibs", + ":com.android.apex.compressed.v1", + ":com.android.apex.compressed.v1_different_digest", + ":com.android.apex.compressed.v1_different_digest_original", + ":com.android.apex.compressed.v1_original", + ":com.android.apex.compressed.v2", + ":com.android.apex.compressed.v2_original", + ":gen_manifest_mismatch_compressed_apex_v2", + "apexd_testdata/com.android.apex.test_package.avbpubkey", + "apexd_testdata/com.android.apex.compressed.avbpubkey", + ":com.android.apex.test.sharedlibs_generated.v1.libvX_prebuilt", + ":com.android.apex.test.sharedlibs_generated.v2.libvY_prebuilt", + ":test.rebootless_apex_v1", + ":test.rebootless_apex_v2", + ":test.rebootless_apex_v2_no_hashtree", + ":test.rebootless_apex_service_v1", + ":test.rebootless_apex_service_v2", + ":gen_manifest_mismatch_rebootless_apex", + ":gen_corrupt_rebootless_apex", + ":test.rebootless_apex_provides_sharedlibs", + ":test.rebootless_apex_provides_native_libs", + ":test.rebootless_apex_requires_shared_apex_libs", + ":test.rebootless_apex_jni_libs", + ":test.rebootless_apex_add_native_lib", + ":test.rebootless_apex_remove_native_lib", + ":test.rebootless_apex_app_in_apex", + ":test.rebootless_apex_priv_app_in_apex", + ], + srcs: [ + "apexservice_test.cpp", + ], + host_supported: false, + compile_multilib: "first", + static_libs: [ + "apex_aidl_interface-cpp", + "libapex", + "libapexd", + "libfstab", + "libgmock", + ], + shared_libs: [ + "libbinder", + "libfs_mgr", + "libutils", + ], + generated_sources: ["apex-info-list-tinyxml"], + test_suites: ["device-tests"], + test_config: "ApexServiceTestCases.xml", } xsd_config { - name: "apex-info-list", - srcs: ["ApexInfoList.xsd"], - package_name: "com.android.apex", - api_dir: "apex-info-list-api", - gen_writer: true, - root_elements: ["apex-info-list"], + name: "apex-info-list", + srcs: ["ApexInfoList.xsd"], + package_name: "com.android.apex", + api_dir: "apex-info-list-api", + gen_writer: true, + root_elements: ["apex-info-list"], } xsd_config { - name: "apex-info-list-tinyxml", - srcs: ["ApexInfoList.xsd"], - package_name: "com.android.apex", - api_dir: "apex-info-list-api", - gen_writer: true, - tinyxml: true, - root_elements: ["apex-info-list"], + name: "apex-info-list-tinyxml", + srcs: ["ApexInfoList.xsd"], + package_name: "com.android.apex", + api_dir: "apex-info-list-api", + gen_writer: true, + tinyxml: true, + root_elements: ["apex-info-list"], } diff --git a/apexd/apexd.cpp b/apexd/apexd.cpp index a09e3d55..d22cebc5 100644 --- a/apexd/apexd.cpp +++ b/apexd/apexd.cpp @@ -167,11 +167,21 @@ static const std::vector<std::string> kBootstrapApexes = ([]() { static constexpr const int kNumRetriesWhenCheckpointingEnabled = 1; bool IsBootstrapApex(const ApexFile& apex) { + static std::vector<std::string> additional = []() { + std::vector<std::string> ret; + if (android::base::GetBoolProperty("ro.boot.apex.early_adbd", false)) { + ret.push_back("com.android.adbd"); + } + return ret; + }(); + if (IsVendorApex(apex) && apex.GetManifest().vendorbootstrap()) { return true; } return std::find(kBootstrapApexes.begin(), kBootstrapApexes.end(), - apex.GetManifest().name()) != kBootstrapApexes.end(); + apex.GetManifest().name()) != kBootstrapApexes.end() || + std::find(additional.begin(), additional.end(), + apex.GetManifest().name()) != additional.end(); } void ReleaseF2fsCompressedBlocks(const std::string& file_path) { diff --git a/apexd/apexd_testdata/Android.bp b/apexd/apexd_testdata/Android.bp index e28c567d..4fec5896 100644 --- a/apexd/apexd_testdata/Android.bp +++ b/apexd/apexd_testdata/Android.bp @@ -40,7 +40,7 @@ apex { prebuilts: ["sample_prebuilt_file"], key: "com.android.apex.test_package.key", installable: false, - min_sdk_version: "29", // test requires hashtree to be present. + min_sdk_version: "29", // test requires hashtree to be present. } apex { @@ -66,101 +66,120 @@ apex { } genrule { - // Generates an apex which has a different public key outside the filesystem image - name: "gen_key_mismatch_with_image_apex", - out: ["apex.apexd_test_wrong_public_key.apex"], - srcs: [":apex.apexd_test"], - tools: ["soong_zip", "zipalign"], - cmd: "unzip -q $(in) -d $(genDir) && " + // unzip input - "echo 'different-key' >> $(genDir)/apex_pubkey && " + // modify the public key - "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + - "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + - "-o $(genDir)/unaligned.apex && " + - "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + - "$(genDir)/apex.apexd_test_wrong_public_key.apex", + // Generates an apex which has a different public key outside the filesystem image + name: "gen_key_mismatch_with_image_apex", + out: ["apex.apexd_test_wrong_public_key.apex"], + srcs: [":apex.apexd_test"], + tools: [ + "soong_zip", + "zipalign", + ], + cmd: "unzip -q $(in) -d $(genDir) && " + // unzip input + "echo 'different-key' >> $(genDir)/apex_pubkey && " + // modify the public key + "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + + "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + + "-o $(genDir)/unaligned.apex && " + + "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + + "$(genDir)/apex.apexd_test_wrong_public_key.apex", } genrule { - // Generates a compressed apex which doesn't have an original_apex file in it - name: "gen_capex_without_apex", - out: ["com.android.apex.compressed.v1_without_apex.capex"], - srcs: [":com.android.apex.compressed.v1"], - tools: ["soong_zip"], - cmd: "unzip -q $(in) -d $(genDir) && rm $(genDir)/original_apex && " + - "$(location soong_zip) -d -C $(genDir) -D $(genDir) -L 9 " + - "-o $(genDir)/com.android.apex.compressed.v1_without_apex.capex" + // Generates a compressed apex which doesn't have an original_apex file in it + name: "gen_capex_without_apex", + out: ["com.android.apex.compressed.v1_without_apex.capex"], + srcs: [":com.android.apex.compressed.v1"], + tools: ["soong_zip"], + cmd: "unzip -q $(in) -d $(genDir) && rm $(genDir)/original_apex && " + + "$(location soong_zip) -d -C $(genDir) -D $(genDir) -L 9 " + + "-o $(genDir)/com.android.apex.compressed.v1_without_apex.capex", } genrule { - // Generates a compressed apex which has different version of original_apex in it - name: "gen_capex_with_v2_apex", - out: ["com.android.apex.compressed.v1_with_v2_apex.capex"], - srcs: [":com.android.apex.compressed.v2"], - tools: ["soong_zip", "conv_apex_manifest"], - cmd: "unzip -q $(in) -d $(genDir) && " + - "$(location conv_apex_manifest) setprop version 1 $(genDir)/apex_manifest.pb && " + - "$(location soong_zip) -d -C $(genDir) -D $(genDir) -L 9 " + - "-o $(genDir)/com.android.apex.compressed.v1_with_v2_apex.capex" + // Generates a compressed apex which has different version of original_apex in it + name: "gen_capex_with_v2_apex", + out: ["com.android.apex.compressed.v1_with_v2_apex.capex"], + srcs: [":com.android.apex.compressed.v2"], + tools: [ + "soong_zip", + "conv_apex_manifest", + ], + cmd: "unzip -q $(in) -d $(genDir) && " + + "$(location conv_apex_manifest) setprop version 1 $(genDir)/apex_manifest.pb && " + + "$(location soong_zip) -d -C $(genDir) -D $(genDir) -L 9 " + + "-o $(genDir)/com.android.apex.compressed.v1_with_v2_apex.capex", } genrule { - // Generates a compressed apex which can be opened but not decompressed - name: "gen_capex_not_decompressible", - out: ["com.android.apex.compressed.v1_not_decompressible.capex"], - srcs: [":com.android.apex.compressed.v1"], - tools: ["soong_zip", "conv_apex_manifest"], - cmd: "unzip -q $(in) -d $(genDir) && echo '' > $(genDir)/original_apex && " + - "$(location soong_zip) -d -C $(genDir) -D $(genDir) -L 9 " + - "-o $(genDir)/com.android.apex.compressed.v1_not_decompressible.capex" + // Generates a compressed apex which can be opened but not decompressed + name: "gen_capex_not_decompressible", + out: ["com.android.apex.compressed.v1_not_decompressible.capex"], + srcs: [":com.android.apex.compressed.v1"], + tools: [ + "soong_zip", + "conv_apex_manifest", + ], + cmd: "unzip -q $(in) -d $(genDir) && echo '' > $(genDir)/original_apex && " + + "$(location soong_zip) -d -C $(genDir) -D $(genDir) -L 9 " + + "-o $(genDir)/com.android.apex.compressed.v1_not_decompressible.capex", } genrule { - // Generates a capex which has same module name as com.android.apex.compressed, but - // is contains a different public key. - name: "gen_key_mismatch_capex", - out: ["com.android.apex.compressed_different_key.capex"], - srcs: [":apex.apexd_test_no_inst_key"], - tools: ["soong_zip", "zipalign", "conv_apex_manifest", "apex_compression_tool", "avbtool"], - cmd: "mkdir $(genDir)/tempdir && unzip -q $(in) -d $(genDir)/tempdir && " + - "$(location conv_apex_manifest) setprop name com.android.apex.compressed $(genDir)/tempdir/apex_manifest.pb && " + - "$(location soong_zip) -d -C $(genDir)/tempdir -D $(genDir)/tempdir " + - "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + - "-o $(genDir)/unaligned.apex && " + - "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + - "$(genDir)/com.android.apex.compressed_different_key.apex && " + - "HOST_OUT_BIN=$$(dirname $(location apex_compression_tool)) && " + - "$(location apex_compression_tool) compress " + - "--apex_compression_tool_path=\"$$HOST_OUT_BIN\" " + - "--input=$(genDir)/com.android.apex.compressed_different_key.apex " + - "--output=$(genDir)/com.android.apex.compressed_different_key.capex" + // Generates a capex which has same module name as com.android.apex.compressed, but + // is contains a different public key. + name: "gen_key_mismatch_capex", + out: ["com.android.apex.compressed_different_key.capex"], + srcs: [":apex.apexd_test_no_inst_key"], + tools: [ + "soong_zip", + "zipalign", + "conv_apex_manifest", + "apex_compression_tool", + "avbtool", + ], + cmd: "mkdir $(genDir)/tempdir && unzip -q $(in) -d $(genDir)/tempdir && " + + "$(location conv_apex_manifest) setprop name com.android.apex.compressed $(genDir)/tempdir/apex_manifest.pb && " + + "$(location soong_zip) -d -C $(genDir)/tempdir -D $(genDir)/tempdir " + + "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + + "-o $(genDir)/unaligned.apex && " + + "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + + "$(genDir)/com.android.apex.compressed_different_key.apex && " + + "HOST_OUT_BIN=$$(dirname $(location apex_compression_tool)) && " + + "$(location apex_compression_tool) compress " + + "--apex_compression_tool_path=\"$$HOST_OUT_BIN\" " + + "--input=$(genDir)/com.android.apex.compressed_different_key.apex " + + "--output=$(genDir)/com.android.apex.compressed_different_key.capex", } genrule { - // Generates a capex which has a different public key than original_apex - name: "gen_key_mismatch_with_original_capex", - out: ["com.android.apex.compressed_key_mismatch_with_original.capex"], - srcs: [":com.android.apex.compressed.v1"], - tools: ["soong_zip"], - cmd: "unzip -q $(in) -d $(genDir) && " + // unzip input - "echo 'different-key' >> $(genDir)/apex_pubkey && " + // modify the public key - "$(location soong_zip) -d -C $(genDir) -D $(genDir) -L 9 " +// repack the compressed APEX - "-o $(genDir)/com.android.apex.compressed_key_mismatch_with_original.capex", + // Generates a capex which has a different public key than original_apex + name: "gen_key_mismatch_with_original_capex", + out: ["com.android.apex.compressed_key_mismatch_with_original.capex"], + srcs: [":com.android.apex.compressed.v1"], + tools: ["soong_zip"], + cmd: "unzip -q $(in) -d $(genDir) && " + // unzip input + "echo 'different-key' >> $(genDir)/apex_pubkey && " + // modify the public key + "$(location soong_zip) -d -C $(genDir) -D $(genDir) -L 9 " + // repack the compressed APEX + "-o $(genDir)/com.android.apex.compressed_key_mismatch_with_original.capex", } genrule { - // Generates an apex which has a different manifest outside the filesystem - // image. - name: "gen_manifest_mismatch_compressed_apex_v2", - out: ["com.android.apex.compressed.v2_manifest_mismatch.apex"], - srcs: [":com.android.apex.compressed.v2_original"], - tools: ["soong_zip", "zipalign", "conv_apex_manifest"], - cmd: "unzip -q $(in) -d $(genDir) && " + - "$(location conv_apex_manifest) setprop version 137 $(genDir)/apex_manifest.pb && " + - "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + - "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + - "-o $(genDir)/unaligned.apex && " + - "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + - "$(genDir)/com.android.apex.compressed.v2_manifest_mismatch.apex" + // Generates an apex which has a different manifest outside the filesystem + // image. + name: "gen_manifest_mismatch_compressed_apex_v2", + out: ["com.android.apex.compressed.v2_manifest_mismatch.apex"], + srcs: [":com.android.apex.compressed.v2_original"], + tools: [ + "soong_zip", + "zipalign", + "conv_apex_manifest", + ], + cmd: "unzip -q $(in) -d $(genDir) && " + + "$(location conv_apex_manifest) setprop version 137 $(genDir)/apex_manifest.pb && " + + "$(location soong_zip) -d -C $(genDir) -D $(genDir) " + + "-s apex_manifest.pb -s apex_payload.img -s apex_pubkey " + + "-o $(genDir)/unaligned.apex && " + + "$(location zipalign) -f 4096 $(genDir)/unaligned.apex " + + "$(genDir)/com.android.apex.compressed.v2_manifest_mismatch.apex", } apex { @@ -250,8 +269,8 @@ apex { manifest: "manifest.json", file_contexts: ":apex.test-file_contexts", prebuilts: [ - "another_prebuilt_file", - "sample_prebuilt_file", + "another_prebuilt_file", + "sample_prebuilt_file", ], key: "com.android.apex.test_package.key", installable: false, @@ -280,11 +299,11 @@ apex { } genrule { - name: "apex.apexd_test_v2_no_pb", - srcs: [":apex.apexd_test_v2_legacy"], - out: ["apex.apexd_test_v2_no_pb.apex"], - tools: ["zip2zip"], - cmd: "$(location zip2zip) -i $(in) -x apex_manifest.pb -o $(out)", // remove apex_manifest.pb + name: "apex.apexd_test_v2_no_pb", + srcs: [":apex.apexd_test_v2_legacy"], + out: ["apex.apexd_test_v2_no_pb.apex"], + tools: ["zip2zip"], + cmd: "$(location zip2zip) -i $(in) -x apex_manifest.pb -o $(out)", // remove apex_manifest.pb } apex { @@ -364,15 +383,15 @@ apex { } prebuilt_etc { - name: "another_prebuilt_file", - src: "another_prebuilt_file", + name: "another_prebuilt_file", + src: "another_prebuilt_file", } prebuilt_apex { - name: "apex.corrupted_b146895998", - src: "corrupted_b146895998.apex", - filename: "corrupted_b146895998.apex", - installable: false, + name: "apex.corrupted_b146895998", + src: "corrupted_b146895998.apex", + filename: "corrupted_b146895998.apex", + installable: false, } // APEX for banned name test cannot be generated at build time. @@ -407,7 +426,7 @@ apex { installable: false, updatable: false, // TODO(ioffe): we should have a separate field to hashtree presence. - min_sdk_version: "29", // test requires hashtree to be present. + min_sdk_version: "29", // test requires hashtree to be present. } apex { @@ -418,7 +437,7 @@ apex { installable: false, updatable: false, // TODO(ioffe): we should have a separate field to hashtree presence. - min_sdk_version: "29", // test requires hashtree to be present. + min_sdk_version: "29", // test requires hashtree to be present. } apex { @@ -514,7 +533,7 @@ apex { updatable: false, apps: ["AppInRebootlessApex"], // TODO(ioffe): we should have a separate field to hashtree presence. - min_sdk_version: "29", // test requires hashtree to be present. + min_sdk_version: "29", // test requires hashtree to be present. } apex { @@ -526,7 +545,7 @@ apex { updatable: false, apps: ["PrivAppInRebootlessApex"], // TODO(ioffe): we should have a separate field to hashtree presence. - min_sdk_version: "29", // test requires hashtree to be present. + min_sdk_version: "29", // test requires hashtree to be present. } android_app { @@ -534,7 +553,7 @@ android_app { sdk_version: "29", manifest: "AppInRebootlessApex_AndroidManifest.xml", apex_available: [ - "test.rebootless_apex_app_in_apex", + "test.rebootless_apex_app_in_apex", ], } @@ -544,7 +563,7 @@ android_app { privileged: true, manifest: "AppInRebootlessApex_AndroidManifest.xml", apex_available: [ - "test.rebootless_apex_priv_app_in_apex", + "test.rebootless_apex_priv_app_in_apex", ], } diff --git a/apexd/sysprop/Android.bp b/apexd/sysprop/Android.bp index 050434b1..1f78fed4 100644 --- a/apexd/sysprop/Android.bp +++ b/apexd/sysprop/Android.bp @@ -3,10 +3,10 @@ package { } sysprop_library { - name: "com.android.sysprop.apex", - srcs: ["ApexProperties.sysprop"], - property_owner: "Platform", - api_packages: ["android.sysprop"], - ramdisk_available: true, - recovery_available: true, + name: "com.android.sysprop.apex", + srcs: ["ApexProperties.sysprop"], + property_owner: "Platform", + api_packages: ["android.sysprop"], + ramdisk_available: true, + recovery_available: true, } diff --git a/apexer/Android.bp b/apexer/Android.bp index 20b9e833..780730b1 100644 --- a/apexer/Android.bp +++ b/apexer/Android.bp @@ -17,26 +17,26 @@ package { } apexer_tools = [ - "aapt2", - "avbtool", - "conv_apex_manifest", - "e2fsdroid", - "mke2fs", - "resize2fs", - "sefcontext_compile", - "zipalign", - "make_f2fs", - "sload_f2fs", - "make_erofs", - // TODO(b/124476339) apex doesn't follow 'required' dependencies so we need to include this - // manually for 'avbtool'. - "fec", + "aapt2", + "avbtool", + "conv_apex_manifest", + "e2fsdroid", + "mke2fs", + "resize2fs", + "sefcontext_compile", + "zipalign", + "make_f2fs", + "sload_f2fs", + "make_erofs", + // TODO(b/124476339) apex doesn't follow 'required' dependencies so we need to include this + // manually for 'avbtool'. + "fec", ] // TODO(b/157110982): cannot specify "required" dependency on go binary apexer_go_tools = [ - "merge_zips", - "soong_zip", + "merge_zips", + "soong_zip", ] python_library_host { @@ -55,7 +55,7 @@ genrule { name: "mke2fs_conf_for_apexer", srcs: [":mke2fs_conf"], out: ["mke2fs.conf"], - cmd: "cp $(in) $(out)" + cmd: "cp $(in) $(out)", } python_binary_host { @@ -98,6 +98,7 @@ python_binary_host { // TODO(b/148659029): this test can't run in TEST_MAPPING. python_test_host { name: "apexer_test", + pkg_path: "apexer_test", main: "apexer_test.py", srcs: [ "apexer_test.py", @@ -118,6 +119,11 @@ python_test_host { libs: [ "apex_manifest", ], + version: { + py3: { + embedded_launcher: true, + }, + }, } apexer_deps_minus_go_tools = apexer_tools + [ diff --git a/apexer/apexer_test.py b/apexer/apexer_test.py index 7915a8d7..fb355d9a 100644 --- a/apexer/apexer_test.py +++ b/apexer/apexer_test.py @@ -25,6 +25,7 @@ import stat import subprocess import tempfile import unittest +from importlib import resources from zipfile import ZipFile from apex_manifest import ValidateApexManifest @@ -125,12 +126,6 @@ def get_sha1sum(file_path): return h.hexdigest() -def get_current_dir(): - """Returns the current dir, relative to the script dir.""" - # The script dir is the one we want, which could be different from pwd. - current_dir = os.path.dirname(os.path.realpath(__file__)) - return current_dir - def round_up(size, unit): assert unit & (unit - 1) == 0 return (size + unit - 1) & (~(unit - 1)) @@ -163,7 +158,7 @@ DEBUG_TEST = False class ApexerRebuildTest(unittest.TestCase): def setUp(self): self._to_cleanup = [] - self._get_host_tools(os.path.join(get_current_dir(), "apexer_test_host_tools.zip")) + self._get_host_tools() def tearDown(self): if not DEBUG_TEST: @@ -176,11 +171,11 @@ class ApexerRebuildTest(unittest.TestCase): else: print(self._to_cleanup) - def _get_host_tools(self, host_tools_file_path): + def _get_host_tools(self): dir_name = tempfile.mkdtemp(prefix=self._testMethodName+"_host_tools_") self._to_cleanup.append(dir_name) - if os.path.isfile(host_tools_file_path): - with ZipFile(host_tools_file_path, 'r') as zip_obj: + with resources.files("apexer_test").joinpath("apexer_test_host_tools.zip").open('rb') as f: + with ZipFile(f, 'r') as zip_obj: zip_obj.extractall(path=dir_name) files = {} @@ -196,7 +191,7 @@ class ApexerRebuildTest(unittest.TestCase): self.host_tools = files self.host_tools_path = os.path.join(dir_name, "bin") - path = os.path.join(dir_name, "bin") + path = self.host_tools_path if "PATH" in os.environ: path += ":" + os.environ["PATH"] os.environ["PATH"] = path @@ -208,6 +203,15 @@ class ApexerRebuildTest(unittest.TestCase): ld_library_path += ":" + os.path.join(os.environ["ANDROID_HOST_OUT"], "lib64") os.environ["LD_LIBRARY_PATH"] = ld_library_path + def _extract_resource(self, resource_name): + with ( + resources.files("apexer_test").joinpath(resource_name).open('rb') as f, + tempfile.NamedTemporaryFile(prefix=resource_name.replace('/', '_'), delete=False) as f2, + ): + self._to_cleanup.append(f2.name) + shutil.copyfileobj(f, f2) + return f2.name + def _get_container_files(self, apex_file_path): dir_name = tempfile.mkdtemp(prefix=self._testMethodName+"_container_files_") self._to_cleanup.append(dir_name) @@ -285,8 +289,8 @@ class ApexerRebuildTest(unittest.TestCase): if not payload_only and "assets" in container_files: cmd.extend(["--assets_dir", container_files["assets"]]) if not unsigned_payload_only: - cmd.extend(["--key", os.path.join(get_current_dir(), TEST_PRIVATE_KEY)]) - cmd.extend(["--pubkey", os.path.join(get_current_dir(), TEST_AVB_PUBLIC_KEY)]) + cmd.extend(["--key", self._extract_resource(TEST_PRIVATE_KEY)]) + cmd.extend(["--pubkey", self._extract_resource(TEST_AVB_PUBLIC_KEY)]) cmd.extend(args) # Decide on output file name @@ -333,8 +337,8 @@ class ApexerRebuildTest(unittest.TestCase): "-Djava.library.path=" + java_dep_lib, "-jar", self.host_tools['signapk.jar'], "-a", "4096", "--align-file-size", - os.path.join(get_current_dir(), TEST_X509_KEY), - os.path.join(get_current_dir(), TEST_PK8_KEY), + self._extract_resource(TEST_X509_KEY), + self._extract_resource(TEST_PK8_KEY), unsigned_apex, fn] run_and_check_output(cmd) return fn @@ -351,7 +355,7 @@ class ApexerRebuildTest(unittest.TestCase): cmd.append('--do_not_generate_fec') cmd.extend(['--algorithm', 'SHA256_RSA4096']) cmd.extend(['--hash_algorithm', 'sha256']) - cmd.extend(['--key', os.path.join(get_current_dir(), TEST_PRIVATE_KEY)]) + cmd.extend(['--key', self._extract_resource(TEST_PRIVATE_KEY)]) manifest_apex = ParseApexManifest(container_files["apex_manifest.pb"]) ValidateApexManifest(manifest_apex) cmd.extend(['--prop', 'apex.key:' + manifest_apex.name]) @@ -371,7 +375,7 @@ class ApexerRebuildTest(unittest.TestCase): run_and_check_output(cmd) def _run_build_test(self, apex_name): - apex_file_path = os.path.join(get_current_dir(), apex_name + ".apex") + apex_file_path = self._extract_resource(apex_name + ".apex") if DEBUG_TEST: fd, fn = tempfile.mkstemp(prefix=self._testMethodName+"_input_", suffix=".apex") os.close(fd) @@ -393,7 +397,7 @@ class ApexerRebuildTest(unittest.TestCase): """Assert that payload-only output from apexer is same as the payload we get by unzipping apex. """ - apex_file_path = os.path.join(get_current_dir(), TEST_APEX + ".apex") + apex_file_path = self._extract_resource(TEST_APEX + ".apex") container_files = self._get_container_files(apex_file_path) payload_dir = self._extract_payload(apex_file_path) payload_only_file_path = self._run_apexer(container_files, payload_dir, ["--payload_only"]) @@ -405,7 +409,7 @@ class ApexerRebuildTest(unittest.TestCase): """Assert that when unsigned-payload-only output from apexer is signed by the avb key, it is same as the payload we get by unzipping apex. """ - apex_file_path = os.path.join(get_current_dir(), TEST_APEX + ".apex") + apex_file_path = self._extract_resource(TEST_APEX + ".apex") container_files = self._get_container_files(apex_file_path) payload_dir = self._extract_payload(apex_file_path) unsigned_payload_only_file_path = self._run_apexer(container_files, payload_dir, @@ -433,7 +437,7 @@ class ApexerRebuildTest(unittest.TestCase): def test_conv_apex_manifest(self): # .pb generation from json - manifest_json_path = os.path.join(get_current_dir(), TEST_MANIFEST_JSON) + manifest_json_path = self._extract_resource(TEST_MANIFEST_JSON) fd, fn = tempfile.mkstemp(prefix=self._testMethodName + "_manifest_", suffix=".pb") os.close(fd) diff --git a/apexer/testdata/Android.bp b/apexer/testdata/Android.bp index 951f849e..42fed721 100644 --- a/apexer/testdata/Android.bp +++ b/apexer/testdata/Android.bp @@ -37,7 +37,7 @@ apex { key: "com.android.example.apex.key", certificate: ":com.android.example.apex.certificate", installable: false, - updatable:false, + updatable: false, generate_hashtree: false, } diff --git a/libs/libapexutil/Android.bp b/libs/libapexutil/Android.bp index 32aca763..db0ec88c 100644 --- a/libs/libapexutil/Android.bp +++ b/libs/libapexutil/Android.bp @@ -34,7 +34,7 @@ cc_library_static { name: "libapexutil", defaults: ["libapexutil-deps"], export_include_dirs: ["."], - srcs: [ "apexutil.cpp" ], + srcs: ["apexutil.cpp"], host_supported: true, apex_available: [ "//apex_available:platform", diff --git a/shim/Android.bp b/shim/Android.bp index d51e7bc9..7ec17b56 100644 --- a/shim/Android.bp +++ b/shim/Android.bp @@ -12,262 +12,260 @@ // See the License for the specific language governing permissions and // limitations under the License. -// TODO: consider removing _prebuilt suffix from module names and make use of -// 'prefer: true' - package { default_applicable_licenses: ["Android-Apache-2.0"], } prebuilt_apex { - name: "com.android.apex.cts.shim.v1_prebuilt", - overrides: ["CtsShimPrebuilt", "CtsShimPrivPrebuilt"], - arch: { - arm: { - src: "prebuilts/arm/com.android.apex.cts.shim.v1.apex", - }, - arm64: { - src: "prebuilts/arm/com.android.apex.cts.shim.v1.apex", - }, - riscv64: { - src: "prebuilts/riscv64/com.android.apex.cts.shim.v1.apex", - }, - x86: { - src: "prebuilts/x86/com.android.apex.cts.shim.v1.apex", - }, - x86_64: { - src: "prebuilts/x86/com.android.apex.cts.shim.v1.apex", - }, - }, - filename: "com.android.apex.cts.shim.apex", - prefer: true, - installable: true, + name: "com.android.apex.cts.shim.v1_prebuilt", + overrides: [ + "CtsShimPrebuilt", + "CtsShimPrivPrebuilt", + ], + arch: { + arm: { + src: "prebuilts/arm/com.android.apex.cts.shim.v1.apex", + }, + arm64: { + src: "prebuilts/arm/com.android.apex.cts.shim.v1.apex", + }, + riscv64: { + src: "prebuilts/riscv64/com.android.apex.cts.shim.v1.apex", + }, + x86: { + src: "prebuilts/x86/com.android.apex.cts.shim.v1.apex", + }, + x86_64: { + src: "prebuilts/x86/com.android.apex.cts.shim.v1.apex", + }, + }, + filename: "com.android.apex.cts.shim.apex", + installable: true, } prebuilt_apex { - name: "com.android.apex.cts.shim.v2_prebuilt", - arch: { - arm: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2.apex", - }, - arm64: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2.apex", - }, - riscv64: { - src: "prebuilts/riscv64/com.android.apex.cts.shim.v2.apex", - }, - x86: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2.apex", - }, - x86_64: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2.apex", - }, - }, - filename: "com.android.apex.cts.shim.v2.apex", - installable: false, + name: "com.android.apex.cts.shim.v2_prebuilt", + arch: { + arm: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2.apex", + }, + arm64: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2.apex", + }, + riscv64: { + src: "prebuilts/riscv64/com.android.apex.cts.shim.v2.apex", + }, + x86: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2.apex", + }, + x86_64: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2.apex", + }, + }, + filename: "com.android.apex.cts.shim.v2.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.cts.shim.v2_wrong_sha_prebuilt", - arch: { - arm: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2_wrong_sha.apex", - }, - arm64: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2_wrong_sha.apex", - }, - riscv64: { - src: "prebuilts/riscv64/com.android.apex.cts.shim.v2_wrong_sha.apex", - }, - x86: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2_wrong_sha.apex", - }, - x86_64: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2_wrong_sha.apex", - }, - }, - filename: "com.android.apex.cts.shim.v2_wrong_sha.apex", - installable: false, + name: "com.android.apex.cts.shim.v2_wrong_sha_prebuilt", + arch: { + arm: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2_wrong_sha.apex", + }, + arm64: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2_wrong_sha.apex", + }, + riscv64: { + src: "prebuilts/riscv64/com.android.apex.cts.shim.v2_wrong_sha.apex", + }, + x86: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2_wrong_sha.apex", + }, + x86_64: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2_wrong_sha.apex", + }, + }, + filename: "com.android.apex.cts.shim.v2_wrong_sha.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.cts.shim.v2_additional_file_prebuilt", - arch: { - arm: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2_additional_file.apex", - }, - arm64: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2_additional_file.apex", - }, - riscv64: { - src: "prebuilts/riscv64/com.android.apex.cts.shim.v2_additional_file.apex", - }, - x86: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2_additional_file.apex", - }, - x86_64: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2_additional_file.apex", - }, - }, - filename: "com.android.apex.cts.shim.v2_additional_file.apex", - installable: false, + name: "com.android.apex.cts.shim.v2_additional_file_prebuilt", + arch: { + arm: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2_additional_file.apex", + }, + arm64: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2_additional_file.apex", + }, + riscv64: { + src: "prebuilts/riscv64/com.android.apex.cts.shim.v2_additional_file.apex", + }, + x86: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2_additional_file.apex", + }, + x86_64: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2_additional_file.apex", + }, + }, + filename: "com.android.apex.cts.shim.v2_additional_file.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.cts.shim.v2_additional_folder_prebuilt", - arch: { - arm: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2_additional_folder.apex", - }, - arm64: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2_additional_folder.apex", - }, - riscv64: { - src: "prebuilts/riscv64/com.android.apex.cts.shim.v2_additional_folder.apex", - }, - x86: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2_additional_folder.apex", - }, - x86_64: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2_additional_folder.apex", - }, - }, - filename: "com.android.apex.cts.shim.v2_additional_folder.apex", - installable: false, + name: "com.android.apex.cts.shim.v2_additional_folder_prebuilt", + arch: { + arm: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2_additional_folder.apex", + }, + arm64: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2_additional_folder.apex", + }, + riscv64: { + src: "prebuilts/riscv64/com.android.apex.cts.shim.v2_additional_folder.apex", + }, + x86: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2_additional_folder.apex", + }, + x86_64: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2_additional_folder.apex", + }, + }, + filename: "com.android.apex.cts.shim.v2_additional_folder.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.cts.shim.v2_with_pre_install_hook_prebuilt", - arch: { - arm: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2_with_pre_install_hook.apex", - }, - arm64: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2_with_pre_install_hook.apex", - }, - riscv64: { - src: "prebuilts/riscv64/com.android.apex.cts.shim.v2_with_pre_install_hook.apex", - }, - x86: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2_with_pre_install_hook.apex", - }, - x86_64: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2_with_pre_install_hook.apex", - }, - }, - filename: "com.android.apex.cts.shim.v2_with_pre_install_hook.apex", - installable: false, + name: "com.android.apex.cts.shim.v2_with_pre_install_hook_prebuilt", + arch: { + arm: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2_with_pre_install_hook.apex", + }, + arm64: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2_with_pre_install_hook.apex", + }, + riscv64: { + src: "prebuilts/riscv64/com.android.apex.cts.shim.v2_with_pre_install_hook.apex", + }, + x86: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2_with_pre_install_hook.apex", + }, + x86_64: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2_with_pre_install_hook.apex", + }, + }, + filename: "com.android.apex.cts.shim.v2_with_pre_install_hook.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.cts.shim.v2_with_post_install_hook_prebuilt", - arch: { - arm: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2_with_post_install_hook.apex", - }, - arm64: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2_with_post_install_hook.apex", - }, - riscv64: { - src: "prebuilts/riscv64/com.android.apex.cts.shim.v2_with_post_install_hook.apex", - }, - x86: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2_with_post_install_hook.apex", - }, - x86_64: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2_with_post_install_hook.apex", - }, - }, - filename: "com.android.apex.cts.shim.v2_with_post_install_hook.apex", - installable: false, + name: "com.android.apex.cts.shim.v2_with_post_install_hook_prebuilt", + arch: { + arm: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2_with_post_install_hook.apex", + }, + arm64: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2_with_post_install_hook.apex", + }, + riscv64: { + src: "prebuilts/riscv64/com.android.apex.cts.shim.v2_with_post_install_hook.apex", + }, + x86: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2_with_post_install_hook.apex", + }, + x86_64: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2_with_post_install_hook.apex", + }, + }, + filename: "com.android.apex.cts.shim.v2_with_post_install_hook.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.cts.shim.v3_prebuilt", - arch: { - arm: { - src: "prebuilts/arm/com.android.apex.cts.shim.v3.apex", - }, - arm64: { - src: "prebuilts/arm/com.android.apex.cts.shim.v3.apex", - }, - riscv64: { - src: "prebuilts/riscv64/com.android.apex.cts.shim.v3.apex", - }, - x86: { - src: "prebuilts/x86/com.android.apex.cts.shim.v3.apex", - }, - x86_64: { - src: "prebuilts/x86/com.android.apex.cts.shim.v3.apex", - }, - }, - filename: "com.android.apex.cts.shim.v3.apex", - installable: false, + name: "com.android.apex.cts.shim.v3_prebuilt", + arch: { + arm: { + src: "prebuilts/arm/com.android.apex.cts.shim.v3.apex", + }, + arm64: { + src: "prebuilts/arm/com.android.apex.cts.shim.v3.apex", + }, + riscv64: { + src: "prebuilts/riscv64/com.android.apex.cts.shim.v3.apex", + }, + x86: { + src: "prebuilts/x86/com.android.apex.cts.shim.v3.apex", + }, + x86_64: { + src: "prebuilts/x86/com.android.apex.cts.shim.v3.apex", + }, + }, + filename: "com.android.apex.cts.shim.v3.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.cts.shim.v2_different_certificate_prebuilt", - arch: { - arm: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2_different_certificate.apex", - }, - arm64: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2_different_certificate.apex", - }, - riscv64: { - src: "prebuilts/riscv64/com.android.apex.cts.shim.v2_different_certificate.apex", - }, - x86: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2_different_certificate.apex", - }, - x86_64: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2_different_certificate.apex", - }, - }, - filename: "com.android.apex.cts.shim.v2_different_certificate.apex", - installable: false, + name: "com.android.apex.cts.shim.v2_different_certificate_prebuilt", + arch: { + arm: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2_different_certificate.apex", + }, + arm64: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2_different_certificate.apex", + }, + riscv64: { + src: "prebuilts/riscv64/com.android.apex.cts.shim.v2_different_certificate.apex", + }, + x86: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2_different_certificate.apex", + }, + x86_64: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2_different_certificate.apex", + }, + }, + filename: "com.android.apex.cts.shim.v2_different_certificate.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.cts.shim.v2_unsigned_apk_container_prebuilt", - arch: { - arm: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2_unsigned_apk_container.apex", - }, - arm64: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2_unsigned_apk_container.apex", - }, - riscv64: { - src: "prebuilts/riscv64/com.android.apex.cts.shim.v2_unsigned_apk_container.apex", - }, - x86: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2_unsigned_apk_container.apex", - }, - x86_64: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2_unsigned_apk_container.apex", - }, - }, - filename: "com.android.apex.cts.shim.v2_unsigned_apk_container.apex", - installable: false, + name: "com.android.apex.cts.shim.v2_unsigned_apk_container_prebuilt", + arch: { + arm: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2_unsigned_apk_container.apex", + }, + arm64: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2_unsigned_apk_container.apex", + }, + riscv64: { + src: "prebuilts/riscv64/com.android.apex.cts.shim.v2_unsigned_apk_container.apex", + }, + x86: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2_unsigned_apk_container.apex", + }, + x86_64: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2_unsigned_apk_container.apex", + }, + }, + filename: "com.android.apex.cts.shim.v2_unsigned_apk_container.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.cts.shim.v2_rebootless_prebuilt", - arch: { - arm: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2_rebootless.apex", - }, - arm64: { - src: "prebuilts/arm/com.android.apex.cts.shim.v2_rebootless.apex", - }, - x86: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2_rebootless.apex", - }, - x86_64: { - src: "prebuilts/x86/com.android.apex.cts.shim.v2_rebootless.apex", - }, - }, - filename: "com.android.apex.cts.shim.v2_rebootless.apex", - installable: false, + name: "com.android.apex.cts.shim.v2_rebootless_prebuilt", + arch: { + arm: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2_rebootless.apex", + }, + arm64: { + src: "prebuilts/arm/com.android.apex.cts.shim.v2_rebootless.apex", + }, + x86: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2_rebootless.apex", + }, + x86_64: { + src: "prebuilts/x86/com.android.apex.cts.shim.v2_rebootless.apex", + }, + }, + filename: "com.android.apex.cts.shim.v2_rebootless.apex", + installable: false, } - diff --git a/shim/build/Android.bp b/shim/build/Android.bp index 9b40add4..080f6c35 100644 --- a/shim/build/Android.bp +++ b/shim/build/Android.bp @@ -19,138 +19,150 @@ package { } genrule { - name: "com.android.apex.cts.shim.pem", - out: ["com.android.apex.cts.shim.pem"], - cmd: "openssl genrsa -out $(out) 4096", + name: "com.android.apex.cts.shim.pem", + out: ["com.android.apex.cts.shim.pem"], + cmd: "openssl genrsa -out $(out) 4096", } genrule { - name: "com.android.apex.cts.shim.pubkey", - srcs: [":com.android.apex.cts.shim.pem"], - out: ["com.android.apex.cts.shim.pubkey"], - tools: ["avbtool"], - cmd: "$(location avbtool) extract_public_key --key $(in) --output $(out)", + name: "com.android.apex.cts.shim.pubkey", + srcs: [":com.android.apex.cts.shim.pem"], + out: ["com.android.apex.cts.shim.pubkey"], + tools: ["avbtool"], + cmd: "$(location avbtool) extract_public_key --key $(in) --output $(out)", } apex_key { - name: "com.android.apex.cts.shim.key", - private_key: ":com.android.apex.cts.shim.pem", - public_key: ":com.android.apex.cts.shim.pubkey", - installable: false, + name: "com.android.apex.cts.shim.key", + private_key: ":com.android.apex.cts.shim.pem", + public_key: ":com.android.apex.cts.shim.pubkey", + installable: false, } genrule { - name: "com.android.apex.cts.shim.debug.pem", - out: ["com.android.apex.cts.shim.debug.pem"], - cmd: "openssl genrsa -out $(out) 4096", + name: "com.android.apex.cts.shim.debug.pem", + out: ["com.android.apex.cts.shim.debug.pem"], + cmd: "openssl genrsa -out $(out) 4096", } genrule { - name: "com.android.apex.cts.shim.debug.pubkey", - srcs: [":com.android.apex.cts.shim.debug.pem"], - out: ["com.android.apex.cts.shim.debug.pubkey"], - tools: ["avbtool"], - cmd: "$(location avbtool) extract_public_key --key $(in) --output $(out)", + name: "com.android.apex.cts.shim.debug.pubkey", + srcs: [":com.android.apex.cts.shim.debug.pem"], + out: ["com.android.apex.cts.shim.debug.pubkey"], + tools: ["avbtool"], + cmd: "$(location avbtool) extract_public_key --key $(in) --output $(out)", } apex_key { - name: "com.android.apex.cts.shim.debug.key", - private_key: ":com.android.apex.cts.shim.debug.pem", - public_key: ":com.android.apex.cts.shim.debug.pubkey", - installable: false, + name: "com.android.apex.cts.shim.debug.key", + private_key: ":com.android.apex.cts.shim.debug.pem", + public_key: ":com.android.apex.cts.shim.debug.pubkey", + installable: false, } genrule { - name: "generate_hash_of_dev_null", - out: ["hash.txt"], - cmd: "sha512sum -b /dev/null | cut -d' ' -f1 | tee $(out)", + name: "generate_hash_of_dev_null", + out: ["hash.txt"], + cmd: "sha512sum -b /dev/null | cut -d' ' -f1 | tee $(out)", } prebuilt_etc { - name: "hash_of_dev_null", - src: ":generate_hash_of_dev_null", - filename: "hash.txt", - installable: false, + name: "hash_of_dev_null", + src: ":generate_hash_of_dev_null", + filename: "hash.txt", + installable: false, } apex { - name: "com.android.apex.cts.shim.v3", - manifest: "manifest_v3.json", - androidManifest: "AndroidManifest.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - apps: ["CtsShim", "CtsShimPriv"], - installable: false, - allowed_files: "default_shim_allowed_list.txt", - updatable: false, + name: "com.android.apex.cts.shim.v3", + manifest: "manifest_v3.json", + androidManifest: "AndroidManifest.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + apps: [ + "CtsShim", + "CtsShimPriv", + ], + installable: false, + allowed_files: "default_shim_allowed_list.txt", + updatable: false, } apex { - name: "com.android.apex.cts.shim.v2", - manifest: "manifest_v2.json", - androidManifest: "AndroidManifest.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - apps: ["CtsShim", "CtsShimPriv"], - installable: false, - allowed_files: "default_shim_allowed_list.txt", - updatable: false, + name: "com.android.apex.cts.shim.v2", + manifest: "manifest_v2.json", + androidManifest: "AndroidManifest.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + apps: [ + "CtsShim", + "CtsShimPriv", + ], + installable: false, + allowed_files: "default_shim_allowed_list.txt", + updatable: false, } apex { - name: "com.android.apex.cts.shim.v2_sign_payload_with_different_key", - // Use manifest_v2_rebootless to also re-use this APEX in the rebootless update test case. - manifest: "manifest_v2_rebootless.json", - androidManifest: "AndroidManifest.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.debug.key", - prebuilts: ["hash_of_dev_null"], - installable: false, - allowed_files: "default_shim_allowed_list.txt", - updatable: false, + name: "com.android.apex.cts.shim.v2_sign_payload_with_different_key", + // Use manifest_v2_rebootless to also re-use this APEX in the rebootless update test case. + manifest: "manifest_v2_rebootless.json", + androidManifest: "AndroidManifest.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.debug.key", + prebuilts: ["hash_of_dev_null"], + installable: false, + allowed_files: "default_shim_allowed_list.txt", + updatable: false, } apex { - name: "com.android.apex.cts.shim.v2_without_apk_in_apex", - manifest: "manifest_v2.json", - androidManifest: "AndroidManifest.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - installable: false, - allowed_files: "default_shim_allowed_list.txt", - updatable: false, + name: "com.android.apex.cts.shim.v2_without_apk_in_apex", + manifest: "manifest_v2.json", + androidManifest: "AndroidManifest.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + installable: false, + allowed_files: "default_shim_allowed_list.txt", + updatable: false, } apex { - name: "com.android.apex.cts.shim.v2_no_hashtree", - manifest: "manifest_v2.json", - androidManifest: "AndroidManifest.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - apps: ["CtsShim", "CtsShimPriv"], - installable: false, - allowed_files: "default_shim_allowed_list.txt", - generate_hashtree: false, - updatable: false, + name: "com.android.apex.cts.shim.v2_no_hashtree", + manifest: "manifest_v2.json", + androidManifest: "AndroidManifest.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + apps: [ + "CtsShim", + "CtsShimPriv", + ], + installable: false, + allowed_files: "default_shim_allowed_list.txt", + generate_hashtree: false, + updatable: false, } apex { - name: "com.android.apex.cts.shim.v2_unsigned_payload", - // Use manifest_v2_rebootless to also re-use this APEX in the rebootless update test case. - manifest: "manifest_v2_rebootless.json", - androidManifest: "AndroidManifest.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - apps: ["CtsShim", "CtsShimPriv"], - installable: false, - allowed_files: "default_shim_allowed_list.txt", - test_only_unsigned_payload: true, - updatable: false, + name: "com.android.apex.cts.shim.v2_unsigned_payload", + // Use manifest_v2_rebootless to also re-use this APEX in the rebootless update test case. + manifest: "manifest_v2_rebootless.json", + androidManifest: "AndroidManifest.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + apps: [ + "CtsShim", + "CtsShimPriv", + ], + installable: false, + allowed_files: "default_shim_allowed_list.txt", + test_only_unsigned_payload: true, + updatable: false, } override_apex { @@ -161,192 +173,201 @@ override_apex { } genrule { - name: "generate_empty_hash", - out: ["hash.txt"], - cmd: "touch $(out)", + name: "generate_empty_hash", + out: ["hash.txt"], + cmd: "touch $(out)", } prebuilt_etc { - name: "empty_hash", - src: ":generate_empty_hash", - filename: "hash.txt", - installable: false, + name: "empty_hash", + src: ":generate_empty_hash", + filename: "hash.txt", + installable: false, } // Use empty hash.txt to make sure that this apex has wrong SHA512, hence trying // to stage it should fail. apex { - name: "com.android.apex.cts.shim.v2_wrong_sha", - // Use manifest_v2_rebootless to also re-use this APEX in the rebootless update test case. - manifest: "manifest_v2_rebootless.json", - androidManifest: "AndroidManifest.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["empty_hash"], - installable: false, - updatable: false, + name: "com.android.apex.cts.shim.v2_wrong_sha", + // Use manifest_v2_rebootless to also re-use this APEX in the rebootless update test case. + manifest: "manifest_v2_rebootless.json", + androidManifest: "AndroidManifest.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["empty_hash"], + installable: false, + updatable: false, } prebuilt_etc { - name: "apex_shim_additional_file", - src: "additional_file", - filename: "additional_file", - installable: false, + name: "apex_shim_additional_file", + src: "additional_file", + filename: "additional_file", + installable: false, } apex { - name: "com.android.apex.cts.shim.v2_additional_file", - // Use manifest_v2_rebootless to also re-use this APEX in the rebootless update test case. - manifest: "manifest_v2_rebootless.json", - androidManifest: "AndroidManifest.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null", "apex_shim_additional_file"], - installable: false, - updatable: false, + name: "com.android.apex.cts.shim.v2_additional_file", + // Use manifest_v2_rebootless to also re-use this APEX in the rebootless update test case. + manifest: "manifest_v2_rebootless.json", + androidManifest: "AndroidManifest.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: [ + "hash_of_dev_null", + "apex_shim_additional_file", + ], + installable: false, + updatable: false, } prebuilt_etc { - name: "apex_shim_additional_folder", - src: "additional_file", - filename: "additional_file", - sub_dir: "additional_folder", - installable: false, + name: "apex_shim_additional_folder", + src: "additional_file", + filename: "additional_file", + sub_dir: "additional_folder", + installable: false, } apex { - name: "com.android.apex.cts.shim.v2_additional_folder", - // Use manifest_v2_rebootless to also re-use this APEX in the rebootless update test case. - manifest: "manifest_v2_rebootless.json", - androidManifest: "AndroidManifest.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null", "apex_shim_additional_folder"], - installable: false, - updatable: false, + name: "com.android.apex.cts.shim.v2_additional_folder", + // Use manifest_v2_rebootless to also re-use this APEX in the rebootless update test case. + manifest: "manifest_v2_rebootless.json", + androidManifest: "AndroidManifest.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: [ + "hash_of_dev_null", + "apex_shim_additional_folder", + ], + installable: false, + updatable: false, } apex { - name: "com.android.apex.cts.shim.v2_with_pre_install_hook", - manifest: "manifest_v2_with_pre_install_hook.json", - androidManifest: "AndroidManifest.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - installable: false, - updatable: false, + name: "com.android.apex.cts.shim.v2_with_pre_install_hook", + manifest: "manifest_v2_with_pre_install_hook.json", + androidManifest: "AndroidManifest.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + installable: false, + updatable: false, } apex { - name: "com.android.apex.cts.shim.v2_with_post_install_hook", - manifest: "manifest_v2_with_post_install_hook.json", - androidManifest: "AndroidManifest.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - installable: false, - updatable: false, + name: "com.android.apex.cts.shim.v2_with_post_install_hook", + manifest: "manifest_v2_with_post_install_hook.json", + androidManifest: "AndroidManifest.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + installable: false, + updatable: false, } genrule { - name: "generate_hash_v1", - srcs: [ - ":com.android.apex.cts.shim.v2", - ":com.android.apex.cts.shim.v2_add_apk_to_apex", - ":com.android.apex.cts.shim.v2_without_apk_in_apex", - ":com.android.apex.cts.shim.v2_additional_file", - ":com.android.apex.cts.shim.v2_additional_folder", - ":com.android.apex.cts.shim.v2_different_certificate", - ":com.android.apex.cts.shim.v2_different_package_name", - ":com.android.apex.cts.shim.v2_no_hashtree", - ":com.android.apex.cts.shim.v2_signed_bob", - ":com.android.apex.cts.shim.v2_signed_bob_rot", - ":com.android.apex.cts.shim.v2_signed_bob_rot_rollback", - ":com.android.apex.cts.shim.v2_with_pre_install_hook", - ":com.android.apex.cts.shim.v2_with_post_install_hook", - ":com.android.apex.cts.shim.v2_sdk_target_p", - ":com.android.apex.cts.shim.v2_apk_in_apex_sdk_target_p", - ":com.android.apex.cts.shim.v2_apk_in_apex_upgrades", - ":com.android.apex.cts.shim.v2_rebootless", - ":com.android.apex.cts.shim.v2_install_constraints_empty", - ":com.android.apex.cts.shim.v2_install_constraints_invalid_fingerprint", - ":com.android.apex.cts.shim.v2_install_constraints_no_value", - ":com.android.apex.cts.shim.v3", - ":com.android.apex.cts.shim.v3_rebootless", - ":com.android.apex.cts.shim.v3_signed_bob", - ":com.android.apex.cts.shim.v3_signed_bob_rot", - ], - out: ["hash.txt"], - cmd: "sha512sum -b $(in) | cut -d' ' -f1 | tee $(out)", + name: "generate_hash_v1", + srcs: [ + ":com.android.apex.cts.shim.v2", + ":com.android.apex.cts.shim.v2_add_apk_to_apex", + ":com.android.apex.cts.shim.v2_without_apk_in_apex", + ":com.android.apex.cts.shim.v2_additional_file", + ":com.android.apex.cts.shim.v2_additional_folder", + ":com.android.apex.cts.shim.v2_different_certificate", + ":com.android.apex.cts.shim.v2_different_package_name", + ":com.android.apex.cts.shim.v2_no_hashtree", + ":com.android.apex.cts.shim.v2_signed_bob", + ":com.android.apex.cts.shim.v2_signed_bob_rot", + ":com.android.apex.cts.shim.v2_signed_bob_rot_rollback", + ":com.android.apex.cts.shim.v2_with_pre_install_hook", + ":com.android.apex.cts.shim.v2_with_post_install_hook", + ":com.android.apex.cts.shim.v2_sdk_target_p", + ":com.android.apex.cts.shim.v2_apk_in_apex_sdk_target_p", + ":com.android.apex.cts.shim.v2_apk_in_apex_upgrades", + ":com.android.apex.cts.shim.v2_rebootless", + ":com.android.apex.cts.shim.v2_install_constraints_empty", + ":com.android.apex.cts.shim.v2_install_constraints_invalid_fingerprint", + ":com.android.apex.cts.shim.v2_install_constraints_no_value", + ":com.android.apex.cts.shim.v3", + ":com.android.apex.cts.shim.v3_rebootless", + ":com.android.apex.cts.shim.v3_signed_bob", + ":com.android.apex.cts.shim.v3_signed_bob_rot", + ], + out: ["hash.txt"], + cmd: "sha512sum -b $(in) | cut -d' ' -f1 | tee $(out)", } prebuilt_etc { - name: "hash_v1", - src: ":generate_hash_v1", - filename: "hash.txt", - installable: false, + name: "hash_v1", + src: ":generate_hash_v1", + filename: "hash.txt", + installable: false, } apex { - name: "com.android.apex.cts.shim.v1", - manifest: "manifest.json", - androidManifest: "AndroidManifest.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_v1"], - apps: ["CtsShim", "CtsShimPriv"], - allowed_files: "default_shim_allowed_list.txt", - updatable: false, + name: "com.android.apex.cts.shim.v1", + manifest: "manifest.json", + androidManifest: "AndroidManifest.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_v1"], + apps: [ + "CtsShim", + "CtsShimPriv", + ], + allowed_files: "default_shim_allowed_list.txt", + updatable: false, } genrule { - name: "com.android.apex.cts.shim_not_pre_installed.pem", - out: ["com.android.apex.cts.shim_not_pre_installed.pem"], - cmd: "openssl genrsa -out $(out) 4096", + name: "com.android.apex.cts.shim_not_pre_installed.pem", + out: ["com.android.apex.cts.shim_not_pre_installed.pem"], + cmd: "openssl genrsa -out $(out) 4096", } genrule { - name: "com.android.apex.cts.shim_not_pre_installed.pubkey", - srcs: [":com.android.apex.cts.shim_not_pre_installed.pem"], - out: ["com.android.apex.cts.shim_not_pre_installed.pubkey"], - tools: ["avbtool"], - cmd: "$(location avbtool) extract_public_key --key $(in) --output $(out)", + name: "com.android.apex.cts.shim_not_pre_installed.pubkey", + srcs: [":com.android.apex.cts.shim_not_pre_installed.pem"], + out: ["com.android.apex.cts.shim_not_pre_installed.pubkey"], + tools: ["avbtool"], + cmd: "$(location avbtool) extract_public_key --key $(in) --output $(out)", } apex_key { - name: "com.android.apex.cts.shim_not_pre_installed.key", - private_key: ":com.android.apex.cts.shim_not_pre_installed.pem", - public_key: ":com.android.apex.cts.shim_not_pre_installed.pubkey", - installable: false, + name: "com.android.apex.cts.shim_not_pre_installed.key", + private_key: ":com.android.apex.cts.shim_not_pre_installed.pem", + public_key: ":com.android.apex.cts.shim_not_pre_installed.pubkey", + installable: false, } apex { - name: "com.android.apex.cts.shim_not_pre_installed", - manifest: "manifest_not_pre_installed.json", - androidManifest: "AndroidManifestNotPreInstalled.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim_not_pre_installed.key", - prebuilts: ["hash_of_dev_null"], - installable: false, - updatable: false, + name: "com.android.apex.cts.shim_not_pre_installed", + manifest: "manifest_not_pre_installed.json", + androidManifest: "AndroidManifestNotPreInstalled.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim_not_pre_installed.key", + prebuilts: ["hash_of_dev_null"], + installable: false, + updatable: false, } apex { - name: "com.android.apex.cts.shim.v2_different_certificate", - // Use manifest_v2_rebootless to also re-use this APEX in the rebootless update test case. - manifest: "manifest_v2_rebootless.json", - androidManifest: "AndroidManifest.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - installable: false, - certificate: ":com.android.apex.cts.shim.debug.cert", - updatable: false, + name: "com.android.apex.cts.shim.v2_different_certificate", + // Use manifest_v2_rebootless to also re-use this APEX in the rebootless update test case. + manifest: "manifest_v2_rebootless.json", + androidManifest: "AndroidManifest.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + installable: false, + certificate: ":com.android.apex.cts.shim.debug.cert", + updatable: false, } android_app_certificate { - name: "com.android.apex.cts.shim.debug.cert", - certificate: "com.android.apex.cts.shim.debug.cert", + name: "com.android.apex.cts.shim.debug.cert", + certificate: "com.android.apex.cts.shim.debug.cert", } // Build rules to build shim apex with rotated keys @@ -357,17 +378,17 @@ android_app_certificate { // Create private key bob in pem format genrule { - name: "com.android.apex.rotation.key.bob.pem", - out: ["bob.pem"], - cmd: "openssl req -x509 -newkey rsa:4096 -nodes -days 999999 -subj '/DN=/EMAILADDRESS=android@android.com/CN=Android/OU=Android/O=Android/L=Mountain View/ST=California/C=US' -keyout $(out)", + name: "com.android.apex.rotation.key.bob.pem", + out: ["bob.pem"], + cmd: "openssl req -x509 -newkey rsa:4096 -nodes -days 999999 -subj '/DN=/EMAILADDRESS=android@android.com/CN=Android/OU=Android/O=Android/L=Mountain View/ST=California/C=US' -keyout $(out)", } // Converts bob's private key to pk8 format genrule { - name: "com.android.apex.rotation.key.bob.pk8", - srcs: [":com.android.apex.rotation.key.bob.pem"], - out: ["bob.pk8"], - cmd: "openssl pkcs8 -topk8 -inform PEM -outform DER -in $(in) -out $(out) -nocrypt", + name: "com.android.apex.rotation.key.bob.pk8", + srcs: [":com.android.apex.rotation.key.bob.pem"], + out: ["bob.pk8"], + cmd: "openssl pkcs8 -topk8 -inform PEM -outform DER -in $(in) -out $(out) -nocrypt", } // Extract bob's public key from its private key @@ -380,258 +401,267 @@ genrule { // Create lineage file for rotating alice to bob genrule { - name: "com.android.apex.rotation.key.bob.rot", - srcs: [ - "alice.pk8", - "alice.x509.pem", - ":com.android.apex.rotation.key.bob.pk8", - ":com.android.apex.rotation.key.bob.x509.pem", - ], - out: ["bob.rot"], - tools: [":apksigner"], - cmd: "$(location :apksigner) rotate --out $(out) --old-signer --key $(location alice.pk8) --cert $(location alice.x509.pem) --new-signer --key $(location :com.android.apex.rotation.key.bob.pk8) --cert $(location :com.android.apex.rotation.key.bob.x509.pem)", + name: "com.android.apex.rotation.key.bob.rot", + srcs: [ + "alice.pk8", + "alice.x509.pem", + ":com.android.apex.rotation.key.bob.pk8", + ":com.android.apex.rotation.key.bob.x509.pem", + ], + out: ["bob.rot"], + tools: [":apksigner"], + cmd: "$(location :apksigner) rotate --out $(out) --old-signer --key $(location alice.pk8) --cert $(location alice.x509.pem) --new-signer --key $(location :com.android.apex.rotation.key.bob.pk8) --cert $(location :com.android.apex.rotation.key.bob.x509.pem)", } // Create lineage file for rotating alice to bob with rollback capability genrule { - name: "com.android.apex.rotation.key.bob.rot.rollback", - srcs: [ - "alice.pk8", - "alice.x509.pem", - ":com.android.apex.rotation.key.bob.pk8", - ":com.android.apex.rotation.key.bob.x509.pem", - ], - out: ["bob.rot"], - tools: [":apksigner"], - cmd: "$(location :apksigner) rotate --out $(out) --old-signer --key $(location alice.pk8) --cert $(location alice.x509.pem) --set-rollback true --new-signer --key $(location :com.android.apex.rotation.key.bob.pk8) --cert $(location :com.android.apex.rotation.key.bob.x509.pem)", + name: "com.android.apex.rotation.key.bob.rot.rollback", + srcs: [ + "alice.pk8", + "alice.x509.pem", + ":com.android.apex.rotation.key.bob.pk8", + ":com.android.apex.rotation.key.bob.x509.pem", + ], + out: ["bob.rot"], + tools: [":apksigner"], + cmd: "$(location :apksigner) rotate --out $(out) --old-signer --key $(location alice.pk8) --cert $(location alice.x509.pem) --set-rollback true --new-signer --key $(location :com.android.apex.rotation.key.bob.pk8) --cert $(location :com.android.apex.rotation.key.bob.x509.pem)", } // v2 cts shim package signed by bob, without lineage genrule { - name: "com.android.apex.cts.shim.v2_signed_bob", - out: ["com.android.apex.cts.shim.v2_signed_bob"], - tools: [":apksigner"], - srcs: [ - ":com.android.apex.cts.shim.v2", - ":com.android.apex.rotation.key.bob.x509.pem", - ":com.android.apex.rotation.key.bob.pk8", - ], - dist: { - targets: ["com.android.apex.cts.shim.v2_signed_bob"], - dest: "com.android.apex.cts.shim.v2_signed_bob.apex", - }, - cmd: "$(location :apksigner) sign --v1-signing-enabled false --v2-signing-enabled false --key $(location :com.android.apex.rotation.key.bob.pk8) --cert $(location :com.android.apex.rotation.key.bob.x509.pem) --out $(out) $(location :com.android.apex.cts.shim.v2)", + name: "com.android.apex.cts.shim.v2_signed_bob", + out: ["com.android.apex.cts.shim.v2_signed_bob"], + tools: [":apksigner"], + srcs: [ + ":com.android.apex.cts.shim.v2", + ":com.android.apex.rotation.key.bob.x509.pem", + ":com.android.apex.rotation.key.bob.pk8", + ], + dist: { + targets: ["com.android.apex.cts.shim.v2_signed_bob"], + dest: "com.android.apex.cts.shim.v2_signed_bob.apex", + }, + cmd: "$(location :apksigner) sign --v1-signing-enabled false --v2-signing-enabled false --key $(location :com.android.apex.rotation.key.bob.pk8) --cert $(location :com.android.apex.rotation.key.bob.x509.pem) --out $(out) $(location :com.android.apex.cts.shim.v2)", } // v2 cts shim package signed by bob + lineage genrule { - name: "com.android.apex.cts.shim.v2_signed_bob_rot", - out: ["com.android.apex.cts.shim.v2_signed_bob_rot"], - tools: [":apksigner"], - srcs: [ - ":com.android.apex.cts.shim.v2", - ":com.android.apex.rotation.key.bob.x509.pem", - ":com.android.apex.rotation.key.bob.pk8", - ":com.android.apex.rotation.key.bob.rot", - ], - dist: { - targets: ["com.android.apex.cts.shim.v2_signed_bob_rot"], - dest: "com.android.apex.cts.shim.v2_signed_bob_rot.apex", - }, - cmd: "$(location :apksigner) sign --v1-signing-enabled false --v2-signing-enabled false --key $(location :com.android.apex.rotation.key.bob.pk8) --cert $(location :com.android.apex.rotation.key.bob.x509.pem) --lineage $(location :com.android.apex.rotation.key.bob.rot) --rotation-min-sdk-version 28 --out $(out) $(location :com.android.apex.cts.shim.v2)", + name: "com.android.apex.cts.shim.v2_signed_bob_rot", + out: ["com.android.apex.cts.shim.v2_signed_bob_rot"], + tools: [":apksigner"], + srcs: [ + ":com.android.apex.cts.shim.v2", + ":com.android.apex.rotation.key.bob.x509.pem", + ":com.android.apex.rotation.key.bob.pk8", + ":com.android.apex.rotation.key.bob.rot", + ], + dist: { + targets: ["com.android.apex.cts.shim.v2_signed_bob_rot"], + dest: "com.android.apex.cts.shim.v2_signed_bob_rot.apex", + }, + cmd: "$(location :apksigner) sign --v1-signing-enabled false --v2-signing-enabled false --key $(location :com.android.apex.rotation.key.bob.pk8) --cert $(location :com.android.apex.rotation.key.bob.x509.pem) --lineage $(location :com.android.apex.rotation.key.bob.rot) --rotation-min-sdk-version 28 --out $(out) $(location :com.android.apex.cts.shim.v2)", } // v2 cts shim package signed by bob + lineage + rollback capability genrule { - name: "com.android.apex.cts.shim.v2_signed_bob_rot_rollback", - out: ["com.android.apex.cts.shim.v2_signed_bob_rot_rollback"], - tools: [":apksigner"], - srcs: [ - ":com.android.apex.cts.shim.v2", - ":com.android.apex.rotation.key.bob.x509.pem", - ":com.android.apex.rotation.key.bob.pk8", - ":com.android.apex.rotation.key.bob.rot.rollback", - ], - dist: { - targets: ["com.android.apex.cts.shim.v2_signed_bob_rot_rollback"], - dest: "com.android.apex.cts.shim.v2_signed_bob_rot_rollback.apex", - }, - cmd: "$(location :apksigner) sign --v1-signing-enabled false --v2-signing-enabled false --key $(location :com.android.apex.rotation.key.bob.pk8) --cert $(location :com.android.apex.rotation.key.bob.x509.pem) --lineage $(location :com.android.apex.rotation.key.bob.rot.rollback) --rotation-min-sdk-version 28 --out $(out) $(location :com.android.apex.cts.shim.v2)", + name: "com.android.apex.cts.shim.v2_signed_bob_rot_rollback", + out: ["com.android.apex.cts.shim.v2_signed_bob_rot_rollback"], + tools: [":apksigner"], + srcs: [ + ":com.android.apex.cts.shim.v2", + ":com.android.apex.rotation.key.bob.x509.pem", + ":com.android.apex.rotation.key.bob.pk8", + ":com.android.apex.rotation.key.bob.rot.rollback", + ], + dist: { + targets: ["com.android.apex.cts.shim.v2_signed_bob_rot_rollback"], + dest: "com.android.apex.cts.shim.v2_signed_bob_rot_rollback.apex", + }, + cmd: "$(location :apksigner) sign --v1-signing-enabled false --v2-signing-enabled false --key $(location :com.android.apex.rotation.key.bob.pk8) --cert $(location :com.android.apex.rotation.key.bob.x509.pem) --lineage $(location :com.android.apex.rotation.key.bob.rot.rollback) --rotation-min-sdk-version 28 --out $(out) $(location :com.android.apex.cts.shim.v2)", } // v3 cts shim package signed by bob genrule { - name: "com.android.apex.cts.shim.v3_signed_bob", - out: ["com.android.apex.cts.shim.v3_signed_bob"], - tools: [":apksigner"], - srcs: [ - ":com.android.apex.cts.shim.v3", - ":com.android.apex.rotation.key.bob.x509.pem", - ":com.android.apex.rotation.key.bob.pk8", - ], - dist: { - targets: ["com.android.apex.cts.shim.v3_signed_bob"], - dest: "com.android.apex.cts.shim.v3_signed_bob.apex", - }, - cmd: "$(location :apksigner) sign --v1-signing-enabled false --v2-signing-enabled false --key $(location :com.android.apex.rotation.key.bob.pk8) --cert $(location :com.android.apex.rotation.key.bob.x509.pem) --out $(out) $(location :com.android.apex.cts.shim.v3)", + name: "com.android.apex.cts.shim.v3_signed_bob", + out: ["com.android.apex.cts.shim.v3_signed_bob"], + tools: [":apksigner"], + srcs: [ + ":com.android.apex.cts.shim.v3", + ":com.android.apex.rotation.key.bob.x509.pem", + ":com.android.apex.rotation.key.bob.pk8", + ], + dist: { + targets: ["com.android.apex.cts.shim.v3_signed_bob"], + dest: "com.android.apex.cts.shim.v3_signed_bob.apex", + }, + cmd: "$(location :apksigner) sign --v1-signing-enabled false --v2-signing-enabled false --key $(location :com.android.apex.rotation.key.bob.pk8) --cert $(location :com.android.apex.rotation.key.bob.x509.pem) --out $(out) $(location :com.android.apex.cts.shim.v3)", } // v3 cts shim package signed by bob + lineage genrule { - name: "com.android.apex.cts.shim.v3_signed_bob_rot", - out: ["com.android.apex.cts.shim.v3_signed_bob_rot"], - tools: [":apksigner"], - srcs: [ - ":com.android.apex.cts.shim.v3", - ":com.android.apex.rotation.key.bob.x509.pem", - ":com.android.apex.rotation.key.bob.pk8", - ":com.android.apex.rotation.key.bob.rot", - ], - dist: { - targets: ["com.android.apex.cts.shim.v3_signed_bob_rot"], - dest: "com.android.apex.cts.shim.v3_signed_bob_rot.apex", - }, - cmd: "$(location :apksigner) sign --v1-signing-enabled false --v2-signing-enabled false --key $(location :com.android.apex.rotation.key.bob.pk8) --cert $(location :com.android.apex.rotation.key.bob.x509.pem) --lineage $(location :com.android.apex.rotation.key.bob.rot) --rotation-min-sdk-version 28 --out $(out) $(location :com.android.apex.cts.shim.v3)", + name: "com.android.apex.cts.shim.v3_signed_bob_rot", + out: ["com.android.apex.cts.shim.v3_signed_bob_rot"], + tools: [":apksigner"], + srcs: [ + ":com.android.apex.cts.shim.v3", + ":com.android.apex.rotation.key.bob.x509.pem", + ":com.android.apex.rotation.key.bob.pk8", + ":com.android.apex.rotation.key.bob.rot", + ], + dist: { + targets: ["com.android.apex.cts.shim.v3_signed_bob_rot"], + dest: "com.android.apex.cts.shim.v3_signed_bob_rot.apex", + }, + cmd: "$(location :apksigner) sign --v1-signing-enabled false --v2-signing-enabled false --key $(location :com.android.apex.rotation.key.bob.pk8) --cert $(location :com.android.apex.rotation.key.bob.x509.pem) --lineage $(location :com.android.apex.rotation.key.bob.rot) --rotation-min-sdk-version 28 --out $(out) $(location :com.android.apex.cts.shim.v3)", } // This one is only used in ApexdHostTest and not meant to be installed // and hence shouldn't be allowed in hash.txt of v1 shim APEX. apex { - name: "com.android.apex.cts.shim.v2_legacy", - manifest: "manifest_v2.json", - androidManifest: "AndroidManifest.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - apps: ["CtsShim", "CtsShimPriv"], - installable: false, - min_sdk_version: "29", - updatable: false, + name: "com.android.apex.cts.shim.v2_legacy", + manifest: "manifest_v2.json", + androidManifest: "AndroidManifest.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + apps: [ + "CtsShim", + "CtsShimPriv", + ], + installable: false, + min_sdk_version: "29", + updatable: false, } genrule { - name: "com.android.apex.cts.shim.v2_no_pb", - srcs: [":com.android.apex.cts.shim.v2_legacy"], - out: ["com.android.apex.cts.shim.v2_no_pb.apex"], - tools: ["zip2zip"], - cmd: "$(location zip2zip) -i $(in) -x apex_manifest.pb -o $(out)", + name: "com.android.apex.cts.shim.v2_no_pb", + srcs: [":com.android.apex.cts.shim.v2_legacy"], + out: ["com.android.apex.cts.shim.v2_no_pb.apex"], + tools: ["zip2zip"], + cmd: "$(location zip2zip) -i $(in) -x apex_manifest.pb -o $(out)", } // Apex shim that targets an old sdk (P) apex { - name: "com.android.apex.cts.shim.v2_sdk_target_p", - // Use manifest_v2_rebootless to also re-use this APEX in the rebootless update test case. - manifest: "manifest_v2_rebootless.json", - androidManifest: "AndroidManifestSdkTargetP.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - installable: false, - apps: ["CtsShim", "CtsShimPriv"], - updatable: false, + name: "com.android.apex.cts.shim.v2_sdk_target_p", + // Use manifest_v2_rebootless to also re-use this APEX in the rebootless update test case. + manifest: "manifest_v2_rebootless.json", + androidManifest: "AndroidManifestSdkTargetP.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + installable: false, + apps: [ + "CtsShim", + "CtsShimPriv", + ], + updatable: false, } // Apex shim with apk-in-apex that targets sdk P apex { - name: "com.android.apex.cts.shim.v2_apk_in_apex_sdk_target_p", - manifest: "manifest_v2.json", - androidManifest: "AndroidManifest.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - apps: ["CtsShimTargetPSdk"], - installable: false, - updatable: false, + name: "com.android.apex.cts.shim.v2_apk_in_apex_sdk_target_p", + manifest: "manifest_v2.json", + androidManifest: "AndroidManifest.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + apps: ["CtsShimTargetPSdk"], + installable: false, + updatable: false, } // Apex shim with unsigned apk genrule { - name: "com.android.apex.cts.shim.v2_unsigned_apk_container", - // Use shim.v2_rebootless to re-use same APEX in the rebootless update test case. - srcs: [":com.android.apex.cts.shim.v2_rebootless"], - out: ["com.android.apex.cts.shim.v2_unsigned_apk_container.apex"], - cmd: "cp -v $(in) $(out) && zip -d $(out) META-INF*", - dist: { - targets: ["com.android.apex.cts.shim.v2_unsigned_apk_container"], - dest: "com.android.apex.cts.shim.v2_unsigned_apk_container.apex", - }, + name: "com.android.apex.cts.shim.v2_unsigned_apk_container", + // Use shim.v2_rebootless to re-use same APEX in the rebootless update test case. + srcs: [":com.android.apex.cts.shim.v2_rebootless"], + out: ["com.android.apex.cts.shim.v2_unsigned_apk_container.apex"], + cmd: "cp -v $(in) $(out) && zip -d $(out) META-INF*", + dist: { + targets: ["com.android.apex.cts.shim.v2_unsigned_apk_container"], + dest: "com.android.apex.cts.shim.v2_unsigned_apk_container.apex", + }, } // Apex shim for testing rebootless updates apex { - name: "com.android.apex.cts.shim.v2_rebootless", - manifest: "manifest_v2_rebootless.json", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - installable: false, - updatable: false, + name: "com.android.apex.cts.shim.v2_rebootless", + manifest: "manifest_v2_rebootless.json", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + installable: false, + updatable: false, } apex { - name: "com.android.apex.cts.shim.v3_rebootless", - manifest: "manifest_v3_rebootless.json", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - installable: false, - updatable: false, + name: "com.android.apex.cts.shim.v3_rebootless", + manifest: "manifest_v3_rebootless.json", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + installable: false, + updatable: false, } // Apex shim with upgraded apk-in-apexes apex { - name: "com.android.apex.cts.shim.v2_apk_in_apex_upgrades", - manifest: "manifest_v2.json", - androidManifest: "AndroidManifest.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - apps: ["CtsShim", "CtsShimPrivUpgrade"], - installable: false, - updatable: false, + name: "com.android.apex.cts.shim.v2_apk_in_apex_upgrades", + manifest: "manifest_v2.json", + androidManifest: "AndroidManifest.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + apps: [ + "CtsShim", + "CtsShimPrivUpgrade", + ], + installable: false, + updatable: false, } apex { - name: "com.android.apex.cts.shim.v2_install_constraints_empty", - manifest: "manifest_v2.json", - androidManifest: "AndroidManifestInstallConstraints_empty.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - installable: false, - updatable: false, + name: "com.android.apex.cts.shim.v2_install_constraints_empty", + manifest: "manifest_v2.json", + androidManifest: "AndroidManifestInstallConstraints_empty.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + installable: false, + updatable: false, } apex { - name: "com.android.apex.cts.shim.v2_install_constraints_invalid_fingerprint", - manifest: "manifest_v2.json", - androidManifest: "AndroidManifestInstallConstraints_invalid_fingerprint.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - installable: false, - updatable: false, + name: "com.android.apex.cts.shim.v2_install_constraints_invalid_fingerprint", + manifest: "manifest_v2.json", + androidManifest: "AndroidManifestInstallConstraints_invalid_fingerprint.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + installable: false, + updatable: false, } apex { - name: "com.android.apex.cts.shim.v2_install_constraints_no_value", - manifest: "manifest_v2.json", - androidManifest: "AndroidManifestInstallConstraints_no_value.xml", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - installable: false, - updatable: false, + name: "com.android.apex.cts.shim.v2_install_constraints_no_value", + manifest: "manifest_v2.json", + androidManifest: "AndroidManifestInstallConstraints_no_value.xml", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + installable: false, + updatable: false, } // Apex shim for running a new app in an apex apex { - name: "com.android.apex.cts.shim.v2_add_apk_to_apex", - manifest: "manifest_v2.json", - file_contexts: ":apex.test-file_contexts", - key: "com.android.apex.cts.shim.key", - prebuilts: ["hash_of_dev_null"], - apps: ["CtsShimAddApkToApex"], - installable: false, - updatable: false, -}
\ No newline at end of file + name: "com.android.apex.cts.shim.v2_add_apk_to_apex", + manifest: "manifest_v2.json", + file_contexts: ":apex.test-file_contexts", + key: "com.android.apex.cts.shim.key", + prebuilts: ["hash_of_dev_null"], + apps: ["CtsShimAddApkToApex"], + installable: false, + updatable: false, +} diff --git a/tests/app/src/com/android/tests/apex/app/VendorApexTests.java b/tests/app/src/com/android/tests/apex/app/VendorApexTests.java index 5e8519ab..1739bad4 100644 --- a/tests/app/src/com/android/tests/apex/app/VendorApexTests.java +++ b/tests/app/src/com/android/tests/apex/app/VendorApexTests.java @@ -32,6 +32,7 @@ import com.android.cts.install.lib.Install; import com.android.cts.install.lib.InstallUtils; import com.android.cts.install.lib.TestApp; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -63,11 +64,16 @@ public class VendorApexTests { "com.android.apex.vendor.foo.v2_with_wrong_vndk_version", APEX_PACKAGE_NAME, 2, /*isApex*/true, "com.android.apex.vendor.foo.v2_with_wrong_vndk_version.apex"); - @Test - public void testRebootlessUpdate() throws Exception { + @Before + public void setUp() { InstallUtils.dropShellPermissionIdentity(); - InstallUtils.adoptShellPermissionIdentity(Manifest.permission.INSTALL_PACKAGE_UPDATES); + InstallUtils.adoptShellPermissionIdentity( + Manifest.permission.INSTALL_PACKAGE_UPDATES, + Manifest.permission.INSTALL_TEST_ONLY_PACKAGE); + } + @Test + public void testRebootlessUpdate() throws Exception { final PackageManager pm = InstrumentationRegistry.getInstrumentation().getContext().getPackageManager(); { @@ -87,9 +93,6 @@ public class VendorApexTests { @Test public void testGenerateLinkerConfigurationOnUpdate() throws Exception { - InstallUtils.dropShellPermissionIdentity(); - InstallUtils.adoptShellPermissionIdentity(Manifest.permission.INSTALL_PACKAGE_UPDATES); - // There's no ld.config.txt for v1 (preinstalled, empty) final Path ldConfigTxt = Paths.get("/linkerconfig", APEX_PACKAGE_NAME, "ld.config.txt"); assertTrue(Files.notExists(ldConfigTxt)); @@ -114,9 +117,6 @@ public class VendorApexTests { @Test public void testRestartServiceAfterRebootlessUpdate() throws Exception { - InstallUtils.dropShellPermissionIdentity(); - InstallUtils.adoptShellPermissionIdentity(Manifest.permission.INSTALL_PACKAGE_UPDATES); - assertThat(SystemProperties.get("init.svc.apex_vendor_foo_v1", "")) .isEqualTo("running"); assertThat(SystemProperties.get("init.svc.apex_vendor_foo_v2", "")) @@ -136,9 +136,6 @@ public class VendorApexTests { @Test public void testInstallAbortsWhenVndkVersionMismatches() throws Exception { - InstallUtils.dropShellPermissionIdentity(); - InstallUtils.adoptShellPermissionIdentity(Manifest.permission.INSTALL_PACKAGE_UPDATES); - InstallUtils.commitExpectingFailure( AssertionError.class, "vndkVersion\\(WrongVndkVersion\\) doesn't match with device VNDK version", @@ -147,9 +144,6 @@ public class VendorApexTests { @Test public void testInstallAbortsWhenVndkVersionMismatches_Staged() throws Exception { - InstallUtils.dropShellPermissionIdentity(); - InstallUtils.adoptShellPermissionIdentity(Manifest.permission.INSTALL_PACKAGE_UPDATES); - InstallUtils.commitExpectingFailure( AssertionError.class, "vndkVersion\\(WrongVndkVersion\\) doesn't match with device VNDK version", diff --git a/tests/src/com/android/tests/apex/SharedLibsApexTest.java b/tests/src/com/android/tests/apex/SharedLibsApexTest.java index df49f62f..797a71b1 100644 --- a/tests/src/com/android/tests/apex/SharedLibsApexTest.java +++ b/tests/src/com/android/tests/apex/SharedLibsApexTest.java @@ -195,9 +195,11 @@ public class SharedLibsApexTest extends BaseHostJUnit4Test { String runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.foo/bin/foo_test"); assertThat(runAsResult).isEqualTo("FOO_VERSION_1 SHARED_LIB_VERSION_X"); - runAsResult = getDevice().executeShellCommand( - "/apex/com.android.apex.test.bar/bin/bar_test32"); - assertThat(runAsResult).isEqualTo("BAR_VERSION_1 SHARED_LIB_VERSION_X"); + if (CpuFeatures.isX86_32(getDevice()) || CpuFeatures.isArm32(getDevice())) { + runAsResult = getDevice().executeShellCommand( + "/apex/com.android.apex.test.bar/bin/bar_test32"); + assertThat(runAsResult).isEqualTo("BAR_VERSION_1 SHARED_LIB_VERSION_X"); + } if (CpuFeatures.isX86_64(getDevice()) || CpuFeatures.isArm64(getDevice())) { runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.bar/bin/bar_test64"); @@ -220,9 +222,11 @@ public class SharedLibsApexTest extends BaseHostJUnit4Test { runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.foo/bin/foo_test"); assertThat(runAsResult).isEqualTo("FOO_VERSION_2 SHARED_LIB_VERSION_Y"); - runAsResult = getDevice().executeShellCommand( - "/apex/com.android.apex.test.bar/bin/bar_test32"); - assertThat(runAsResult).isEqualTo("BAR_VERSION_2 SHARED_LIB_VERSION_Y"); + if (CpuFeatures.isX86_32(getDevice()) || CpuFeatures.isArm32(getDevice())) { + runAsResult = getDevice().executeShellCommand( + "/apex/com.android.apex.test.bar/bin/bar_test32"); + assertThat(runAsResult).isEqualTo("BAR_VERSION_2 SHARED_LIB_VERSION_Y"); + } if (CpuFeatures.isX86_64(getDevice()) || CpuFeatures.isArm64(getDevice())) { runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.bar/bin/bar_test64"); @@ -267,9 +271,11 @@ public class SharedLibsApexTest extends BaseHostJUnit4Test { String runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.foo/bin/foo_test"); assertThat(runAsResult).isEqualTo("FOO_VERSION_1 SHARED_LIB_VERSION_X"); - runAsResult = getDevice().executeShellCommand( - "/apex/com.android.apex.test.bar/bin/bar_test32"); - assertThat(runAsResult).isEqualTo("BAR_VERSION_1 SHARED_LIB_VERSION_X"); + if (CpuFeatures.isX86_32(getDevice()) || CpuFeatures.isArm32(getDevice())) { + runAsResult = getDevice().executeShellCommand( + "/apex/com.android.apex.test.bar/bin/bar_test32"); + assertThat(runAsResult).isEqualTo("BAR_VERSION_1 SHARED_LIB_VERSION_X"); + } if (CpuFeatures.isX86_64(getDevice()) || CpuFeatures.isArm64(getDevice())) { runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.bar/bin/bar_test64"); @@ -308,9 +314,11 @@ public class SharedLibsApexTest extends BaseHostJUnit4Test { runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.foo/bin/foo_test"); assertThat(runAsResult).isEqualTo("FOO_VERSION_1 SHARED_LIB_VERSION_X"); - runAsResult = getDevice().executeShellCommand( - "/apex/com.android.apex.test.bar/bin/bar_test32"); - assertThat(runAsResult).isEqualTo("BAR_VERSION_1 SHARED_LIB_VERSION_X"); + if (CpuFeatures.isX86_32(getDevice()) || CpuFeatures.isArm32(getDevice())) { + runAsResult = getDevice().executeShellCommand( + "/apex/com.android.apex.test.bar/bin/bar_test32"); + assertThat(runAsResult).isEqualTo("BAR_VERSION_1 SHARED_LIB_VERSION_X"); + } if (CpuFeatures.isX86_64(getDevice()) || CpuFeatures.isArm64(getDevice())) { runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.bar/bin/bar_test64"); @@ -350,9 +358,11 @@ public class SharedLibsApexTest extends BaseHostJUnit4Test { runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.foo/bin/foo_test"); assertThat(runAsResult).isEqualTo("FOO_VERSION_2 SHARED_LIB_VERSION_Y"); - runAsResult = getDevice().executeShellCommand( - "/apex/com.android.apex.test.bar/bin/bar_test32"); - assertThat(runAsResult).isEqualTo("BAR_VERSION_2 SHARED_LIB_VERSION_Y"); + if (CpuFeatures.isX86_32(getDevice()) || CpuFeatures.isArm32(getDevice())) { + runAsResult = getDevice().executeShellCommand( + "/apex/com.android.apex.test.bar/bin/bar_test32"); + assertThat(runAsResult).isEqualTo("BAR_VERSION_2 SHARED_LIB_VERSION_Y"); + } if (CpuFeatures.isX86_64(getDevice()) || CpuFeatures.isArm64(getDevice())) { runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.bar/bin/bar_test64"); @@ -386,9 +396,11 @@ public class SharedLibsApexTest extends BaseHostJUnit4Test { runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.foo/bin/foo_test"); assertThat(runAsResult).isEqualTo("FOO_VERSION_2 SHARED_LIB_VERSION_Y"); - runAsResult = getDevice().executeShellCommand( - "/apex/com.android.apex.test.bar/bin/bar_test32"); - assertThat(runAsResult).isEqualTo("BAR_VERSION_2 SHARED_LIB_VERSION_Y"); + if (CpuFeatures.isX86_32(getDevice()) || CpuFeatures.isArm32(getDevice())) { + runAsResult = getDevice().executeShellCommand( + "/apex/com.android.apex.test.bar/bin/bar_test32"); + assertThat(runAsResult).isEqualTo("BAR_VERSION_2 SHARED_LIB_VERSION_Y"); + } if (CpuFeatures.isX86_64(getDevice()) || CpuFeatures.isArm64(getDevice())) { runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.bar/bin/bar_test64"); @@ -430,9 +442,11 @@ public class SharedLibsApexTest extends BaseHostJUnit4Test { String runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.foo/bin/foo_test"); assertThat(runAsResult).isEqualTo("FOO_VERSION_1 SHARED_LIB_VERSION_X"); - runAsResult = getDevice().executeShellCommand( - "/apex/com.android.apex.test.bar/bin/bar_test32"); - assertThat(runAsResult).isEqualTo("BAR_VERSION_1 SHARED_LIB_VERSION_X"); + if (CpuFeatures.isX86_32(getDevice()) || CpuFeatures.isArm32(getDevice())) { + runAsResult = getDevice().executeShellCommand( + "/apex/com.android.apex.test.bar/bin/bar_test32"); + assertThat(runAsResult).isEqualTo("BAR_VERSION_1 SHARED_LIB_VERSION_X"); + } if (CpuFeatures.isX86_64(getDevice()) || CpuFeatures.isArm64(getDevice())) { runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.bar/bin/bar_test64"); @@ -465,9 +479,11 @@ public class SharedLibsApexTest extends BaseHostJUnit4Test { runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.foo/bin/foo_test"); assertThat(runAsResult).isEqualTo("FOO_VERSION_1 SHARED_LIB_VERSION_X"); - runAsResult = getDevice().executeShellCommand( - "/apex/com.android.apex.test.bar/bin/bar_test32"); - assertThat(runAsResult).isEqualTo("BAR_VERSION_1 SHARED_LIB_VERSION_X"); + if (CpuFeatures.isX86_32(getDevice()) || CpuFeatures.isArm32(getDevice())) { + runAsResult = getDevice().executeShellCommand( + "/apex/com.android.apex.test.bar/bin/bar_test32"); + assertThat(runAsResult).isEqualTo("BAR_VERSION_1 SHARED_LIB_VERSION_X"); + } if (CpuFeatures.isX86_64(getDevice()) || CpuFeatures.isArm64(getDevice())) { runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.bar/bin/bar_test64"); @@ -524,9 +540,11 @@ public class SharedLibsApexTest extends BaseHostJUnit4Test { runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.foo/bin/foo_test"); assertThat(runAsResult).isEqualTo("FOO_VERSION_2 SHARED_LIB_VERSION_Y"); - runAsResult = getDevice().executeShellCommand( - "/apex/com.android.apex.test.bar/bin/bar_test32"); - assertThat(runAsResult).isEqualTo("BAR_VERSION_2 SHARED_LIB_VERSION_Y"); + if (CpuFeatures.isX86_32(getDevice()) || CpuFeatures.isArm32(getDevice())) { + runAsResult = getDevice().executeShellCommand( + "/apex/com.android.apex.test.bar/bin/bar_test32"); + assertThat(runAsResult).isEqualTo("BAR_VERSION_2 SHARED_LIB_VERSION_Y"); + } if (CpuFeatures.isX86_64(getDevice()) || CpuFeatures.isArm64(getDevice())) { runAsResult = getDevice().executeShellCommand( "/apex/com.android.apex.test.bar/bin/bar_test64"); diff --git a/tests/testdata/apkinapex/com.android.apex.product.test/Android.bp b/tests/testdata/apkinapex/com.android.apex.product.test/Android.bp index df7fc121..8765777f 100644 --- a/tests/testdata/apkinapex/com.android.apex.product.test/Android.bp +++ b/tests/testdata/apkinapex/com.android.apex.product.test/Android.bp @@ -30,7 +30,7 @@ android_app_certificate { apex { name: "com.android.apex.product.test", manifest: "manifest.json", - file_contexts: ":apex.test-file_contexts", // Default, please edit, see go/android-apex-howto + file_contexts: ":apex.test-file_contexts", // Default, please edit, see go/android-apex-howto key: "com.android.apex.product.test.key", updatable: false, apps: ["com.android.apex.product.app.test"], @@ -43,7 +43,7 @@ android_app { privileged: true, apex_available: [ "com.android.apex.product.test", - ] + ], } filegroup { diff --git a/tests/testdata/apkinapex/com.android.apex.system.test/Android.bp b/tests/testdata/apkinapex/com.android.apex.system.test/Android.bp index 72822702..7b88a5cf 100644 --- a/tests/testdata/apkinapex/com.android.apex.system.test/Android.bp +++ b/tests/testdata/apkinapex/com.android.apex.system.test/Android.bp @@ -30,7 +30,7 @@ android_app_certificate { apex { name: "com.android.apex.system.test", manifest: "manifest.json", - file_contexts: ":apex.test-file_contexts", // Default, please edit, see go/android-apex-howto + file_contexts: ":apex.test-file_contexts", // Default, please edit, see go/android-apex-howto key: "com.android.apex.system.test.key", updatable: false, apps: ["com.android.apex.system.app.test"], @@ -43,7 +43,7 @@ android_app { privileged: true, apex_available: [ "com.android.apex.system.test", - ] + ], } filegroup { diff --git a/tests/testdata/apkinapex/com.android.apex.system_ext.test/Android.bp b/tests/testdata/apkinapex/com.android.apex.system_ext.test/Android.bp index ebab4558..b328ba0a 100644 --- a/tests/testdata/apkinapex/com.android.apex.system_ext.test/Android.bp +++ b/tests/testdata/apkinapex/com.android.apex.system_ext.test/Android.bp @@ -30,7 +30,7 @@ android_app_certificate { apex { name: "com.android.apex.system_ext.test", manifest: "manifest.json", - file_contexts: ":apex.test-file_contexts", // Default, please edit, see go/android-apex-howto + file_contexts: ":apex.test-file_contexts", // Default, please edit, see go/android-apex-howto key: "com.android.apex.system_ext.test.key", updatable: false, apps: ["com.android.apex.system_ext.app.test"], @@ -43,7 +43,7 @@ android_app { privileged: true, apex_available: [ "com.android.apex.system_ext.test", - ] + ], } filegroup { diff --git a/tests/testdata/apkinapex/com.android.apex.vendor.test/Android.bp b/tests/testdata/apkinapex/com.android.apex.vendor.test/Android.bp index 8300d6f9..85eb7470 100644 --- a/tests/testdata/apkinapex/com.android.apex.vendor.test/Android.bp +++ b/tests/testdata/apkinapex/com.android.apex.vendor.test/Android.bp @@ -30,7 +30,7 @@ android_app_certificate { apex { name: "com.android.apex.vendor.test", manifest: "manifest.json", - file_contexts: ":apex.test-file_contexts", // Default, please edit, see go/android-apex-howto + file_contexts: ":apex.test-file_contexts", // Default, please edit, see go/android-apex-howto key: "com.android.apex.vendor.test.key", updatable: false, apps: ["com.android.apex.vendor.app.test"], @@ -43,7 +43,7 @@ android_app { privileged: true, apex_available: [ "com.android.apex.vendor.test", - ] + ], } filegroup { diff --git a/tests/testdata/maxsdk/com.android.apex.maxsdk.test/Android.bp b/tests/testdata/maxsdk/com.android.apex.maxsdk.test/Android.bp index a54da039..29d15f00 100644 --- a/tests/testdata/maxsdk/com.android.apex.maxsdk.test/Android.bp +++ b/tests/testdata/maxsdk/com.android.apex.maxsdk.test/Android.bp @@ -30,7 +30,7 @@ android_app_certificate { apex_test { name: "com.android.apex.maxsdk.test", manifest: "manifest.json", - file_contexts: ":apex.test-file_contexts", // Default, please edit, see go/android-apex-howto + file_contexts: ":apex.test-file_contexts", // Default, please edit, see go/android-apex-howto key: "com.android.apex.maxsdk.test.key", certificate: ":com.android.apex.maxsdk.test.certificate", updatable: false, @@ -48,7 +48,7 @@ android_app { sdk_version: "31", apex_available: [ "com.android.apex.maxsdk.test", - ] + ], } android_app { @@ -57,7 +57,7 @@ android_app { sdk_version: "31", apex_available: [ "com.android.apex.maxsdk.test", - ] + ], } android_app { @@ -66,5 +66,5 @@ android_app { sdk_version: "31", apex_available: [ "com.android.apex.maxsdk.test", - ] + ], } diff --git a/tests/testdata/sharedlibs/build/Android.bp b/tests/testdata/sharedlibs/build/Android.bp index 999024cd..f8fa184a 100644 --- a/tests/testdata/sharedlibs/build/Android.bp +++ b/tests/testdata/sharedlibs/build/Android.bp @@ -12,7 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - package { default_applicable_licenses: ["Android-Apache-2.0"], } @@ -21,7 +20,7 @@ cc_binary { name: "noop", srcs: ["noop.cc"], shared_libs: [ - "libsharedlibtest", + "libsharedlibtest", ], multilib: { lib32: { @@ -35,8 +34,8 @@ cc_binary { compile_multilib: "both", apex_available: [ - "com.android.apex.test.sharedlibs_stub", - "com.android.apex.test.sharedlibs_secondary_stub", + "com.android.apex.test.sharedlibs_stub", + "com.android.apex.test.sharedlibs_secondary_stub", ], } @@ -62,7 +61,7 @@ python_binary_host { cc_library_shared { name: "libsharedlibtest", - srcs: [ "sharedlibstest.cpp", ], + srcs: ["sharedlibstest.cpp"], local_include_dirs: [ "include", diff --git a/tests/testdata/sharedlibs/build/com.android.apex.test.bar/Android.bp b/tests/testdata/sharedlibs/build/com.android.apex.test.bar/Android.bp index 0c62e645..3fec14ba 100644 --- a/tests/testdata/sharedlibs/build/com.android.apex.test.bar/Android.bp +++ b/tests/testdata/sharedlibs/build/com.android.apex.test.bar/Android.bp @@ -32,7 +32,7 @@ apex { file_contexts: ":apex.test-file_contexts", key: "com.android.apex.test.bar.key", installable: false, - binaries: [ "bar_test" ], + binaries: ["bar_test"], dist: { targets: ["sharedlibs_test"], }, @@ -51,7 +51,7 @@ cc_binary { name: "bar_test", srcs: ["bar_test.cc"], shared_libs: [ - "libsharedlibtest", + "libsharedlibtest", ], multilib: { lib32: { @@ -64,7 +64,7 @@ cc_binary { compile_multilib: "both", - apex_available: [ "com.android.apex.test.bar" ], + apex_available: ["com.android.apex.test.bar"], } genrule { @@ -85,12 +85,12 @@ genrule { "shared_libs_repack", ], cmd: "$(location shared_libs_repack) " + - " --mode strip" + - " --key $(location com.android.apex.test.bar.pem)" + - " --input $(location :com.android.apex.test.bar)" + - " --output $(genDir)/com.android.apex.test.bar_stripped.apex" + - " --pk8key $(location com.android.apex.test.bar.pk8)" + - " --pubkey $(location com.android.apex.test.bar.avbpubkey)" + - " --x509key $(location com.android.apex.test.bar.x509.pem)" + - " --tmpdir $(genDir)", + " --mode strip" + + " --key $(location com.android.apex.test.bar.pem)" + + " --input $(location :com.android.apex.test.bar)" + + " --output $(genDir)/com.android.apex.test.bar_stripped.apex" + + " --pk8key $(location com.android.apex.test.bar.pk8)" + + " --pubkey $(location com.android.apex.test.bar.avbpubkey)" + + " --x509key $(location com.android.apex.test.bar.x509.pem)" + + " --tmpdir $(genDir)", } diff --git a/tests/testdata/sharedlibs/build/com.android.apex.test.baz/Android.bp b/tests/testdata/sharedlibs/build/com.android.apex.test.baz/Android.bp index 6076d71d..b32a6b97 100644 --- a/tests/testdata/sharedlibs/build/com.android.apex.test.baz/Android.bp +++ b/tests/testdata/sharedlibs/build/com.android.apex.test.baz/Android.bp @@ -32,7 +32,7 @@ apex { file_contexts: ":apex.test-file_contexts", key: "com.android.apex.test.baz.key", installable: false, - binaries: [ "baz_test" ], + binaries: ["baz_test"], dist: { targets: ["sharedlibs_test"], }, @@ -43,9 +43,9 @@ cc_binary { name: "baz_test", srcs: ["baz_test.cc"], shared_libs: [ - "libsharedlibtest", + "libsharedlibtest", ], - apex_available: [ "com.android.apex.test.baz" ], + apex_available: ["com.android.apex.test.baz"], } genrule { @@ -66,12 +66,12 @@ genrule { "shared_libs_repack", ], cmd: "$(location shared_libs_repack) " + - " --mode strip" + - " --key $(location com.android.apex.test.baz.pem)" + - " --input $(location :com.android.apex.test.baz)" + - " --output $(genDir)/com.android.apex.test.baz_stripped.apex" + - " --pk8key $(location com.android.apex.test.baz.pk8)" + - " --pubkey $(location com.android.apex.test.baz.avbpubkey)" + - " --x509key $(location com.android.apex.test.baz.x509.pem)" + - " --tmpdir $(genDir)", + " --mode strip" + + " --key $(location com.android.apex.test.baz.pem)" + + " --input $(location :com.android.apex.test.baz)" + + " --output $(genDir)/com.android.apex.test.baz_stripped.apex" + + " --pk8key $(location com.android.apex.test.baz.pk8)" + + " --pubkey $(location com.android.apex.test.baz.avbpubkey)" + + " --x509key $(location com.android.apex.test.baz.x509.pem)" + + " --tmpdir $(genDir)", } diff --git a/tests/testdata/sharedlibs/build/com.android.apex.test.foo/Android.bp b/tests/testdata/sharedlibs/build/com.android.apex.test.foo/Android.bp index 451f8a01..0c4e9522 100644 --- a/tests/testdata/sharedlibs/build/com.android.apex.test.foo/Android.bp +++ b/tests/testdata/sharedlibs/build/com.android.apex.test.foo/Android.bp @@ -32,7 +32,7 @@ apex { file_contexts: ":apex.test-file_contexts", key: "com.android.apex.test.foo.key", installable: false, - binaries: [ "foo_test" ], + binaries: ["foo_test"], dist: { targets: ["sharedlibs_test"], }, @@ -43,9 +43,9 @@ cc_binary { name: "foo_test", srcs: ["foo_test.cc"], shared_libs: [ - "libsharedlibtest", + "libsharedlibtest", ], - apex_available: [ "com.android.apex.test.foo" ], + apex_available: ["com.android.apex.test.foo"], } genrule { @@ -66,12 +66,12 @@ genrule { "shared_libs_repack", ], cmd: "$(location shared_libs_repack) " + - " --mode strip" + - " --key $(location com.android.apex.test.foo.pem)" + - " --input $(location :com.android.apex.test.foo)" + - " --output $(genDir)/com.android.apex.test.foo_stripped.apex" + - " --pk8key $(location com.android.apex.test.foo.pk8)" + - " --pubkey $(location com.android.apex.test.foo.avbpubkey)" + - " --x509key $(location com.android.apex.test.foo.x509.pem)" + - " --tmpdir $(genDir)", + " --mode strip" + + " --key $(location com.android.apex.test.foo.pem)" + + " --input $(location :com.android.apex.test.foo)" + + " --output $(genDir)/com.android.apex.test.foo_stripped.apex" + + " --pk8key $(location com.android.apex.test.foo.pk8)" + + " --pubkey $(location com.android.apex.test.foo.avbpubkey)" + + " --x509key $(location com.android.apex.test.foo.x509.pem)" + + " --tmpdir $(genDir)", } diff --git a/tests/testdata/sharedlibs/build/com.android.apex.test.pony/Android.bp b/tests/testdata/sharedlibs/build/com.android.apex.test.pony/Android.bp index 3dd0349e..14b15ead 100644 --- a/tests/testdata/sharedlibs/build/com.android.apex.test.pony/Android.bp +++ b/tests/testdata/sharedlibs/build/com.android.apex.test.pony/Android.bp @@ -32,7 +32,7 @@ apex { file_contexts: ":apex.test-file_contexts", key: "com.android.apex.test.pony.key", installable: false, - binaries: [ "pony_test" ], + binaries: ["pony_test"], dist: { targets: ["sharedlibs_test"], }, @@ -43,9 +43,9 @@ cc_binary { name: "pony_test", srcs: ["pony_test.cc"], shared_libs: [ - "libsharedlibtest", + "libsharedlibtest", ], - apex_available: [ "com.android.apex.test.pony" ], + apex_available: ["com.android.apex.test.pony"], } genrule { @@ -66,12 +66,12 @@ genrule { "shared_libs_repack", ], cmd: "$(location shared_libs_repack) " + - " --mode strip" + - " --key $(location com.android.apex.test.pony.pem)" + - " --input $(location :com.android.apex.test.pony)" + - " --output $(genDir)/com.android.apex.test.pony_stripped.apex" + - " --pk8key $(location com.android.apex.test.pony.pk8)" + - " --pubkey $(location com.android.apex.test.pony.avbpubkey)" + - " --x509key $(location com.android.apex.test.pony.x509.pem)" + - " --tmpdir $(genDir)", + " --mode strip" + + " --key $(location com.android.apex.test.pony.pem)" + + " --input $(location :com.android.apex.test.pony)" + + " --output $(genDir)/com.android.apex.test.pony_stripped.apex" + + " --pk8key $(location com.android.apex.test.pony.pk8)" + + " --pubkey $(location com.android.apex.test.pony.avbpubkey)" + + " --x509key $(location com.android.apex.test.pony.x509.pem)" + + " --tmpdir $(genDir)", } diff --git a/tests/testdata/sharedlibs/build/com.android.apex.test.sharedlibs/Android.bp b/tests/testdata/sharedlibs/build/com.android.apex.test.sharedlibs/Android.bp index 78816364..efea81f6 100644 --- a/tests/testdata/sharedlibs/build/com.android.apex.test.sharedlibs/Android.bp +++ b/tests/testdata/sharedlibs/build/com.android.apex.test.sharedlibs/Android.bp @@ -33,7 +33,7 @@ apex { key: "com.android.apex.test.sharedlibs.key", installable: false, // We want to force libc++.so to be available in this stub APEX, so put an empty binary. - binaries: [ "noop" ], + binaries: ["noop"], updatable: false, compile_multilib: "both", multilib: { @@ -63,12 +63,12 @@ genrule { "shared_libs_repack", ], cmd: "$(location shared_libs_repack) " + - " --mode sharedlibs" + - " --key $(location com.android.apex.test.sharedlibs.pem)" + - " --input $(location :com.android.apex.test.sharedlibs_stub)" + - " --output $(genDir)/com.android.apex.test.sharedlibs_generated.apex" + - " --pk8key $(location com.android.apex.test.sharedlibs.pk8)" + - " --pubkey $(location com.android.apex.test.sharedlibs.avbpubkey)" + - " --x509key $(location com.android.apex.test.sharedlibs.x509.pem)" + - " --tmpdir $(genDir)", + " --mode sharedlibs" + + " --key $(location com.android.apex.test.sharedlibs.pem)" + + " --input $(location :com.android.apex.test.sharedlibs_stub)" + + " --output $(genDir)/com.android.apex.test.sharedlibs_generated.apex" + + " --pk8key $(location com.android.apex.test.sharedlibs.pk8)" + + " --pubkey $(location com.android.apex.test.sharedlibs.avbpubkey)" + + " --x509key $(location com.android.apex.test.sharedlibs.x509.pem)" + + " --tmpdir $(genDir)", } diff --git a/tests/testdata/sharedlibs/build/com.android.apex.test.sharedlibs_secondary/Android.bp b/tests/testdata/sharedlibs/build/com.android.apex.test.sharedlibs_secondary/Android.bp index 9e803e32..0098a334 100644 --- a/tests/testdata/sharedlibs/build/com.android.apex.test.sharedlibs_secondary/Android.bp +++ b/tests/testdata/sharedlibs/build/com.android.apex.test.sharedlibs_secondary/Android.bp @@ -33,7 +33,7 @@ apex { key: "com.android.apex.test.sharedlibs_secondary.key", installable: false, // We want to force libc++.so to be available in this stub APEX, so put an empty binary. - binaries: [ "noop" ], + binaries: ["noop"], updatable: false, } @@ -55,12 +55,12 @@ genrule { "shared_libs_repack", ], cmd: "$(location shared_libs_repack) " + - " --mode sharedlibs" + - " --key $(location com.android.apex.test.sharedlibs_secondary.pem)" + - " --input $(location :com.android.apex.test.sharedlibs_secondary_stub)" + - " --output $(genDir)/com.android.apex.test.sharedlibs_secondary_generated.apex" + - " --pk8key $(location com.android.apex.test.sharedlibs_secondary.pk8)" + - " --pubkey $(location com.android.apex.test.sharedlibs_secondary.avbpubkey)" + - " --x509key $(location com.android.apex.test.sharedlibs_secondary.x509.pem)" + - " --tmpdir $(genDir)", + " --mode sharedlibs" + + " --key $(location com.android.apex.test.sharedlibs_secondary.pem)" + + " --input $(location :com.android.apex.test.sharedlibs_secondary_stub)" + + " --output $(genDir)/com.android.apex.test.sharedlibs_secondary_generated.apex" + + " --pk8key $(location com.android.apex.test.sharedlibs_secondary.pk8)" + + " --pubkey $(location com.android.apex.test.sharedlibs_secondary.avbpubkey)" + + " --x509key $(location com.android.apex.test.sharedlibs_secondary.x509.pem)" + + " --tmpdir $(genDir)", } diff --git a/tests/testdata/sharedlibs/prebuilts/Android.bp b/tests/testdata/sharedlibs/prebuilts/Android.bp index 1ef2977e..55fc9523 100644 --- a/tests/testdata/sharedlibs/prebuilts/Android.bp +++ b/tests/testdata/sharedlibs/prebuilts/Android.bp @@ -21,281 +21,281 @@ package { } prebuilt_apex { - name: "com.android.apex.test.bar_stripped.v1.libvX_prebuilt", - arch: { - arm: { - src: "arm/com.android.apex.test.bar_stripped.v1.libvX.apex", - }, - arm64: { - src: "arm64/com.android.apex.test.bar_stripped.v1.libvX.apex", - }, - x86: { - src: "x86/com.android.apex.test.bar_stripped.v1.libvX.apex", - }, - x86_64: { - src: "x86_64/com.android.apex.test.bar_stripped.v1.libvX.apex", - }, - }, - filename: "com.android.apex.test.bar_stripped.v1.libvX.apex", - installable: false, + name: "com.android.apex.test.bar_stripped.v1.libvX_prebuilt", + arch: { + arm: { + src: "arm/com.android.apex.test.bar_stripped.v1.libvX.apex", + }, + arm64: { + src: "arm64/com.android.apex.test.bar_stripped.v1.libvX.apex", + }, + x86: { + src: "x86/com.android.apex.test.bar_stripped.v1.libvX.apex", + }, + x86_64: { + src: "x86_64/com.android.apex.test.bar_stripped.v1.libvX.apex", + }, + }, + filename: "com.android.apex.test.bar_stripped.v1.libvX.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.test.bar_stripped.v2.libvY_prebuilt", - arch: { - arm: { - src: "arm/com.android.apex.test.bar_stripped.v2.libvY.apex", - }, - arm64: { - src: "arm64/com.android.apex.test.bar_stripped.v2.libvY.apex", - }, - x86: { - src: "x86/com.android.apex.test.bar_stripped.v2.libvY.apex", - }, - x86_64: { - src: "x86_64/com.android.apex.test.bar_stripped.v2.libvY.apex", - }, - }, - filename: "com.android.apex.test.bar_stripped.v2.libvY.apex", - installable: false, + name: "com.android.apex.test.bar_stripped.v2.libvY_prebuilt", + arch: { + arm: { + src: "arm/com.android.apex.test.bar_stripped.v2.libvY.apex", + }, + arm64: { + src: "arm64/com.android.apex.test.bar_stripped.v2.libvY.apex", + }, + x86: { + src: "x86/com.android.apex.test.bar_stripped.v2.libvY.apex", + }, + x86_64: { + src: "x86_64/com.android.apex.test.bar_stripped.v2.libvY.apex", + }, + }, + filename: "com.android.apex.test.bar_stripped.v2.libvY.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.test.bar.v1.libvX_prebuilt", - arch: { - arm: { - src: "arm/com.android.apex.test.bar.v1.libvX.apex", - }, - arm64: { - src: "arm64/com.android.apex.test.bar.v1.libvX.apex", - }, - x86: { - src: "x86/com.android.apex.test.bar.v1.libvX.apex", - }, - x86_64: { - src: "x86_64/com.android.apex.test.bar.v1.libvX.apex", - }, - }, - filename: "com.android.apex.test.bar.v1.libvX.apex", - installable: false, + name: "com.android.apex.test.bar.v1.libvX_prebuilt", + arch: { + arm: { + src: "arm/com.android.apex.test.bar.v1.libvX.apex", + }, + arm64: { + src: "arm64/com.android.apex.test.bar.v1.libvX.apex", + }, + x86: { + src: "x86/com.android.apex.test.bar.v1.libvX.apex", + }, + x86_64: { + src: "x86_64/com.android.apex.test.bar.v1.libvX.apex", + }, + }, + filename: "com.android.apex.test.bar.v1.libvX.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.test.bar.v2.libvY_prebuilt", - arch: { - arm: { - src: "arm/com.android.apex.test.bar.v2.libvY.apex", - }, - arm64: { - src: "arm64/com.android.apex.test.bar.v2.libvY.apex", - }, - x86: { - src: "x86/com.android.apex.test.bar.v2.libvY.apex", - }, - x86_64: { - src: "x86_64/com.android.apex.test.bar.v2.libvY.apex", - }, - }, - filename: "com.android.apex.test.bar.v2.libvY.apex", - installable: false, + name: "com.android.apex.test.bar.v2.libvY_prebuilt", + arch: { + arm: { + src: "arm/com.android.apex.test.bar.v2.libvY.apex", + }, + arm64: { + src: "arm64/com.android.apex.test.bar.v2.libvY.apex", + }, + x86: { + src: "x86/com.android.apex.test.bar.v2.libvY.apex", + }, + x86_64: { + src: "x86_64/com.android.apex.test.bar.v2.libvY.apex", + }, + }, + filename: "com.android.apex.test.bar.v2.libvY.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.test.baz_stripped.v1.libvX_prebuilt", - arch: { - arm: { - src: "arm/com.android.apex.test.baz_stripped.v1.libvX.apex", - }, - arm64: { - src: "arm64/com.android.apex.test.baz_stripped.v1.libvX.apex", - }, - x86: { - src: "x86/com.android.apex.test.baz_stripped.v1.libvX.apex", - }, - x86_64: { - src: "x86_64/com.android.apex.test.baz_stripped.v1.libvX.apex", - }, - }, - filename: "com.android.apex.test.baz_stripped.v1.libvX.apex", - installable: false, + name: "com.android.apex.test.baz_stripped.v1.libvX_prebuilt", + arch: { + arm: { + src: "arm/com.android.apex.test.baz_stripped.v1.libvX.apex", + }, + arm64: { + src: "arm64/com.android.apex.test.baz_stripped.v1.libvX.apex", + }, + x86: { + src: "x86/com.android.apex.test.baz_stripped.v1.libvX.apex", + }, + x86_64: { + src: "x86_64/com.android.apex.test.baz_stripped.v1.libvX.apex", + }, + }, + filename: "com.android.apex.test.baz_stripped.v1.libvX.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.test.foo_stripped.v1.libvX_prebuilt", - arch: { - arm: { - src: "arm/com.android.apex.test.foo_stripped.v1.libvX.apex", - }, - arm64: { - src: "arm64/com.android.apex.test.foo_stripped.v1.libvX.apex", - }, - x86: { - src: "x86/com.android.apex.test.foo_stripped.v1.libvX.apex", - }, - x86_64: { - src: "x86_64/com.android.apex.test.foo_stripped.v1.libvX.apex", - }, - }, - filename: "com.android.apex.test.foo_stripped.v1.libvX.apex", - installable: false, + name: "com.android.apex.test.foo_stripped.v1.libvX_prebuilt", + arch: { + arm: { + src: "arm/com.android.apex.test.foo_stripped.v1.libvX.apex", + }, + arm64: { + src: "arm64/com.android.apex.test.foo_stripped.v1.libvX.apex", + }, + x86: { + src: "x86/com.android.apex.test.foo_stripped.v1.libvX.apex", + }, + x86_64: { + src: "x86_64/com.android.apex.test.foo_stripped.v1.libvX.apex", + }, + }, + filename: "com.android.apex.test.foo_stripped.v1.libvX.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.test.foo_stripped.v2.libvY_prebuilt", - arch: { - arm: { - src: "arm/com.android.apex.test.foo_stripped.v2.libvY.apex", - }, - arm64: { - src: "arm64/com.android.apex.test.foo_stripped.v2.libvY.apex", - }, - x86: { - src: "x86/com.android.apex.test.foo_stripped.v2.libvY.apex", - }, - x86_64: { - src: "x86_64/com.android.apex.test.foo_stripped.v2.libvY.apex", - }, - }, - filename: "com.android.apex.test.foo_stripped.v2.libvY.apex", - installable: false, + name: "com.android.apex.test.foo_stripped.v2.libvY_prebuilt", + arch: { + arm: { + src: "arm/com.android.apex.test.foo_stripped.v2.libvY.apex", + }, + arm64: { + src: "arm64/com.android.apex.test.foo_stripped.v2.libvY.apex", + }, + x86: { + src: "x86/com.android.apex.test.foo_stripped.v2.libvY.apex", + }, + x86_64: { + src: "x86_64/com.android.apex.test.foo_stripped.v2.libvY.apex", + }, + }, + filename: "com.android.apex.test.foo_stripped.v2.libvY.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.test.foo.v1.libvX_prebuilt", - arch: { - arm: { - src: "arm/com.android.apex.test.foo.v1.libvX.apex", - }, - arm64: { - src: "arm64/com.android.apex.test.foo.v1.libvX.apex", - }, - x86: { - src: "x86/com.android.apex.test.foo.v1.libvX.apex", - }, - x86_64: { - src: "x86_64/com.android.apex.test.foo.v1.libvX.apex", - }, - }, - filename: "com.android.apex.test.foo.v1.libvX.apex", - installable: false, + name: "com.android.apex.test.foo.v1.libvX_prebuilt", + arch: { + arm: { + src: "arm/com.android.apex.test.foo.v1.libvX.apex", + }, + arm64: { + src: "arm64/com.android.apex.test.foo.v1.libvX.apex", + }, + x86: { + src: "x86/com.android.apex.test.foo.v1.libvX.apex", + }, + x86_64: { + src: "x86_64/com.android.apex.test.foo.v1.libvX.apex", + }, + }, + filename: "com.android.apex.test.foo.v1.libvX.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.test.foo.v2.libvY_prebuilt", - arch: { - arm: { - src: "arm/com.android.apex.test.foo.v2.libvY.apex", - }, - arm64: { - src: "arm64/com.android.apex.test.foo.v2.libvY.apex", - }, - x86: { - src: "x86/com.android.apex.test.foo.v2.libvY.apex", - }, - x86_64: { - src: "x86_64/com.android.apex.test.foo.v2.libvY.apex", - }, - }, - filename: "com.android.apex.test.foo.v2.libvY.apex", - installable: false, + name: "com.android.apex.test.foo.v2.libvY_prebuilt", + arch: { + arm: { + src: "arm/com.android.apex.test.foo.v2.libvY.apex", + }, + arm64: { + src: "arm64/com.android.apex.test.foo.v2.libvY.apex", + }, + x86: { + src: "x86/com.android.apex.test.foo.v2.libvY.apex", + }, + x86_64: { + src: "x86_64/com.android.apex.test.foo.v2.libvY.apex", + }, + }, + filename: "com.android.apex.test.foo.v2.libvY.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.test.pony_stripped.v1.libvZ_prebuilt", - arch: { - arm: { - src: "arm/com.android.apex.test.pony_stripped.v1.libvZ.apex", - }, - arm64: { - src: "arm64/com.android.apex.test.pony_stripped.v1.libvZ.apex", - }, - x86: { - src: "x86/com.android.apex.test.pony_stripped.v1.libvZ.apex", - }, - x86_64: { - src: "x86_64/com.android.apex.test.pony_stripped.v1.libvZ.apex", - }, - }, - filename: "com.android.apex.test.pony_stripped.v1.libvZ.apex", - installable: false, + name: "com.android.apex.test.pony_stripped.v1.libvZ_prebuilt", + arch: { + arm: { + src: "arm/com.android.apex.test.pony_stripped.v1.libvZ.apex", + }, + arm64: { + src: "arm64/com.android.apex.test.pony_stripped.v1.libvZ.apex", + }, + x86: { + src: "x86/com.android.apex.test.pony_stripped.v1.libvZ.apex", + }, + x86_64: { + src: "x86_64/com.android.apex.test.pony_stripped.v1.libvZ.apex", + }, + }, + filename: "com.android.apex.test.pony_stripped.v1.libvZ.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.test.pony.v1.libvZ_prebuilt", - arch: { - arm: { - src: "arm/com.android.apex.test.pony.v1.libvZ.apex", - }, - arm64: { - src: "arm64/com.android.apex.test.pony.v1.libvZ.apex", - }, - x86: { - src: "x86/com.android.apex.test.pony.v1.libvZ.apex", - }, - x86_64: { - src: "x86_64/com.android.apex.test.pony.v1.libvZ.apex", - }, - }, - filename: "com.android.apex.test.pony.v1.libvZ.apex", - installable: false, + name: "com.android.apex.test.pony.v1.libvZ_prebuilt", + arch: { + arm: { + src: "arm/com.android.apex.test.pony.v1.libvZ.apex", + }, + arm64: { + src: "arm64/com.android.apex.test.pony.v1.libvZ.apex", + }, + x86: { + src: "x86/com.android.apex.test.pony.v1.libvZ.apex", + }, + x86_64: { + src: "x86_64/com.android.apex.test.pony.v1.libvZ.apex", + }, + }, + filename: "com.android.apex.test.pony.v1.libvZ.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.test.sharedlibs_generated.v1.libvX_prebuilt", - arch: { - arm: { - src: "arm/com.android.apex.test.sharedlibs_generated.v1.libvX.apex", - }, - arm64: { - src: "arm64/com.android.apex.test.sharedlibs_generated.v1.libvX.apex", - }, - x86: { - src: "x86/com.android.apex.test.sharedlibs_generated.v1.libvX.apex", - }, - x86_64: { - src: "x86_64/com.android.apex.test.sharedlibs_generated.v1.libvX.apex", - }, - }, - filename: "com.android.apex.test.sharedlibs_generated.v1.libvX.apex", - installable: false, + name: "com.android.apex.test.sharedlibs_generated.v1.libvX_prebuilt", + arch: { + arm: { + src: "arm/com.android.apex.test.sharedlibs_generated.v1.libvX.apex", + }, + arm64: { + src: "arm64/com.android.apex.test.sharedlibs_generated.v1.libvX.apex", + }, + x86: { + src: "x86/com.android.apex.test.sharedlibs_generated.v1.libvX.apex", + }, + x86_64: { + src: "x86_64/com.android.apex.test.sharedlibs_generated.v1.libvX.apex", + }, + }, + filename: "com.android.apex.test.sharedlibs_generated.v1.libvX.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.test.sharedlibs_generated.v2.libvY_prebuilt", - arch: { - arm: { - src: "arm/com.android.apex.test.sharedlibs_generated.v2.libvY.apex", - }, - arm64: { - src: "arm64/com.android.apex.test.sharedlibs_generated.v2.libvY.apex", - }, - x86: { - src: "x86/com.android.apex.test.sharedlibs_generated.v2.libvY.apex", - }, - x86_64: { - src: "x86_64/com.android.apex.test.sharedlibs_generated.v2.libvY.apex", - }, - }, - filename: "com.android.apex.test.sharedlibs_generated.v2.libvY.apex", - installable: false, + name: "com.android.apex.test.sharedlibs_generated.v2.libvY_prebuilt", + arch: { + arm: { + src: "arm/com.android.apex.test.sharedlibs_generated.v2.libvY.apex", + }, + arm64: { + src: "arm64/com.android.apex.test.sharedlibs_generated.v2.libvY.apex", + }, + x86: { + src: "x86/com.android.apex.test.sharedlibs_generated.v2.libvY.apex", + }, + x86_64: { + src: "x86_64/com.android.apex.test.sharedlibs_generated.v2.libvY.apex", + }, + }, + filename: "com.android.apex.test.sharedlibs_generated.v2.libvY.apex", + installable: false, } prebuilt_apex { - name: "com.android.apex.test.sharedlibs_secondary_generated.v1.libvZ_prebuilt", - arch: { - arm: { - src: "arm/com.android.apex.test.sharedlibs_secondary_generated.v1.libvZ.apex", - }, - arm64: { - src: "arm64/com.android.apex.test.sharedlibs_secondary_generated.v1.libvZ.apex", - }, - x86: { - src: "x86/com.android.apex.test.sharedlibs_secondary_generated.v1.libvZ.apex", - }, - x86_64: { - src: "x86_64/com.android.apex.test.sharedlibs_secondary_generated.v1.libvZ.apex", - }, - }, - filename: "com.android.apex.test.sharedlibs_secondary_generated.v1.libvZ.apex", - installable: false, + name: "com.android.apex.test.sharedlibs_secondary_generated.v1.libvZ_prebuilt", + arch: { + arm: { + src: "arm/com.android.apex.test.sharedlibs_secondary_generated.v1.libvZ.apex", + }, + arm64: { + src: "arm64/com.android.apex.test.sharedlibs_secondary_generated.v1.libvZ.apex", + }, + x86: { + src: "x86/com.android.apex.test.sharedlibs_secondary_generated.v1.libvZ.apex", + }, + x86_64: { + src: "x86_64/com.android.apex.test.sharedlibs_secondary_generated.v1.libvZ.apex", + }, + }, + filename: "com.android.apex.test.sharedlibs_secondary_generated.v1.libvZ.apex", + installable: false, } diff --git a/tools/Android.bp b/tools/Android.bp index 8dd38533..a7ff261d 100644 --- a/tools/Android.bp +++ b/tools/Android.bp @@ -74,6 +74,7 @@ python_binary_host { python_test_host { name: "apex_compression_test", + pkg_path: "apex_compression_test", main: "apex_compression_test.py", srcs: [ "apex_compression_test.py", @@ -93,6 +94,11 @@ python_test_host { test_options: { unit_test: true, }, + version: { + py3: { + embedded_launcher: true, + }, + }, } cc_binary_host { @@ -141,7 +147,7 @@ sh_test_host { python_library_host { name: "apexer_wrapper_utils", - srcs: ["apexer_wrapper_utils.py"] + srcs: ["apexer_wrapper_utils.py"], } python_binary_host { @@ -165,6 +171,9 @@ python_test_host { srcs: [ "apexer_with_DCLA_preprocessing_test.py", ], + // Need to add a pkg_path because importlib.resources + // cannot load resources from the root package. + pkg_path: "apexer_with_DCLA_preprocessing_test", data: [ ":apexer_test_host_tools", ":apexer_with_DCLA_preprocessing", @@ -175,6 +184,11 @@ python_test_host { test_options: { unit_test: true, }, + version: { + py3: { + embedded_launcher: true, + }, + }, } python_binary_host { diff --git a/tools/apex_compression_test.py b/tools/apex_compression_test.py index 2a30007a..042a2781 100644 --- a/tools/apex_compression_test.py +++ b/tools/apex_compression_test.py @@ -19,9 +19,11 @@ import hashlib import logging import os import shutil +import stat import subprocess import tempfile import unittest +from importlib import resources from zipfile import ZipFile, ZIP_STORED, ZIP_DEFLATED import apex_manifest_pb2 @@ -70,15 +72,6 @@ def run(args, verbose=None, **kwargs): return subprocess.Popen(args, **kwargs) -def run_host_command(args, verbose=None, **kwargs): - host_build_top = os.environ.get('ANDROID_BUILD_TOP') - if host_build_top: - host_command_dir = os.path.join(host_build_top, - 'out/host/linux-x86/bin') - args[0] = os.path.join(host_command_dir, args[0]) - return run_and_check_output(args, verbose, **kwargs) - - def run_and_check_output(args, verbose=None, **kwargs): """Runs the given command and returns the output. @@ -135,6 +128,7 @@ def get_sha1sum(file_path): class ApexCompressionTest(unittest.TestCase): def setUp(self): self._to_cleanup = [] + self._get_host_tools() def tearDown(self): if not DEBUG_TEST: @@ -147,18 +141,33 @@ class ApexCompressionTest(unittest.TestCase): else: print('Cleanup: ' + str(self._to_cleanup)) - def _run_apex_compression_tool(self, args): - cmd = ['apex_compression_tool'] - host_build_top = os.environ.get('ANDROID_BUILD_TOP') - if host_build_top: - os.environ['APEX_COMPRESSION_TOOL_PATH'] = ( - os.path.join(host_build_top, 'out/host/linux-x86/bin') - + ':' + os.path.join(host_build_top, 'prebuilts/sdk/tools/linux/bin')) - else: - os.environ['APEX_COMPRESSION_TOOL_PATH'] = os.path.dirname( - shutil.which('apex_compression_tool')) - cmd.extend(args) - run_host_command(cmd, True) + def _get_host_tools(self): + dir_name = tempfile.mkdtemp(prefix=self._testMethodName+"_host_tools_") + self._to_cleanup.append(dir_name) + for tool in ["avbtool", "conv_apex_manifest", "apex_compression_tool", "deapexer", "soong_zip"]: + with ( + resources.files("apex_compression_test").joinpath(tool).open('rb') as tool_resource, + open(os.path.join(dir_name, tool), 'wb') as f + ): + shutil.copyfileobj(tool_resource, f) + os.chmod(os.path.join(dir_name, tool), stat.S_IRUSR | stat.S_IXUSR) + os.environ['APEX_COMPRESSION_TOOL_PATH'] = dir_name + path = dir_name + if "PATH" in os.environ: + path += ":" + os.environ["PATH"] + os.environ["PATH"] = path + + def _get_test_apex(self): + tmpdir = tempfile.mkdtemp() + self._to_cleanup.append(tmpdir) + apexPath = os.path.join(tmpdir, TEST_APEX + '.apex') + with ( + resources.files('apex_compression_test').joinpath(TEST_APEX + '.apex').open('rb') as f, + open(apexPath, 'wb') as f2, + ): + shutil.copyfileobj(f, f2) + + return apexPath def _get_container_files(self, apex_file_path): dir_name = tempfile.mkdtemp( @@ -183,7 +192,7 @@ class ApexCompressionTest(unittest.TestCase): avbtool_cmd = ['avbtool', 'print_partition_digests', '--image', files['apex_payload']] # avbtool_cmd output has format "<name>: <value>" - files['digest'] = run_host_command( + files['digest'] = run_and_check_output( avbtool_cmd, True).split(': ')[1].strip() return files @@ -194,7 +203,7 @@ class ApexCompressionTest(unittest.TestCase): 'print', manifest_path ]) - return run_host_command(cmd, 'True') + return run_and_check_output(cmd, 'True') # Mutates the manifest located at |manifest_path| def _unset_original_apex_digest(self, manifest_path): @@ -213,7 +222,8 @@ class ApexCompressionTest(unittest.TestCase): suffix='.capex') os.close(fd) self._to_cleanup.append(compressed_apex_fp) - self._run_apex_compression_tool([ + run_and_check_output([ + 'apex_compression_tool', 'compress', '--input', uncompressed_apex_fp, '--output', compressed_apex_fp @@ -232,7 +242,7 @@ class ApexCompressionTest(unittest.TestCase): '--input', compressed_apex_fp, '--output', decompressed_apex_fp ]) - run_host_command(cmd, True) + run_and_check_output(cmd, True) self.assertTrue(os.path.exists(decompressed_apex_fp), 'Decompressed APEX does not exist') @@ -241,10 +251,10 @@ class ApexCompressionTest(unittest.TestCase): def _get_type(self, apex_file_path): cmd = ['deapexer', 'info', '--print-type', apex_file_path] - return run_host_command(cmd, True).strip() + return run_and_check_output(cmd, True).strip() def test_compression(self): - uncompressed_apex_fp = os.path.join(get_current_dir(), TEST_APEX + '.apex') + uncompressed_apex_fp = self._get_test_apex() # TODO(samiul): try compressing a compressed APEX compressed_apex_fp = self._compress_apex(uncompressed_apex_fp) @@ -284,7 +294,7 @@ class ApexCompressionTest(unittest.TestCase): def test_decompression(self): # setup: create compressed APEX - uncompressed_apex_fp = os.path.join(get_current_dir(), TEST_APEX + '.apex') + uncompressed_apex_fp = self._get_test_apex() compressed_apex_fp = self._compress_apex(uncompressed_apex_fp) # Decompress it @@ -306,7 +316,7 @@ class ApexCompressionTest(unittest.TestCase): + ' is not a compressed APEX', str(error.exception)) def test_only_original_apex_is_compressed(self): - uncompressed_apex_fp = os.path.join(get_current_dir(), TEST_APEX + '.apex') + uncompressed_apex_fp = self._get_test_apex() compressed_apex_fp = self._compress_apex(uncompressed_apex_fp) with ZipFile(compressed_apex_fp, 'r') as zip_obj: diff --git a/tools/apexer_with_DCLA_preprocessing_test.py b/tools/apexer_with_DCLA_preprocessing_test.py index a9e3b655..1396cf52 100644 --- a/tools/apexer_with_DCLA_preprocessing_test.py +++ b/tools/apexer_with_DCLA_preprocessing_test.py @@ -16,13 +16,13 @@ """Unit tests for apexer_with_DCLA_preprocessing.""" import hashlib -import logging +import importlib.resources import os import shutil import stat import subprocess import tempfile -from typing import List +from typing import List, BinaryIO import unittest import zipfile @@ -39,11 +39,8 @@ TEST_APEX = 'com.android.example.apex' # test. DEBUG_TEST = False -def get_current_dir(): - """returns the current dir, relative to the script dir.""" - # The script dir is the one we want, which could be different from pwd. - current_dir = os.path.dirname(os.path.realpath(__file__)) - return current_dir +def resources(): + return importlib.resources.files('apexer_with_DCLA_preprocessing_test') # TODO: consolidate these common test utilities into a common python_library_host # to be shared across tests under system/apex @@ -53,44 +50,17 @@ def run_command(cmd: List[str]) -> None: if DEBUG_TEST: cmd_str = ' '.join(cmd) print(f'\nRunning: \n{cmd_str}\n') - res = subprocess.run( + subprocess.run( cmd, check=True, + text=True, stdout=subprocess.PIPE, - universal_newlines=True, stderr=subprocess.PIPE) except subprocess.CalledProcessError as err: print(err.stderr) print(err.output) raise err -def get_apexer_with_DCLA_preprocessing() -> str: - tool_binary = os.path.join(get_current_dir(), 'apexer_with_DCLA_preprocessing') - if not os.path.isfile(tool_binary): - raise FileNotFoundError(f'cannot find tooling apexer with DCLA preprocessing') - else: - os.chmod(tool_binary, stat.S_IRUSR | stat.S_IXUSR); - return tool_binary - -def get_host_tool(tool_name: str) -> str: - """get host tools.""" - tool_binary = os.path.join(get_current_dir(), 'bin', tool_name) - if not os.path.isfile(tool_binary): - host_build_top = os.environ.get('ANDROID_BUILD_TOP') - if host_build_top: - host_command_dir = os.path.join(host_build_top, 'out/host/linux-x86/bin') - tool_binary = os.path.join(host_command_dir, tool_name) - if not os.path.isfile(tool_binary): - host_command_dir = os.path.join(host_build_top, 'prebuilts/sdk/current/public') - tool_binary = os.path.join(host_command_dir, tool_name) - else: - tool_binary = shutil.which(tool_name) - - if not tool_binary or not os.path.isfile(tool_binary): - raise FileNotFoundError(f'cannot find tooling {tool_name}') - else: - return tool_binary - def get_digest(file_path: str) -> str: """Get sha512 digest of a file """ digester = hashlib.sha512() @@ -103,8 +73,7 @@ class ApexerWithDCLAPreprocessingTest(unittest.TestCase): def setUp(self): self._to_cleanup = [] - tools_zip_file = os.path.join(get_current_dir(), 'apexer_test_host_tools.zip') - self.unzip_host_tools(tools_zip_file) + self.unzip_host_tools() def tearDown(self): if not DEBUG_TEST: @@ -122,7 +91,7 @@ class ApexerWithDCLAPreprocessingTest(unittest.TestCase): self._to_cleanup.append(tmp_dir) return tmp_dir - def expand_apex(self, apex_file: str) -> None: + def expand_apex(self, apex_file: str | BinaryIO) -> None: """expand an apex file include apex_payload.""" apex_dir = self.create_temp_dir() with zipfile.ZipFile(apex_file, 'r') as apex_zip: @@ -130,8 +99,7 @@ class ApexerWithDCLAPreprocessingTest(unittest.TestCase): payload_img = os.path.join(apex_dir, 'apex_payload.img') extract_dir = os.path.join(apex_dir, 'payload_extract') os.mkdir(extract_dir) - debugfs = get_host_tool('debugfs_static') - run_command([debugfs, payload_img, '-R', f'rdump / {extract_dir}']) + run_command([self.debugfs_static, payload_img, '-R', f'rdump / {extract_dir}']) # remove /etc and /lost+found and /payload_extract/apex_manifest.pb lost_and_found = os.path.join(extract_dir, 'lost+found') @@ -144,23 +112,42 @@ class ApexerWithDCLAPreprocessingTest(unittest.TestCase): return apex_dir - def unzip_host_tools(self, host_tools_file_path: str) -> None: - dir_name = get_current_dir() - if os.path.isfile(host_tools_file_path): - with zipfile.ZipFile(host_tools_file_path, 'r') as zip_obj: - zip_obj.extractall(dir_name) - - for i in ["apexer", "deapexer", "avbtool", "mke2fs", "sefcontext_compile", "e2fsdroid", - "resize2fs", "soong_zip", "aapt2", "merge_zips", "zipalign", "debugfs_static", - "signapk.jar", "android.jar"]: - file_path = os.path.join(dir_name, "bin", i) + def unzip_host_tools(self) -> None: + host_tools_dir = self.create_temp_dir() + with ( + resources().joinpath('apexer_test_host_tools.zip').open(mode='rb') as host_tools_zip_resource, + resources().joinpath(TEST_PRIVATE_KEY).open(mode='rb') as key_file_resource, + resources().joinpath('apexer_with_DCLA_preprocessing').open(mode='rb') as apexer_wrapper_resource, + ): + with zipfile.ZipFile(host_tools_zip_resource, 'r') as zip_obj: + zip_obj.extractall(host_tools_dir) + apexer_wrapper = os.path.join(host_tools_dir, 'apexer_with_DCLA_preprocessing') + with open(apexer_wrapper, 'wb') as f: + shutil.copyfileobj(apexer_wrapper_resource, f) + key_file = os.path.join(host_tools_dir, 'key.pem') + with open(key_file, 'wb') as f: + shutil.copyfileobj(key_file_resource, f) + + + self.apexer_tool_path = os.path.join(host_tools_dir, 'bin') + self.apexer_wrapper = apexer_wrapper + self.key_file = key_file + self.debugfs_static = os.path.join(host_tools_dir, 'bin/debugfs_static') + self.android_jar = os.path.join(host_tools_dir, 'bin/android.jar') + self.apexer = os.path.join(host_tools_dir, 'bin/apexer') + os.chmod(apexer_wrapper, stat.S_IRUSR | stat.S_IXUSR); + for i in ['apexer', 'deapexer', 'avbtool', 'mke2fs', 'sefcontext_compile', 'e2fsdroid', + 'resize2fs', 'soong_zip', 'aapt2', 'merge_zips', 'zipalign', 'debugfs_static', + 'signapk.jar', 'android.jar']: + file_path = os.path.join(host_tools_dir, 'bin', i) if os.path.exists(file_path): os.chmod(file_path, stat.S_IRUSR | stat.S_IXUSR); + def test_DCLA_preprocessing(self): """test DCLA preprocessing done properly.""" - apex_file = os.path.join(get_current_dir(), TEST_APEX + '.apex') - apex_dir = self.expand_apex(apex_file) + with resources().joinpath(TEST_APEX + '.apex').open(mode='rb') as apex_file: + apex_dir = self.expand_apex(apex_file) # create apex canned_fs_config file, TEST_APEX does not come with one canned_fs_config_file = os.path.join(apex_dir, 'canned_fs_config') @@ -174,8 +161,8 @@ class ApexerWithDCLAPreprocessingTest(unittest.TestCase): foo_digest = get_digest(foo_file) # add /lib dir and /lib/foo.so in canned_fs_config - f.write(f'/lib 0 2000 0755\n') - f.write(f'/lib/foo.so 1000 1000 0644\n') + f.write('/lib 0 2000 0755\n') + f.write('/lib/foo.so 1000 1000 0644\n') # add /lib/bar.so file lib_dir = os.path.join(apex_dir, 'payload_extract', 'lib64') @@ -186,29 +173,25 @@ class ApexerWithDCLAPreprocessingTest(unittest.TestCase): bar_digest = get_digest(bar_file) # add /lib dir and /lib/foo.so in canned_fs_config - f.write(f'/lib64 0 2000 0755\n') - f.write(f'/lib64/bar.so 1000 1000 0644\n') + f.write('/lib64 0 2000 0755\n') + f.write('/lib64/bar.so 1000 1000 0644\n') - f.write(f'/ 0 2000 0755\n') - f.write(f'/apex_manifest.pb 1000 1000 0644\n') + f.write('/ 0 2000 0755\n') + f.write('/apex_manifest.pb 1000 1000 0644\n') # call apexer_with_DCLA_preprocessing manifest_file = os.path.join(apex_dir, 'apex_manifest.pb') build_info_file = os.path.join(apex_dir, 'apex_build_info.pb') - key_file = os.path.join(get_current_dir(), TEST_PRIVATE_KEY) - apexer= get_host_tool('apexer') - apexer_wrapper = get_apexer_with_DCLA_preprocessing() - android_jar = get_host_tool('android.jar') apex_out = os.path.join(apex_dir, 'DCLA_preprocessed_output.apex') - run_command([apexer_wrapper, - '--apexer', apexer, + run_command([self.apexer_wrapper, + '--apexer', self.apexer, '--canned_fs_config', canned_fs_config_file, os.path.join(apex_dir, 'payload_extract'), apex_out, '--', - '--android_jar_path', android_jar, - '--apexer_tool_path', os.path.dirname(apexer), - '--key', key_file, + '--android_jar_path', self.android_jar, + '--apexer_tool_path', self.apexer_tool_path, + '--key', self.key_file, '--manifest', manifest_file, '--build_info', build_info_file, '--payload_fs_type', 'ext4', |