Revert "Shrink surfaceflinger"

This reverts commit 1b0d669d6796400407aedfa7568f0ad65ccc5874.

Reason for revert: Build breakage in build_test
Bug: 168032169

Change-Id: Ic2aa6d0d387a10b25bdac37d680775c499510714
diff --git a/services/surfaceflinger/Android.bp b/services/surfaceflinger/Android.bp
index 40e445b..b039f6e 100644
--- a/services/surfaceflinger/Android.bp
+++ b/services/surfaceflinger/Android.bp
@@ -186,18 +186,22 @@
     ],
 }
 
-cc_defaults {
-    name: "libsurfaceflinger_binary",
-    defaults: [
-        "surfaceflinger_defaults",
-        "libsurfaceflinger_production_defaults",
+cc_library_shared {
+    // Please use libsurfaceflinger_defaults to configure how the sources are
+    // built, so the same settings can be used elsewhere.
+    name: "libsurfaceflinger",
+    defaults: ["libsurfaceflinger_production_defaults"],
+    srcs: [
+        ":libsurfaceflinger_sources",
+
+        // Note: SurfaceFlingerFactory is not in the default sources so that it
+        // can be easily replaced.
+        "SurfaceFlingerFactory.cpp",
     ],
     cflags: [
-        "-DLOG_TAG=\"SurfaceFlinger\"",
         "-DUSE_VR_COMPOSER=1",
     ],
     // VrComposer is not used when building surfaceflinger for vendors
-    // TODO: Is this ever built for vendors?
     target: {
         vendor: {
             cflags: [
@@ -205,6 +209,15 @@
             ],
         },
     },
+    logtags: ["EventLog/EventLogTags.logtags"],
+}
+
+cc_defaults {
+    name: "libsurfaceflinger_binary",
+    defaults: ["surfaceflinger_defaults"],
+    cflags: [
+        "-DLOG_TAG=\"SurfaceFlinger\"",
+    ],
     shared_libs: [
         "android.frameworks.displayservice@1.0",
         "android.hardware.configstore-utils",
@@ -226,18 +239,12 @@
         "libserviceutils",
         "libtrace_proto",
     ],
-    logtags: ["EventLog/EventLogTags.logtags"],
+    ldflags: ["-Wl,--export-dynamic"],
 }
 
 filegroup {
     name: "surfaceflinger_binary_sources",
-    srcs: [
-        ":libsurfaceflinger_sources",
-        // Note: SurfaceFlingerFactory is not in the default sources so that it
-        // can be easily replaced.
-        "SurfaceFlingerFactory.cpp",
-        "main_surfaceflinger.cpp"
-    ],
+    srcs: ["main_surfaceflinger.cpp"],
 }
 
 cc_binary {
@@ -246,6 +253,7 @@
     init_rc: ["surfaceflinger.rc"],
     srcs: [":surfaceflinger_binary_sources"],
     shared_libs: [
+        "libsurfaceflinger",
         "libSurfaceFlingerProp",
     ],
 }
diff --git a/services/surfaceflinger/tests/unittests/Android.bp b/services/surfaceflinger/tests/unittests/Android.bp
index fb78bcb..a90f672 100644
--- a/services/surfaceflinger/tests/unittests/Android.bp
+++ b/services/surfaceflinger/tests/unittests/Android.bp
@@ -90,6 +90,7 @@
     shared_libs: [
         "libprotoutil",
         "libstatssocket",
+        "libsurfaceflinger",
         "libtimestats",
         "libtimestats_proto",
     ],