In launch_thread_state_dur_sum, include a main thread only if it is of the launching process.

Bug: 264278479

Test: Unit and Diff tests.

Change-Id: I4feed41f856242e05532d2bca0dce24efc311783
diff --git a/src/trace_processor/metrics/sql/android/startup/thread_state_breakdown.sql b/src/trace_processor/metrics/sql/android/startup/thread_state_breakdown.sql
index b3939bb..4ef1fc4 100644
--- a/src/trace_processor/metrics/sql/android/startup/thread_state_breakdown.sql
+++ b/src/trace_processor/metrics/sql/android/startup/thread_state_breakdown.sql
@@ -38,8 +38,10 @@
 CREATE TABLE launch_thread_state_io_wait_dur_sum AS
 SELECT startup_id, state, is_main_thread, thread_name, io_wait, SUM(dur) AS dur
 FROM launch_threads_by_thread_state l
+JOIN android_startup_processes p USING (startup_id)
 WHERE
-  is_main_thread
+  -- If it is a main thread, only add it if it is the lauching thread.
+  (is_main_thread AND p.startup_type NOT NULL)
   -- Allowlist specific threads which need this. Do not add to this list
   -- without careful consideration as every thread added here can cause
   -- memory usage to balloon.