1 /*
2  * Copyright 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <nativehelper/ScopedUtfChars.h>
18 #include <nativeloader/native_loader.h>
19 #include <vulkan/vulkan_loader_data.h>
20 
21 #include "core_jni_helpers.h"
22 
setupVulkanLayerPath_native(JNIEnv * env,jobject clazz,jobject classLoader,jstring librarySearchPath)23 static void setupVulkanLayerPath_native(JNIEnv* env, jobject clazz,
24         jobject classLoader, jstring librarySearchPath) {
25     ScopedUtfChars layerPathChars(env, librarySearchPath);
26     vulkan::LoaderData& loader_data = vulkan::LoaderData::GetInstance();
27     loader_data.layer_path = layerPathChars.c_str();
28     loader_data.app_namespace = android::FindNamespaceByClassLoader(env, classLoader);
29 }
30 
31 static const JNINativeMethod g_methods[] = {
32     { "setupVulkanLayerPath", "(Ljava/lang/ClassLoader;Ljava/lang/String;)V",
33       reinterpret_cast<void*>(setupVulkanLayerPath_native) },
34 };
35 
36 static const char* const kApplicationLoadersName = "android/app/ApplicationLoaders";
37 
38 namespace android
39 {
40 
register_android_app_ApplicationLoaders(JNIEnv * env)41 int register_android_app_ApplicationLoaders(JNIEnv* env) {
42     return RegisterMethodsOrDie(env, kApplicationLoadersName, g_methods, NELEM(g_methods));
43 }
44 
45 } // namespace android
46