Add a version of update engine that does not send stats
update_engine_nostats has the same functionality as the update_engine
but without interaction with statsd libraires and without build
dependency on it.
Test: Apply an upadte to an aosp cf vm - note that merge stats are
reported in logcat.
Replace update engine with the nostats service in the product
packages and apply an update - note that stats reporting is
skipped.
Bug: 328227527
Change-Id: Iba87119838ecb9bdd8c94f8a913ec0d6e86a26d1
diff --git a/Android.bp b/Android.bp
index 62afe09..4e5f6f5 100644
--- a/Android.bp
+++ b/Android.bp
@@ -422,6 +422,16 @@
}
cc_library_static {
+ name: "libupdate_engine_boot_control_nostats",
+ cflags: ["-DUE_DISABLE_STATS"],
+ defaults: [
+ "libupdate_engine_boot_control_defaults",
+ "libupdate_engine_boot_control_exports",
+ "libpayload_consumer_exports",
+ ],
+}
+
+cc_library_static {
name: "libupdate_engine_boot_control_proto-full",
defaults: [
"libupdate_engine_boot_control_defaults",
@@ -564,6 +574,43 @@
init_rc: ["update_engine.rc"],
}
+// update_engine_nostats (type: executable)
+// ========================================================
+// update_engine daemon version without the stats integration.
+cc_binary {
+ name: "update_engine_nostats",
+ defaults: [
+ "ue_defaults",
+ "libupdate_engine_android_exports",
+ ],
+
+ static_libs: [
+ "libupdate_engine_android",
+ "libgflags",
+ "libupdate_engine_boot_control_nostats",
+ ],
+ required: [
+ "cacerts",
+ "otacerts",
+ ],
+
+ exclude_static_libs: [
+ "libstatslog_ue",
+ "libupdate_engine_boot_control"
+ ],
+
+ exclude_shared_libs: [
+ "libstatssocket",
+ ],
+
+ cflags: ["-DUE_DISABLE_STATS"],
+ srcs: [
+ "main.cc",
+ "common/metrics_reporter_stub.cc",
+ ],
+ init_rc: ["update_engine_nostats.rc"],
+}
+
// update_engine_sideload (type: executable)
// ========================================================
// A binary executable equivalent to update_engine daemon that installs an update
@@ -579,7 +626,10 @@
],
recovery: true,
- cflags: ["-D_UE_SIDELOAD"],
+ cflags: [
+ "-D_UE_SIDELOAD",
+ "-DUE_DISABLE_STATS",
+ ],
header_libs: ["libgtest_prod_headers"],
srcs: [
diff --git a/aosp/cleanup_previous_update_action.cc b/aosp/cleanup_previous_update_action.cc
index 3b54f80..9c0843c 100644
--- a/aosp/cleanup_previous_update_action.cc
+++ b/aosp/cleanup_previous_update_action.cc
@@ -26,7 +26,7 @@
#include <base/bind.h>
#include <libsnapshot/snapshot.h>
-#ifndef __ANDROID_RECOVERY__
+#if !defined(__ANDROID_RECOVERY__) && !defined(UE_DISABLE_STATS)
#include <statslog_ue.h>
#endif
@@ -502,6 +502,8 @@
#ifdef __ANDROID_RECOVERY__
LOG(INFO) << "Skip reporting merge stats in recovery.";
+#elif defined(UE_DISABLE_STATS)
+ LOG(INFO) << "Skip reporting merge stats because metrics are disabled.";
#else
const auto& report = result->report();
diff --git a/update_engine.rc b/update_engine.rc
index bc6447b..45f05af 100644
--- a/update_engine.rc
+++ b/update_engine.rc
@@ -1,3 +1,4 @@
+# LINT.IfChange
service update_engine /system/bin/update_engine --logtostderr --logtofile --foreground
class late_start
user root
@@ -7,3 +8,4 @@
on property:ro.boot.slot_suffix=*
enable update_engine
+# LINT.ThenChange(update_engine_nostats.rc)
diff --git a/update_engine_nostats.rc b/update_engine_nostats.rc
new file mode 100644
index 0000000..512f0eb
--- /dev/null
+++ b/update_engine_nostats.rc
@@ -0,0 +1,11 @@
+# LINT.IfChange
+service update_engine /system/bin/update_engine_nostats --logtostderr --logtofile --foreground
+ class late_start
+ user root
+ group root system wakelock inet cache media_rw
+ task_profiles OtaProfiles
+ disabled
+
+on property:ro.boot.slot_suffix=*
+ enable update_engine
+# LINT.ThenChange(update_engine.rc)