Add hardcoded mapping of Winscope table name to proto name and allowed fields.

Bug: 311643446
Test: npm run test:unit:ci
Change-Id: Ibe6f2daa8408acc4150197b6e64e72f71d63b30a
diff --git a/Android.bp b/Android.bp
index a7de450..2e4aaa2 100644
--- a/Android.bp
+++ b/Android.bp
@@ -2547,6 +2547,7 @@
         ":perfetto_src_trace_processor_util_trace_blob_view_reader",
         ":perfetto_src_trace_processor_util_trace_type",
         ":perfetto_src_trace_processor_util_util",
+        ":perfetto_src_trace_processor_util_winscope_proto_mapping",
         ":perfetto_src_trace_processor_util_zip_reader",
         ":perfetto_src_traced_probes_android_game_intervention_list_android_game_intervention_list",
         ":perfetto_src_traced_probes_android_log_android_log",
@@ -14099,6 +14100,11 @@
     name: "perfetto_src_trace_processor_util_util",
 }
 
+// GN: //src/trace_processor/util:winscope_proto_mapping
+filegroup {
+    name: "perfetto_src_trace_processor_util_winscope_proto_mapping",
+}
+
 // GN: //src/trace_processor/util:zip_reader
 filegroup {
     name: "perfetto_src_trace_processor_util_zip_reader",
@@ -15720,6 +15726,7 @@
         ":perfetto_src_trace_processor_util_trace_type",
         ":perfetto_src_trace_processor_util_unittests",
         ":perfetto_src_trace_processor_util_util",
+        ":perfetto_src_trace_processor_util_winscope_proto_mapping",
         ":perfetto_src_trace_processor_util_zip_reader",
         ":perfetto_src_trace_redaction_trace_redaction",
         ":perfetto_src_trace_redaction_unittests",
@@ -16772,6 +16779,7 @@
         ":perfetto_src_trace_processor_util_trace_blob_view_reader",
         ":perfetto_src_trace_processor_util_trace_type",
         ":perfetto_src_trace_processor_util_util",
+        ":perfetto_src_trace_processor_util_winscope_proto_mapping",
         ":perfetto_src_trace_processor_util_zip_reader",
         "src/trace_processor/trace_processor_shell.cc",
     ],
@@ -17195,6 +17203,7 @@
         ":perfetto_src_trace_processor_util_trace_blob_view_reader",
         ":perfetto_src_trace_processor_util_trace_type",
         ":perfetto_src_trace_processor_util_util",
+        ":perfetto_src_trace_processor_util_winscope_proto_mapping",
         ":perfetto_src_trace_processor_util_zip_reader",
         ":perfetto_src_traceconv_lib",
         ":perfetto_src_traceconv_main",
diff --git a/BUILD b/BUILD
index 9335ace..f1cb6bb 100644
--- a/BUILD
+++ b/BUILD
@@ -306,6 +306,7 @@
         ":src_trace_processor_util_trace_blob_view_reader",
         ":src_trace_processor_util_trace_type",
         ":src_trace_processor_util_util",
+        ":src_trace_processor_util_winscope_proto_mapping",
         ":src_trace_processor_util_zip_reader",
     ],
     hdrs = [
@@ -3494,6 +3495,14 @@
     ],
 )
 
+# GN target: //src/trace_processor/util:winscope_proto_mapping
+perfetto_filegroup(
+    name = "src_trace_processor_util_winscope_proto_mapping",
+    srcs = [
+        "src/trace_processor/util/winscope_proto_mapping.h",
+    ],
+)
+
 # GN target: //src/trace_processor/util:zip_reader
 perfetto_filegroup(
     name = "src_trace_processor_util_zip_reader",
@@ -6592,6 +6601,7 @@
         ":src_trace_processor_util_trace_blob_view_reader",
         ":src_trace_processor_util_trace_type",
         ":src_trace_processor_util_util",
+        ":src_trace_processor_util_winscope_proto_mapping",
         ":src_trace_processor_util_zip_reader",
     ],
     hdrs = [
@@ -6799,6 +6809,7 @@
         ":src_trace_processor_util_trace_blob_view_reader",
         ":src_trace_processor_util_trace_type",
         ":src_trace_processor_util_util",
+        ":src_trace_processor_util_winscope_proto_mapping",
         ":src_trace_processor_util_zip_reader",
         "src/trace_processor/trace_processor_shell.cc",
     ],
