libbinder: export fewer symbols for non-vendor builds

We did this for bionic builds only in https://r.android.com/3096103, but
it was reverted in https://r.android.com/3148521 because of issues in
vendor code. We no longer need to limit this to bionic builds, so I've
simplified that part of the change and added an override to disable for
vendor builds.

Bug: 338458975
Bug: 349657329
Test: boot mokey without seeing a libbinder related crash
Change-Id: I6a67b4aea73ce496b2460a084736c472ed5e2430
diff --git a/libs/binder/Android.bp b/libs/binder/Android.bp
index 1abde5c..80720b0 100644
--- a/libs/binder/Android.bp
+++ b/libs/binder/Android.bp
@@ -267,7 +267,20 @@
         "-Wunused-const-variable",
         "-DANDROID_BASE_UNIQUE_FD_DISABLE_IMPLICIT_CONVERSION",
         "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION",
+        // Hide symbols by default and set the BUILDING_LIBBINDER macro so that
+        // the code knows to export them.
+        "-fvisibility=hidden",
+        "-DBUILDING_LIBBINDER",
     ],
+
+    target: {
+        vendor: {
+            // Trimming the exported symbols reveals a bug in vendor code, so
+            // disable it for the vendor variant for now. http://b/349657329
+            // TODO: Fix the issue and remove this override.
+            cflags: ["-fvisibility=default"],
+        },
+    },
 }
 
 cc_defaults {