Extract Startup activity name

Bug: 182170886
Change-Id: I4449c86354451f2fcdda000c76c09ddd1ba5aae9
diff --git a/protos/perfetto/metrics/android/startup_metric.proto b/protos/perfetto/metrics/android/startup_metric.proto
index a93a6a5..61b8203 100644
--- a/protos/perfetto/metrics/android/startup_metric.proto
+++ b/protos/perfetto/metrics/android/startup_metric.proto
@@ -88,7 +88,7 @@
     optional Slice full_startup = 1;
   }
 
-  // Next id: 8
+  // Next id: 11
   message Startup {
     // Random id uniquely identifying an app startup in this trace.
     optional uint32 startup_id = 1;
@@ -99,6 +99,9 @@
     // Name of the process launched
     optional string process_name = 3;
 
+    // Name of the activity launched
+    optional string activity_name = 10;
+
     // Did we ask the zygote for a new process
     optional bool zygote_new_process = 4;
 
diff --git a/protos/perfetto/metrics/perfetto_merged_metrics.proto b/protos/perfetto/metrics/perfetto_merged_metrics.proto
index 496ad35..21fa4ad 100644
--- a/protos/perfetto/metrics/perfetto_merged_metrics.proto
+++ b/protos/perfetto/metrics/perfetto_merged_metrics.proto
@@ -744,7 +744,7 @@
     optional Slice full_startup = 1;
   }
 
-  // Next id: 8
+  // Next id: 11
   message Startup {
     // Random id uniquely identifying an app startup in this trace.
     optional uint32 startup_id = 1;
@@ -755,6 +755,9 @@
     // Name of the process launched
     optional string process_name = 3;
 
+    // Name of the activity launched
+    optional string activity_name = 10;
+
     // Did we ask the zygote for a new process
     optional bool zygote_new_process = 4;
 
diff --git a/src/trace_processor/metrics/android/android_startup.sql b/src/trace_processor/metrics/android/android_startup.sql
index 18be8ee0..78236dc 100644
--- a/src/trace_processor/metrics/android/android_startup.sql
+++ b/src/trace_processor/metrics/android/android_startup.sql
@@ -92,6 +92,8 @@
   'activityResume',
   'Choreographer#doFrame',
   'inflate')
+  OR slice.name LIKE 'performResume:%'
+  OR slice.name LIKE 'performCreate:%'
 GROUP BY 1, 2;
 
 DROP TABLE IF EXISTS report_fully_drawn_per_launch;
@@ -153,6 +155,13 @@
         LIMIT 1
       )
     ),
+    'activity_name', (
+      SELECT STR_SPLIT(name, ':', 1)
+      FROM main_process_slice s
+      WHERE s.launch_id = launches.id
+      AND (name LIKE 'performResume:%' OR name LIKE 'performCreate:%')
+      LIMIT 1
+    ),
     'zygote_new_process', EXISTS(SELECT TRUE FROM zygote_forks_by_id WHERE id = launches.id),
     'activity_hosting_process_count', (
       SELECT COUNT(1) FROM launch_processes p
diff --git a/src/trace_processor/python/perfetto/trace_processor/metrics.descriptor b/src/trace_processor/python/perfetto/trace_processor/metrics.descriptor
index 3b231ca..854eaef 100644
--- a/src/trace_processor/python/perfetto/trace_processor/metrics.descriptor
+++ b/src/trace_processor/python/perfetto/trace_processor/metrics.descriptor
Binary files differ
diff --git a/test/trace_processor/startup/android_startup_breakdown.out b/test/trace_processor/startup/android_startup_breakdown.out
index e26b0b3..80e2c79 100644
--- a/test/trace_processor/startup/android_startup_breakdown.out
+++ b/test/trace_processor/startup/android_startup_breakdown.out
@@ -6,6 +6,7 @@
     process: {
       name: "com.google.android.calendar"
     }
+    activity_name: "com.google.android.calendar.MainActivity"
     zygote_new_process: true
     to_first_frame {
       dur_ns: 108
diff --git a/test/trace_processor/startup/android_startup_breakdown.py b/test/trace_processor/startup/android_startup_breakdown.py
index b7d2d7b..22b93f9 100644
--- a/test/trace_processor/startup/android_startup_breakdown.py
+++ b/test/trace_processor/startup/android_startup_breakdown.py
@@ -42,6 +42,12 @@
 trace.add_atrace_end(ts=195, tid=1, pid=1)
 
 trace.add_atrace_begin(ts=185, tid=3, pid=3, buf='bindApplication')
+trace.add_atrace_begin(
+    ts=188,
+    tid=3,
+    pid=3,
+    buf='performCreate:com.google.android.calendar.MainActivity')
+trace.add_atrace_end(ts=192, tid=3, pid=3)
 trace.add_atrace_end(ts=195, tid=3, pid=3)
 
 trace.add_atrace_async_end(