Load vendor-provided drm hidl hal modules

Prior to this change, the default legacy hal
module was explicitly referenced. This change
uses the service manager to iterate through
any hal instances so vendor-provided hals
can be loaded.

bug:34507158
Change-Id: I23bc4fdb2dc7d5254833c9a977241f1fede726a9
diff --git a/media/libmedia/include/CryptoHal.h b/media/libmedia/include/CryptoHal.h
index 9d0c3e4..28ade20 100644
--- a/media/libmedia/include/CryptoHal.h
+++ b/media/libmedia/include/CryptoHal.h
@@ -20,11 +20,14 @@
 
 #include <android/hardware/drm/1.0/ICryptoFactory.h>
 #include <android/hardware/drm/1.0/ICryptoPlugin.h>
+
 #include <media/ICrypto.h>
 #include <utils/KeyedVector.h>
 #include <utils/threads.h>
 
-#include "SharedLibrary.h"
+using ::android::hardware::drm::V1_0::ICryptoFactory;
+using ::android::hardware::drm::V1_0::ICryptoPlugin;
+using ::android::hardware::drm::V1_0::SharedBuffer;
 
 class IMemoryHeap;
 
@@ -60,9 +63,8 @@
 private:
     mutable Mutex mLock;
 
-    sp<SharedLibrary> mLibrary;
-    sp<::android::hardware::drm::V1_0::ICryptoFactory> mFactory;
-    sp<::android::hardware::drm::V1_0::ICryptoPlugin> mPlugin;
+    const Vector<sp<ICryptoFactory>> mFactories;
+    sp<ICryptoPlugin> mPlugin;
 
     /**
      * mInitCheck is:
@@ -75,16 +77,13 @@
     KeyedVector<void *, uint32_t> mHeapBases;
     uint32_t mNextBufferId;
 
-    sp<::android::hardware::drm::V1_0::ICryptoFactory>
-            makeCryptoFactory();
-    sp<::android::hardware::drm::V1_0::ICryptoPlugin>
-            makeCryptoPlugin(const uint8_t uuid[16], const void *initData,
-                size_t size);
+    Vector<sp<ICryptoFactory>> makeCryptoFactories();
+    sp<ICryptoPlugin> makeCryptoPlugin(const sp<ICryptoFactory>& factory,
+            const uint8_t uuid[16], const void *initData, size_t size);
 
     void setHeapBase(const sp<IMemoryHeap>& heap);
 
-    status_t toSharedBuffer(const sp<IMemory>& memory,
-            ::android::hardware::drm::V1_0::SharedBuffer* buffer);
+    status_t toSharedBuffer(const sp<IMemory>& memory, ::SharedBuffer* buffer);
 
     DISALLOW_EVIL_CONSTRUCTORS(CryptoHal);
 };
diff --git a/media/libmedia/include/DrmHal.h b/media/libmedia/include/DrmHal.h
index 82d2555..e031765 100644
--- a/media/libmedia/include/DrmHal.h
+++ b/media/libmedia/include/DrmHal.h
@@ -87,7 +87,7 @@
                                               Vector<uint8_t> &certificate,
                                               Vector<uint8_t> &wrappedKey);
 
-    virtual status_t getSecureStops(List<Vector<uint8_t> > &secureStops);
+    virtual status_t getSecureStops(List<Vector<uint8_t>> &secureStops);
     virtual status_t getSecureStop(Vector<uint8_t> const &ssid, Vector<uint8_t> &secureStop);
 
     virtual status_t releaseSecureStops(Vector<uint8_t> const &ssRelease);
@@ -158,7 +158,7 @@
     mutable Mutex mEventLock;
     mutable Mutex mNotifyLock;
 
-    sp<IDrmFactory> mFactory;
+    const Vector<sp<IDrmFactory>> mFactories;
     sp<IDrmPlugin> mPlugin;
 
     /**
@@ -169,9 +169,9 @@
      */
     status_t mInitCheck;
 
-    sp<IDrmFactory> makeDrmFactory();
-    sp<IDrmPlugin> makeDrmPlugin(const uint8_t uuid[16],
-                                 const String8 &appPackageName);
+    Vector<sp<IDrmFactory>> makeDrmFactories();
+    sp<IDrmPlugin> makeDrmPlugin(const sp<IDrmFactory>& factory,
+            const uint8_t uuid[16], const String8& appPackageName);
 
     void writeByteArray(Parcel &obj, const hidl_vec<uint8_t>& array);