From 068329e97771588489eb9626c24cc61f23cb8888 Mon Sep 17 00:00:00 2001 From: Jacky Liu Date: Tue, 21 Dec 2021 00:32:50 +0800 Subject: [PATCH] Move package verifier from libinstall to libotautil So it can be used by device-specific codes. Bug: 184693830 Test: m; atest recovery_unit_test Change-Id: I5885334c1bd04214c9cc295f2337306261a1735c --- install/Android.bp | 3 --- install/include/install/install.h | 2 +- install/include/install/wipe_device.h | 2 +- install/install.cpp | 4 ++-- install/wipe_device.cpp | 2 +- otautil/Android.bp | 5 +++++ {install => otautil}/asn1_decoder.cpp | 0 .../include/install => otautil/include/otautil}/package.h | 2 +- .../include/install => otautil/include/otautil}/verifier.h | 0 {install => otautil}/include/private/asn1_decoder.h | 0 {install => otautil}/package.cpp | 2 +- {install => otautil}/verifier.cpp | 2 +- recovery.cpp | 2 +- tests/fuzz/verify_package_fuzzer.cpp | 2 +- tests/unit/package_test.cpp | 2 +- tests/unit/verifier_test.cpp | 4 ++-- 16 files changed, 18 insertions(+), 16 deletions(-) rename {install => otautil}/asn1_decoder.cpp (100%) rename {install/include/install => otautil/include/otautil}/package.h (98%) rename {install/include/install => otautil/include/otautil}/verifier.h (100%) rename {install => otautil}/include/private/asn1_decoder.h (100%) rename {install => otautil}/package.cpp (99%) rename {install => otautil}/verifier.cpp (99%) diff --git a/install/Android.bp b/install/Android.bp index e239ddc4..c5917145 100644 --- a/install/Android.bp +++ b/install/Android.bp @@ -105,12 +105,9 @@ cc_library_static { srcs: [ "adb_install.cpp", - "asn1_decoder.cpp", "fuse_install.cpp", "install.cpp", - "package.cpp", "snapshot_utils.cpp", - "verifier.cpp", "wipe_data.cpp", "wipe_device.cpp", "spl_check.cpp", diff --git a/install/include/install/install.h b/install/include/install/install.h index bef23e9c..704841f8 100644 --- a/install/include/install/install.h +++ b/install/include/install/install.h @@ -24,7 +24,7 @@ #include -#include "package.h" +#include "otautil/package.h" #include "recovery_ui/ui.h" enum InstallResult { diff --git a/install/include/install/wipe_device.h b/install/include/install/wipe_device.h index c60b9999..903ddfdc 100644 --- a/install/include/install/wipe_device.h +++ b/install/include/install/wipe_device.h @@ -19,7 +19,7 @@ #include #include -#include "install/package.h" +#include "otautil/package.h" #include "recovery_ui/device.h" // Wipes the current A/B device, with a secure wipe of all the partitions in RECOVERY_WIPE. diff --git a/install/install.cpp b/install/install.cpp index 6e74f80a..bb8c3b82 100644 --- a/install/install.cpp +++ b/install/install.cpp @@ -46,13 +46,13 @@ #include #include -#include "install/package.h" #include "install/spl_check.h" -#include "install/verifier.h" #include "install/wipe_data.h" #include "otautil/error_code.h" +#include "otautil/package.h" #include "otautil/paths.h" #include "otautil/sysutil.h" +#include "otautil/verifier.h" #include "private/setup_commands.h" #include "recovery_ui/ui.h" #include "recovery_utils/roots.h" diff --git a/install/wipe_device.cpp b/install/wipe_device.cpp index 915c87b4..0a525fa9 100644 --- a/install/wipe_device.cpp +++ b/install/wipe_device.cpp @@ -35,7 +35,7 @@ #include "bootloader_message/bootloader_message.h" #include "install/install.h" -#include "install/package.h" +#include "otautil/package.h" #include "recovery_ui/device.h" #include "recovery_ui/ui.h" diff --git a/otautil/Android.bp b/otautil/Android.bp index 557b8a31..4b043adf 100644 --- a/otautil/Android.bp +++ b/otautil/Android.bp @@ -34,16 +34,21 @@ cc_library_static { // Minimal set of files to support host build. srcs: [ + "asn1_decoder.cpp", "dirutil.cpp", + "package.cpp", "paths.cpp", "rangeset.cpp", "sysutil.cpp", + "verifier.cpp", ], shared_libs: [ "libbase", + "libcrypto", "libcutils", "libselinux", + "libziparchive", ], export_include_dirs: [ diff --git a/install/asn1_decoder.cpp b/otautil/asn1_decoder.cpp similarity index 100% rename from install/asn1_decoder.cpp rename to otautil/asn1_decoder.cpp diff --git a/install/include/install/package.h b/otautil/include/otautil/package.h similarity index 98% rename from install/include/install/package.h rename to otautil/include/otautil/package.h index 0b423323..f4f4d348 100644 --- a/install/include/install/package.h +++ b/otautil/include/otautil/package.h @@ -26,7 +26,7 @@ #include -#include "verifier.h" +#include "otautil/verifier.h" enum class PackageType { kMemory, diff --git a/install/include/install/verifier.h b/otautil/include/otautil/verifier.h similarity index 100% rename from install/include/install/verifier.h rename to otautil/include/otautil/verifier.h diff --git a/install/include/private/asn1_decoder.h b/otautil/include/private/asn1_decoder.h similarity index 100% rename from install/include/private/asn1_decoder.h rename to otautil/include/private/asn1_decoder.h diff --git a/install/package.cpp b/otautil/package.cpp similarity index 99% rename from install/package.cpp rename to otautil/package.cpp index 86fc0647..242204ee 100644 --- a/install/package.cpp +++ b/otautil/package.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "install/package.h" +#include "otautil/package.h" #include #include diff --git a/install/verifier.cpp b/otautil/verifier.cpp similarity index 99% rename from install/verifier.cpp rename to otautil/verifier.cpp index 3f026013..92b9faf2 100644 --- a/install/verifier.cpp +++ b/otautil/verifier.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "install/verifier.h" +#include "otautil/verifier.h" #include #include diff --git a/recovery.cpp b/recovery.cpp index 36924fbd..641fe478 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -48,12 +48,12 @@ #include "install/adb_install.h" #include "install/fuse_install.h" #include "install/install.h" -#include "install/package.h" #include "install/snapshot_utils.h" #include "install/wipe_data.h" #include "install/wipe_device.h" #include "otautil/boot_state.h" #include "otautil/error_code.h" +#include "otautil/package.h" #include "otautil/paths.h" #include "otautil/sysutil.h" #include "recovery_ui/screen_ui.h" diff --git a/tests/fuzz/verify_package_fuzzer.cpp b/tests/fuzz/verify_package_fuzzer.cpp index baa44e07..36c85346 100644 --- a/tests/fuzz/verify_package_fuzzer.cpp +++ b/tests/fuzz/verify_package_fuzzer.cpp @@ -17,7 +17,7 @@ #include "fuzzer/FuzzedDataProvider.h" #include "install/install.h" -#include "install/package.h" +#include "otautil/package.h" #include "recovery_ui/stub_ui.h" std::unique_ptr CreatePackage(std::vector& content) { diff --git a/tests/unit/package_test.cpp b/tests/unit/package_test.cpp index 164a93d5..66882bb4 100644 --- a/tests/unit/package_test.cpp +++ b/tests/unit/package_test.cpp @@ -26,7 +26,7 @@ #include #include "common/test_constants.h" -#include "install/package.h" +#include "otautil/package.h" class PackageTest : public ::testing::Test { protected: diff --git a/tests/unit/verifier_test.cpp b/tests/unit/verifier_test.cpp index ded23c52..08a3ddfc 100644 --- a/tests/unit/verifier_test.cpp +++ b/tests/unit/verifier_test.cpp @@ -35,8 +35,8 @@ #include #include "common/test_constants.h" -#include "install/package.h" -#include "install/verifier.h" +#include "otautil/package.h" +#include "otautil/verifier.h" #include "otautil/sysutil.h" using namespace std::string_literals;