Reference sqlite_ext_percentile module from Perfetto

Reference the percentile module added in aosp/2186160 when building
Perfetto from the Android tree

Bug: 239932997
Test: Builds and percentile function present in shell trace processor
Change-Id: I84b1ef7a146c1df06074002dde5ad2d904353eca
diff --git a/Android.bp b/Android.bp
index 559160d..44a423b 100644
--- a/Android.bp
+++ b/Android.bp
@@ -2040,6 +2040,7 @@
         "libgtest",
         "libperfetto_client_experimental",
         "perfetto_src_trace_processor_demangle",
+        "sqlite_ext_percentile",
     ],
     whole_static_libs: [
         "perfetto_gtest_logcat_printer",
@@ -10973,6 +10974,7 @@
         "libgmock",
         "libgtest",
         "perfetto_src_trace_processor_demangle",
+        "sqlite_ext_percentile",
     ],
     whole_static_libs: [
         "perfetto_gtest_logcat_printer",
@@ -11305,12 +11307,16 @@
                 "libutils",
                 "libz",
             ],
+            static_libs: [
+                "sqlite_ext_percentile",
+            ],
         },
         host: {
             static_libs: [
                 "libprotobuf-cpp-full",
                 "libsqlite",
                 "libz",
+                "sqlite_ext_percentile",
             ],
             stl: "libc++_static",
             dist: {
@@ -11420,6 +11426,7 @@
         "libsqlite",
         "libz",
         "perfetto_src_trace_processor_demangle",
+        "sqlite_ext_percentile",
     ],
     generated_headers: [
         "perfetto_protos_perfetto_common_zero_gen_headers",
diff --git a/gn/perfetto.gni b/gn/perfetto.gni
index 5d72402..aaeb8f4a 100644
--- a/gn/perfetto.gni
+++ b/gn/perfetto.gni
@@ -269,7 +269,8 @@
 
   # Enables the optional SQLite percentile module.
   enable_perfetto_trace_processor_percentile =
-      enable_perfetto_trace_processor && perfetto_build_standalone
+      enable_perfetto_trace_processor &&
+      (perfetto_build_standalone || perfetto_build_with_android)
 
   # Enables the REPL interactive prompt in the trace processor.
   enable_perfetto_trace_processor_linenoise =
diff --git a/include/perfetto/base/build_configs/android_tree/perfetto_build_flags.h b/include/perfetto/base/build_configs/android_tree/perfetto_build_flags.h
index 502e9bf..85f8ad2 100644
--- a/include/perfetto/base/build_configs/android_tree/perfetto_build_flags.h
+++ b/include/perfetto/base/build_configs/android_tree/perfetto_build_flags.h
@@ -34,7 +34,7 @@
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_FORCE_DCHECK_OFF() (0)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_VERBOSE_LOGS() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_VERSION_GEN() (1)
-#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_PERCENTILE() (0)
+#define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_PERCENTILE() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_LINENOISE() (0)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_HTTPD() (1)
 #define PERFETTO_BUILDFLAG_DEFINE_PERFETTO_TP_JSON() (0)
diff --git a/tools/gen_android_bp b/tools/gen_android_bp
index a369ff7..9a21781 100755
--- a/tools/gen_android_bp
+++ b/tools/gen_android_bp
@@ -308,18 +308,22 @@
 def enable_sqlite(module):
   if module.type == 'cc_binary_host':
     module.static_libs.add('libsqlite')
+    module.static_libs.add('sqlite_ext_percentile')
   elif module.host_supported:
     # Copy what the sqlite3 command line tool does.
     module.android.shared_libs.add('libsqlite')
     module.android.shared_libs.add('libicu')
     module.android.shared_libs.add('liblog')
     module.android.shared_libs.add('libutils')
+    module.android.static_libs.add('sqlite_ext_percentile')
     module.host.static_libs.add('libsqlite')
+    module.host.static_libs.add('sqlite_ext_percentile')
   else:
     module.shared_libs.add('libsqlite')
     module.shared_libs.add('libicu')
     module.shared_libs.add('liblog')
     module.shared_libs.add('libutils')
+    module.static_libs.add('sqlite_ext_percentile')
 
 
 def enable_zlib(module):