summaryrefslogtreecommitdiffstats
path: root/recovery.cpp
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2018-10-25 19:39:01 +0200
committerTianjie Xu <xunchang@google.com>2018-10-31 19:03:58 +0100
commit93b5bf261ca984dcebdb538b7691fe47576069eb (patch)
treeab26271f7a86709192850d60bd569ceda83852e2 /recovery.cpp
parentMerge "Add description for the new translation" (diff)
downloadandroid_bootable_recovery-93b5bf261ca984dcebdb538b7691fe47576069eb.tar
android_bootable_recovery-93b5bf261ca984dcebdb538b7691fe47576069eb.tar.gz
android_bootable_recovery-93b5bf261ca984dcebdb538b7691fe47576069eb.tar.bz2
android_bootable_recovery-93b5bf261ca984dcebdb538b7691fe47576069eb.tar.lz
android_bootable_recovery-93b5bf261ca984dcebdb538b7691fe47576069eb.tar.xz
android_bootable_recovery-93b5bf261ca984dcebdb538b7691fe47576069eb.tar.zst
android_bootable_recovery-93b5bf261ca984dcebdb538b7691fe47576069eb.zip
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp33
1 files changed, 8 insertions, 25 deletions
diff --git a/recovery.cpp b/recovery.cpp
index d7bc6fd2f..e17526a95 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -520,34 +520,17 @@ static bool check_wipe_package(size_t wipe_package_size) {
LOG(ERROR) << "Can't open wipe package : " << ErrorCodeString(err);
return false;
}
- std::string metadata;
- if (!read_metadata_from_package(zip, &metadata)) {
- CloseArchive(zip);
- return false;
+
+ std::map<std::string, std::string> metadata;
+ if (!ReadMetadataFromPackage(zip, &metadata)) {
+ LOG(ERROR) << "Failed to parse metadata in the zip file";
+ return false;
}
+
+ int result = CheckPackageMetadata(metadata, OtaType::BRICK);
CloseArchive(zip);
- // Check metadata
- std::vector<std::string> lines = android::base::Split(metadata, "\n");
- bool ota_type_matched = false;
- bool device_type_matched = false;
- bool has_serial_number = false;
- bool serial_number_matched = false;
- for (const auto& line : lines) {
- if (line == "ota-type=BRICK") {
- ota_type_matched = true;
- } else if (android::base::StartsWith(line, "pre-device=")) {
- std::string device_type = line.substr(strlen("pre-device="));
- std::string real_device_type = android::base::GetProperty("ro.build.product", "");
- device_type_matched = (device_type == real_device_type);
- } else if (android::base::StartsWith(line, "serialno=")) {
- std::string serial_no = line.substr(strlen("serialno="));
- std::string real_serial_no = android::base::GetProperty("ro.serialno", "");
- has_serial_number = true;
- serial_number_matched = (serial_no == real_serial_no);
- }
- }
- return ota_type_matched && device_type_matched && (!has_serial_number || serial_number_matched);
+ return result == 0;
}
// Wipes the current A/B device, with a secure wipe of all the partitions in RECOVERY_WIPE.