summaryrefslogtreecommitdiffstats
path: root/recovery.cpp
diff options
context:
space:
mode:
authorBill Rassieur <rassb@google.com>2019-04-02 20:26:46 +0200
committerBill Rassieur <rassb@google.com>2019-04-02 20:26:46 +0200
commit86de943dcc7b81567514273be718e57703cf075c (patch)
treee9f635bd39b426228247ae3cf528f17061a55629 /recovery.cpp
parentMerge master@5406228 into git_qt-dev-plus-aosp. (diff)
parentMerge changes Ibbe7084e,If584fc8a am: bb8f0fff17 am: effd4ca883 (diff)
downloadandroid_bootable_recovery-86de943dcc7b81567514273be718e57703cf075c.tar
android_bootable_recovery-86de943dcc7b81567514273be718e57703cf075c.tar.gz
android_bootable_recovery-86de943dcc7b81567514273be718e57703cf075c.tar.bz2
android_bootable_recovery-86de943dcc7b81567514273be718e57703cf075c.tar.lz
android_bootable_recovery-86de943dcc7b81567514273be718e57703cf075c.tar.xz
android_bootable_recovery-86de943dcc7b81567514273be718e57703cf075c.tar.zst
android_bootable_recovery-86de943dcc7b81567514273be718e57703cf075c.zip
Diffstat (limited to '')
-rw-r--r--recovery.cpp42
1 files changed, 11 insertions, 31 deletions
diff --git a/recovery.cpp b/recovery.cpp
index d9c1f22f5..034918498 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -24,7 +24,6 @@
#include <limits.h>
#include <linux/fs.h>
#include <linux/input.h>
-#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -50,20 +49,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 +78,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;
@@ -272,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<std::string> headers{ question1, question2 };
std::vector<std::string> items{ " No", " Yes" };
@@ -439,7 +432,7 @@ static std::unique_ptr<Package> 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 +686,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);
}
@@ -746,20 +739,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;
@@ -1030,7 +1009,8 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
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 +1076,7 @@ Device::BuiltinAction start_recovery(Device* device, const std::vector<std::stri
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;