Revert^2 "[metrics] Report CompilationReason and CompilerFilter"

Since we do not know the real primary OAT file when the runtime starts
up, we have to wait until NotifyStartupCompleted to be sure we have
the right one. To accomodate this, we delay starting the metrics
session until the first report and then send updated session
information in NotifyStartupCompleted.

Note that we could delay the whole metrics reporting initialization to
NotifyStartupCompleted, but this doesn't get called in all
circumstances, which would mean metrics reporting is disabled in cases
where we want it.

This reverts commit 8b07c653a7e45886ee92d8a12aa439e98e84befa.

Reason for revert: Fixing crash

The bug was get GetPrimaryOatFile could return null in some cases, but
we were not handling this correctly.

Bug: 178239096
Test: manual
Change-Id: I468837ee8f026edd82c47bd216ddb5b2d9c2ece3
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 6e7167d..e690d55 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -3063,6 +3063,14 @@
   ProfileSaver::NotifyStartupCompleted();
 
   if (metrics_reporter_ != nullptr) {
+    const OatFile* primary_oat_file = oat_file_manager_->GetPrimaryOatFile();
+    if (primary_oat_file != nullptr) {
+      const char* compilation_reason = primary_oat_file->GetCompilationReason();
+      metrics_reporter_->SetCompilationInfo(
+          compilation_reason != nullptr ? metrics::CompilationReasonFromName(compilation_reason) :
+                                          metrics::CompilationReason::kUnknown,
+          primary_oat_file->GetCompilerFilter());
+    }
     metrics_reporter_->NotifyStartupCompleted();
   }
 }