recovery: clean up ask_to_continue_unverified
Change-Id: Ia7e0f5f150a7799efefd64e08a8f5dee35352317
diff --git a/install/adb_install.cpp b/install/adb_install.cpp
index ad4be38..fd1ca1a 100644
--- a/install/adb_install.cpp
+++ b/install/adb_install.cpp
@@ -90,9 +90,7 @@
// Installs the package from FUSE. Returns the installation result and whether it should continue
// waiting for new commands.
-static auto AdbInstallPackageHandler(
- Device* device, int* result,
- const std::function<bool(Device*)>& ask_to_continue_unverified_fn) {
+static auto AdbInstallPackageHandler(Device* device, int* result) {
RecoveryUI* ui = device->GetUI();
// How long (in seconds) we wait for the package path to be ready. It doesn't need to be too long
@@ -117,8 +115,8 @@
ui->CancelWaitKey();
*result = install_package(FUSE_SIDELOAD_HOST_PATHNAME, false, false, 0, true /* verify */, ui);
- if (*result == INSTALL_UNVERIFIED && ask_to_continue_unverified_fn &&
- ask_to_continue_unverified_fn(device)) {
+ if (*result == INSTALL_UNVERIFIED &&
+ ui->IsTextVisible() && ask_to_continue_unverified(device)) {
*result =
install_package(FUSE_SIDELOAD_HOST_PATHNAME, false, false, 0, false /* verify */, ui);
}
@@ -357,8 +355,7 @@
signal(SIGPIPE, SIG_DFL);
}
-int ApplyFromAdb(Device* device, bool rescue_mode, Device::BuiltinAction* reboot_action,
- const std::function<bool(Device*)>& ask_to_continue_unverified_fn) {
+int ApplyFromAdb(Device* device, bool rescue_mode, Device::BuiltinAction* reboot_action) {
// Save the usb state to restore after the sideload operation.
std::string usb_state = android::base::GetProperty("sys.usb.state", "none");
// Clean up state and stop adbd.
@@ -369,8 +366,7 @@
int install_result = INSTALL_ERROR;
std::map<MinadbdCommand, CommandFunction> command_map{
- { MinadbdCommand::kInstall, std::bind(&AdbInstallPackageHandler, device, &install_result,
- ask_to_continue_unverified_fn) },
+ { MinadbdCommand::kInstall, std::bind(&AdbInstallPackageHandler, device, &install_result) },
{ MinadbdCommand::kRebootAndroid, std::bind(&AdbRebootHandler, MinadbdCommand::kRebootAndroid,
&install_result, reboot_action) },
{ MinadbdCommand::kRebootBootloader,
diff --git a/install/fuse_sdcard_install.cpp b/install/fuse_sdcard_install.cpp
index 195652c..e7f4c0d 100644
--- a/install/fuse_sdcard_install.cpp
+++ b/install/fuse_sdcard_install.cpp
@@ -136,8 +136,7 @@
return run_fuse_sideload(std::move(file_data_reader)) == 0;
}
-int ApplyFromSdcard(Device* device, RecoveryUI* ui,
- const std::function<bool(Device*)>& ask_to_continue_unverified_fn) {
+int ApplyFromSdcard(Device* device, RecoveryUI* ui) {
if (ensure_path_mounted(SDCARD_ROOT) != 0) {
LOG(ERROR) << "\n-- Couldn't mount " << SDCARD_ROOT << ".\n";
return INSTALL_ERROR;
@@ -193,7 +192,7 @@
result = install_package(FUSE_SIDELOAD_HOST_PATHNAME, false, false, 0 /*retry_count*/,
true /* verify */, ui);
- if (result == INSTALL_UNVERIFIED && ask_to_continue_unverified_fn(device)) {
+ if (result == INSTALL_UNVERIFIED && ask_to_continue_unverified(device)) {
result = install_package(FUSE_SIDELOAD_HOST_PATHNAME, false, false, 0 /*retry_count*/,
false /* verify */, ui);
}
diff --git a/install/include/install/adb_install.h b/install/include/install/adb_install.h
index 4c7b1ab..3a0a817 100644
--- a/install/include/install/adb_install.h
+++ b/install/include/install/adb_install.h
@@ -21,5 +21,4 @@
// Applies a package via `adb sideload` or `adb rescue`. Returns the install result (in `enum
// InstallResult`). When a reboot has been requested, INSTALL_REBOOT will be the return value, with
// the reboot target set in reboot_action.
-int ApplyFromAdb(Device* device, bool rescue_mode, Device::BuiltinAction* reboot_action,
- const std::function<bool(Device*)>& ask_to_continue_unverified = nullptr);
+int ApplyFromAdb(Device* device, bool rescue_mode, Device::BuiltinAction* reboot_action);
diff --git a/install/include/install/fuse_sdcard_install.h b/install/include/install/fuse_sdcard_install.h
index 7f47535..d9214ca 100644
--- a/install/include/install/fuse_sdcard_install.h
+++ b/install/include/install/fuse_sdcard_install.h
@@ -19,5 +19,4 @@
#include "recovery_ui/device.h"
#include "recovery_ui/ui.h"
-int ApplyFromSdcard(Device* device, RecoveryUI* ui,
- const std::function<bool(Device*)>& ask_to_continue_unverified_fn);
+int ApplyFromSdcard(Device* device, RecoveryUI* ui);
diff --git a/install/include/install/install.h b/install/include/install/install.h
index fe4c87e..a0763af 100644
--- a/install/include/install/install.h
+++ b/install/include/install/install.h
@@ -25,6 +25,7 @@
#include <ziparchive/zip_archive.h>
#include "package.h"
+#include "recovery_ui/device.h"
#include "recovery_ui/ui.h"
enum InstallResult {
@@ -70,3 +71,6 @@
// Mandatory checks: ota-type, pre-device and serial number(if presents)
// AB OTA specific checks: pre-build version, fingerprint, timestamp.
int CheckPackageMetadata(const std::map<std::string, std::string>& metadata, OtaType ota_type);
+
+// Defined in recovery.cpp, just declare it and it will eventually link fine.
+bool ask_to_continue_unverified(Device* device);