Refactor upload-only to process bazel metrics outside of upload.go

Bug: 279987768
Test: m nothing
Test: b build libcore:all (with prints to verify similiar data)
Change-Id: I01d960a7215be30728c9e90f52c2455fd21cf1b8
diff --git a/cmd/soong_ui/main.go b/cmd/soong_ui/main.go
index bd774c6..1c6aaad 100644
--- a/cmd/soong_ui/main.go
+++ b/cmd/soong_ui/main.go
@@ -99,7 +99,7 @@
 		// Upload-only mode mostly skips to the metrics-uploading phase of soong_ui.
 		// However, this invocation marks the true "end of the build", and thus we
 		// need to update the total runtime of the build to include this upload step.
-		run: updateTotalRealTime,
+		run: finalizeBazelMetrics,
 	},
 }
 
@@ -203,8 +203,6 @@
 	bazelMetricsFile := filepath.Join(logsDir, c.logsPrefix+"bazel_metrics.pb")
 	soongBuildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_build_metrics.pb")
 
-	//the profile file generated by Bazel"
-	bazelProfileFile := filepath.Join(logsDir, c.logsPrefix+"analyzed_bazel_profile.txt")
 	metricsFiles := []string{
 		buildErrorFile,           // build error strings
 		rbeMetricsFile,           // high level metrics related to remote build execution.
@@ -226,7 +224,7 @@
 		criticalPath.WriteToMetrics(met)
 		met.Dump(soongMetricsFile)
 		if !config.SkipMetricsUpload() {
-			build.UploadMetrics(buildCtx, config, c.simpleOutput, buildStarted, bazelProfileFile, bazelMetricsFile, metricsFiles...)
+			build.UploadMetrics(buildCtx, config, c.simpleOutput, buildStarted, metricsFiles...)
 		}
 	}()
 	c.run(buildCtx, config, args)
@@ -692,6 +690,15 @@
 	}
 }
 
+func finalizeBazelMetrics(ctx build.Context, config build.Config, args []string) {
+	updateTotalRealTime(ctx, config, args)
+
+	logsDir := config.LogsDir()
+	logsPrefix := config.GetLogsPrefix()
+	bazelMetricsFile := filepath.Join(logsDir, logsPrefix+"bazel_metrics.pb")
+	bazelProfileFile := filepath.Join(logsDir, logsPrefix+"analyzed_bazel_profile.txt")
+	build.ProcessBazelMetrics(bazelProfileFile, bazelMetricsFile, ctx, config)
+}
 func updateTotalRealTime(ctx build.Context, config build.Config, args []string) {
 	soongMetricsFile := filepath.Join(config.LogsDir(), "soong_metrics")