From efc35594dd2d0df9923877646863fe438cf5b316 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Sun, 8 Jan 2017 22:45:47 -0800 Subject: 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 --- recovery.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'recovery.cpp') diff --git a/recovery.cpp b/recovery.cpp index fac241d63..25d3546e3 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -892,8 +892,8 @@ static bool check_wipe_package(size_t wipe_package_size) { // Extract metadata ZipArchiveHandle zip; - int err = OpenArchiveFromMemory(reinterpret_cast(&wipe_package[0]), - wipe_package.size(), "wipe_package", &zip); + int err = OpenArchiveFromMemory(static_cast(&wipe_package[0]), wipe_package.size(), + "wipe_package", &zip); if (err != 0) { LOG(ERROR) << "Can't open wipe package : " << ErrorCodeString(err); return false; @@ -916,13 +916,11 @@ static bool check_wipe_package(size_t wipe_package_size) { ota_type_matched = true; } else if (android::base::StartsWith(line, "pre-device=")) { std::string device_type = line.substr(strlen("pre-device=")); - char real_device_type[PROPERTY_VALUE_MAX]; - property_get("ro.build.product", real_device_type, ""); + 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=")); - char real_serial_no[PROPERTY_VALUE_MAX]; - property_get("ro.serialno", real_serial_no, ""); + std::string real_serial_no = android::base::GetProperty("ro.serialno", ""); has_serial_number = true; serial_number_matched = (serial_no == real_serial_no); } @@ -1361,15 +1359,15 @@ static void set_retry_bootloader_message(int retry_count, int argc, char** argv) } static bool bootreason_in_blacklist() { - char bootreason[PROPERTY_VALUE_MAX]; - if (property_get("ro.boot.bootreason", bootreason, nullptr) > 0) { - for (const auto& str : bootreason_blacklist) { - if (strcasecmp(str.c_str(), bootreason) == 0) { - return true; - } - } + std::string bootreason = android::base::GetProperty("ro.boot.bootreason", ""); + if (!bootreason.empty()) { + for (const auto& str : bootreason_blacklist) { + if (strcasecmp(str.c_str(), bootreason.c_str()) == 0) { + return true; + } } - return false; + } + return false; } static void log_failure_code(ErrorCode code, const char *update_package) { -- cgit v1.2.3