event_manager: Record timestamp in IntentStart even the tracing is not am: f1d3b75ef1 am: cb2ceae5c5 am: 0d629500a7

Change-Id: I7dada00a14f5669f50817dce7f49d4afc28d55fb
diff --git a/src/manager/event_manager.cc b/src/manager/event_manager.cc
index 8839c9e..582fcf4 100644
--- a/src/manager/event_manager.cc
+++ b/src/manager/event_manager.cc
@@ -228,6 +228,18 @@
         history_id_observable.connect();
 
         DCHECK(!IsTracing());
+
+        // The time should be set before perfetto tracing.
+        // Record the timestamp even no perfetto tracing is triggered,
+        // because the tracing may start in the following ActivityLaunched
+        // event. Otherwise, there will be no starting timestamp and
+        // trace without starting timestamp is not considered for compilation.
+        if (event.timestamp_nanos >= 0) {
+          intent_started_ns_ = event.timestamp_nanos;
+        } else {
+          LOG(WARNING) << "Negative event timestamp: " << event.timestamp_nanos;
+        }
+
         // Optimistically start tracing if we have the activity in the intent.
         if (!event.intent_proto->has_component()) {
           // Can't do anything if there is no component in the proto.
@@ -235,13 +247,6 @@
           break;
         }
 
-        // The time should be set before perfetto tracing.
-        if (event.timestamp_nanos >= 0) {
-          intent_started_ns_ = event.timestamp_nanos;
-        } else {
-          LOG(WARNING) << "Negative event timestamp: " << event.timestamp_nanos;
-        }
-
         if (allowed_readahead_) {
           StartReadAhead(sequence_id_, component_name);
         }