Use libmedia_helper as shared lib.

The dependencies to static libraries in frameworks should be removed
as many as possible to reduce a size of the system partition.
And that will improve coverage of the VNDK libraries because this
effort might find new necessary shared libs which were linked
statically before.

Size diffs of affected binaries on angler-userdebug build are as
follows.

libmedia                    : 598056 -> 547928 (-50128)
libstagefright              : 1496420 -> 1492124 (-4296)
libaudiopolicyservice       : 75372 -> 66940 (-8432)
libaudiopolicymanagerdefault: 613168 -> 583516 (-29652)
libaudioflinger             : 397840 -> 364380 (-33460)
libaudiohal                 : 114752 -> 68684 (-46068)
libaudiopolicyenginedefault : 122096 -> 71968 (-50128)
libmedia_helper             : 0 -> 66288 (+66288)

total                       : (-155876)

Test: building succeeded, and the image was tested on angler.
Bug: 33056637
Change-Id: I00a71e518337a1efcf7f55256145776311596991
diff --git a/media/libaudiohal/Android.mk b/media/libaudiohal/Android.mk
index 63aa9c6..e82766f 100644
--- a/media/libaudiohal/Android.mk
+++ b/media/libaudiohal/Android.mk
@@ -29,9 +29,8 @@
     android.hardware.audio@2.0             \
     android.hardware.audio.common@2.0      \
     android.hardware.audio.common@2.0-util \
-    android.hardware.audio.effect@2.0
-
-LOCAL_WHOLE_STATIC_LIBRARIES := libmedia_helper
+    android.hardware.audio.effect@2.0 \
+    libmedia_helper
 
 else  # if !ENABLE_TREBLE
 
diff --git a/media/libmedia/Android.bp b/media/libmedia/Android.bp
index 6e28ba9..4b14543 100644
--- a/media/libmedia/Android.bp
+++ b/media/libmedia/Android.bp
@@ -1,4 +1,4 @@
-cc_library_static {
+cc_library {
     name: "libmedia_helper",
     srcs: ["AudioParameter.cpp", "TypeConverter.cpp"],
     cflags: [
@@ -6,5 +6,8 @@
         "-Wno-error=deprecated-declarations",
         "-Wall",
     ],
+    shared: {
+      shared_libs: ["libutils", "liblog"],
+    },
     clang: true,
 }
diff --git a/media/libmedia/Android.mk b/media/libmedia/Android.mk
index 02947b0..8fff414 100644
--- a/media/libmedia/Android.mk
+++ b/media/libmedia/Android.mk
@@ -59,12 +59,11 @@
 LOCAL_SHARED_LIBRARIES := \
 	libui liblog libcutils libutils libbinder libsonivox libicuuc libicui18n libexpat \
         libcamera_client libstagefright_foundation \
-        libgui libdl libaudioutils libaudioclient
+        libgui libdl libaudioutils libaudioclient \
+        libmedia_helper
 
 LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libbinder libsonivox
 
-LOCAL_WHOLE_STATIC_LIBRARIES := libmedia_helper
-
 # for memory heap analysis
 LOCAL_STATIC_LIBRARIES := libc_malloc_debug_backtrace libc_logging
 
diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk
index bd837ae..f3d622b 100644
--- a/media/libstagefright/Android.mk
+++ b/media/libstagefright/Android.mk
@@ -108,9 +108,9 @@
         libstagefright_mpeg2ts \
         libstagefright_id3 \
         libFLAC \
-        libmedia_helper \
 
 LOCAL_SHARED_LIBRARIES += \
+        libmedia_helper \
         libstagefright_foundation \
         libdl \
         libRScpp \
diff --git a/services/audioflinger/Android.mk b/services/audioflinger/Android.mk
index e2a93ad..51d785a 100644
--- a/services/audioflinger/Android.mk
+++ b/services/audioflinger/Android.mk
@@ -57,11 +57,11 @@
     libserviceutility \
     libsonic \
     libmediautils \
-    libmemunreachable
+    libmemunreachable \
+    libmedia_helper
 
 LOCAL_STATIC_LIBRARIES := \
     libcpustats \
-    libmedia_helper
 
 LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
 
diff --git a/services/audiopolicy/Android.mk b/services/audiopolicy/Android.mk
index 9f3488d..a1420ff 100644
--- a/services/audiopolicy/Android.mk
+++ b/services/audiopolicy/Android.mk
@@ -23,10 +23,10 @@
     libaudioclient \
     libhardware_legacy \
     libserviceutility \
-    libaudiopolicymanager
+    libaudiopolicymanager \
+    libmedia_helper
 
 LOCAL_STATIC_LIBRARIES := \
-    libmedia_helper \
     libaudiopolicycomponents
 
 LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
@@ -76,7 +76,7 @@
 LOCAL_STATIC_LIBRARIES := \
     libaudiopolicycomponents
 
-LOCAL_WHOLE_STATIC_LIBRARIES := libmedia_helper
+LOCAL_SHARED_LIBRARIES += libmedia_helper
 
 ifeq ($(USE_XML_AUDIO_POLICY_CONF), 1)
 LOCAL_STATIC_LIBRARIES += libxml2
diff --git a/services/audiopolicy/engineconfigurable/Android.mk b/services/audiopolicy/engineconfigurable/Android.mk
index 08c677e..341357c 100644
--- a/services/audiopolicy/engineconfigurable/Android.mk
+++ b/services/audiopolicy/engineconfigurable/Android.mk
@@ -40,8 +40,6 @@
 LOCAL_MODULE := libaudiopolicyengineconfigurable
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_WHOLE_STATIC_LIBRARIES := libmedia_helper
-
 LOCAL_STATIC_LIBRARIES := \
     libaudiopolicypfwwrapper \
     libaudiopolicycomponents \
@@ -53,7 +51,8 @@
     libutils \
     liblog \
     libaudioutils \
-    libparameter
+    libparameter \
+    libmedia_helper
 
 include $(BUILD_SHARED_LIBRARY)
 
diff --git a/services/audiopolicy/engineconfigurable/wrapper/Android.mk b/services/audiopolicy/engineconfigurable/wrapper/Android.mk
index d031bc3..066ee0d 100644
--- a/services/audiopolicy/engineconfigurable/wrapper/Android.mk
+++ b/services/audiopolicy/engineconfigurable/wrapper/Android.mk
@@ -14,10 +14,9 @@
 
 LOCAL_SRC_FILES:= ParameterManagerWrapper.cpp
 
-LOCAL_WHOLE_STATIC_LIBRARIES := libmedia_helper
-
 LOCAL_SHARED_LIBRARIES := \
     libparameter \
+    libmedia_helper
 
 LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
 
diff --git a/services/audiopolicy/enginedefault/Android.mk b/services/audiopolicy/enginedefault/Android.mk
index c1bb3fb..47dc545 100644
--- a/services/audiopolicy/enginedefault/Android.mk
+++ b/services/audiopolicy/enginedefault/Android.mk
@@ -34,8 +34,6 @@
 LOCAL_MODULE := libaudiopolicyenginedefault
 LOCAL_MODULE_TAGS := optional
 
-LOCAL_WHOLE_STATIC_LIBRARIES := libmedia_helper
-
 LOCAL_STATIC_LIBRARIES := \
     libaudiopolicycomponents \
     libxml2
@@ -44,5 +42,6 @@
     liblog \
     libcutils \
     libutils \
+    libmedia_helper
 
 include $(BUILD_SHARED_LIBRARY)