@@ -7057,6 +7068,7 @@
         ":src_trace_processor_util_trace_blob_view_reader",
         ":src_trace_processor_util_trace_type",
         ":src_trace_processor_util_util",
+        ":src_trace_processor_util_winscope_proto_mapping",
         ":src_trace_processor_util_zip_reader",
         ":src_traceconv_lib",
         ":src_traceconv_main",
diff --git a/src/trace_processor/importers/proto/winscope/BUILD.gn b/src/trace_processor/importers/proto/winscope/BUILD.gn
index e04c4f0..ba4452c 100644
--- a/src/trace_processor/importers/proto/winscope/BUILD.gn
+++ b/src/trace_processor/importers/proto/winscope/BUILD.gn
@@ -55,6 +55,7 @@
     "../../common:parser_types",
     "../../proto:minimal",
     "../../proto:packet_sequence_state_generation_hdr",
+    "../../../util:winscope_proto_mapping"
   ]
 }
 
diff --git a/src/trace_processor/importers/proto/winscope/android_input_event_parser.cc b/src/trace_processor/importers/proto/winscope/android_input_event_parser.cc
index f52597c..e3b2553 100644
--- a/src/trace_processor/importers/proto/winscope/android_input_event_parser.cc
+++ b/src/trace_processor/importers/proto/winscope/android_input_event_parser.cc
@@ -23,6 +23,7 @@
 #include "src/trace_processor/storage/trace_storage.h"
 #include "src/trace_processor/tables/android_tables_py.h"
 #include "src/trace_processor/types/trace_processor_context.h"
