bootstat: Log the ro.boot.bootreason property through the new
platform_reason Tron field.
Bug: 63584589
Test: none
Change-Id: I369e6977c77619513eb7ce7637c1e3112e5a4b13
(cherry picked from commit 51e91f5e0b4b0d1b75dc93fa2efee85c66f6f8c0)
diff --git a/bootstat/bootstat.cpp b/bootstat/bootstat.cpp
index bd611f0..f887d46 100644
--- a/bootstat/bootstat.cpp
+++ b/bootstat/bootstat.cpp
@@ -358,7 +358,12 @@
// Records the boot_reason metric by querying the ro.boot.bootreason system
// property.
void RecordBootReason() {
- int32_t boot_reason = BootReasonStrToEnum(GetProperty("ro.boot.bootreason"));
+ std::string boot_reason_str = GetProperty("ro.boot.bootreason");
+ android::metricslogger::LogMultiAction(android::metricslogger::ACTION_BOOT,
+ android::metricslogger::FIELD_PLATFORM_REASON,
+ boot_reason_str);
+
+ int32_t boot_reason = BootReasonStrToEnum(boot_reason_str);
BootEventRecordStore boot_event_store;
boot_event_store.AddBootEventWithValue("boot_reason", boot_reason);
}
diff --git a/libmetricslogger/Android.bp b/libmetricslogger/Android.bp
index 26a041a..15d1ff2 100644
--- a/libmetricslogger/Android.bp
+++ b/libmetricslogger/Android.bp
@@ -20,10 +20,13 @@
"-Wextra",
"-Werror",
- // 524291 corresponds to sysui_histogram, from
- // frameworks/base/core/java/com/android/internal/logging/EventLogTags.logtags
- "-DHISTOGRAM_LOG_TAG=524292",
+ // The following defines map logtag IDs as represented by:
+ // frameworks/base/core/java/com/android/internal/logging/EventLogTags.logtags
+ //
+ // E.g., 524290 corresponds to sysui_count.
"-DCOUNT_LOG_TAG=524290",
+ "-DHISTOGRAM_LOG_TAG=524292",
+ "-DMULTI_ACTION_LOG_TAG=524292",
],
}
diff --git a/libmetricslogger/include/metricslogger/metrics_logger.h b/libmetricslogger/include/metricslogger/metrics_logger.h
index 36e124d..fcabcc9 100644
--- a/libmetricslogger/include/metricslogger/metrics_logger.h
+++ b/libmetricslogger/include/metricslogger/metrics_logger.h
@@ -28,14 +28,26 @@
// log buffer.
void LogCounter(const std::string& name, int32_t val);
+// Logs a Tron multi_action with category|category| containing the string
+// |value| in the field |field|.
+void LogMultiAction(int32_t category, int32_t field, const std::string& value);
+
// TODO: replace these with the metric_logger.proto definitions
enum {
LOGBUILDER_CATEGORY = 757,
+ LOGBUILDER_TYPE = 758,
LOGBUILDER_NAME = 799,
LOGBUILDER_BUCKET = 801,
LOGBUILDER_VALUE = 802,
LOGBUILDER_COUNTER = 803,
LOGBUILDER_HISTOGRAM = 804,
+
+ ACTION_BOOT = 1092,
+ FIELD_PLATFORM_REASON = 1093,
+};
+
+enum {
+ TYPE_ACTION = 4,
};
} // namespace metricslogger
diff --git a/libmetricslogger/metrics_logger.cpp b/libmetricslogger/metrics_logger.cpp
index 6f65e10..a0dcf09 100644
--- a/libmetricslogger/metrics_logger.cpp
+++ b/libmetricslogger/metrics_logger.cpp
@@ -37,5 +37,12 @@
<< val << LOG_ID_EVENTS;
}
+// Mirror com.android.internal.logging.MetricsLogger#action().
+void LogMultiAction(int32_t category, int32_t field, const std::string& value) {
+ android_log_event_list log(MULTI_ACTION_LOG_TAG);
+ log << LOGBUILDER_CATEGORY << category << LOGBUILDER_TYPE << TYPE_ACTION
+ << field << value << LOG_ID_EVENTS;
+}
+
} // namespace metricslogger
} // namespace android