Move install to separate module
Build libinstall as a shared library. Also drop the dependency on the
global variables in common.h.
Test: unit tests pass, sideload an OTA
Change-Id: I30a20047768ce00689fc0e7851c1c5d712a365a0
diff --git a/recovery.cpp b/recovery.cpp
index d9c1f22..421bc12 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -50,20 +50,20 @@
#include <healthhalutils/HealthHalUtils.h>
#include <ziparchive/zip_archive.h>
-#include "adb_install.h"
#include "common.h"
#include "fsck_unshare_blocks.h"
-#include "fuse_sdcard_install.h"
-#include "install.h"
+#include "install/adb_install.h"
+#include "install/fuse_sdcard_install.h"
+#include "install/install.h"
+#include "install/package.h"
#include "logging.h"
#include "otautil/dirutil.h"
#include "otautil/error_code.h"
#include "otautil/paths.h"
+#include "otautil/roots.h"
#include "otautil/sysutil.h"
-#include "package.h"
#include "recovery_ui/screen_ui.h"
#include "recovery_ui/ui.h"
-#include "roots.h"
static constexpr const char* CACHE_LOG_DIR = "/cache/recovery";
static constexpr const char* COMMAND_FILE = "/cache/recovery/command";
@@ -79,7 +79,7 @@
// into target_files.zip. Assert the version defined in code and in Android.mk are consistent.
static_assert(kRecoveryApiVersion == RECOVERY_API_VERSION, "Mismatching recovery API versions.");
-bool modified_flash = false;
+static bool modified_flash = false;
std::string stage;
const char* reason = nullptr;
@@ -439,7 +439,7 @@
// 1. verify the package.
// 2. check metadata (ota-type, pre-device and serial number if having one).
static bool CheckWipePackage(Package* wipe_package) {
- if (!verify_package(wipe_package)) {
+ if (!verify_package(wipe_package, ui)) {
LOG(ERROR) << "Failed to verify package";
return false;
}
@@ -693,7 +693,7 @@
modified_flash = true;
bool adb = (chosen_action == Device::APPLY_ADB_SIDELOAD);
if (adb) {
- status = apply_from_adb(&should_wipe_cache);
+ status = apply_from_adb(&should_wipe_cache, ui);
} else {
status = ApplyFromSdcard(device, &should_wipe_cache, ui);
}
@@ -1030,7 +1030,8 @@
set_retry_bootloader_message(retry_count + 1, args);
}
- status = install_package(update_package, &should_wipe_cache, true, retry_count);
+ modified_flash = true;
+ status = install_package(update_package, &should_wipe_cache, true, retry_count, ui);
if (status == INSTALL_SUCCESS && should_wipe_cache) {
wipe_cache(false, device);
}
@@ -1096,7 +1097,7 @@
if (!sideload_auto_reboot) {
ui->ShowText(true);
}
- status = apply_from_adb(&should_wipe_cache);
+ status = apply_from_adb(&should_wipe_cache, ui);
if (status == INSTALL_SUCCESS && should_wipe_cache) {
if (!wipe_cache(false, device)) {
status = INSTALL_ERROR;