libvulkan: refactor the layer discovery logic

Previously, the layer discovery logic is only executed once along with the
driver loading. However, once Vulkan driver is preloaded in Zygote, new layers
pushed to the system or shipped with the App's apk won't be discovered at
runtime. This change refactors the logic of layer discovery. It doesn't hurt to
keep finding new layers available in the layer search path, because the app apk
itself won't change at runtime. Even if we push new layers to the system search
path, that's only on the debug build of the system.

Bug: 135536511
Test: preload Vulkan and atest CtsGpuToolsHostTestCases
Change-Id: I915b78dacfd9b637a202f76969d559a31eded686
diff --git a/vulkan/libvulkan/api.cpp b/vulkan/libvulkan/api.cpp
index 368130d..4608be2 100644
--- a/vulkan/libvulkan/api.cpp
+++ b/vulkan/libvulkan/api.cpp
@@ -1172,11 +1172,16 @@
 
     std::call_once(once_flag, []() {
         if (driver::OpenHAL()) {
-            DiscoverLayers();
             initialized = true;
         }
     });
 
+    {
+        static std::mutex layer_lock;
+        std::lock_guard<std::mutex> lock(layer_lock);
+        DiscoverLayers();
+    }
+
     return initialized;
 }