+#include "src/trace_processor/util/winscope_proto_mapping.h"
 
 namespace perfetto::trace_processor {
 
@@ -89,7 +90,9 @@
   ArgsParser writer{packet_ts, inserter, *context_.storage};
 
   base::Status status =
-      args_parser_.ParseMessage(bytes, ".perfetto.protos.AndroidMotionEvent",
+      args_parser_.ParseMessage(bytes,
+                                *util::winscope_proto_mapping::GetProtoName(
+                                    tables::AndroidMotionEventsTable::Name()),
                                 nullptr /*parse all fields*/, writer);
   if (!status.ok())
     context_.storage->IncrementStats(stats::android_input_event_parse_errors);
@@ -114,7 +117,9 @@
   ArgsParser writer{packet_ts, inserter, *context_.storage};
 
   base::Status status =
-      args_parser_.ParseMessage(bytes, ".perfetto.protos.AndroidKeyEvent",
+      args_parser_.ParseMessage(bytes,
+                                *util::winscope_proto_mapping::GetProtoName(
+                                    tables::AndroidKeyEventsTable::Name()),
                                 nullptr /*parse all fields*/, writer);
   if (!status.ok())
     context_.storage->IncrementStats(stats::android_input_event_parse_errors);
@@ -142,7 +147,9 @@
   ArgsParser writer{packet_ts, inserter, *context_.storage};
 
   base::Status status = args_parser_.ParseMessage(
-      bytes, ".perfetto.protos.AndroidWindowInputDispatchEvent",
+      bytes,
+      *util::winscope_proto_mapping::GetProtoName(
+          tables::AndroidInputEventDispatchTable::Name()),
       nullptr /*parse all fields*/, writer);
   if (!status.ok())
     context_.storage->IncrementStats(stats::android_input_event_parse_errors);
diff --git a/src/trace_processor/importers/proto/winscope/shell_transitions_parser.cc b/src/trace_processor/importers/proto/winscope/shell_transitions_parser.cc
index d8e6e4e..07fef5e 100644
--- a/src/trace_processor/importers/proto/winscope/shell_transitions_parser.cc
+++ b/src/trace_processor/importers/proto/winscope/shell_transitions_parser.cc
@@ -23,6 +23,7 @@
 #include "src/trace_processor/importers/proto/args_parser.h"
 #include "src/trace_processor/storage/trace_storage.h"
 #include "src/trace_processor/types/trace_processor_context.h"
+#include "src/trace_processor/util/winscope_proto_mapping.h"
 
 namespace perfetto {
 namespace trace_processor {
@@ -49,11 +50,13 @@
       base::StringView(base::Base64Encode(blob.data, blob.size)));
   row.set_base64_proto(base64_proto);
   row.set_base64_proto_id(base64_proto.raw_id());
-
   auto inserter = context_->args_tracker->AddArgsTo(row_id);
   ArgsParser writer(/*timestamp=*/0, inserter, *context_->storage.get());
   base::Status status = args_parser_.ParseMessage(
-      blob, kShellTransitionsProtoName, nullptr /* parse all fields */, writer);
+      blob,
+      *util::winscope_proto_mapping::GetProtoName(
+          tables::WindowManagerShellTransitionsTable::Name()),
+      nullptr /* parse all fields */, writer);
 
   if (!status.ok()) {
     context_->storage->IncrementStats(
diff --git a/src/trace_processor/importers/proto/winscope/shell_transitions_parser.h b/src/trace_processor/importers/proto/winscope/shell_transitions_parser.h
index c757239..3dfe529 100644
--- a/src/trace_processor/importers/proto/winscope/shell_transitions_parser.h
+++ b/src/trace_processor/importers/proto/winscope/shell_transitions_parser.h
@@ -33,9 +33,6 @@
   void ParseHandlerMappings(protozero::ConstBytes);
 
  private:
-  static constexpr auto* kShellTransitionsProtoName =
-      ".perfetto.protos.ShellTransition";
-
   TraceProcessorContext* const context_;
   util::ProtoToArgsParser args_parser_;
 };
diff --git a/src/trace_processor/importers/proto/winscope/shell_transitions_tracker.cc b/src/trace_processor/importers/proto/winscope/shell_transitions_tracker.cc
index 6025d91..3526750 100644
--- a/src/trace_processor/importers/proto/winscope/shell_transitions_tracker.cc
+++ b/src/trace_processor/importers/proto/winscope/shell_transitions_tracker.cc
@@ -19,6 +19,7 @@
 #include "src/trace_processor/importers/common/process_tracker.h"
 #include "src/trace_processor/storage/metadata.h"
 #include "src/trace_processor/types/trace_processor_context.h"
+#include "src/trace_processor/util/winscope_proto_mapping.h"
 
 namespace perfetto {
 namespace trace_processor {
diff --git a/src/trace_processor/importers/proto/winscope/shell_transitions_tracker.h b/src/trace_processor/importers/proto/winscope/shell_transitions_tracker.h
index 07ef736..5218a7b 100644
--- a/src/trace_processor/importers/proto/winscope/shell_transitions_tracker.h
+++ b/src/trace_processor/importers/proto/winscope/shell_transitions_tracker.h
@@ -20,6 +20,7 @@
 #include "perfetto/trace_processor/basic_types.h"
 #include "src/trace_processor/storage/trace_storage.h"
 #include "src/trace_processor/types/trace_processor_context.h"
+#include "src/trace_processor/util/winscope_proto_mapping.h"
 
 namespace perfetto {
 namespace trace_processor {
diff --git a/src/trace_processor/importers/proto/winscope/surfaceflinger_layers_parser.cc b/src/trace_processor/importers/proto/winscope/surfaceflinger_layers_parser.cc
index 34136db..1975f5d 100644
--- a/src/trace_processor/importers/proto/winscope/surfaceflinger_layers_parser.cc
+++ b/src/trace_processor/importers/proto/winscope/surfaceflinger_layers_parser.cc
@@ -21,6 +21,7 @@
 #include "src/trace_processor/importers/common/args_tracker.h"
 #include "src/trace_processor/importers/proto/args_parser.h"
 #include "src/trace_processor/types/trace_processor_context.h"
+#include "src/trace_processor/util/winscope_proto_mapping.h"
 
 namespace perfetto {
 namespace trace_processor {
@@ -46,9 +47,12 @@
 
   auto inserter = context_->args_tracker->AddArgsTo(snapshot_id);
   ArgsParser writer(timestamp, inserter, *context_->storage);
-  base::Status status =
-      args_parser_.ParseMessage(blob, kLayersSnapshotProtoName,
-                                &kLayersSnapshotFieldsToArgsParse, writer);
+  const auto table_name = tables::SurfaceFlingerLayersSnapshotTable::Name();
+  auto allowed_fields =
+      util::winscope_proto_mapping::GetAllowedFields(table_name);
+  base::Status status = args_parser_.ParseMessage(
+      blob, *util::winscope_proto_mapping::GetProtoName(table_name),
+      &allowed_fields.value(), writer);
   if (!status.ok()) {
     context_->storage->IncrementStats(stats::winscope_sf_layers_parse_errors);
   }
@@ -75,8 +79,11 @@
   ArgsTracker tracker(context_);
   auto inserter = tracker.AddArgsTo(layerId);
   ArgsParser writer(timestamp, inserter, *context_->storage);
-  base::Status status = args_parser_.ParseMessage(
-      blob, kLayerProtoName, nullptr /* parse all fields */, writer);
+  base::Status status =
+      args_parser_.ParseMessage(blob,
+                                *util::winscope_proto_mapping::GetProtoName(
+                                    tables::SurfaceFlingerLayerTable::Name()),
+                                nullptr /* parse all fields */, writer);
   if (!status.ok()) {
     context_->storage->IncrementStats(stats::winscope_sf_layers_parse_errors);
   }
diff --git a/src/trace_processor/importers/proto/winscope/surfaceflinger_layers_parser.h b/src/trace_processor/importers/proto/winscope/surfaceflinger_layers_parser.h
index 963b2b6..987eb81 100644
--- a/src/trace_processor/importers/proto/winscope/surfaceflinger_layers_parser.h
+++ b/src/trace_processor/importers/proto/winscope/surfaceflinger_layers_parser.h
@@ -33,12 +33,6 @@
   void Parse(int64_t timestamp, protozero::ConstBytes);
 
  private:
-  const std::vector<std::uint32_t> kLayersSnapshotFieldsToArgsParse{1, 2, 4, 5,
-                                                                    6, 7, 8};
-  static constexpr auto* kLayersSnapshotProtoName =
-      ".perfetto.protos.LayersSnapshotProto";
-  static constexpr auto* kLayerProtoName = ".perfetto.protos.LayerProto";
-
   void ParseLayer(int64_t timestamp,
                   protozero::ConstBytes blob,
                   tables::SurfaceFlingerLayersSnapshotTable::Id);
diff --git a/src/trace_processor/importers/proto/winscope/surfaceflinger_transactions_parser.cc b/src/trace_processor/importers/proto/winscope/surfaceflinger_transactions_parser.cc
index 1353cd5..2fa14b6 100644
--- a/src/trace_processor/importers/proto/winscope/surfaceflinger_transactions_parser.cc
+++ b/src/trace_processor/importers/proto/winscope/surfaceflinger_transactions_parser.cc
@@ -22,6 +22,7 @@
 #include "src/trace_processor/importers/proto/args_parser.h"
 #include "src/trace_processor/storage/trace_storage.h"
 #include "src/trace_processor/types/trace_processor_context.h"
+#include "src/trace_processor/util/winscope_proto_mapping.h"
 
 namespace perfetto {
 namespace trace_processor {
@@ -44,9 +45,11 @@
   ArgsTracker tracker(context_);
   auto inserter = tracker.AddArgsTo(rowId);
   ArgsParser writer(timestamp, inserter, *context_->storage.get());
-  base::Status status =
-      args_parser_.ParseMessage(blob, kTransactionTraceEntryProtoName,
-                                nullptr /* parse all fields */, writer);
+  base::Status status = args_parser_.ParseMessage(
+      blob,
+      *util::winscope_proto_mapping::GetProtoName(
+          tables::SurfaceFlingerTransactionsTable::Name()),
+      nullptr /* parse all fields */, writer);
   if (!status.ok()) {
     context_->storage->IncrementStats(
         stats::winscope_sf_transactions_parse_errors);
diff --git a/src/trace_processor/importers/proto/winscope/surfaceflinger_transactions_parser.h b/src/trace_processor/importers/proto/winscope/surfaceflinger_transactions_parser.h
index 0ccb53a..b696408 100644
--- a/src/trace_processor/importers/proto/winscope/surfaceflinger_transactions_parser.h
+++ b/src/trace_processor/importers/proto/winscope/surfaceflinger_transactions_parser.h
@@ -32,9 +32,6 @@
   void Parse(int64_t timestamp, protozero::ConstBytes);
 
  private:
-  static constexpr auto* kTransactionTraceEntryProtoName =
-      ".perfetto.protos.TransactionTraceEntry";
-
   TraceProcessorContext* const context_;
   util::ProtoToArgsParser args_parser_;
 };
diff --git a/src/trace_processor/importers/proto/winscope/winscope_module.cc b/src/trace_processor/importers/proto/winscope/winscope_module.cc
index ad828c0..a25a05d 100644
--- a/src/trace_processor/importers/proto/winscope/winscope_module.cc
+++ b/src/trace_processor/importers/proto/winscope/winscope_module.cc
@@ -21,6 +21,7 @@
 #include "src/trace_processor/importers/proto/args_parser.h"
 #include "src/trace_processor/importers/proto/winscope/viewcapture_args_parser.h"
 #include "src/trace_processor/importers/proto/winscope/winscope.descriptor.h"
+#include "src/trace_processor/util/winscope_proto_mapping.h"
 
 namespace perfetto {
 namespace trace_processor {
@@ -145,7 +146,9 @@
   auto inserter = tracker.AddArgsTo(rowId);
   ArgsParser writer(timestamp, inserter, *context_->storage.get());
   base::Status status =
-      args_parser_.ParseMessage(blob, kInputMethodClientsProtoName,
+      args_parser_.ParseMessage(blob,
+                                *util::winscope_proto_mapping::GetProtoName(
+                                    tables::InputMethodClientsTable::Name()),
                                 nullptr /* parse all fields */, writer);
   if (!status.ok()) {
     context_->storage->IncrementStats(
@@ -168,9 +171,11 @@
   ArgsTracker tracker(context_);
   auto inserter = tracker.AddArgsTo(rowId);
   ArgsParser writer(timestamp, inserter, *context_->storage.get());
-  base::Status status =
-      args_parser_.ParseMessage(blob, kInputMethodManagerServiceProtoName,
-                                nullptr /* parse all fields */, writer);
+  base::Status status = args_parser_.ParseMessage(
+      blob,
+      *util::winscope_proto_mapping::GetProtoName(
+          tables::InputMethodManagerServiceTable::Name()),
+      nullptr /* parse all fields */, writer);
   if (!status.ok()) {
     context_->storage->IncrementStats(
         stats::winscope_inputmethod_manager_service_parse_errors);
@@ -191,7 +196,9 @@
   auto inserter = tracker.AddArgsTo(rowId);
   ArgsParser writer(timestamp, inserter, *context_->storage.get());
   base::Status status =
-      args_parser_.ParseMessage(blob, kInputMethodServiceProtoName,
+      args_parser_.ParseMessage(blob,
+                                *util::winscope_proto_mapping::GetProtoName(
+                                    tables::InputMethodServiceTable::Name()),
                                 nullptr /* parse all fields */, writer);
   if (!status.ok()) {
     context_->storage->IncrementStats(
@@ -214,8 +221,11 @@
   auto inserter = tracker.AddArgsTo(rowId);
   ViewCaptureArgsParser writer(timestamp, inserter, *context_->storage.get(),
                                sequence_state);
-  base::Status status = args_parser_.ParseMessage(
-      blob, kViewCaptureProtoName, nullptr /* parse all fields */, writer);
+  base::Status status =
+      args_parser_.ParseMessage(blob,
+                                *util::winscope_proto_mapping::GetProtoName(
+                                    tables::ViewCaptureTable::Name()),
+                                nullptr /* parse all fields */, writer);
   if (!status.ok()) {
     context_->storage->IncrementStats(stats::winscope_viewcapture_parse_errors);
   }
@@ -233,8 +243,11 @@
   ArgsTracker tracker(context_);
   auto inserter = tracker.AddArgsTo(rowId);
   ArgsParser writer(timestamp, inserter, *context_->storage.get());
-  base::Status status = args_parser_.ParseMessage(
-      blob, kWindowManagerProtoName, nullptr /* parse all fields */, writer);
+  base::Status status =
+      args_parser_.ParseMessage(blob,
+                                *util::winscope_proto_mapping::GetProtoName(
+                                    tables::WindowManagerTable::Name()),
+                                nullptr /* parse all fields */, writer);
   if (!status.ok()) {
     context_->storage->IncrementStats(
         stats::winscope_windowmanager_parse_errors);
diff --git a/src/trace_processor/importers/proto/winscope/winscope_module.h b/src/trace_processor/importers/proto/winscope/winscope_module.h
index ea7e506..b6e876f 100644
--- a/src/trace_processor/importers/proto/winscope/winscope_module.h
+++ b/src/trace_processor/importers/proto/winscope/winscope_module.h
@@ -63,16 +63,6 @@
                             PacketSequenceStateGeneration* sequence_state);
   void ParseWindowManagerData(int64_t timestamp, protozero::ConstBytes blob);
 
-  static constexpr auto* kInputMethodClientsProtoName =
-      ".perfetto.protos.InputMethodClientsTraceProto";
-  static constexpr auto* kInputMethodManagerServiceProtoName =
-      ".perfetto.protos.InputMethodManagerServiceTraceProto";
-  static constexpr auto* kInputMethodServiceProtoName =
-      ".perfetto.protos.InputMethodServiceTraceProto";
-  static constexpr auto* kViewCaptureProtoName = ".perfetto.protos.ViewCapture";
-  static constexpr auto* kWindowManagerProtoName =
-      ".perfetto.protos.WindowManagerTraceEntry";
-
   TraceProcessorContext* const context_;
   util::ProtoToArgsParser args_parser_;
 
diff --git a/src/trace_processor/util/BUILD.gn b/src/trace_processor/util/BUILD.gn
index fc6ee4b..73bdbcb 100644
--- a/src/trace_processor/util/BUILD.gn
+++ b/src/trace_processor/util/BUILD.gn
@@ -284,6 +284,15 @@
   ]
 }
 
+source_set("winscope_proto_mapping") {
+  sources = ["winscope_proto_mapping.h"]
+  deps = [
+    "../../../gn:default_deps",
+    "../../../include/perfetto/ext/base:base",
+    "../tables",
+  ]
+}
+
 source_set("unittests") {
   sources = [
     "bump_allocator_unittest.cc",
diff --git a/src/trace_processor/util/winscope_proto_mapping.h b/src/trace_processor/util/winscope_proto_mapping.h
new file mode 100644
index 0000000..b9bd320
--- /dev/null
+++ b/src/trace_processor/util/winscope_proto_mapping.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SRC_TRACE_PROCESSOR_UTIL_WINSCOPE_PROTO_MAPPING_H_
+#define SRC_TRACE_PROCESSOR_UTIL_WINSCOPE_PROTO_MAPPING_H_
+
+#include "perfetto/ext/base/status_or.h"
+#include "src/trace_processor/tables/android_tables_py.h"
+#include "src/trace_processor/tables/winscope_tables_py.h"
+
+namespace perfetto::trace_processor {
+namespace util {
+namespace winscope_proto_mapping {
+inline base::StatusOr<const char* const> GetProtoName(
+    const std::string& table_name) {
+  if (table_name == tables::SurfaceFlingerLayerTable::Name()) {
+    return ".perfetto.protos.LayerProto";
+  }
+  if (table_name == tables::SurfaceFlingerLayersSnapshotTable::Name()) {
+    return ".perfetto.protos.LayersSnapshotProto";
+  }
+  if (table_name == tables::SurfaceFlingerTransactionsTable::Name()) {
+    return ".perfetto.protos.TransactionTraceEntry";
+  }
+  if (table_name == tables::WindowManagerShellTransitionsTable::Name()) {
+    return ".perfetto.protos.ShellTransition";
+  }
+  if (table_name == tables::InputMethodClientsTable::Name()) {
+    return ".perfetto.protos.InputMethodClientsTraceProto";
+  }
+  if (table_name == tables::InputMethodManagerServiceTable::Name()) {
+    return ".perfetto.protos.InputMethodManagerServiceTraceProto";
+  }
+  if (table_name == tables::InputMethodServiceTable::Name()) {
+    return ".perfetto.protos.InputMethodServiceTraceProto";
+  }
+  if (table_name == tables::ViewCaptureTable::Name()) {
+    return ".perfetto.protos.ViewCapture";
+  }
+  if (table_name == tables::WindowManagerTable::Name()) {
+    return ".perfetto.protos.WindowManagerTraceEntry";
+  }
+  if (table_name == tables::AndroidKeyEventsTable::Name()) {
+    return ".perfetto.protos.AndroidKeyEvent";
+  }
+  if (table_name == tables::AndroidMotionEventsTable::Name()) {
+    return ".perfetto.protos.AndroidMotionEvent";
+  }
+  if (table_name == tables::AndroidInputEventDispatchTable::Name()) {
+    return ".perfetto.protos.AndroidWindowInputDispatchEvent";
+  }
+  return base::ErrStatus("%s table does not have proto descriptor.",
+                         table_name.c_str());
+}
+
+inline std::optional<const std::vector<uint32_t>> GetAllowedFields(
+    const std::string& table_name) {
+  if (table_name == tables::SurfaceFlingerLayersSnapshotTable::Name()) {
+    return std::vector<uint32_t>({1, 2, 4, 5, 6, 7, 8});
+  }
+  return std::nullopt;
+}
+}  // namespace winscope_proto_mapping
+}  // namespace util
+}  // namespace perfetto::trace_processor
+
+#endif  // SRC_TRACE_PROCESSOR_UTIL_WINSCOPE_PROTO_MAPPING_H_