From c19588cfc81e4e464040a2a556fc970f5039cc3b Mon Sep 17 00:00:00 2001 From: sergeyv Date: Thu, 28 Apr 2016 19:33:09 -0700 Subject: [PATCH] atrace: read package names from multiple sysprops bug: 28200530 Change-Id: I4597a84f4fb16098b0e57684cde5e57c1f41eed5 --- libcutils/trace-dev.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/libcutils/trace-dev.c b/libcutils/trace-dev.c index 5df1c5a90..778e4f03b 100644 --- a/libcutils/trace-dev.c +++ b/libcutils/trace-dev.c @@ -66,24 +66,17 @@ void atrace_set_tracing_enabled(bool enabled) // values listed in the app_cmdlines property. static bool atrace_is_cmdline_match(const char* cmdline) { + int count = property_get_int32("debug.atrace.app_number", 0); + + char buf[PROPERTY_KEY_MAX]; char value[PROPERTY_VALUE_MAX]; - char* start = value; - property_get("debug.atrace.app_cmdlines", value, ""); - - while (start != NULL) { - char* end = strchr(start, ','); - - if (end != NULL) { - *end = '\0'; - end++; - } - - if (strcmp(cmdline, start) == 0) { + for (int i = 0; i < count; i++) { + snprintf(buf, sizeof(buf), "debug.atrace.app_%d", i); + property_get(buf, value, ""); + if (strcmp(value, cmdline) == 0) { return true; } - - start = end; } return false;