libaudiohal: Dynamically load appropriate HIDL shim library

Remove static linking to libaudiohal@N.0.so libraries.
Instead, use HIDL IServiceManager to figure out the actual
version used by the device and load the appropriate library
dynamically.

Bug: 142480271
Bug: 148118201
Test: make and check audio on the device
Change-Id: I8e6eb9eeef3335da516d983d5d4f0f1b128ef0a6
diff --git a/media/libaudiohal/Android.bp b/media/libaudiohal/Android.bp
index 74b48f3..1709d1e 100644
--- a/media/libaudiohal/Android.bp
+++ b/media/libaudiohal/Android.bp
@@ -4,6 +4,7 @@
     srcs: [
         "DevicesFactoryHalInterface.cpp",
         "EffectsFactoryHalInterface.cpp",
+        "FactoryHalHidl.cpp",
     ],
 
     cflags: [
@@ -12,11 +13,17 @@
         "-Werror",
     ],
 
-    shared_libs: [
+    required: [
         "libaudiohal@2.0",
         "libaudiohal@4.0",
         "libaudiohal@5.0",
         "libaudiohal@6.0",
+    ],
+
+    shared_libs: [
+        "libdl",
+        "libhidlbase",
+        "liblog",
         "libutils",
     ],