From 5b9defd41d61b000c82c84662f02394e89192d93 Mon Sep 17 00:00:00 2001 From: Pirama Arumuga Nainar Date: Tue, 4 Jun 2019 15:33:45 -0700 Subject: Refactor property-watch optout logic Bug: http://b/116873221 Refactor the processes without property-watch thread into a list. Test: Build cuttlefish with coverage Change-Id: Id8f0ceab133b961219b1cf77ae02b00eba4cfaf5 --- toolchain-extras/profile-extras.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'toolchain-extras') diff --git a/toolchain-extras/profile-extras.cpp b/toolchain-extras/profile-extras.cpp index f999a6b2..cdb19e8f 100644 --- a/toolchain-extras/profile-extras.cpp +++ b/toolchain-extras/profile-extras.cpp @@ -67,6 +67,18 @@ void *property_watch_loop(__unused void *arg) { } } +#if defined(__ANDROID_API__) && __ANDROID_API__ >= __ANDROID_API_L__ +static char prop_watch_disabled_procs[][128] = { + "zygote", + "zygote32", + "app_process", + "app_process32", +}; + +static size_t prop_watch_num_disabled_procs = \ + sizeof(prop_watch_disabled_procs) / sizeof(prop_watch_disabled_procs[0]); +#endif + __attribute__((weak)) int init_profile_extras_once = 0; // Initialize libprofile-extras: @@ -98,11 +110,10 @@ __attribute__((constructor)) int init_profile_extras(void) { // getprogname() was added. #if defined(__ANDROID_API__) && __ANDROID_API__ >= __ANDROID_API_L__ const char *prog_basename = basename(getprogname()); - if (strncmp(prog_basename, "zygote", strlen("zygote")) == 0) { - return 0; - } - if (strncmp(prog_basename, "app_process", strlen("app_process")) == 0) { - return 0; + for (size_t i = 0; i < prop_watch_num_disabled_procs; i ++) { + if (strcmp(prog_basename, prop_watch_disabled_procs[i]) == 0) { + return 0; + } } #endif -- cgit v1.2.3