Guard uprobestats behind a flag.
Test: m uprobestats
Bug: 296108553
Change-Id: I712692484112fb8a99727b144afc8cf3aed7f77b
diff --git a/src/Android.bp b/src/Android.bp
index cf30962..bb76e77 100644
--- a/src/Android.bp
+++ b/src/Android.bp
@@ -2,6 +2,17 @@
default_applicable_licenses: ["Android-Apache-2.0"],
}
+aconfig_declarations {
+ name: "uprobestats_flags",
+ package: "android.uprobestats.flags",
+ srcs: ["flag.aconfig"],
+}
+
+cc_aconfig_library {
+ name: "uprobestats_flags_c_lib",
+ aconfig_declarations: "uprobestats_flags",
+}
+
cc_library {
name: "libuprobestats",
srcs: [
@@ -29,6 +40,7 @@
static_libs: [
"libc++fs",
"libuprobestats",
+ "uprobestats_flags_c_lib",
],
shared_libs: [
"libbase",
diff --git a/src/UprobeStats.cpp b/src/UprobeStats.cpp
index 1a84e05..3f0a420 100644
--- a/src/UprobeStats.cpp
+++ b/src/UprobeStats.cpp
@@ -20,6 +20,7 @@
#include <android-base/logging.h>
#include <android-base/parseint.h>
#include <android-base/strings.h>
+#include <android_uprobestats_flags.h>
#include <string>
@@ -47,7 +48,12 @@
}
int main(int argc, char **argv) {
+ if (!android::uprobestats::flags::enable_uprobestats()) {
+ LOG(ERROR) << "uprobestats disabled by flag. Exiting.";
+ return 1;
+ }
if (argc < 2) {
+ LOG(ERROR) << "Not enough command line arguments. Exiting.";
return 1;
}
std::string filename;
diff --git a/src/flag.aconfig b/src/flag.aconfig
new file mode 100644
index 0000000..3c0c71c
--- /dev/null
+++ b/src/flag.aconfig
@@ -0,0 +1,9 @@
+package: "android.uprobestats.flags"
+
+flag {
+ name: "enable_uprobestats"
+ namespace: "system_performance"
+ description: "Whether to enable uprobestats."
+ bug: "296108553"
+ is_fixed_read_only: true
+}