fastboot: Hide bootloader/baseband/hw versions if empty

Change-Id: I557957da2a13a2c64b76f6126409363334af7a93
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index d905093..898d15c 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -25,6 +25,7 @@
 
 #include <android-base/logging.h>
 #include <android-base/properties.h>
+#include <android-base/strings.h>
 #include <bootloader_message/bootloader_message.h>
 
 #include "recovery_ui/ui.h"
@@ -39,15 +40,23 @@
 Device::BuiltinAction StartFastboot(Device* device, const std::vector<std::string>& /* args */) {
   RecoveryUI* ui = device->GetUI();
 
+  std::string bootloader_version = android::base::GetProperty("ro.bootloader", "");
+  std::string baseband_version = android::base::GetProperty("ro.build.expect.baseband", "");
+  std::string hw_version = android::base::GetProperty("ro.revision", "");
   std::vector<std::string> title_lines;
   title_lines.push_back("Product name - " + android::base::GetProperty("ro.product.device", ""));
-  title_lines.push_back("Bootloader version - " + android::base::GetProperty("ro.bootloader", ""));
-  title_lines.push_back("Baseband version - " +
-                        android::base::GetProperty("ro.build.expect.baseband", ""));
+  if (!android::base::EqualsIgnoreCase(bootloader_version, "unknown")) {
+    title_lines.push_back("Bootloader version - " + bootloader_version);
+  }
+  if (!baseband_version.empty()) {
+    title_lines.push_back("Baseband version - " + baseband_version);
+  }
   title_lines.push_back("Serial number - " + android::base::GetProperty("ro.serialno", ""));
   title_lines.push_back(std::string("Secure boot - ") +
                         ((android::base::GetProperty("ro.secure", "") == "1") ? "yes" : "no"));
-  title_lines.push_back("HW version - " + android::base::GetProperty("ro.revision", ""));
+  if (!android::base::EqualsIgnoreCase(hw_version, "0")) {
+    title_lines.push_back("HW version - " + hw_version);
+  }
 
   ui->ResetKeyInterruptStatus();
   ui->SetTitle(title_lines);