From f07ed2efeb18121fd3f1c489053e84fd9f46c4c1 Mon Sep 17 00:00:00 2001 From: xunchang Date: Mon, 25 Feb 2019 14:14:01 -0800 Subject: Create a wrapper class for update package Creates a new class handle the package in memory and package read from fd. Define the new interface functions, and make approximate changes to the verify and install functions. Bug: 127071893 Test: unit tests pass, sideload a package Change-Id: I66ab00654df92471184536fd147b237a86e9c5b5 --- recovery.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'recovery.cpp') diff --git a/recovery.cpp b/recovery.cpp index 90c84878b..2c9f9de68 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -64,6 +64,7 @@ #include "otautil/error_code.h" #include "otautil/paths.h" #include "otautil/sysutil.h" +#include "package.h" #include "roots.h" #include "screen_ui.h" #include "ui.h" @@ -517,13 +518,15 @@ static std::string ReadWipePackage(size_t wipe_package_size) { // 1. verify the package. // 2. check metadata (ota-type, pre-device and serial number if having one). static bool CheckWipePackage(const std::string& wipe_package) { - if (!verify_package(reinterpret_cast(wipe_package.data()), - wipe_package.size())) { + auto package = Package::CreateMemoryPackage( + std::vector(wipe_package.begin(), wipe_package.end()), nullptr); + + if (!package || !verify_package(package.get())) { LOG(ERROR) << "Failed to verify package"; return false; } - // Extract metadata + // TODO(xunchang) get zip archive from package. ZipArchiveHandle zip; if (auto err = OpenArchiveFromMemory(const_cast(static_cast(&wipe_package[0])), -- cgit v1.2.3