odrefresh: add metrics support

Adds metrics to stages of odrefresh.

Bug: 169925964
Test: atest art_odrefresh_tests
Test: atest --host art_odrefresh_tests

(cherry picked from commit 3d877f082636f26ad57c92e3aae1525faacff51b)
Merged-In: I768ce5f122b0c1b839f4cdf55aa6dafb68708eb2
Change-Id: I8355fd38c28e41b04f0ea52384061b686cb1e362
diff --git a/odrefresh/Android.bp b/odrefresh/Android.bp
index 6f84e8f..8a9acd3 100644
--- a/odrefresh/Android.bp
+++ b/odrefresh/Android.bp
@@ -30,12 +30,15 @@
     srcs: [
         "odrefresh.cc",
         "odr_fs_utils.cc",
+        "odr_metrics.cc",
+        "odr_metrics_record.cc",
     ],
     local_include_dirs: ["include"],
     header_libs: ["dexoptanalyzer_headers"],
     generated_sources: [
         "apex-info-list",
         "art-apex-cache-info",
+        "art-odrefresh-operator-srcs",
     ],
     shared_libs: [
         "libartpalette",
@@ -81,6 +84,16 @@
     visibility: ["//visibility:public"],
 }
 
+gensrcs {
+    name: "art-odrefresh-operator-srcs",
+    cmd: "$(location generate_operator_out) art/odrefresh $(in) > $(out)",
+    tools: ["generate_operator_out"],
+    srcs: [
+        "odr_metrics.h",
+    ],
+    output_extension: "operator_out.cc",
+}
+
 art_cc_binary {
     name: "odrefresh",
     defaults: ["odrefresh-defaults"],
@@ -126,16 +139,19 @@
     defaults: [
         "art_gtest_defaults",
     ],
+    generated_sources: ["art-odrefresh-operator-srcs"],
     header_libs: ["odrefresh_headers"],
     srcs: [
         "odr_artifacts_test.cc",
         "odr_fs_utils.cc",
         "odr_fs_utils_test.cc",
+        "odr_metrics.cc",
+        "odr_metrics_test.cc",
+        "odr_metrics_record.cc",
+        "odr_metrics_record_test.cc",
         "odrefresh_test.cc",
     ],
-    shared_libs: [
-        "libbase",
-    ],
+    shared_libs: ["libbase"],
 }
 
 xsd_config {