Merge "Convert recovery to use AIDL bootcontrol HAL" am: ab532fdfc7
Original change: https://android-review.googlesource.com/c/platform/bootable/recovery/+/2135412 Change-Id: Ie4637afb2076cff47cbd03850274bc1d90cc19a9 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
819c91a522
3 changed files with 19 additions and 17 deletions
|
@ -94,6 +94,8 @@ cc_defaults {
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
"android.hardware.boot@1.0",
|
"android.hardware.boot@1.0",
|
||||||
"android.hardware.boot@1.1",
|
"android.hardware.boot@1.1",
|
||||||
|
"android.hardware.boot-V1-ndk",
|
||||||
|
"libboot_control_client",
|
||||||
"libbase",
|
"libbase",
|
||||||
"libbootloader_message",
|
"libbootloader_message",
|
||||||
"libcrypto",
|
"libcrypto",
|
||||||
|
@ -158,6 +160,7 @@ cc_binary {
|
||||||
|
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
"android.hardware.health-V1-ndk", // from librecovery_utils
|
"android.hardware.health-V1-ndk", // from librecovery_utils
|
||||||
|
"android.hardware.boot-V1-ndk",
|
||||||
"librecovery_ui",
|
"librecovery_ui",
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,7 @@ cc_library_static {
|
||||||
|
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
"android.hardware.boot@1.0",
|
"android.hardware.boot@1.0",
|
||||||
|
"libboot_control_client",
|
||||||
"libbase",
|
"libbase",
|
||||||
"libcutils",
|
"libcutils",
|
||||||
"libbinder",
|
"libbinder",
|
||||||
|
@ -118,6 +119,7 @@ cc_binary {
|
||||||
"libprotobuf-cpp-lite",
|
"libprotobuf-cpp-lite",
|
||||||
"libbinder",
|
"libbinder",
|
||||||
"libutils",
|
"libutils",
|
||||||
|
"libboot_control_client",
|
||||||
],
|
],
|
||||||
|
|
||||||
init_rc: [
|
init_rc: [
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
#include <future>
|
#include <future>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
#include <BootControlClient.h>
|
||||||
#include <android-base/chrono_utils.h>
|
#include <android-base/chrono_utils.h>
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
|
@ -59,7 +60,6 @@
|
||||||
#include <android-base/properties.h>
|
#include <android-base/properties.h>
|
||||||
#include <android-base/strings.h>
|
#include <android-base/strings.h>
|
||||||
#include <android-base/unique_fd.h>
|
#include <android-base/unique_fd.h>
|
||||||
#include <android/hardware/boot/1.0/IBootControl.h>
|
|
||||||
#include <android/os/IVold.h>
|
#include <android/os/IVold.h>
|
||||||
#include <binder/BinderService.h>
|
#include <binder/BinderService.h>
|
||||||
#include <binder/Status.h>
|
#include <binder/Status.h>
|
||||||
|
@ -67,11 +67,6 @@
|
||||||
|
|
||||||
#include "care_map.pb.h"
|
#include "care_map.pb.h"
|
||||||
|
|
||||||
using android::sp;
|
|
||||||
using android::hardware::boot::V1_0::IBootControl;
|
|
||||||
using android::hardware::boot::V1_0::BoolResult;
|
|
||||||
using android::hardware::boot::V1_0::CommandResult;
|
|
||||||
|
|
||||||
// TODO(xunchang) remove the prefix and use a default path instead.
|
// TODO(xunchang) remove the prefix and use a default path instead.
|
||||||
constexpr const char* kDefaultCareMapPrefix = "/data/ota_package/care_map";
|
constexpr const char* kDefaultCareMapPrefix = "/data/ota_package/care_map";
|
||||||
|
|
||||||
|
@ -92,7 +87,7 @@ UpdateVerifier::UpdateVerifier()
|
||||||
// partition's integrity.
|
// partition's integrity.
|
||||||
std::map<std::string, std::string> UpdateVerifier::FindDmPartitions() {
|
std::map<std::string, std::string> UpdateVerifier::FindDmPartitions() {
|
||||||
static constexpr auto DM_PATH_PREFIX = "/sys/block/";
|
static constexpr auto DM_PATH_PREFIX = "/sys/block/";
|
||||||
dirent** namelist;
|
dirent** namelist = nullptr;
|
||||||
int n = scandir(DM_PATH_PREFIX, &namelist, dm_name_filter, alphasort);
|
int n = scandir(DM_PATH_PREFIX, &namelist, dm_name_filter, alphasort);
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
PLOG(ERROR) << "Failed to scan dir " << DM_PATH_PREFIX;
|
PLOG(ERROR) << "Failed to scan dir " << DM_PATH_PREFIX;
|
||||||
|
@ -329,18 +324,21 @@ int update_verifier(int argc, char** argv) {
|
||||||
LOG(INFO) << "Started with arg " << i << ": " << argv[i];
|
LOG(INFO) << "Started with arg " << i << ": " << argv[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
sp<IBootControl> module = IBootControl::getService();
|
const auto module = android::hal::BootControlClient::WaitForService();
|
||||||
if (module == nullptr) {
|
if (module == nullptr) {
|
||||||
LOG(ERROR) << "Error getting bootctrl module.";
|
LOG(ERROR) << "Error getting bootctrl module.";
|
||||||
return reboot_device();
|
return reboot_device();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t current_slot = module->getCurrentSlot();
|
uint32_t current_slot = module->GetCurrentSlot();
|
||||||
BoolResult is_successful = module->isSlotMarkedSuccessful(current_slot);
|
const auto is_successful = module->IsSlotMarkedSuccessful(current_slot);
|
||||||
LOG(INFO) << "Booting slot " << current_slot << ": isSlotMarkedSuccessful="
|
if (!is_successful.has_value()) {
|
||||||
<< static_cast<int32_t>(is_successful);
|
LOG(INFO) << "Booting slot " << current_slot << " failed";
|
||||||
|
} else {
|
||||||
if (is_successful == BoolResult::FALSE) {
|
LOG(INFO) << "Booting slot " << current_slot
|
||||||
|
<< ": isSlotMarkedSuccessful=" << is_successful.value();
|
||||||
|
}
|
||||||
|
if (is_successful.has_value() && !is_successful.value()) {
|
||||||
// The current slot has not booted successfully.
|
// The current slot has not booted successfully.
|
||||||
|
|
||||||
bool skip_verification = false;
|
bool skip_verification = false;
|
||||||
|
@ -386,8 +384,7 @@ int update_verifier(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!supports_checkpoint) {
|
if (!supports_checkpoint) {
|
||||||
CommandResult cr;
|
const auto cr = module->MarkBootSuccessful();
|
||||||
module->markBootSuccessful([&cr](CommandResult result) { cr = result; });
|
|
||||||
if (!cr.success) {
|
if (!cr.success) {
|
||||||
LOG(ERROR) << "Error marking booted successfully: " << cr.errMsg;
|
LOG(ERROR) << "Error marking booted successfully: " << cr.errMsg;
|
||||||
return reboot_device();
|
return reboot_device();
|
||||||
|
|
Loading…
Reference in a new issue