diff options
author | Pirama Arumuga Nainar <pirama@google.com> | 2019-06-04 15:33:45 -0700 |
---|---|---|
committer | Oliver Nguyen <olivernguyen@google.com> | 2020-01-27 15:45:30 -0800 |
commit | 6d9db09a456950c168b10a8cddd6f2198206c710 (patch) | |
tree | 47abea5124cdc3b5113979769679bc75c4bc0523 | |
parent | 2b1bdd1079b035c1023db310f31fe52793c8cd9c (diff) | |
download | extras-6d9db09a456950c168b10a8cddd6f2198206c710.tar.gz |
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
Merged-In: Id8f0ceab133b961219b1cf77ae02b00eba4cfaf5
(cherry picked from commit 5b9defd41d61b000c82c84662f02394e89192d93)
-rw-r--r-- | toolchain-extras/profile-extras.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
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 |