Merge "Parse process labels from proto"
diff --git a/protos/perfetto/metrics/android/multiuser_metric.proto b/protos/perfetto/metrics/android/multiuser_metric.proto
index eba37d9..c29ea6e 100644
--- a/protos/perfetto/metrics/android/multiuser_metric.proto
+++ b/protos/perfetto/metrics/android/multiuser_metric.proto
@@ -36,6 +36,9 @@
       optional int32 cpu_mcycles = 3;
       // The ratio of this process's cycles to the total for all processes, expressed as a percentage.
       optional float cpu_percentage = 4;
+      // General identifier for this usage source: determined from the process name, user, etc.
+      // Should be stable across multiple runs (i.e. does not print the user_id directly).
+      optional string identifier = 5;
     }
     repeated CpuUsage cpu_usage = 2;
   }
diff --git a/protos/perfetto/metrics/perfetto_merged_metrics.proto b/protos/perfetto/metrics/perfetto_merged_metrics.proto
index 36e5073..7128494 100644
--- a/protos/perfetto/metrics/perfetto_merged_metrics.proto
+++ b/protos/perfetto/metrics/perfetto_merged_metrics.proto
@@ -751,6 +751,9 @@
       optional int32 cpu_mcycles = 3;
       // The ratio of this process's cycles to the total for all processes, expressed as a percentage.
       optional float cpu_percentage = 4;
+      // General identifier for this usage source: determined from the process name, user, etc.
+      // Should be stable across multiple runs (i.e. does not print the user_id directly).
+      optional string identifier = 5;
     }
     repeated CpuUsage cpu_usage = 2;
   }
diff --git a/src/trace_processor/metrics/android/android_multiuser_populator.sql b/src/trace_processor/metrics/android/android_multiuser_populator.sql
index 65dbab1..140bd36 100644
--- a/src/trace_processor/metrics/android/android_multiuser_populator.sql
+++ b/src/trace_processor/metrics/android/android_multiuser_populator.sql
@@ -88,6 +88,7 @@
 SELECT
     user_id,
     process_name,
+    process_name || ":" || (CASE WHEN user_id = 0 THEN "system" ELSE "secondary" END) AS identifier,
     CAST(cpu_kcycles / 1e3 AS INT) AS cpu_mcycles,
     cpu_kcycles / (SELECT SUM(cpu_kcycles) FROM cpu_usage_all) * 100 AS cpu_percentage
 FROM
@@ -106,6 +107,7 @@
   'cpu_usage', (
     SELECT RepeatedField(
       AndroidMultiuserMetric_EventData_CpuUsage(
+        'identifier', identifier,
         'user_id', user_id,
         'process_name', process_name,
         'cpu_mcycles', cpu_mcycles,
diff --git a/src/trace_processor/python/perfetto/trace_processor/metrics.descriptor b/src/trace_processor/python/perfetto/trace_processor/metrics.descriptor
index 6bb7dbf..c94c320 100644
--- a/src/trace_processor/python/perfetto/trace_processor/metrics.descriptor
+++ b/src/trace_processor/python/perfetto/trace_processor/metrics.descriptor
Binary files differ