Move codec and extractor to libc_scudo.

The mediaswcodec and mediaextractor use the scudo libraries as a
sanitizer. This has some downsides since it bypasses all of the normal
allocation handlers used by the rest of the system.

Switching from the plain sanitizer to a wrapper library libc_scudo.so
allows the use of the allocation handler code from
bionic/libc/bionic/malloc_common.cpp.

This is a temporary workaround, later versions of Android should
support scudo as a first class native allocator.

NOTE: The two libraries that make up the scudo override combined are
smaller than the libclang_rt.scudo-XXX.so library, so this is a space
win too.

Bug: 123689570

Test: Builds and boots. Verified that scudo is used as the allocator.
Test: Verified that the allocation limit is properly set for mediaextractor.
Test: Ran a few of the CtsMediaTestCases tests.

Change-Id: I3bdf76bfeea503b33da765e093e38818b620a481
diff --git a/services/mediacodec/Android.bp b/services/mediacodec/Android.bp
index 25c36fa..32d2fde 100644
--- a/services/mediacodec/Android.bp
+++ b/services/mediacodec/Android.bp
@@ -20,6 +20,15 @@
             exclude_shared_libs: ["libavservices_minijail"],
             shared_libs: ["libavservices_minijail_vendor"],
         },
+        android: {
+            product_variables: {
+                malloc_not_svelte: {
+                    // Scudo increases memory footprint, so only enable on
+                    // non-svelte devices.
+                    shared_libs: ["libc_scudo"],
+                },
+            },
+        },
     },
 
     header_libs: [
@@ -35,10 +44,6 @@
         "-Wall",
         "-Wno-error=deprecated-declarations",
     ],
-
-    sanitize: {
-        scudo: true,
-    },
 }
 
 prebuilt_etc {
diff --git a/services/mediacodec/main_swcodecservice.cpp b/services/mediacodec/main_swcodecservice.cpp
index c44be28..a5db031 100644
--- a/services/mediacodec/main_swcodecservice.cpp
+++ b/services/mediacodec/main_swcodecservice.cpp
@@ -31,12 +31,6 @@
 static const char kVendorSeccompPolicyPath[] =
         "/vendor/etc/seccomp_policy/mediaswcodec.policy";
 
-// Disable Scudo's mismatch allocation check, as it is being triggered
-// by some third party code.
-extern "C" const char *__scudo_default_options() {
-    return "DeallocationTypeMismatch=false";
-}
-
 extern "C" void RegisterCodecServices();
 
 int main(int argc __unused, char** /*argv*/)