link libutilscallstack only when VALIDATE_REGIONS is defined

Add cc_defaults in Android.bp to enable this macro and add the lib.

It is not an issue for system build as the lib always exist in system
partition. However some apex builds may use vendor version of the binaries
and we don't want to include unused libs into the apex, since they not
only increase the apex size, but also incur runtime memory cost.

Removing libutilscallstack from the deps will also get rid of its
transitive dependencies such as libbacktrace, liblzma, liblibunwindstack
and libutilscallstack.

bug: 128894663
test: build; manually check that libbacktrace, liblzma, liblibunwindstack
and libutilscallstack are not packaged into com.android.media.swcodec apex.

Change-Id: Ib64b8aa29e8cefe8d1f9eb2bd095221eb5c9a174
diff --git a/libs/ui/Android.bp b/libs/ui/Android.bp
index 755418e..0407d88 100644
--- a/libs/ui/Android.bp
+++ b/libs/ui/Android.bp
@@ -82,6 +82,9 @@
         "frameworks/native/include",
     ],
 
+    // Uncomment the following line to enable VALIDATE_REGIONS traces
+    //defaults: ["libui-validate-regions-defaults"],
+
     shared_libs: [
         "android.frameworks.bufferhub@1.0",
         "android.hardware.graphics.allocator@2.0",
@@ -98,7 +101,6 @@
         "libhwbinder",
         "libsync",
         "libutils",
-        "libutilscallstack",
         "liblog",
     ],
 
@@ -175,6 +177,13 @@
     ],
 }
 
+// defaults to enable VALIDATE_REGIONS traces
+cc_defaults {
+    name: "libui-validate-regions-defaults",
+    shared_libs: ["libutilscallstack"],
+    cflags: ["-DVALIDATE_REGIONS"],
+}
+
 subdirs = [
     "tests",
     "tools",