Remove EXPAND/STRINGIFY macros.

This reverts commit 8be0f39fec7f26164fd0791ff6d15bde65fc849c to reland
the change that removes EXPAND/STRINGIFY macros.

It's error-prone by putting anything into a string (e.g.
EXPAND(RECOVERY_API_VERSION) would become "RECOVER_API_VERSION" if we
forgot to pass -DRECOVERY_API_VERSION=3).

The initial attempt put RECOVERY_API_VERSION into common.h, which might
be included by device-specific codes but without defining that when
compiling the module. This CL avoids the issue by using a constant
in the header, with a static_assert in recovery.cpp that guards the
consistency.

Test: recovery_component_test
Test: Sideload OTAs on bullhead and sailfish respectively.
Change-Id: I12af3f73392a85554ba703f04970ec9d984ccbaa
diff --git a/common.h b/common.h
index 62fb132..8b336f8 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 586dbbe..507161c 100644
--- a/install.cpp
+++ b/install.cpp
@@ -290,7 +290,7 @@
 
   *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 6f62ff1..d037b79 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -125,6 +125,10 @@
 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 @@
     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;