summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2017-09-13 22:53:53 +0200
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-09-13 22:53:53 +0200
commit6e7df82c7ba4b868487d638e641e3ba62b12211e (patch)
tree4e9b138c4234d80b88cc856effa3f55e340044f5
parentMerge "Close cmd_pipe properly after updater test finishes" (diff)
parentRemove EXPAND/STRINGIFY macros. (diff)
downloadandroid_bootable_recovery-6e7df82c7ba4b868487d638e641e3ba62b12211e.tar
android_bootable_recovery-6e7df82c7ba4b868487d638e641e3ba62b12211e.tar.gz
android_bootable_recovery-6e7df82c7ba4b868487d638e641e3ba62b12211e.tar.bz2
android_bootable_recovery-6e7df82c7ba4b868487d638e641e3ba62b12211e.tar.lz
android_bootable_recovery-6e7df82c7ba4b868487d638e641e3ba62b12211e.tar.xz
android_bootable_recovery-6e7df82c7ba4b868487d638e641e3ba62b12211e.tar.zst
android_bootable_recovery-6e7df82c7ba4b868487d638e641e3ba62b12211e.zip
Diffstat (limited to '')
-rw-r--r--common.h5
-rw-r--r--install.cpp2
-rw-r--r--recovery.cpp6
3 files changed, 9 insertions, 4 deletions
diff --git a/common.h b/common.h
index 62fb1324b..8b336f806 100644
--- a/common.h
+++ b/common.h
@@ -22,8 +22,9 @@
#include <string>
-#define STRINGIFY(x) #x
-#define EXPAND(x) STRINGIFY(x)
+// Not using the command-line defined macro here because this header could be included by
+// device-specific recovery libraries. We static assert the value consistency in recovery.cpp.
+static constexpr int kRecoveryApiVersion = 3;
class RecoveryUI;
diff --git a/install.cpp b/install.cpp
index 586dbbe2c..507161c2e 100644
--- a/install.cpp
+++ b/install.cpp
@@ -290,7 +290,7 @@ int update_binary_command(const std::string& package, ZipArchiveHandle zip,
*cmd = {
binary_path,
- EXPAND(RECOVERY_API_VERSION), // defined in Android.mk
+ std::to_string(kRecoveryApiVersion),
std::to_string(status_fd),
package,
};
diff --git a/recovery.cpp b/recovery.cpp
index 6f62ff17c..d037b7971 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -125,6 +125,10 @@ static const int BATTERY_WITH_CHARGER_OK_PERCENTAGE = 15;
static constexpr const char* RECOVERY_WIPE = "/etc/recovery.wipe";
static constexpr const char* DEFAULT_LOCALE = "en-US";
+// We define RECOVERY_API_VERSION in Android.mk, which will be picked up by build system and packed
+// into target_files.zip. Assert the version defined in code and in Android.mk are consistent.
+static_assert(kRecoveryApiVersion == RECOVERY_API_VERSION, "Mismatching recovery API versions.");
+
static std::string locale;
static bool has_cache = false;
@@ -1498,7 +1502,7 @@ int main(int argc, char **argv) {
property_list(print_property, NULL);
printf("\n");
- ui->Print("Supported API: %d\n", RECOVERY_API_VERSION);
+ ui->Print("Supported API: %d\n", kRecoveryApiVersion);
int status = INSTALL_SUCCESS;