summaryrefslogtreecommitdiffstats
path: root/liblog/log_is_loggable.c
diff options
context:
space:
mode:
authorMark Salyzyn <salyzyn@google.com>2016-03-25 15:50:46 -0700
committerMark Salyzyn <salyzyn@google.com>2016-03-29 13:52:21 -0700
commit7ef5249afacffe3901e3a602372c7d34cf655675 (patch)
tree608776f5c0e1444cdacd32a106ba91b7ea198605 /liblog/log_is_loggable.c
parentfbdbf100cb48f18d308c96f1959945cf7d1909ec (diff)
downloadsystem_core-7ef5249afacffe3901e3a602372c7d34cf655675.tar.gz
system_core-7ef5249afacffe3901e3a602372c7d34cf655675.tar.bz2
system_core-7ef5249afacffe3901e3a602372c7d34cf655675.zip
liblog: suppress pmsg on user builds
- add optimized & cached LIBLOG_HIDDEN __android_log_is_debuggable() - check when writing, either LOG_ID_SECURITY, SafetyNet or debuggable when pushing content to the pmsg buffer. Bug: 27566046 Change-Id: I85f1b55ec329b38e00f4183836b6ed53046c323d
Diffstat (limited to 'liblog/log_is_loggable.c')
-rw-r--r--liblog/log_is_loggable.c31
1 files changed, 31 insertions, 0 deletions
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,
return logLevel >= 0 && prio >= logLevel;
}
+LIBLOG_HIDDEN int __android_log_is_debuggable()
+{
+ static uint32_t serial;
+ static struct cache tag_cache;
+ static const char key[] = "ro.debuggable";
+ int ret;
+
+ if (tag_cache.c) { /* ro property does not change after set */
+ ret = tag_cache.c == '1';
+ } else if (lock()) {
+ struct cache temp_cache = { NULL, -1, '\0' };
+ refresh_cache(&temp_cache, key);
+ ret = temp_cache.c == '1';
+ } else {
+ int change_detected = check_cache(&tag_cache);
+ uint32_t current_serial = __system_property_area_serial();
+ if (current_serial != serial) {
+ change_detected = 1;
+ }
+ if (change_detected) {
+ refresh_cache(&tag_cache, key);
+ serial = current_serial;
+ }
+ ret = tag_cache.c == '1';
+
+ unlock();
+ }
+
+ return ret;
+}
+
/*
* For properties that are read often, but generally remain constant.
* Since a change is rare, we will accept a trylock failure gracefully.