aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-04-09 23:23:48 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-04-09 23:23:48 +0000
commitb87c8d2f6319254a49c7e3139cd913d2efbf582d (patch)
tree9c1c5ea28d675c278428086282887336df55df4b
parentc768a3247ec009f3499d50af73f2bd5cdc0ef447 (diff)
parent6265ac36ad13effdb08be381814e536f81b67f5f (diff)
downloadrecovery-b87c8d2f6319254a49c7e3139cd913d2efbf582d.tar.gz
Merge "Snap for 11692525 from 3bf54b57d2abe885fbcbf886b13d69c8287732da to sdk-release" into sdk-release
-rw-r--r--install/install.cpp11
-rw-r--r--recovery.cpp5
-rw-r--r--recovery_main.cpp10
3 files changed, 23 insertions, 3 deletions
diff --git a/install/install.cpp b/install/install.cpp
index a9786cfd..6294a3dc 100644
--- a/install/install.cpp
+++ b/install/install.cpp
@@ -189,6 +189,17 @@ static bool CheckAbSpecificMetadata(const std::map<std::string, std::string>& me
return false;
}
}
+ const auto post_build = get_value(metadata, "post-build");
+ const auto build_fingerprint = android::base::Tokenize(post_build, "/");
+ if (!build_fingerprint.empty()) {
+ const auto& post_build_tag = build_fingerprint.back();
+ const auto build_tag = android::base::GetProperty("ro.build.tags", "");
+ if (build_tag != post_build_tag) {
+ LOG(ERROR) << "Post build-tag " << post_build_tag << " does not match device build tag "
+ << build_tag;
+ return false;
+ }
+ }
return true;
}
diff --git a/recovery.cpp b/recovery.cpp
index e7a33a9e..fbfe6468 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -176,6 +176,11 @@ static bool ask_to_wipe_data(Device* device) {
}
static InstallResult prompt_and_wipe_data(Device* device) {
+ // Reset to normal system boot so recovery won't cycle indefinitely.
+ std::string err;
+ if (!clear_bootloader_message(&err)) {
+ LOG(ERROR) << "Failed to clear BCB message: " << err;
+ }
// Use a single string and let ScreenRecoveryUI handles the wrapping.
std::vector<std::string> wipe_data_menu_headers{
"Can't load Android system. Your data may be corrupt. "
diff --git a/recovery_main.cpp b/recovery_main.cpp
index cb3f0c13..903a3173 100644
--- a/recovery_main.cpp
+++ b/recovery_main.cpp
@@ -155,9 +155,13 @@ static std::vector<std::string> get_args(const int argc, char** const argv, std:
// Write the arguments (excluding the filename in args[0]) back into the
// bootloader control block. So the device will always boot into recovery to
// finish the pending work, until FinishRecovery() is called.
- std::vector<std::string> options(args.cbegin() + 1, args.cend());
- if (!update_bootloader_message(options, &err)) {
- LOG(ERROR) << "Failed to set BCB message: " << err;
+ // This should only be done for boot-recovery command so that other commands
+ // won't be overwritten.
+ if (boot_command == "boot-recovery") {
+ std::vector<std::string> options(args.cbegin() + 1, args.cend());
+ if (!update_bootloader_message(options, &err)) {
+ LOG(ERROR) << "Failed to set BCB message: " << err;
+ }
}
// Finally, if no arguments were specified, check whether we should boot