Snap for 11651058 from 4d45b8613f650acb36df41a6e970a9694ae464a2 to mainline-healthfitness-release

Change-Id: I3c0196886544b878650b83d6066495fe56ebf81d
diff --git a/artd/art_standalone_artd_tests.xml b/artd/art_standalone_artd_tests.xml
index 8a48b84..468b200 100644
--- a/artd/art_standalone_artd_tests.xml
+++ b/artd/art_standalone_artd_tests.xml
@@ -43,7 +43,6 @@
         <option name="mainline-module-package-name" value="com.android.art" />
     </object>
 
-    <!-- Only run tests if the device under test is SDK version 31 (Android 12) or above. -->
-    <!-- TODO(jiakaiz): Change this to U once `ro.build.version.sdk` is bumped. -->
-    <object type="module_controller" class="com.android.tradefed.testtype.suite.module.Sdk31ModuleController" />
+    <!-- Only run tests if the device under test is SDK version 34 (Android 14) or above. -->
+    <object type="module_controller" class="com.android.tradefed.testtype.suite.module.Sdk34ModuleController" />
 </configuration>
diff --git a/runtime/trace.cc b/runtime/trace.cc
index 81c86f1..20436d6 100644
--- a/runtime/trace.cc
+++ b/runtime/trace.cc
@@ -774,6 +774,15 @@
   CHECK_IMPLIES(trace_file == nullptr, output_mode == TraceOutputMode::kDDMS);
 
   uint16_t trace_version = GetTraceVersion(clock_source_);
+
+  // We initialize the start_time_ from the timestamp counter. This may not match
+  // with the monotonic timer but we only use this time to calculate the elapsed
+  // time from this point which should be the same for both cases.
+  // We record monotonic time at the start of the trace, because Android Studio
+  // fetches the monotonic timer from other places and matches these times to
+  // construct a cpu profile. See b/318052824 for more context.
+  uint64_t start_time_monotonic = start_time_ + (MicroTime() - GetMicroTime(GetTimestamp()));
+
   if (output_mode == TraceOutputMode::kStreaming) {
     trace_version |= 0xF0U;
   }
@@ -782,7 +791,7 @@
   Append4LE(buf_.get(), kTraceMagicValue);
   Append2LE(buf_.get() + 4, trace_version);
   Append2LE(buf_.get() + 6, kTraceHeaderLength);
-  Append8LE(buf_.get() + 8, start_time_);
+  Append8LE(buf_.get() + 8, start_time_monotonic);
   if (trace_version >= kTraceVersionDualClock) {
     uint16_t record_size = GetRecordSize(clock_source_);
     Append2LE(buf_.get() + 16, record_size);