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)
diff --git a/toolchain-extras/profile-extras.cpp b/toolchain-extras/profile-extras.cpp
index f999a6b..cdb19e8 100644
--- a/toolchain-extras/profile-extras.cpp
+++ b/toolchain-extras/profile-extras.cpp
@@ -67,6 +67,18 @@
}
}
+#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 @@
// 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