Add GetPrintableBuildID().

The GetBuildID() function returns the raw build id data, so add a function
to get the printable hex version of the data.

Bug: 120606663

Test: New unit tests pass.
Change-Id: Ia5aefc97457efb08bbd30ea96cbb2d47ae59f954
diff --git a/libunwindstack/MapInfo.cpp b/libunwindstack/MapInfo.cpp
index f319971..9e6bcd4 100644
--- a/libunwindstack/MapInfo.cpp
+++ b/libunwindstack/MapInfo.cpp
@@ -22,6 +22,8 @@
 #include <mutex>
 #include <string>
 
+#include <android-base/stringprintf.h>
+
 #include <unwindstack/Elf.h>
 #include <unwindstack/MapInfo.h>
 #include <unwindstack/Maps.h>
@@ -311,4 +313,16 @@
   return *reinterpret_cast<std::string*>(id);
 }
 
+std::string MapInfo::GetPrintableBuildID() {
+  std::string raw_build_id = GetBuildID();
+  if (raw_build_id.empty()) {
+    return "";
+  }
+  std::string printable_build_id;
+  for (const char& c : raw_build_id) {
+    printable_build_id += android::base::StringPrintf("%02x", c);
+  }
+  return printable_build_id;
+}
+
 }  // namespace unwindstack