summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2016-03-31 16:07:32 -0500
committerandroid-build-merger2016-03-31 16:07:32 -0500
commit33aecaa7843d6d6df2c426e6360c13eb52812bb9 (patch)
tree5969a1c7ec8b68761964b7e36cabae3d24f9fe09
parent35b004a56d11bda773c48b80d7f26b33e5e6eada (diff)
parent24967e5f5e87e5079f416d3cbc3d6a5dba7e8865 (diff)
downloadplatform-system-core-33aecaa7843d6d6df2c426e6360c13eb52812bb9.tar.gz
platform-system-core-33aecaa7843d6d6df2c426e6360c13eb52812bb9.tar.xz
platform-system-core-33aecaa7843d6d6df2c426e6360c13eb52812bb9.zip
Merge "liblog: suppress pmsg on user builds" am: 0858071
am: 24967e5 * commit '24967e5f5e87e5079f416d3cbc3d6a5dba7e8865': liblog: suppress pmsg on user builds Change-Id: Ic4f2c02e227ee3c0dc29eb11757dc024aae3b950
-rw-r--r--liblog/Android.bp1
-rw-r--r--liblog/Android.mk1
-rw-r--r--liblog/log_is_loggable.c31
-rw-r--r--liblog/logger.h1
-rw-r--r--liblog/pmsg_writer.c23
5 files changed, 57 insertions, 0 deletions
diff --git a/liblog/Android.bp b/liblog/Android.bp
index 9e8491b72..9c68fcae1 100644
--- a/liblog/Android.bp
+++ b/liblog/Android.bp
@@ -84,6 +84,7 @@ cc_library {
84 // $(LOCAL_PATH)/event.logtags) 84 // $(LOCAL_PATH)/event.logtags)
85 // so make sure we do not regret hard-coding it as follows: 85 // so make sure we do not regret hard-coding it as follows:
86 "-DLIBLOG_LOG_TAG=1005", 86 "-DLIBLOG_LOG_TAG=1005",
87 "-DSNET_EVENT_LOG_TAG=1397638484",
87 ], 88 ],
88 compile_multilib: "both", 89 compile_multilib: "both",
89 stl: "none", 90 stl: "none",
diff --git a/liblog/Android.mk b/liblog/Android.mk
index 01c8e77b2..b24b489aa 100644
--- a/liblog/Android.mk
+++ b/liblog/Android.mk
@@ -23,6 +23,7 @@ include $(CLEAR_VARS)
23# $(LOCAL_PATH)/event.logtags) 23# $(LOCAL_PATH)/event.logtags)
24# so make sure we do not regret hard-coding it as follows: 24# so make sure we do not regret hard-coding it as follows:
25liblog_cflags := -DLIBLOG_LOG_TAG=1005 25liblog_cflags := -DLIBLOG_LOG_TAG=1005
26liblog_cflags += -DSNET_EVENT_LOG_TAG=1397638484
26 27
27liblog_sources := log_event_list.c log_event_write.c logger_write.c 28liblog_sources := log_event_list.c log_event_write.c logger_write.c
28liblog_sources += config_write.c logger_name.c logger_lock.c 29liblog_sources += config_write.c logger_name.c logger_lock.c
diff --git a/liblog/log_is_loggable.c b/liblog/log_is_loggable.c
index 551fa7684..79a567051 100644
--- a/liblog/log_is_loggable.c
+++ b/liblog/log_is_loggable.c
@@ -259,6 +259,37 @@ LIBLOG_ABI_PUBLIC int __android_log_is_loggable(int prio, const char *tag,
259 return logLevel >= 0 && prio >= logLevel; 259 return logLevel >= 0 && prio >= logLevel;
260} 260}
261 261
262LIBLOG_HIDDEN int __android_log_is_debuggable()
263{
264 static uint32_t serial;
265 static struct cache tag_cache;
266 static const char key[] = "ro.debuggable";
267 int ret;
268
269 if (tag_cache.c) { /* ro property does not change after set */
270 ret = tag_cache.c == '1';
271 } else if (lock()) {
272 struct cache temp_cache = { NULL, -1, '\0' };
273 refresh_cache(&temp_cache, key);
274 ret = temp_cache.c == '1';
275 } else {
276 int change_detected = check_cache(&tag_cache);
277 uint32_t current_serial = __system_property_area_serial();
278 if (current_serial != serial) {
279 change_detected = 1;
280 }
281 if (change_detected) {
282 refresh_cache(&tag_cache, key);
283 serial = current_serial;
284 }
285 ret = tag_cache.c == '1';
286
287 unlock();
288 }
289
290 return ret;
291}
292
262/* 293/*
263 * For properties that are read often, but generally remain constant. 294 * For properties that are read often, but generally remain constant.
264 * Since a change is rare, we will accept a trylock failure gracefully. 295 * Since a change is rare, we will accept a trylock failure gracefully.
diff --git a/liblog/logger.h b/liblog/logger.h
index 5d031d79f..c727f294a 100644
--- a/liblog/logger.h
+++ b/liblog/logger.h
@@ -154,6 +154,7 @@ LIBLOG_HIDDEN pid_t __android_log_pid();
154LIBLOG_HIDDEN void __android_log_lock(); 154LIBLOG_HIDDEN void __android_log_lock();
155LIBLOG_HIDDEN int __android_log_trylock(); 155LIBLOG_HIDDEN int __android_log_trylock();
156LIBLOG_HIDDEN void __android_log_unlock(); 156LIBLOG_HIDDEN void __android_log_unlock();
157LIBLOG_HIDDEN int __android_log_is_debuggable();
157 158
158__END_DECLS 159__END_DECLS
159 160
diff --git a/liblog/pmsg_writer.c b/liblog/pmsg_writer.c
index 7034cebaa..9cd3c48ff 100644
--- a/liblog/pmsg_writer.c
+++ b/liblog/pmsg_writer.c
@@ -73,6 +73,11 @@ static int pmsgAvailable(log_id_t logId)
73 if (logId > LOG_ID_SECURITY) { 73 if (logId > LOG_ID_SECURITY) {
74 return -EINVAL; 74 return -EINVAL;
75 } 75 }
76 if ((logId != LOG_ID_SECURITY) &&
77 (logId != LOG_ID_EVENTS) &&
78 !__android_log_is_debuggable()) {
79 return -EINVAL;
80 }
76 if (pmsgLoggerWrite.context.fd < 0) { 81 if (pmsgLoggerWrite.context.fd < 0) {
77 if (access("/dev/pmsg0", W_OK) == 0) { 82 if (access("/dev/pmsg0", W_OK) == 0) {
78 return 0; 83 return 0;
@@ -82,6 +87,14 @@ static int pmsgAvailable(log_id_t logId)
82 return 1; 87 return 1;
83} 88}
84 89
90/*
91 * Extract a 4-byte value from a byte stream.
92 */
93static inline uint32_t get4LE(const uint8_t* src)
94{
95 return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
96}
97
85static int pmsgWrite(log_id_t logId, struct timespec *ts, 98static int pmsgWrite(log_id_t logId, struct timespec *ts,
86 struct iovec *vec, size_t nr) 99 struct iovec *vec, size_t nr)
87{ 100{
@@ -92,6 +105,16 @@ static int pmsgWrite(log_id_t logId, struct timespec *ts,
92 size_t i, payloadSize; 105 size_t i, payloadSize;
93 ssize_t ret; 106 ssize_t ret;
94 107
108 if ((logId == LOG_ID_EVENTS) && !__android_log_is_debuggable()) {
109 if (vec[0].iov_len < 4) {
110 return -EINVAL;
111 }
112
113 if (SNET_EVENT_LOG_TAG != get4LE(vec[0].iov_base)) {
114 return -EPERM;
115 }
116 }
117
95 if (pmsgLoggerWrite.context.fd < 0) { 118 if (pmsgLoggerWrite.context.fd < 0) {
96 return -EBADF; 119 return -EBADF;
97 } 120 }