recovery: Properly detect userdebug or eng builds

The recovery system behaves a little bit differently on userdebug or
eng builds by presenting error reports to the user in the ui.
This is controlled by checking the build fingerprint for the string
:userdebug/ or :eng/. But with AOSP version numbers most AOSP
builds blows the 92 char limit of ro.build.fingerprint and therefore
the property is not set, so this condition will always be evaluated
to false, for most builds.

Instead of depending on the flaky ro.build.fingerprint this change
uses ro.debuggable.

Change-Id: I74bc00c655ac596aaf4b488ecea58f0a8de9c26b
diff --git a/adb_install.cpp b/adb_install.cpp
index be3b9a0..e328960 100644
--- a/adb_install.cpp
+++ b/adb_install.cpp
@@ -61,9 +61,7 @@
 
 static void
 maybe_restart_adbd() {
-    char value[PROPERTY_VALUE_MAX+1];
-    int len = property_get("ro.debuggable", value, NULL);
-    if (len == 1 && value[0] == '1') {
+    if (is_ro_debuggable()) {
         ui->Print("Restarting adbd...\n");
         set_usb_driver(true);
         property_set("ctl.start", "adbd");
diff --git a/common.h b/common.h
index 768f499..4f1c099 100644
--- a/common.h
+++ b/common.h
@@ -17,6 +17,7 @@
 #ifndef RECOVERY_COMMON_H
 #define RECOVERY_COMMON_H
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdarg.h>
 
@@ -46,6 +47,8 @@
 
 void ui_print(const char* format, ...);
 
+bool is_ro_debuggable();
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/recovery.cpp b/recovery.cpp
index 7f17b16..d8756d7 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -161,6 +161,11 @@
     return fp;
 }
 
+bool is_ro_debuggable() {
+    char value[PROPERTY_VALUE_MAX+1];
+    return (property_get("ro.debuggable", value, NULL) == 1 && value[0] == '1');
+}
+
 // close a file, log an error if the error indicator is set
 static void
 check_and_fclose(FILE *fp, const char *name) {
@@ -954,9 +959,7 @@
             // If this is an eng or userdebug build, then automatically
             // turn the text display on if the script fails so the error
             // message is visible.
-            char buffer[PROPERTY_VALUE_MAX+1];
-            property_get("ro.build.fingerprint", buffer, "");
-            if (strstr(buffer, ":userdebug/") || strstr(buffer, ":eng/")) {
+            if (is_ro_debuggable()) {
                 ui->ShowText(true);
             }
         }