summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Murray <timmurray@google.com>2016-08-22 20:19:19 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-08-22 20:19:19 +0000
commit67ea7311f0933ed47e2e4cd406c469699f60d63c (patch)
treec2f79922df0aa6ba1856f98caf23efbb4754e223
parentaf8d67e0327a03dfa5411caa96a913402824ecdf (diff)
parentf894b96a9211dcefb83b175720b53a2e49b8e463 (diff)
Merge "Restrict pmsg use to eng builds." into nyc-dr1-dev
-rw-r--r--liblog/pmsg_writer.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/liblog/pmsg_writer.c b/liblog/pmsg_writer.c
index 944febae8..b338dca4c 100644
--- a/liblog/pmsg_writer.c
+++ b/liblog/pmsg_writer.c
@@ -31,6 +31,8 @@
#include <private/android_filesystem_config.h>
#include <private/android_logger.h>
+#include <sys/system_properties.h>
+
#include "config_write.h"
#include "log_portability.h"
#include "logger.h"
@@ -51,8 +53,25 @@ LIBLOG_HIDDEN struct android_log_transport_write pmsgLoggerWrite = {
.write = pmsgWrite,
};
+static bool pmsgShouldUse = false;
+
+// Only use pmsg on eng builds
+static bool pmsgIsEng() {
+ char buf[PROP_VALUE_MAX];
+
+ if (__system_property_get("ro.build.type", buf) == 0) {
+ return false;
+ }
+
+ if (!strncmp(buf, "eng", sizeof("eng"))) {
+ return true;
+ }
+ return false;
+}
+
static int pmsgOpen()
{
+ pmsgShouldUse = pmsgIsEng();
if (pmsgLoggerWrite.context.fd < 0) {
pmsgLoggerWrite.context.fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY | O_CLOEXEC));
}
@@ -75,7 +94,7 @@ static int pmsgAvailable(log_id_t logId)
}
if ((logId != LOG_ID_SECURITY) &&
(logId != LOG_ID_EVENTS) &&
- !__android_log_is_debuggable()) {
+ (!pmsgShouldUse || !__android_log_is_debuggable())) {
return -EINVAL;
}
if (pmsgLoggerWrite.context.fd < 0) {
@@ -105,7 +124,7 @@ static int pmsgWrite(log_id_t logId, struct timespec *ts,
size_t i, payloadSize;
ssize_t ret;
- if ((logId == LOG_ID_EVENTS) && !__android_log_is_debuggable()) {
+ if ((logId == LOG_ID_EVENTS) && (!pmsgShouldUse || !__android_log_is_debuggable())) {
if (vec[0].iov_len < 4) {
return -EINVAL;
}