system/corennnnn
Révision | f894b96a9211dcefb83b175720b53a2e49b8e463 (tree) |
---|---|
l'heure | 2016-08-23 05:02:45 |
Auteur | Tim Murray <timmurray@goog...> |
Commiter | Tim Murray |
Restrict pmsg use to eng builds.
bug 30375418
Change-Id: I50c6c74a2373593495cf6a3b94b31f9a865c950c
@@ -31,6 +31,8 @@ | ||
31 | 31 | #include <private/android_filesystem_config.h> |
32 | 32 | #include <private/android_logger.h> |
33 | 33 | |
34 | +#include <sys/system_properties.h> | |
35 | + | |
34 | 36 | #include "config_write.h" |
35 | 37 | #include "log_portability.h" |
36 | 38 | #include "logger.h" |
@@ -51,8 +53,25 @@ LIBLOG_HIDDEN struct android_log_transport_write pmsgLoggerWrite = { | ||
51 | 53 | .write = pmsgWrite, |
52 | 54 | }; |
53 | 55 | |
56 | +static bool pmsgShouldUse = false; | |
57 | + | |
58 | +// Only use pmsg on eng builds | |
59 | +static bool pmsgIsEng() { | |
60 | + char buf[PROP_VALUE_MAX]; | |
61 | + | |
62 | + if (__system_property_get("ro.build.type", buf) == 0) { | |
63 | + return false; | |
64 | + } | |
65 | + | |
66 | + if (!strncmp(buf, "eng", sizeof("eng"))) { | |
67 | + return true; | |
68 | + } | |
69 | + return false; | |
70 | +} | |
71 | + | |
54 | 72 | static int pmsgOpen() |
55 | 73 | { |
74 | + pmsgShouldUse = pmsgIsEng(); | |
56 | 75 | if (pmsgLoggerWrite.context.fd < 0) { |
57 | 76 | pmsgLoggerWrite.context.fd = TEMP_FAILURE_RETRY(open("/dev/pmsg0", O_WRONLY | O_CLOEXEC)); |
58 | 77 | } |
@@ -75,7 +94,7 @@ static int pmsgAvailable(log_id_t logId) | ||
75 | 94 | } |
76 | 95 | if ((logId != LOG_ID_SECURITY) && |
77 | 96 | (logId != LOG_ID_EVENTS) && |
78 | - !__android_log_is_debuggable()) { | |
97 | + (!pmsgShouldUse || !__android_log_is_debuggable())) { | |
79 | 98 | return -EINVAL; |
80 | 99 | } |
81 | 100 | if (pmsgLoggerWrite.context.fd < 0) { |
@@ -105,7 +124,7 @@ static int pmsgWrite(log_id_t logId, struct timespec *ts, | ||
105 | 124 | size_t i, payloadSize; |
106 | 125 | ssize_t ret; |
107 | 126 | |
108 | - if ((logId == LOG_ID_EVENTS) && !__android_log_is_debuggable()) { | |
127 | + if ((logId == LOG_ID_EVENTS) && (!pmsgShouldUse || !__android_log_is_debuggable())) { | |
109 | 128 | if (vec[0].iov_len < 4) { |
110 | 129 | return -EINVAL; |
111 | 130 | } |