aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao2017-01-09 00:45:47 -0600
committerTao Bao2017-01-13 14:08:34 -0600
commitefc35594dd2d0df9923877646863fe438cf5b316 (patch)
treee67d1332fe1116c8ffc7e111a6c3d5ef92f06dea /recovery.cpp
parent8031c2d2bb0881ef3c46aafdde87af47cc2fe595 (diff)
downloadplatform-bootable-recovery-efc35594dd2d0df9923877646863fe438cf5b316.tar.gz
platform-bootable-recovery-efc35594dd2d0df9923877646863fe438cf5b316.tar.xz
platform-bootable-recovery-efc35594dd2d0df9923877646863fe438cf5b316.zip
recovery: Move property_get() to android::base::GetProperty().
Test: Apply two A/B incremental OTAs with the new recovery image. The one with incorrect pre-build should be blocked, while the other works fine. Change-Id: I94d97eb8798599da1630f66343fb603e87464187
Diffstat (limited to 'recovery.cpp')
-rw-r--r--recovery.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/recovery.cpp b/recovery.cpp
index fac241d6..25d3546e 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -892,8 +892,8 @@ static bool check_wipe_package(size_t wipe_package_size) {
892 892
893 // Extract metadata 893 // Extract metadata
894 ZipArchiveHandle zip; 894 ZipArchiveHandle zip;
895 int err = OpenArchiveFromMemory(reinterpret_cast<void*>(&wipe_package[0]), 895 int err = OpenArchiveFromMemory(static_cast<void*>(&wipe_package[0]), wipe_package.size(),
896 wipe_package.size(), "wipe_package", &zip); 896 "wipe_package", &zip);
897 if (err != 0) { 897 if (err != 0) {
898 LOG(ERROR) << "Can't open wipe package : " << ErrorCodeString(err); 898 LOG(ERROR) << "Can't open wipe package : " << ErrorCodeString(err);
899 return false; 899 return false;
@@ -916,13 +916,11 @@ static bool check_wipe_package(size_t wipe_package_size) {
916 ota_type_matched = true; 916 ota_type_matched = true;
917 } else if (android::base::StartsWith(line, "pre-device=")) { 917 } else if (android::base::StartsWith(line, "pre-device=")) {
918 std::string device_type = line.substr(strlen("pre-device=")); 918 std::string device_type = line.substr(strlen("pre-device="));
919 char real_device_type[PROPERTY_VALUE_MAX]; 919 std::string real_device_type = android::base::GetProperty("ro.build.product", "");
920 property_get("ro.build.product", real_device_type, "");
921 device_type_matched = (device_type == real_device_type); 920 device_type_matched = (device_type == real_device_type);
922 } else if (android::base::StartsWith(line, "serialno=")) { 921 } else if (android::base::StartsWith(line, "serialno=")) {
923 std::string serial_no = line.substr(strlen("serialno=")); 922 std::string serial_no = line.substr(strlen("serialno="));
924 char real_serial_no[PROPERTY_VALUE_MAX]; 923 std::string real_serial_no = android::base::GetProperty("ro.serialno", "");
925 property_get("ro.serialno", real_serial_no, "");
926 has_serial_number = true; 924 has_serial_number = true;
927 serial_number_matched = (serial_no == real_serial_no); 925 serial_number_matched = (serial_no == real_serial_no);
928 } 926 }
@@ -1361,15 +1359,15 @@ static void set_retry_bootloader_message(int retry_count, int argc, char** argv)
1361} 1359}
1362 1360
1363static bool bootreason_in_blacklist() { 1361static bool bootreason_in_blacklist() {
1364 char bootreason[PROPERTY_VALUE_MAX]; 1362 std::string bootreason = android::base::GetProperty("ro.boot.bootreason", "");
1365 if (property_get("ro.boot.bootreason", bootreason, nullptr) > 0) { 1363 if (!bootreason.empty()) {
1366 for (const auto& str : bootreason_blacklist) { 1364 for (const auto& str : bootreason_blacklist) {
1367 if (strcasecmp(str.c_str(), bootreason) == 0) { 1365 if (strcasecmp(str.c_str(), bootreason.c_str()) == 0) {
1368 return true; 1366 return true;
1369 } 1367 }
1370 }
1371 } 1368 }
1372 return false; 1369 }
1370 return false;
1373} 1371}
1374 1372
1375static void log_failure_code(ErrorCode code, const char *update_package) { 1373static void log_failure_code(ErrorCode code, const char *update_package) {