Merge "Convert vold to new BootControl client" am: 6083e0196b
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2132797 Change-Id: I97d3bcacc85ba0295ccadd216a3db8cabf0cc3a2 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
de2d1b6cc7
2 changed files with 16 additions and 19 deletions
|
@ -43,6 +43,8 @@ cc_defaults {
|
||||||
],
|
],
|
||||||
shared_libs: [
|
shared_libs: [
|
||||||
"android.hardware.boot@1.0",
|
"android.hardware.boot@1.0",
|
||||||
|
"android.hardware.boot-V1-ndk",
|
||||||
|
"libboot_control_client",
|
||||||
"libbase",
|
"libbase",
|
||||||
"libbinder",
|
"libbinder",
|
||||||
"libcrypto",
|
"libcrypto",
|
||||||
|
|
|
@ -26,12 +26,12 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <BootControlClient.h>
|
||||||
#include <android-base/file.h>
|
#include <android-base/file.h>
|
||||||
#include <android-base/logging.h>
|
#include <android-base/logging.h>
|
||||||
#include <android-base/parseint.h>
|
#include <android-base/parseint.h>
|
||||||
#include <android-base/properties.h>
|
#include <android-base/properties.h>
|
||||||
#include <android-base/unique_fd.h>
|
#include <android-base/unique_fd.h>
|
||||||
#include <android/hardware/boot/1.0/IBootControl.h>
|
|
||||||
#include <cutils/android_reboot.h>
|
#include <cutils/android_reboot.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <fs_mgr.h>
|
#include <fs_mgr.h>
|
||||||
|
@ -48,11 +48,7 @@ using android::base::SetProperty;
|
||||||
using android::binder::Status;
|
using android::binder::Status;
|
||||||
using android::fs_mgr::Fstab;
|
using android::fs_mgr::Fstab;
|
||||||
using android::fs_mgr::ReadFstabFromFile;
|
using android::fs_mgr::ReadFstabFromFile;
|
||||||
using android::hardware::hidl_string;
|
using android::hal::BootControlClient;
|
||||||
using android::hardware::boot::V1_0::BoolResult;
|
|
||||||
using android::hardware::boot::V1_0::CommandResult;
|
|
||||||
using android::hardware::boot::V1_0::IBootControl;
|
|
||||||
using android::hardware::boot::V1_0::Slot;
|
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
namespace vold {
|
namespace vold {
|
||||||
|
@ -128,11 +124,10 @@ Status cp_startCheckpoint(int retry) {
|
||||||
if (retry < -1) return error(EINVAL, "Retry count must be more than -1");
|
if (retry < -1) return error(EINVAL, "Retry count must be more than -1");
|
||||||
std::string content = std::to_string(retry + 1);
|
std::string content = std::to_string(retry + 1);
|
||||||
if (retry == -1) {
|
if (retry == -1) {
|
||||||
sp<IBootControl> module = IBootControl::getService();
|
auto module = BootControlClient::WaitForService();
|
||||||
if (module) {
|
if (module) {
|
||||||
std::string suffix;
|
std::string suffix = module->GetSuffix(module->GetCurrentSlot());
|
||||||
auto cb = [&suffix](hidl_string s) { suffix = s; };
|
if (!suffix.empty()) content += " " + suffix;
|
||||||
if (module->getSuffix(module->getCurrentSlot(), cb).isOk()) content += " " + suffix;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!android::base::WriteStringToFile(content, kMetadataCPFile))
|
if (!android::base::WriteStringToFile(content, kMetadataCPFile))
|
||||||
|
@ -162,10 +157,9 @@ Status cp_commitChanges() {
|
||||||
<< "NOT COMMITTING CHECKPOINT BECAUSE persist.vold.dont_commit_checkpoint IS 1";
|
<< "NOT COMMITTING CHECKPOINT BECAUSE persist.vold.dont_commit_checkpoint IS 1";
|
||||||
return Status::ok();
|
return Status::ok();
|
||||||
}
|
}
|
||||||
sp<IBootControl> module = IBootControl::getService();
|
auto module = BootControlClient::WaitForService();
|
||||||
if (module) {
|
if (module) {
|
||||||
CommandResult cr;
|
auto cr = module->MarkBootSuccessful();
|
||||||
module->markBootSuccessful([&cr](CommandResult result) { cr = result; });
|
|
||||||
if (!cr.success)
|
if (!cr.success)
|
||||||
return error(EINVAL, "Error marking booted successfully: " + std::string(cr.errMsg));
|
return error(EINVAL, "Error marking booted successfully: " + std::string(cr.errMsg));
|
||||||
LOG(INFO) << "Marked slot as booted successfully.";
|
LOG(INFO) << "Marked slot as booted successfully.";
|
||||||
|
@ -173,6 +167,8 @@ Status cp_commitChanges() {
|
||||||
if (!SetProperty("ota.warm_reset", "0")) {
|
if (!SetProperty("ota.warm_reset", "0")) {
|
||||||
LOG(WARNING) << "Failed to reset the warm reset flag";
|
LOG(WARNING) << "Failed to reset the warm reset flag";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
LOG(ERROR) << "Failed to get BootControl HAL, not marking slot as successful.";
|
||||||
}
|
}
|
||||||
// Must take action for list of mounted checkpointed things here
|
// Must take action for list of mounted checkpointed things here
|
||||||
// To do this, we walk the list of mounted file systems.
|
// To do this, we walk the list of mounted file systems.
|
||||||
|
@ -254,12 +250,11 @@ bool cp_needsRollback() {
|
||||||
if (content == "0") return true;
|
if (content == "0") return true;
|
||||||
if (content.substr(0, 3) == "-1 ") {
|
if (content.substr(0, 3) == "-1 ") {
|
||||||
std::string oldSuffix = content.substr(3);
|
std::string oldSuffix = content.substr(3);
|
||||||
sp<IBootControl> module = IBootControl::getService();
|
auto module = BootControlClient::WaitForService();
|
||||||
std::string newSuffix;
|
std::string newSuffix;
|
||||||
|
|
||||||
if (module) {
|
if (module) {
|
||||||
auto cb = [&newSuffix](hidl_string s) { newSuffix = s; };
|
newSuffix = module->GetSuffix(module->GetCurrentSlot());
|
||||||
module->getSuffix(module->getCurrentSlot(), cb);
|
|
||||||
if (oldSuffix == newSuffix) return true;
|
if (oldSuffix == newSuffix) return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,11 +271,11 @@ bool cp_needsCheckpoint() {
|
||||||
|
|
||||||
bool ret;
|
bool ret;
|
||||||
std::string content;
|
std::string content;
|
||||||
sp<IBootControl> module = IBootControl::getService();
|
auto module = BootControlClient::WaitForService();
|
||||||
|
|
||||||
if (isCheckpointing) return isCheckpointing;
|
if (isCheckpointing) return isCheckpointing;
|
||||||
|
// In case of INVALID slot or other failures, we do not perform checkpoint.
|
||||||
if (module && module->isSlotMarkedSuccessful(module->getCurrentSlot()) == BoolResult::FALSE) {
|
if (module && !module->IsSlotMarkedSuccessful(module->GetCurrentSlot()).value_or(true)) {
|
||||||
isCheckpointing = true;
|
isCheckpointing = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue