Merge "Only Log Netlink Messages on Eng Builds" into pi-dev
diff --git a/server/XfrmController.cpp b/server/XfrmController.cpp
index 8a891eb..b9a5a41 100644
--- a/server/XfrmController.cpp
+++ b/server/XfrmController.cpp
@@ -44,11 +44,6 @@
 #include <linux/xfrm.h>
 
 #define LOG_TAG "XfrmController"
-#include "android-base/stringprintf.h"
-#include "android-base/strings.h"
-#include "android-base/unique_fd.h"
-#include <android/net/INetd.h>
-#include <log/log_properties.h>
 #include "InterfaceController.h"
 #include "NetdConstants.h"
 #include "NetlinkCommands.h"
@@ -57,6 +52,11 @@
 #include "netdutils/Fd.h"
 #include "netdutils/Slice.h"
 #include "netdutils/Syscalls.h"
+#include <android-base/properties.h>
+#include <android-base/stringprintf.h>
+#include <android-base/strings.h>
+#include <android-base/unique_fd.h>
+#include <android/net/INetd.h>
 #include <cutils/log.h>
 #include <cutils/properties.h>
 #include <logwrap/logwrap.h>
@@ -87,6 +87,11 @@
 
 constexpr uint32_t INVALID_SPI = 0;
 
+static inline bool isEngBuild() {
+    static const std::string sBuildType = android::base::GetProperty("ro.build.type", "user");
+    return sBuildType == "eng";
+}
+
 #define XFRM_MSG_TRANS(x)                                                                          \
     case x:                                                                                        \
         return #x;
@@ -126,18 +131,18 @@
 void* kPadBytes = static_cast<void*>(kPadBytesArray);
 
 #define LOG_HEX(__desc16__, __buf__, __len__)                                                      \
-    if (__android_log_is_debuggable()) {                                                           \
-        do {                                                                                       \
+    do {                                                                                           \
+        if (isEngBuild()) {                                                                        \
             logHex(__desc16__, __buf__, __len__);                                                  \
-        } while (0);                                                                               \
-    }
+        }                                                                                          \
+    } while (0)
 
 #define LOG_IOV(__iov__)                                                                           \
-    if (__android_log_is_debuggable()) {                                                           \
-        do {                                                                                       \
+    do {                                                                                           \
+        if (isEngBuild()) {                                                                        \
             logIov(__iov__);                                                                       \
-        } while (0);                                                                               \
-    }
+        }                                                                                          \
+    } while (0)
 
 void logHex(const char* desc16, const char* buf, size_t len) {
     char* printBuf = new char[len * 2 + 1 + 26]; // len->ascii, +newline, +prefix strlen