[RELAND] tp: move thread state implementation to trace processor

Thread state is pretty complicated to calculate and has a lot of edge
cases and subtlety that's hard to capture in SQL. The other problem is
that we also want to have thread state available for metrics (currently
some metrics have recreated a cut down version of this class).

For this reason, move the thread state computation as a dynamic table in
C++ which allows sharing it with other places. It also has the advantage
of making startup of the UI much faster as it doesn't need to compute
the thread state table.

This is a reland of aosp/1360559

Bug: 163812686
Change-Id: I48ed30e9b9696890fb8d389b0014d65e609feb3d
diff --git a/Android.bp b/Android.bp
index a5a45c5..bd994b3 100644
--- a/Android.bp
+++ b/Android.bp
@@ -6787,6 +6787,7 @@
     "src/trace_processor/dynamic/experimental_flamegraph_generator.cc",
     "src/trace_processor/dynamic/experimental_sched_upid_generator.cc",
     "src/trace_processor/dynamic/experimental_slice_layout_generator.cc",
+    "src/trace_processor/dynamic/thread_state_generator.cc",
     "src/trace_processor/iterator_impl.cc",
     "src/trace_processor/read_trace.cc",
     "src/trace_processor/trace_processor.cc",
@@ -6985,6 +6986,7 @@
   srcs: [
     "src/trace_processor/dynamic/experimental_counter_dur_generator_unittest.cc",
     "src/trace_processor/dynamic/experimental_slice_layout_generator_unittest.cc",
+    "src/trace_processor/dynamic/thread_state_generator_unittest.cc",
     "src/trace_processor/forwarding_trace_parser_unittest.cc",
     "src/trace_processor/importers/ftrace/sched_event_tracker_unittest.cc",
     "src/trace_processor/importers/fuchsia/fuchsia_trace_utils_unittest.cc",