From 2478885f3ca47fe2c4073df1100f7bd6ad4931af Mon Sep 17 00:00:00 2001 From: xunchang Date: Fri, 22 Mar 2019 16:08:52 -0700 Subject: 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 --- recovery.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'recovery.cpp') diff --git a/recovery.cpp b/recovery.cpp index d9c1f22f5..421bc12f2 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -50,20 +50,20 @@ #include #include -#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 @@ static constexpr const char* METADATA_ROOT = "/metadata"; // 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 @@ static std::unique_ptr 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(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 @@ static Device::BuiltinAction prompt_and_wait(Device* device, int status) { 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 @@ Device::BuiltinAction start_recovery(Device* device, const std::vectorShowText(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; -- cgit v1.2.3 From bc982a4f8845e5fa0cd2630ddcc3d8f70066b083 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 29 Mar 2019 15:43:09 -0700 Subject: Remove ui_print(). This used to be a helper function that allows printing message to UI. We no longer have any active user in bootable/recovery. Device-specific code can achieve the same functionality by calling GetUI()->Print() instead. Test: mmma -j bootable/recovery Change-Id: If584fc8a51d1af466f1d94d8ea5faa262603a784 --- recovery.cpp | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'recovery.cpp') diff --git a/recovery.cpp b/recovery.cpp index 421bc12f2..02cc53c2c 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -746,20 +745,6 @@ static void print_property(const char* key, const char* name, void* /* cookie */ printf("%s=%s\n", key, name); } -void ui_print(const char* format, ...) { - std::string buffer; - va_list ap; - va_start(ap, format); - android::base::StringAppendV(&buffer, format, ap); - va_end(ap); - - if (ui != nullptr) { - ui->Print("%s", buffer.c_str()); - } else { - fputs(buffer.c_str(), stdout); - } -} - static bool is_battery_ok(int* required_battery_level) { using android::hardware::health::V1_0::BatteryStatus; using android::hardware::health::V2_0::get_health_service; -- cgit v1.2.3 From e0cfab3de9d0e1b09799c7e488f171b31ddfe7bf Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 29 Mar 2019 15:53:23 -0700 Subject: recovery: Remove SetUsbConfig() out of common.h. libinstall now has its own copy. Test: mmma -j bootable/recovery Change-Id: Ibbe7084e15baeb7e744f2175d5944477092acc9e --- recovery.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'recovery.cpp') diff --git a/recovery.cpp b/recovery.cpp index 02cc53c2c..034918498 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -271,12 +271,6 @@ static bool erase_volume(const char* volume) { return (result == 0); } -// Sets the usb config to 'state' -bool SetUsbConfig(const std::string& state) { - android::base::SetProperty("sys.usb.config", state); - return android::base::WaitForProperty("sys.usb.state", state); -} - static bool yes_no(Device* device, const char* question1, const char* question2) { std::vector headers{ question1, question2 }; std::vector items{ " No", " Yes" }; -- cgit v1.2.3